PDA

View Full Version : Display list problem with new nVidia drivers



prabuva
07-21-2004, 01:39 AM
Following code is not rendering triangles with latest nvidia drivers. But, older nVidia drivers were able to render them. Am I not following OpenGL standards?

Thanks for the help.

glNewList( 1, GL_COMPILE );
glBegin(GL_TRIANGLES);
glVertex2f(1.0f, 1.0f);
glVertex2f(0.0f, 0.0f);
glVertex2f(-1.0f, 1.0f);
glEnd();
glBegin(GL_TRIANGLES);
glVertex2f(1.0f, -1.0f);
glEndList()

glNewList( 2, GL_COMPILE );
glVertex2f(0.0f, 0.0f);
glVertex2f(-1.0f, -1.0f);
glEnd();
glEndList()
.
..
glCallList (1);
glCallList (2);

SeskaPeel
07-21-2004, 01:53 AM
Heheheeeeeeee

This question is too advanced for me ... Anyway ...

1/ RTFM
2/ RTFMSDN
3/ RTFRedBook

or simply google "glNewList sample".

SeskaPeel.

prabuva
07-21-2004, 01:58 AM
Hey I know the following code will work.

glNewList( 1, GL_COMPILE ); // Create display list for triangle 1
glBegin(GL_TRIANGLES);
glVertex2f(1.0f, 1.0f);
glVertex2f(0.0f, 0.0f);
glVertex2f(-1.0f, 1.0f);
glEnd();
glEndList()
glNewList( 2, GL_COMPILE ); // // Create display list for triangle 2
glBegin(GL_TRIANGLES);
glVertex2f(1.0f, -1.0f);
glVertex2f(0.0f, 0.0f);
glVertex2f(-1.0f, -1.0f);
glEnd();
glEndList()
.
..
glCallList (1); // Draw the Triangle 1
glCallList (2); // Draw the Triangle 2

But, we have some software which is using code similar to the one I have mentioned before. Do you think this not according to OpenGL specification?

SeskaPeel
07-21-2004, 02:00 AM
You are completely misunderstanding the way glNewList works.

Why don't you follow my advice and RTFM ?

SeskaPeel.

prabuva
07-21-2004, 02:50 AM
Hey I know the following code will work.

glNewList( 1, GL_COMPILE ); // Create display list for triangle 1
glBegin(GL_TRIANGLES);
glVertex2f(1.0f, 1.0f);
glVertex2f(0.0f, 0.0f);
glVertex2f(-1.0f, 1.0f);
glEnd();
glEndList()
glNewList( 2, GL_COMPILE ); // // Create display list for triangle 2
glBegin(GL_TRIANGLES);
glVertex2f(1.0f, -1.0f);
glVertex2f(0.0f, 0.0f);
glVertex2f(-1.0f, -1.0f);
glEnd();
glEndList()
.
..
glCallList (1); // Draw the Triangle 1
glCallList (2); // Draw the Triangle 2

But, we have some software which is using code similar to the one I have mentioned before. Do you think this not according to OpenGL specification?

Relic
07-21-2004, 03:38 AM
Originally posted by SeskaPeel:
You are completely misunderstanding the way glNewList works.

Why don't you follow my advice and RTFM ?

SeskaPeel.No, the code in the first post is valid.
Every command which is able to be compiled into a display list should just be played back if called this way.
In this example replace the CallList calls with the commands inside the display list and see what you get? Two triangles.

Ok, if this worked before the "latest"(?) driver whatever that is for you, has a bug.

Riff
07-21-2004, 04:25 AM
Prabuva's list example is not valid. Page 268 of the OpenGl Reference Manual, Second Edition, states in the ERRORS section:

GL_INVALID_OPERATION is generated if glNewList or glEndList is executed between the execution of glBegin and the corresponding execution of glEnd.

The first display list example should return GL_INVALID_OPERATION because you are calling glEndList after a glBegin, but before the corresponding glEnd. This means that previous driver versions were in error with respect to the OpenGL specifications and the latest driver is behaving correctly.

Relic
07-21-2004, 05:35 AM
Wrong, the display list is generated with GL_COMPILE, the glBegin and glEnd calls are not executed. :rolleyes:

Riff
07-21-2004, 06:51 AM
The error conditions supported by glNewList and glEndList are specifically geared towards compilation. I don't see much use for them if they only apply to compile-and-execute mode. For one thing, having a glEndList in the middle of a glBegin/glEnd pair would be no more difficult to handle than any other state-saving code. During execution, the pipeline always knows the current state so if the list compiler needed to save some internal "in-the-middle-of-a-primitive" state, it would certainly be able to do so. Yet this is not the case, and the specs state that a GL_INVALID_OPERATION will be returned. This implies to me that attempting to compile a list in the middle of a primitive is not allowed due to the pipeline not saving intermediate states or so that the pipeline can assume that glCallList can reset the primitive state.

You can use roll-eyes smileys all you want, but unless the specs explicitly state that lists must be able to end in arbitrary positions, then a "it worked before, and it doesn't work now, so it must be a bug" hypothesis is no better than the explanation I am suggesting. You need to take the stance that anything not explicitly stated in the specification is considered undefined and that anything undefined is considered "your mileage may vary," where behavior may not be consistent between driver releases, even if by the same vendor.

You might as well just email nvidia developer relations and ask them directly. It seems like that would be an official answer and be a lot more productive than arguing about undefined behavior.

SirKnight
07-21-2004, 06:55 AM
Ok I don't know what SeskaPeel's deal is, but that first code posting should work just fine. Looks like a bug to me! :)

