View Full Version : Static scene with just one moving object

01-13-2001, 07:10 AM
Hi there,

I have an optimization problem.
I made an animation with just a few objects... (about 15 QUADS) but it is too slow.
In this scene, just one object (made with 3 QUADS) change its position. So I would like to know if I can:
1) draw the static scene
2) save it in the memory
3) draw the mobile object
4) render the scene
5) then load the static scene (saved in step 2)

The glLoadMatrix, glPopMatrix, glPushMatrix can do it? Or these "matrixs" just hold the viewport and translation/rotation informations?
The static scene uses textured QUADS.

Thank You

Michael Steinberg
01-13-2001, 07:17 AM
I don't exactly get what you mean.
You could put the static scene in a display list. After that you can put the moving object into a display list as well.

1) Draw static scene
2) Change modelview matrix as needed
3) Draw moved object

Maybe I'm getting you totally wrong. Could you repeat what you want to do?

01-13-2001, 07:43 AM
I understood your sugestion about the diplay list and I'll try it!

My doubt is if the OpenGL really renders the hole scene every time or when I call glPopMatrix it gets back to the previously scene rendered (like a buffer!).

The problem is the speed... the animation is too slow and I have just a few QUADS and textures. There are a lots of games that uses many more textures and polygons and are fast!
For exemple, in quake, every time we turn around a little degree, does opengl render the entire scene with textures and all that polygons???

Michael Steinberg
01-13-2001, 07:53 AM
In any 3d engine I know, the full geometry is rendered every frame. I can't believe that you get poor performance with just a few quads (even when in software mode).

Michael Steinberg
01-13-2001, 07:55 AM
OpenGL implements matrix stacks. That is, there is a stack for matrixes that can be used for example in skeletal animation. These matrices only affect vertex data etc, and have nothing to do with the actual color buffer. The technique to render animation is:

Use Doublebuffering.

1) Clear Color and Depth Buffer (if second is necessary)
2) Draw the whole scene

You won't get flickering because of double buffering.
3) start again at 1

01-13-2001, 08:14 AM
OK, the problem might be the texture stuff.
Take a look what I'm doing. I draw a simple ground with the texture 1.
then I draw some boxes over the ground using another texture.

//************************************************** **********
// Draw the ground

for( ... list of boxes )
// here I change to the another texture
// draw Face A

// here I change to the another texture
// draw Face B

// here I change to the another texture
// draw Face C
//************************************************** **********

I already tried withou these many call to glEnable, glDisable... inside the loop but I got very wierd results...
Is the problem about the glBindTexture inside the loop?
Any ideias to optimize that?

ps: If I try with more than 5 boxes the TEXTURE gets automatically disabled and the scene gets white! ( probably a memory problem, I think :-) )

01-13-2001, 02:48 PM
You don't need all those calls, for enable/disable... just 1 is enough. http://www.opengl.org/discussion_boards/ubb/smile.gif

After the bind, you then just draw the quads/triangles whatever, and it should be using that (assuming you have it setup correctly that is).
Like as in:
begin ... end //polygon data
begin ... end //next data set
and so on...

How big are the textures? voodoo cards can't handle higher than 256x256 (or is that 128x128? hmm) What gfx card you got, and how much mem?

01-14-2001, 05:31 AM
I cut off those calls to glbind... but I still get a white scene if I draw many boxes...

My video card is SiS 4Meg http://www.opengl.org/discussion_boards/ubb/frown.gif
... but the textures are just two of 64x64 pixels. One of them used in all the boxes...
The problem must be in my code, because I run other programs with complex scenes and there is no problem.

The textures are setted with:

In the init method:
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);

01-14-2001, 06:52 AM
It could be a fillrate problem.

What resolution are you running and how big are these quads?

And don't rule out the possiblity that something could be forcing your program into software.


01-14-2001, 07:19 AM
What did you mean with:
> forcing your program into software

I use coordinates between 0 and 650 for x axis, 0 to 350 to the z axis and the y are fix to something about 5. The whole scene is drawn in this area. the boxes are about (60x5x50) each.
Before draw the scene I use:
glTranslated( 100.0, 100.0, 5.0);
glRotatef( XAngle, 1.0, 0.0, 0.0);
glRotatef( YAngle, 0.0, 1.0, 0.0);
glScalef( 0.5, 1.0, 0.9);

I use 1024x720 resolution, but the program does not run in full screen mode.

01-14-2001, 09:49 AM
Hmm a Sis 4MB card? Hmm never heard of it. http://www.opengl.org/discussion_boards/ubb/smile.gif

Anyway, you are running out of memory, since 1024x768x32x16+textures+ whatever the desktop is set to...= over 4MB.
Try it 320x200 since it is only a window anyway, with 16bit depth(change desktop to 16 bit deth), and 16bit Z, you should have ~2MB to play with then.

Better yet, get a new gfx card, like a 16/32MB tnt2 or geforce2mx, or rage 128 pro...

01-15-2001, 08:09 AM
I solved this problem. This was some of that "alien" problems.
This is what was happening:
1) create list with coordinates of the polygons;
2) create new form with an opengl window;
3) render the scene;
For some unknown reason, if the number of polygons were too big, the textures got white. I just made a pause betwen steps 2 and 3 and everything went ok.

Besides this crazy stuff...
I have one more question about this issue.
If I use some texture on a QUAD with coordinates (0.0,0.0) (0.0,1.0)(1.0,1.0)(1.0,0.0)
and in another program I use the same texture in a QUAD with
(0.0,0.0) (0.0,10.0)(10.0,10.0)(10.0,0.0). And, in both, i use diferent scales to get exactly the same results on the screen (I mean, the user wouldn't see any diference beetwen the size of both QUADs)
Is there any performance diference? If I want the same result, it would be better to use some scale in my data before pass it to opengl?