views:

27

answers:

2

Hi,

I have a set of textures which I need to draw at different vertices such that every texture is visible.I cannot define a static set of vertices since I load the textures dynamically and I dont know how many textures will be loaded everytime ( i choose them based on a condition).

This is how my code looks as of now.

for(int i=0;i<num_img;i++)
{    
    glLoadIdentity();
    glTranslatef(0.0, 0.0, -3.0);
    glRotatef(rot, 1.0, 1.0, 1.0);
    glBindTexture(GL_TEXTURE_2D, texture[i]);
    glVertexPointer(3, GL_FLOAT, 0, vertices);
    glNormalPointer(GL_FLOAT, 0, normals);
    glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}

Is there anyway to dynamically generate vertices that can be passed as final argument of glVertexPointer() ?

A: 

Do you know the maximum number of vertices that you will use? Maybe you could create the vertices array to be that maximum size then in the first parameter of glVertexPointer you only pass the number of vertices that you actually use.

No one in particular
A: 

I can set maximum number of vertices I will use.But how will I be able to generate vertex coordinates dynamically?

whocares