glGenProgramsARB fails...

Sage
Posts: 1,199
Joined: 2004.10
Post: #1
All

I'm trying to learn to use ARB_fragment_program; I've got the OpenGL Superbible and associated source code, as well as a nice Shader class which I found in some excellent sample code ( from frustum.org )

Now, I *know* my PB supports ARB_fragment_program, since I've got an NVIDIA 5200 Fx Go and because the superbible sample code compiles and runs fine.

So the trouble is, glGenProgramsARB is failing. I *know* my OpenGL context is valid and initialized. Also, I'm using GLEW for my extension management.

Here's a snippet:
Code:
else if(!strncmp(data,"!!ARBfp1.0",10))
{
    printf( "Shader::Shader()\tLoading !!ARBfp1.0\n" );

    _target = GL_FRAGMENT_PROGRAM_ARB;
    glGenProgramsARB(1,&_id); // <-- fails here
    printf( "\t%d\tError: %s\n", __LINE__, gluErrorString( glGetError() ));

    glBindProgramARB(_target,_id);
    printf( "\t%d\tError: %s\n", __LINE__, gluErrorString( glGetError() ));

    glProgramStringARB(_target,GL_PROGRAM_FORMAT_ASCII_ARB,strlen(data),data);
    printf( "\t%d\tError: %s\n", __LINE__, gluErrorString( glGetError() ));

    glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB,&error);
    printf( "\t%d\tError: %s\n", __LINE__, gluErrorString( glGetError() ));

}

It fails on glGenProgramsARB with the error: "invalid value". Does anybody have *any* idea what's going on here?
Quote this message in a reply
Mars_999
Unregistered
 
Post: #2
What kind of variable is _id? It sould be a pointer to an unsigned int. I see you are using the & so I am assuming you are using a local or auto variable? Try setting _id to an array like so

Code:
unsigned int fp_id[1] = {0};

Also not sure why you are using _ on your variables but you should stop. Some compilers reserve _ for its own use....
Quote this message in a reply
Member
Posts: 41
Joined: 2005.02
Post: #3
Mars_999 Wrote:Also not sure why you are using _ on your variables but you should stop. Some compilers reserve _ for its own use....

GCC, the complier in question, uses a double underscore. I have never had a problem with a single underscore in a variable name. I don't know why Tomorrow is using it, but they are often used to denote private, hidden, and variables with a small scope. Now using the common semantics of the mac libraries, one would not use an underscore. Using those semantics have never been required to make something work though...

On that note, I agree with Mars though. Stop using an underscore if you are programming using Apple's API. Wink At least I make it clear that I just like it better without an underscore.

Note: One variable name that can really be bad is just a single underscore and nothing else, "_". It will work under GCC3 (as seen below) but I really wouldn't suggest using it.

Code:
[sage@legomaster ~/src ] $ cat underscore.c ; gcc --version ; gcc underscore.c ; ./a.out
#include <stdio.h>

int main ( void ) {
        int _ = 0;
        printf("_ is... %d\n", ++_);
        return 0;
}
gcc (GCC) 3.3 20030304 (Apple Computer, Inc. build 1671)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

_ is... 1
[sage@legomaster ~/src ] $

Now I've gone way off topic...
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #4
Is it possible that an earlier OpenGL call is generating the invalid value error? In the snippet you pasted, glGetError() isn't called to clear the error before calling glGenProgramsARB. Might be something to try, at least...

- Alex Diener
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
GenProgramsARB cannot cause an error. I'm betting the error is from an earlier OpenGL call.

If you use the OpenGL profiler, you can have it break when an OpenGL error is raised. That will give you a backtrace to the error-causing call.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #6
Thanks for the replies. Regarding the underscore, when I code in C++, which is 99% of the time, I prefix member variables with underscores -- and I'm not in a minority doing so! This is a segment from a class method, and it makes my life a lot easier to know which are local and which are instance variables. I know there are other conventions, such as "m_" or a prefix "f" but I think those are ugly. That said, I generally try to do as the Romans do in Cocoa and there I don't underscore.

OSC -- thanks for the note. That's a bit of a relief; I'll give the profiler a stab when I get home. Oh wait, I'm going out drinking tonight... maybe tomorrow then Wink
Quote this message in a reply
Moderator
Posts: 771
Joined: 2003.04
Post: #7
TomorrowPlusX Wrote:Regarding the underscore, when I code in C++, which is 99% of the time, I prefix member variables with underscores -- and I'm not in a minority doing so! This is a segment from a class method, and it makes my life a lot easier to know which are local and which are instance variables. I know there are other conventions, such as "m_" or a prefix "f" but I think those are ugly. That said, I generally try to do as the Romans do in Cocoa and there I don't underscore.

Same here Smile
I don't use them for Cocoa, because of Apple's Obj-C coding guidelines, but even so, not everyone agrees:

http://www.stone.com/The_Cocoa_Files/Wri..._Code.html
http://www.stepwise.com/Articles/Technic...13.01.html

Also, I found this page where they say "In fact, the idea of a private prefix is largely unnecessary, as virtually all instance variables in Cocoa are protected anyway."
That is not the issue for me, but rather being able to tell (as you said) "which are local and which are instance variables".

[/offtopic] Blush
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  CGBitmapContextCreate fails for RGB NYGhost 3 5,982 Feb 15, 2006 10:11 PM
Last Post: arekkusu
  SDL on Tiger fails to update display Dan Compton 2 2,718 Jan 9, 2006 08:18 AM
Last Post: DanLab