Un - rendering

Started by
8 comments, last by Stani R 18 years, 4 months ago
Hey guys - if i am using one function to render my scene - how can i "unrender" so to speal, an object in it? Also, when a the game, or something in the game is loading - how can i display a bitmap saying something like "Loading" or "Please wait". Thanks :) Mike
Advertisement
uhhhh..... glClear?
Quote:
Hey guys - if i am using one function to render my scene - how can i "unrender" so to speal, an object in it?


That will be very hard without re-rendering the scene, if you need to remove an object just don't render it, if you already have rendered it you need to re-render the scene (some other techniques may exist, but they will likely either take up GBs of memory and/or require seconds of processing, which is not acceptable for a game). Why do you need to remove an object once it is rendered? If you are talking about a game you should re-render your scene for at least 30 times a second and you can just not render it next time then.

Quote:
Also, when a the game, or something in the game is loading - how can i display a bitmap saying something like "Loading" or "Please wait".


You can do this in multiple ways, the simplest would be to load a texture and use glOrtho to render the texture to the whole screen.
Quote:Original post by CTar
Quote:
Hey guys - if i am using one function to render my scene - how can i "unrender" so to speal, an object in it?


That will be very hard without re-rendering the scene, if you need to remove an object just don't render it, if you already have rendered it you need to re-render the scene (some other techniques may exist, but they will likely either take up GBs of memory and/or require seconds of processing, which is not acceptable for a game). Why do you need to remove an object once it is rendered? If you are talking about a game you should re-render your scene for at least 30 times a second and you can just not render it next time then.

Quote:
Also, when a the game, or something in the game is loading - how can i display a bitmap saying something like "Loading" or "Please wait".


You can do this in multiple ways, the simplest would be to load a texture and use glOrtho to render the texture to the whole screen.





Exactly what i want to do is this -
I have loaded a 3ds model of a castle couryard.
Now, when my player collides with the door, which is at a certain position, i want to render a different scene ( which is another .3ds model ), and un render the previous scene

Ah just shutdown the rendering function for that model then... use a flag and when whatever causes it don't allow it to render...
Quote:Original post by Beaverbutt8
Exactly what i want to do is this -
I have loaded a 3ds model of a castle couryard.
Now, when my player collides with the door, which is at a certain position, i want to render a different scene ( which is another .3ds model ), and un render the previous scene

What you need in your scenegraph is a switching variable or Node. You have to load both Open and Closed Door models. In the original mapping you'd mark the model as Closed on your Display-List. When the player-door collision occurs, you'd have to mark it as OPEN and put the OPEN model onto your display list.

What's your display-list like?
Doh! I'm not using one, i just have a function called "DrawGLscene"

I think i'm starting to see my problem.
Ok, now i'm using one.
My question is now - how do i "un call" a display list?
You can't. You most likely want to do something like this:
void RenderScene(){  for(/*each object*/)  {    object.Render();  }}class SceneObject{public:  bool m_shouldBeVisible;  //all your other object data  void Render()  {    if(m_shouldBeVisible == true)    {      //all your rendering goes here    }  }};

Your scene tells every object to render itself, while the object desides if it should be visible.
I think the wording "display list" was a bit unfortunate due to the overloading of the original meaning that happened here.

Beaverbutt8, in case you have not figured this out yet, ZoomBoy was in fact not referring to OpenGL display lists, but to a "list of all objects to be rendered this frame".

As the others have pointed out already, what you want to do is, roughly, each frame:
1) decide what objects are visible (switching/level of detail, culling, whatever else)
2) put these objects into a list (probably sorting by texture or similar, but sorting can be added later on)
3) pass this list to your "DrawGLScene"
4) in your "DrawGLScene", render every object in that list

Thus, your objects don't necessarily have to know about how to render themselves, your rendering code is kept to your DrawGLScene method/object. What the scene objects do need to know is the lighting/texture/material/whatever needed to render them. On the other hand, the rendering routine does not need to know about the objects it renders, only about how to get the needed info from them to render them.

Edit: As to how you render the objects, whether it's using immediate mode, display lists, vertex arrays, or vertex buffer objects - that's up to you.

This topic is closed to new replies.

Advertisement