tags:

views:

37

answers:

2

hello, i am starting out with opengles coming from old opengl. i see there is no immediate mode anymore. so functions like glVertex glTexCoord are missing, right?

instead i have to use vertexarrays. right?

how can i modify the values of those arrays each frame?

for example, if i want to animate the texture coordinates, in old OpenGL i did:

  glTexCoord2f(x*time, y*time);

how can i achieve a similar effect with vertex arrays?

thanks!

+2  A: 

Just update the arrays you pass to gl*Pointer, and draw again.

If you use VBOs, you'll need to update the VBO contents also.

Matias Valdenegro
If this is done every frame make sure that the VBO is set to GL_STREAM_DRAW.
Mk12
+2  A: 

if all you want to do is scroll the texture, there are direct ways to modify the texture coordinates as they go through the pipeline.

glMatrixMode( GL_TEXTURE );
glLoadIdentity();
glTranslatef(...);
glMatrixMode(...);

In general, cases where actual texcoord data should really change (as in because you want to apply a non-uniform transformation to them) are rare.

Bahbar
Keep in mind that these are all deprecated in 3.0.
Mk12
@Mk12: Huh ? we're talking GL ES here, and I assume he meant ES 1.0, but he did not specify. on ES 2.0, you'd just do the transformation in the vertex shader...
Bahbar
Oh, right sorry I was thinking normal OpenGL.
Mk12