total noob in OpenGL

Started by
3 comments, last by alnite 20 years ago
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.
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.
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.
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.
Also, use gluOrtho2D to set your projection matrix instead of gluPerspective or gluOrtho. You probably knew this already.

This topic is closed to new replies.

Advertisement