PDA

View Full Version : GL (glut?) matrix stack



ugluk
10-21-2010, 05:45 PM
I am now a fervent adherent of batching, but I have a problem. Whenever a new frame starts (I'm using glut) something clears the modelview matrix. My batcher thinks the old modelview matrix is still loaded and does not reload it. The consequence of this, of course, is a garbled frame. The code looks something like this:



// if (batch_ptr->matrix_ptr != matrix_ptr)
{
glLoadMatrixf(batch_ptr->matrix_ptr->data());

matrix_ptr = batch_ptr->matrix_ptr;
}


The comment is present, because, to get correct behaviour, I must reload the modelview matrix every frame. Where do the GL or glut specs say that the modelview matrix is to be cleared every frame?

Alfonse Reinheart
10-21-2010, 06:11 PM
They don't. Therefore, you're likely the one doing the clearing. You may want to try GLIntercept to track things down.

ugluk
10-21-2010, 08:27 PM
You were right, though I changed the modelview matrix indirectly. There was a stray glScale() in my code. I can't compile GLIntercept for linux, do you have some other suggestion?

Also, with batching I'll need to do many matrix mults on the CPU, but I suppose the driver does this even if one works with glScale(), glRotate() and glTranslate() transform family. The huge number of transforms I need to do for almost every batch is worrying me :)