Archived

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

Rellik

Localizing Global Effects

Recommended Posts

Certain effects are set up for the whole of the OpenGL application; for example, things that are set up in InitGL. Like enabling Depth Testing, and changing the way the backs and fronts of polygons appear. In something like Tutorial 09, you are required to disable Depth Testing, among other things, to make the Bitmaps blend correctly. If I were to want to display something, at the same time on the same screen in the same render, but with Depth Testing enabled (for example, if I wanted to do Blending), how would I configure it so that I could do both? Another example is, like in Tutorial 11, it renders a flag (a literal flag, to be more specific, not a boolean flag) with global settings (not state settings like Color or Texture) to display the front of the polygons as solid but the back of the polygons as lines. If I wanted to display something with other options, perhaps solid on both sides, or lines on both sides, or some other combination, but I wanted to display it at the same time, on the same render, as the Flag, how would I localise the global effect? Thanks for your help.

Share this post


Link to post
Share on other sites
You don't have to just use those in an init function.


At any point if you wish to enable or disable somthing you can.

IE say you want to draw somthing blended, then somthing without blending...

glEnable(GL_BLEND);
drawsomthing();
glDisable(GL_BLEND);
anotherdraw();

[edited by - skow on October 20, 2003 9:14:51 PM]

Share this post


Link to post
Share on other sites
yup, u dont really need to rely entirely on the init function. It IS good to dump stuff which probably wont ever change much, or are likely to change about the least. But in most cases, it just sets up the initial state for the first few things u''ll be renderin.

U can mess around with state changes anytime u like. But some state changes are expensive and are not advised, especially if done every frame. I guess thats where the concept of grouping comes in. If u have many groups of obejcts that require diff state changes, group em for rendering based on their similarities. For instance, material/texture changes are probably a huge slowdown if u use a lot of textures in a high poly scene. So ppl recommend rendering polys of a given texture before going to the next, instead of renderign by polygon order.

The same goes for particles and even alpha-blended object, which are usually rendered with depth-masking. hope that helps.

Share this post


Link to post
Share on other sites
Thanks! I did not understand that when you glEnable something, it is just another state change (normally, I think of "Enable" as a global flag, as opposed to just a state change). I will be sure to follow that grouping advice too; it makes a lot of sense.

Share this post


Link to post
Share on other sites