Jump to content
  • Advertisement
Sign in to follow this  
Tiresias

OpenGL opengl to opengl es code

This topic is 3077 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello
how would be translated this opengl code:


glBegin(GL_QUADS);

glTexCoord2f(u1, v1); glVertex2f(sx, sy);
glTexCoord2f(u2, v1); glVertex2f(sx+sw, sy);
glTexCoord2f(u2, v2); glVertex2f(sx+sw, sy+sh);
glTexCoord2f(u1, v2); glVertex2f(sx, sy+sh);

glEnd();

into OpenGL ES ? ( i know that there si no begin/end on ES)

Share this post


Link to post
Share on other sites
Advertisement
I don't use OpenGL ES myself but I believe you should use Vertex Buffers (VBO's). The bright side is that you should be using these anyway, even if glBegin/End was available.

Share this post


Link to post
Share on other sites
hello
not at all, nothing to see with VBO.
i think this shall work:
GL_FLOAT vertex2[]={sx, sy, sx+sw, sy, sx+sw, sy+sh, sx, sy+sh};
GL_FLOAT textureCoor2[]={u1,v1, u2, v1, u2,v2, u1,v2};

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COOR_ARRAY);

glVertexPointer(2, GL_FLOAT, 0, &vertex2);
glTexCoordPointer( 2, GL_FLOAT, 0, &textureCoor2);

glDrawArrays(GL_QUADS, 0, 4);

will try, it is actually better than the begin end for sure.

Share this post


Link to post
Share on other sites
Hi,

glDrawArrays and glDrawElements work fine, but VBO is another way to do it, and more efficiently.

Here is an article about it (in French s'il vous plait ;)) :

http://www.game-lab.com/index.php?section=tutorials§ion_id=1&p=tutorial&action=showtut&id=244

Bye

Share this post


Link to post
Share on other sites
yes of course VBO would be faster.
just wondering how faster? i have perf issues on some card, i have no idea why (in my old laptop its more efficient than on my new one ...), could it be VBO related?

Share this post


Link to post
Share on other sites
The way I see the difference between glBegin/End, glDraw and VBO :

- glBegin / glEnd : A lot of function calls is needed

- glDraw : It is the same as glBegin, but reduce considerably the number of function calls

- VBO : Reduce bus activity (only if your geometry is static maybe ? because if it is dynamic you'll have to transfer data each time)

I've seen some interesting bechmarks about it, for geometry composed of hundreds of thousand (and more) polygons, you can esperate a ratio of 3 to 4 time faster.

However, for a lower count of polygons you will not see great performance differences.

Share this post


Link to post
Share on other sites
All articles I've read about making OpenGL ES as efficient as possible recommend using VBOs. The setup is very similar to using a regular client side (in memory) vertex array (along with colors, normals, texture coordinates) with the exception of giving OpenGL a hint about how often the VBO data will be changed and putting your data in a DataBuffer (server side).

There's actually a number of great articles about making GL Code more efficient, especially if you're coding for iPhone and want to write what's best for it's PowerVR GPU. Using floats for example instead of Fixed since there's a built in FPU.

Share this post


Link to post
Share on other sites
Quote:
Original post by GFalcon
The way I see the difference between glBegin/End, glDraw and VBO :
- glBegin / glEnd : A lot of function calls is needed
- glDraw : It is the same as glBegin, but reduce considerably the number of function calls
- VBO : Reduce bus activity (only if your geometry is static maybe ? because if it is dynamic you'll have to transfer data each time)
Things a re actually considerably more complicated than that. For starters, using glDrawElements/glDrawArrays with vertex arrays or VBO guarantees that each vertex has exactly the same elements (position, colour, normal, etc.) specified. glBegin/glEnd makes no such guarantee, and the programmer is free to skip elements, causing the driver to have to reinterpret the incoming vertices.
Quote:
However, for a lower count of polygons you will not see great performance differences.
I have encountered cases where VBO show many times improvement even for small amounts of geometry (say ~10,000 vertices).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!