PDA

View Full Version : Vertex Program (should be) simple error



SeskaPeel
08-20-2003, 02:39 AM
I can't generate a vertex program object ...
The code seems crystal clear :

GLuint VProgID ;
glGenProgramsARB(1, &VProgID) ;
if (! glIsProgramARB(VProgID)) return 0 ;

Instead of going further, it returns 0 ...
Did I forget something ?

SeskaPeel.

zeckensack
08-20-2003, 02:56 AM
AFAIK it will only turn into a shader object once you bind it. The check is too early.

Textures and display lists behave the same way. The glGen* functions give you unused identifiers.

Eg, you can do this

glNewList(1,GL_COMPILE);without ever 'generating' a display list. This is perfectly valid code.

But it requires you to keep track of which objects you already created so that you don't use numbers twice. That's why the glGen* thingies exist http://www.opengl.org/discussion_boards/ubb/smile.gif

Bob
08-20-2003, 03:00 AM
The rendering context perhaps?

edit: Never mind, zeckensack's explanations is probably more correct.


[This message has been edited by Bob (edited 08-20-2003).]

SeskaPeel
08-20-2003, 03:40 AM
This code doesn't work neither (same result)


std::string VProg ;
if (! ReadProgramFile(VertexFile, VProg)) return 0 ;

GLuint VProgID ;
glGenProgramsARB(1, &VProgID) ;
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, VProgID) ;

glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, VProg.size(), VProg.c_str()) ;

if (! glIsProgramARB(VProgID)) return 0 ;

Even if glIsProgram returns false, the id is still 1, and works very well, I just would like to have a right test at init time.

[This message has been edited by SeskaPeel (edited 08-20-2003).]

Humus
08-20-2003, 04:13 AM
Why do you need to check whether your id is a program object anyway?

SeskaPeel
08-20-2003, 04:18 AM
To check is Gen went OK

SirKnight
08-20-2003, 01:42 PM
Originally posted by SeskaPeel:
To check is Gen went OK

You don't need to worry about that. What you should check for instead is when you load a program is if it had any errors or anything like that.

Actually you don't really need the glGenProgramsARB function. As long as each program you load has it's own id all will be ok. All glGen does is return in the second param the next available integer to be used as an id for a program.


-SirKnight

SirKnight
08-20-2003, 01:44 PM
you can even do this:

glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 1) ;
glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, VProg.size(), VProg.c_str()) ;

Now every time you bind 1 when you render, it will use that program glProgramStringARB just loaded up there.

-SirKnight

jra101
08-20-2003, 01:58 PM
Make sure you have a valid OpenGL rendering context active before calling any OpenGL functions.

MichaelK
08-22-2003, 05:24 AM
Originally posted by SeskaPeel:
To check is Gen went OK

If You want to do this, simpy check if generated value is > 0. Program 0 is reserved and never will be returned by glGen.

zeckensack
08-22-2003, 06:23 AM
It still somewhat looks like a driver issue. glIsProgramARB should return true once the object has been bound and initialized.

SeskaPeel,
care to share with us what graphics card and driver version you're using?

SeskaPeel
08-22-2003, 06:25 AM
GeForce FX 5200
driver 45.23

jra101
08-22-2003, 08:16 AM
If you post or email me source for your app, I'll file a bug on this and make sure it gets fixed in a future release.

SeskaPeel
08-22-2003, 08:32 AM
jra, I can't post you the whole app.

I could compile a small app showing the problem, but I really don't mind if it never gets fixed. I was just wondering why it didn't work.

SeskaPeel.