PDA

View Full Version : Trouble with glDrawElements



mountain_ike
02-26-2004, 11:27 AM
I am having troubles with the following snipet of code. The way things are set up I will be rendering terrain with this code. This works fine when first loaded.
However, if the user wants to increase the terrain magnification I need to recalculate the mesh and re-run this code. When that happens it starts removing pieces of the rendered image until it is all gone! Is OGL not reassigning the pointer values and collecteding bad memory locations?
call glVertexPointer(3, GL_FLOAT, 0, loc(cubeverts))
call glNormalPointer(GL_FLOAT, 0,loc(cubenormals))

call glnewlist(1,GL_COMPILE)
call glDrawElements(GL_QUADS,nverts,GL_UNSIGNED_INT,ind ecies)
call glendlist()

shielded
02-26-2004, 01:00 PM
Why dont you just use glScale?

mountain_ike
02-26-2004, 01:18 PM
I need to change the ratio of the highs to the lows, then calculate new normals to get the correct effect. Just changing the scale doesn't work right.

[This message has been edited by mountain_ike (edited 02-26-2004).]

jwatte
02-26-2004, 07:47 PM
Display lists copy the client state data at the point of compile. Changing the pointers, or the data pointed at, after you've compiled the list won't change the list contents at all.

mountain_ike
02-27-2004, 05:47 AM
Do I need to delete the call list to clear it? I thought that calling glnewlist again would reset the compiled data...

jwatte
02-27-2004, 04:18 PM
Yes, that's how it's supposed to work. From your code, it was un-clear to me whether you did this every frame -- if so, why are you using display lists at all?

idr
02-28-2004, 07:57 PM
To be honest, a display list does not sound like the right too for this job. In any case, the spec isn't completely clear on what happens when a list ID is re-used. I would assume that it should behave the same as with texture objects. Have you tried your program with a different driver or perhaps with Mesa?

CGameProgrammer
02-28-2004, 10:43 PM
I believe you can call glNewList on the same ID without a problem. glDeleteLists() undoes glGenLists(), it's not for undoing glNewList. However I have found that remaking display lists is extremely slow.

mountain_ike
03-01-2004, 07:10 AM
I am only regenerating the display list under very special circumstances, but I will still need to do it. Most of the time I just access the list without generating it. This may not be a question for the advanced group, but is there a better way to do this?

[This message has been edited by mountain_ike (edited 03-01-2004).]

Aeluned
03-02-2004, 10:44 AM
I'm having the same problem having VBOs and Display Lists get along nicely together. I also have vertex data that needs to be updated. If the only reason you're updating your vertex data is in order to recalculate the normals you might try enabling GL_RESCALE_NORMAL.
this way you could use glScalef to do your scaling and your normals would automatically get rescaled as well.