PDA

View Full Version : OpenGL Display Lists and Shaders



jleffelm
10-28-2003, 05:45 AM
I am trying to use cg shaders with some display lists(bitmap fonts), and none of them seem to work. When I use the same shader with a gluSphere, everything is fine, so I am pretty sure it isn't the shader. The gl code I am using is something like(sorry, my code isn't on this computer, but I am sure this looks pretty familiar):




glPushAttrib(GL_LIST_BIT);
glListBase(base - 32);
glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);
glPopAttrib();


Is there something about display lists in OpenGL(I had the same problem when I put the gluSphere in a display list instead of just creating and drawing it every frame) that don't work with Cg shaders? Is there something slightly different that needs to be done with display lists? Is there a way around this? Any insight would be appreciated.

-Drew

Relic
10-28-2003, 06:17 AM
"none of them seem to work"
Doesn't really help. How does it look like?

Where's your glRasterPos which sets the startpoint and all vertex attributes for the following bitmaps?
Does the text work in immediate mode?

Display lists just replay what you can put into them.
If you have general problems with display lists, try to use a smaller example to analyze a single triangle with all attributes you need for the shader.

Do you have multiple contexts? (wglShareLists?)
Context current while you built the display lists?

jleffelm
10-29-2003, 05:30 AM
Me thinks I should have reread my post. So I will try and answer your questions, as best I can.

When I try using display lists and cg, the shapes always comes out white(if it's text or a cube). I will try and post the rest of the code tonight, when I am near the computer that has the code on it.

I do not use multiple contexts in this program. How would I check to see if the context is current when I build the display list? Should I just use wglGetCurrentContext(), or is there a way to check that the context is current?

You mentioned: "Display lists just replay what you can put into them." I haven't had much experience with Display Lists except in text, would I need to include the cg code in between the glNewList and glEndList? I have been trying to use some old code I have for generating text, and putting that function call between the cgEnableProfile and cgDisableProfile calls.

Hope this helps a little more, and sorry for the really vague question. Thanks for posting these questions instead of just ignoring what was a poorly thought out question.

BTW, should this question have gone in the beginners section? I just posted here because I thought I had seen more questions about cgshaders here than in the beginners section.

-Drew


Originally posted by Relic:
"none of them seem to work"
Doesn't really help. How does it look like?

Where's your glRasterPos which sets the startpoint and all vertex attributes for the following bitmaps?
Does the text work in immediate mode?

Display lists just replay what you can put into them.
If you have general problems with display lists, try to use a smaller example to analyze a single triangle with all attributes you need for the shader.

Do you have multiple contexts? (wglShareLists?)
Context current while you built the display lists?

Relic
10-29-2003, 05:59 AM
"Should I just use wglGetCurrentContext(), or is there a way to check that the context is current?"

Yes, or put a breakpoint on all wglMakeCurrent calls and the glNewList and see what the last wglMakeCurrent before your glNewList was.

Sprinkle some glGetError between code which doesn't seem to work.

I don't know if Cg has an interaction with display lists. It shouldn't.

The question is, if you replace the glCallLists with the exact same stuff you do between glNewList and glEndList, does it work? (Ok, this would mean to manually do some glBitmap calls in the font case, so start with the simpler triangle case.)