Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

alnite

OpenGL total noob in OpenGL

This topic is 5208 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

Ok, I think I might like it, but before I go too deep learning it and ended up disliking it, I need to know some things first. My target is not making a full 3D environment, but 2D using textured quads. 1. does calling glBegin() and glEnd() for every object (textured quad) is efficient? In Direct3D, you want to minimize calling DrawPrimitive() if you aim for efficiency (speed). 2. How expensive is glBindTexture()? Would that be fine if I call glBindTexture() for each object? 3. What is the best way of creating/managing/displaying textured quads with transparency/color key, alpha blending, rotation, and diffuse color? From NeHe, it appears that I need to create masks for each texture just for the color key, but I don''t like masks. Can I use PNG files with alpha channel instead? Those are my questions, so far. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by alnite
1. does calling glBegin() and glEnd() for every object (textured quad) is efficient? In Direct3D, you want to minimize calling DrawPrimitive() if you aim for efficiency (speed).

There are many ways to specify geometry in OpenGL. The glBegin/glEnd method is the least efficient of these, and thus only to be used in simple programs. Look into vertex arrays and vertex buffer objects for far more efficient alternatives.
quote:
Original post by alnite
2. How expensive is glBindTexture()? Would that be fine if I call glBindTexture() for each object?
It depends. If you have to change the texture, you have to change the texture. Just try to minimize it (e.g. batch based on texture).
quote:
Original post by alnite
3. What is the best way of creating/managing/displaying textured quads with transparency/color key, alpha blending, rotation, and diffuse color? From NeHe, it appears that I need to create masks for each texture just for the color key, but I don''t like masks. Can I use PNG files with alpha channel instead?
If you''re just going for a color mask effect, using the alpha channel in conjunction with alpha test is the way to go. There''s no need for separate masks.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I''d like to add to Myopic''s post only one thing. You explained that you didn''t want to get too deep into OpenGL yet; vertex arrays(and vertex buffer objects) tend to be overwhelming at first. If your vertex data is static (like 2D textured quads), look into the Display Lists. They act like macros, you compile a list from a set of OpenGL state commands (like you would in immediate mode, with glBegin/glEnd/glVertex/etc) and then reference the list at run time. This batching of the commands increases performance phenomenally.

Share this post


Link to post
Share on other sites
Thanks a lot!

quote:
Original post by Anonymous Poster
I''d like to add to Myopic''s post only one thing. You explained that you didn''t want to get too deep into OpenGL yet; vertex arrays(and vertex buffer objects) tend to be overwhelming at first. If your vertex data is static (like 2D textured quads), look into the Display Lists. They act like macros, you compile a list from a set of OpenGL state commands (like you would in immediate mode, with glBegin/glEnd/glVertex/etc) and then reference the list at run time. This batching of the commands increases performance phenomenally.
That one sounds much easier to do. I''ll go with that one.

Share this post


Link to post
Share on other sites
Also, use gluOrtho2D to set your projection matrix instead of gluPerspective or gluOrtho. You probably knew this already.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!