-SirKnight

Relic
07-21-2004, 07:14 AM
@Riff: You looked up the spec, which is good, but you cited the wrong error case.

The error you mention is this
// E.g. while not in display list compile mode
glBegin
glNewList => INVALID_OPERATION
...

The case here is clearly outlined in the spec Chapter 5 "NewList":

"If mode is COMPILE, then commands are not executed as they are placed in the display list.
...
After calling NewList all subsequent GL commands are placed in the display list (in the order the commands are issued) until a call to
void EndList( void );
occurs, after which the GL returns to its normal command execution state.
...
Once defined, a display list is executed by calling
void CallList( uint n );
n gives the index of the display list to be called. This causes the commands saved
in the display list to be executed, in order, just as if they were issued without using
a display list."

The code is correct, I've seen something like this running before. Agreed, it's weird and I wouldn't program that way either. Ok, I'm out of here.

@prabuva: What's your "latest" driver and hardware.

dorbie
07-21-2004, 08:42 AM
The sample code has an endlist call between a glBegin glEnd pair.

Technically it is illegal code IMHO section 2.6.3 "GL Commands Within Begin/End" states you may invoke a calllist between begin end pair but does not say endlist is permitted.

Whether the mode is COMPILE or COMPILE & EXECUTE does not affect the legality of this although it may affect the execution in practice IMHO (it's an imperfect world). It makes some sense that this would work on some implementations and not on others.

You should see an INVALID_OPERATION error immediately after you issue the endlist call.

Relic
07-21-2004, 09:58 PM
But only if the glBegin had been executed. If your build a display list GL_COMPILE the glBegin has not been executed. The error you cite is true for an immediate mode or display list compile_and_execute glBegin-glEnd pair. Read the specs in my previous post.

prabuva
07-21-2004, 10:40 PM
>>@prabuva: What's your "latest" driver and >>hardware.

Driver version: NVIDIA 5.6.7.2 (Not working)
Driver version: NVIDIA 4.5.2.3 (Working)

Chipset: NVIDIA GeForce4 Ti 4600.

Thanks for the response.

Relic
07-22-2004, 02:19 AM
You see, "latest" means nothing, it's already outdated by 61.76. Might give it a try.

prabuva
07-22-2004, 02:42 AM
>>You see, "latest" means nothing, it's already >>outdated by 61.76. Might give it a try.

I have tried it. It did not work:-(

V-man
07-22-2004, 03:48 AM
Originally posted by Relic:
But only if the glBegin had been executed. If your build a display list GL_COMPILE the glBegin has not been executed. The error you cite is true for an immediate mode or display list compile_and_execute glBegin-glEnd pair. Read the specs in my previous post.I think Dorbie is right.

Calling glBegin counts as executing.
The word "COMPILE_AND_EXECUTE" that you pass to glNewList has nothing to do with it.

If one does

glNewList(ID, GL_COMPILE);
glColor3f(.....);
glBegin(.....);
glVertex(.......);
glVertex(.......);
glVertex(.......);
glVertex(.......);
glEnd();
glEndList();

If I understood it right, the current color comes from the call to glColor3f in the display list, even though nothing is getting rendered.

prabuva
07-22-2004, 04:25 AM
When I executed the code in my first post with the recent drivers, no error occured. The glGetError returned GL_NO_ERROR instead of GL_INVALID_OPERATION error as mentioned by Dorbie. But, I could not see the triangles.

evanGLizr
07-22-2004, 09:32 AM
The sample code is correct. Relic was spot on in his explanation: when you are in COMPILE mode, the commands are not executed, they are just stored inside the display list.

In fact, this means that if a command compiled inside a display list would give an error if executed, the error won't be detected at compile time, but at display list execution time. But then at execution time, there's no glEndList, so in the sample's case, no error should occur.

This is supported by the fact that glCallList/s is valid inside begin/end. So it's perfectly valid to do


Display lists require one bit of state to indicate whether a GL command should be executed immediately or placed in a display list. In the initial state, commands are executed immediately.
(OpenGL spec 1.5 pg 210)

Just take a look at SGI\'s sample implementation\'s (http://oss.sgi.com/projects/ogl-sample/) __gllc_* (list compile) and __glle_* (list execute) functions (normally dl_* files).
You will see that __gllc_Begin (the function called when a begin is compiled inside a display list) doesn't set the flag of "inside begin/end", so when __glim_EndList is called it doesn't fail the begin/end check.

For example, one of the curious things SGI's implementation does is, when an OpenGL command compiled inside a display list would return an error if executed, it stores the error directly inside the display list instead of storing the OpenGL command.
As cited earlier, that's not the case when glEndList is called inside begin/end - when in COMPILE mode - it's not an error so no error is placed in the display list.

nystep
07-22-2004, 11:19 PM
I don't know display lists very well, and i might be wrong, but doesn't someone has to call glNewLists before compiling a display list?

zeckensack
07-23-2004, 12:48 AM
Originally posted by nystep:
I don't know display lists very well, and i might be wrong, but doesn't someone has to call glNewLists before compiling a display list?glNewList initiates compilation. You probably meant glGenLists, but that isn't necessary either. List creation is implicit in the glNewList call. glGenLists just reserves names but doesn't initialize them. Its only function is to eliminate application side namespace management.
Texture objects have similar behaviour.

nystep
07-23-2004, 08:04 AM
I meant glGenLists of course ;)
thanks for the answer.

prabuva
08-15-2004, 09:59 PM
nVidia declined to fix this problem:-(