Rotating Cube: PopMatrix, PushMatrix?

Greets,

I've got a piece of code on my Windows-box that I found and now worked on for a while. 

It's a texture-mapped rotating cube. When I tried to apply motion-blur with GlAccum, it just brought the system (1.2Ghz, GeForce2, 512MB RAM) to its knees. I figured it could be done better. 

Been scouring some docs, and read about PopMatrix and PushMatrix, but not sure if that is something I should implement for this spinning cube, so I want your opinion on it.

The render-code looks like:

BEGIN CODE

glLoadIdentity

glClear clrColorBufferBit Or clrDepthBufferBit

glTranslatef 0#, 0#, -5#

glRotatef rot, 1#, 1#,1#

glBindTexture glTexture2D, gaTextures(0)

glBegin GL_QUADS
… DrawStuff
glEnd

rot = rot + 1

If rot = 360 Then rot = 0

END CODE

How could I speed this baby up so the motion-blur works without a hitch? I know nothing about how to apply PopMatrix and PushMatrix in this matter.

Best regards,

Tom

I don’t think glPush/PopMatrix is going to help you any. The problem is that the accumulation buffer isn’t implemented in hardware and can be VERY slow. In fact, there is no consumer-level card that implements an accumulation buffer in hardware.

With that said, what you use the push/pop matrix for is to “store” the current matrix on the top of the matrix stack. It’s got a lot of uses but probably the most common would be something like so…

ClearScene

for each object in scene
glPushMatrix
object.doTransformations
object.Draw
glPopMatrix
next object

Where each object stores the current state of its own rotational and positional data.

Hmmm … any suggestions on how to implement motionblur for this rotating cube? Or just forget about it?

Use an array to store “trailing” positions of the cube, with their own rotation and position and alpha (for translucency). Draw the last trailing picture first and work your way back towards the original object, which is drawn last. Maybe turn off depth buffering before you do it? I’m new to gl.

pseudocode:

for a=7 to 0 // or less, depending on how many trailing images looks good
{
rotate(trailing[a].rotation);
translate(trailing[a].translation);
setColor (r,g,b,trailing[a].alpha)
draw (trailing[a])
setNewRotationTranslation(trailing[a])
}

I hope that makes sense. I would think this would draw transparent images increasing in opacity up to the original object.

Let me know if you think it will work.

Heaven
heaven@knology.net