i am tryin to use the code that was put up on nehe. i have a whole bunch of numerical values (increase sequentially) to display. when i use a for loop to display i get an overflow message. my code looks like :
glNewList 102, lstCompileAndExecute
glPushMatrix
For intI = 0 To 10
dblXpoints = dblScaleX * intI
glTranslated dblXMin, dblYMin +
dblScaleY, -dblZMin
glScalef 500, 500, 500
glPrint dblXpoints
Next intI
glPopMatrix
glEndList
i think the opengl matrix is getting overflowed. is there any other way around this problem?
No, with the push/pop matrix outside of the for loop, you only scale by 500 the first time through the loop. The second time you scale by 500500 (as well as adding to your former translations). The second time it’s 500500*500, etc…
You have to remember that OpenGL is a state machine. Each time you do a glTranslate/glScale/glRotate, etc. It multiplies that translate/scale/rotate to the current matrix. Without restoring the matrix to its former state within that loop via something like a push/pop matrix, your translations/scales/rotates are all cumulating.
Originally posted by Deiussum:
[b]No, with the push/pop matrix outside of the for loop, you only scale by 500 the first time through the loop. The second time you scale by 500500 (as well as adding to your former translations). The second time it’s 500500*500, etc…
You have to remember that OpenGL is a state machine. Each time you do a glTranslate/glScale/glRotate, etc. It multiplies that translate/scale/rotate to the current matrix. Without restoring the matrix to its former state within that loop via something like a push/pop matrix, your translations/scales/rotates are all cumulating.[/b]