View Full Version : Trouble with glDrawElements
02-26-2004, 10: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 glDrawElements(GL_QUADS,nverts,GL_UNSIGNED_INT,ind ecies)
02-26-2004, 12:00 PM
Why dont you just use glScale?
02-26-2004, 12: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).]
02-26-2004, 06: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.
02-27-2004, 04:47 AM
Do I need to delete the call list to clear it? I thought that calling glnewlist again would reset the compiled data...
02-27-2004, 03: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?
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?
02-28-2004, 09: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.
03-01-2004, 06: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).]
03-02-2004, 09: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.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.