PDA

View Full Version : help with NEHE outline fonts - lesson 14



mithun_daa
11-20-2003, 07:57 AM
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?

Relic
11-21-2003, 04:55 AM
You're scaling by 500, 250000, 125000000, 62500000000, ... Are you sure you want that instead of

glNewList 102, lstCompileAndExecute
For intI = 0 To 10
dblXpoints = dblScaleX * intI
glPushMatrix
glTranslated dblXMin, dblYMin +
dblScaleY, -dblZMin
glScalef 500, 500, 500
glPrint dblXpoints
glPopMatrix
Next intI
glEndList

mithun_daa
11-21-2003, 06:39 AM
Originally posted by Relic:
You're scaling by 500, 250000, 125000000, 62500000000, ... Are you sure you want that instead of

glNewList 102, lstCompileAndExecute
For intI = 0 To 10
dblXpoints = dblScaleX * intI
glPushMatrix
glTranslated dblXMin, dblYMin +
dblScaleY, -dblZMin
glScalef 500, 500, 500
glPrint dblXpoints
glPopMatrix
Next intI
glEndList

im not scaling by multiples of 500, it is alwayz scaled by 500 and its the points are being plotted on a scale, actually being translated.

Deiussum
11-21-2003, 06:54 AM
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 500*500 (as well as adding to your former translations). The second time it's 500*500*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.

mithun_daa
11-21-2003, 07:56 AM
Originally posted by Deiussum:
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 500*500 (as well as adding to your former translations). The second time it's 500*500*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.

so what do i do now?

mithun_daa
11-21-2003, 08:05 AM
Originally posted by mithun_daa:
so what do i do now?

awriteeeee, i fixed it. thanx a lot Deiussum for ur help. i really appreciate it.

Deiussum
11-21-2003, 09:49 AM
No problem. But it was really Relic who found it first. He even gave you the solution of moving your glPushMatrix/glPopMatrix inside the for loop.