Vertex Program (should be) simple error

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.

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

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).]

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).]

Why do you need to check whether your id is a program object anyway?

To check is Gen went OK

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

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

Make sure you have a valid OpenGL rendering context active before calling any OpenGL functions.

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.

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?

GeForce FX 5200
driver 45.23

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.

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.