Jump to content

  • Log In with Google      Sign In   
  • Create Account


how to use glVertexPointer


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 lanhaiou   Members   -  Reputation: 101

Like
0Likes
Like

Posted 05 August 2012 - 08:32 AM

Hi,
I am pretty new to OPENGL, and could any one help me ? thanks !!

I have a texture which contains number of tiles (each tile is part of this texture).
now I want to draw all the tiles in one draw call : glDrawElements(), (every tile's vertex coordination is different).
something like:

glVertexPointer(); //set the vertex array,
glTexCoordPointer(); //set the coordinations of the tile in texture.
glDrawElements();

do I have to call glTexCoordPointer() to set the coordinations for every tile ? that will be 3 times call of above code if I want to draw 3 tiles.
is there any efficient way to handle that ?

thank you very much !!

Sponsor:

#2 V-man   Members   -  Reputation: 797

Like
0Likes
Like

Posted 05 August 2012 - 06:27 PM

You can put your data in one large array and just setup the pointers once. One call to glVertexPointer and one to glTexCoordPointer.
A more efficient way would be to move up to GL 1.5 and start using VBO so that your vertices will be in video memory rather than local RAM.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS