total noob in OpenGL
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.
quote:Original post by alniteThere 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.
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).
quote:Original post by alniteIt 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).
2. How expensive is glBindTexture()? Would that be fine if I call glBindTexture() for each object?
quote:Original post by alniteIf 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.
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?
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 PosterThat one sounds much easier to do. I''ll go with that one.
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.
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
Popular Topics
Advertisement