Skip to main content
GameDev.net gamedev.net
🔒 Locked

Getting pointers to glsl functions? (solved)

Started by Fibonacci One Mar 15, 2005 at 12:20 AM 8 replies 3.6k views
Original Post
Fibonacci One
Fibonacci One
Hello, I've got the source for my first shaders written in GLSL all done and ready to test. Now I'm trying to create a simple program that will load, compile, link, and use these shaders. The only experience I have with extensions is with using VBOs, so it didn't come as a suprise to me when the first bug I encountered was with these. I assume that in order to use the various functions (like glCreateShaderObjectARB) I need to do the same thing I did to get the pointers for the VBO functions. So I wrote a bunch of these:

	glUniform2fARB	                 = (PFNGLUNIFORM2FARBPROC)				wglGetProcAddress("glUniform2fARB");
	glUniform3fARB	                 = (PFNGLUNIFORM3FARBPROC)				wglGetProcAddress("glUniform3fARB");
	glGetUniformLocationARB		 = (PFNGLGETUNIFORMLOCATIONARBPROC)		wglGetProcAddress("glGetUniformLocationARB");
	glDeleteObjectARB                = (PFNGLDELETEOBJECTARBPROC)			wglGetProcAddress("glDeleteObjectARB");
	glGetObjectParameterivARB        = (PFNGLGETOBJECTPARAMETERIVARBPROC)	wglGetProcAddress("glGetObjectParameterivARB");
	glCreateShaderObjectARB		 = (PFNGLCREATESHADEROBJECTARBPROC)		wglGetProcAddress("glCreateShaderObjectARB");
	glShaderSourceARB	         = (PFNGLSHADERSOURCEARBPROC)			wglGetProcAddress("glShaderSourceARB");
	glCompileShaderARB		 = (PFNGLCOMPILESHADERARBPROC)			wglGetProcAddress("glCompileShaderARB");	
	glCreateProgramObjectARB	 = (PFNGLCREATEPROGRAMOBJECTARBPROC)		wglGetProcAddress("glCreateProgramObjectARB");
	glAttachObjectARB	         = (PFNGLATTACHOBJECTARBPROC)			wglGetProcAddress("glAttachObjectARB");
	glLinkProgramARB                 = (PFNGLLINKPROGRAMARBPROC)				wglGetProcAddress("glLinkProgramARB");
	glUseProgramObjectARB            = (PFNGLUSEPROGRAMOBJECTARBPROC)		wglGetProcAddress("glUseProgramObjectARB");



However, when I run the program, wglGetProcAddress keeps returning null. Is there some other way I'm supposed to get these pointers? Thanks (BTW: I do have GL_ARB_fragment_program and GL_ARB_vertex_program) [Edited by - Fibonacci One on March 15, 2005 2:33:25 PM]
Ademan555
Ademan555
2 things, the first is, when are you trying to get these pointers? I'm not entirely sure if it depends on there already being a valid openGL context (having the opengl32.dll open or something) so you might want to move your initialization. And the second thing is a question, do ALL of the calls to wglGetProcAddress() return null? it could be youve screwed up a couple of your symbol names, but off the top of my head they look alright
hope that helps
-Dan
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out hi
jerm007
jerm007
Hey,

Do you have a properly initialized HDC and HGLRC before you try getting the function pointers?

If you want an easy approach to all the extensions stuff, I would recommend using GLee as it automatically sets up all the pointers for you, so you can worry about using OpenGL as it is intended.

If that isn't it, I'll try to help further.

Jeremiah
Power User / Programmer / Game Player ( Not computer nerd :)
cwhite
cwhite
Quote:
Original post by jerm007
If you want an easy approach to all the extensions stuff, I would recommend using GLee as it automatically sets up all the pointers for you, so you can worry about using OpenGL as it is intended.


Seconded. Glee will set up extensions automatically and then proceed to cure cancer and bring world peace.
Ademan555
Ademan555
lets not forget glew (i personally use glee and love it, but lets not hide the competition :-p)

-Dan
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out hi
Fibonacci One
Fibonacci One
I have these calls inside the constructor for a class that is not called until after I've created my openGL window.
Also, all of the functions alternate between returning null or 0xcccccccc.
(edit: see my next post)
Fibonacci One
Fibonacci One
Quote:
Original post by cwhite
Quote:
Original post by jerm007
If you want an easy approach to all the extensions stuff, I would recommend using GLee as it automatically sets up all the pointers for you, so you can worry about using OpenGL as it is intended.


Seconded. Glee will set up extensions automatically and then proceed to cure cancer and bring world peace.


My TI-89 already did all that when I was taking high school calculus =). I'll check it out anyway though.

Thanks =)
jerm007
jerm007
Hello again,

Yes, GLew is also available, but GLee is made by a resident member here at GameDev.net, so I recommended it instead.

Related to Fibonacci's post:

It is very similar to using any sort of library. Any Direct3D calls, for example, wouldn't work until you initialized it. You could add some sort of initialize function for your classes that can be called after OpenGL is initialized. This is better anyway because if something in your class initialization fails (like what is currently happening) you can check for that. Constructors have no return values, so error checking in them can be difficult.

Edit: Do you create the class on the heap? More specifically, how are the objects being created after the window?

-Jeremiah
Power User / Programmer / Game Player ( Not computer nerd :)
terminate
terminate
Your card may not actually support GLSL as you are checking for the wrong extensions.

The extensions tring should contain

GL_ARB_shader_objects
GL_ARB_vertex_shader (not GL_ARB_vertex_program, GLSL uses _shader)
GL_ARB_fragment_shader (again, shader, not program)

It should also contain GL_ARB_shading_language_100 to signify it supports version 1.00 of GLSL.

-Evan
Those who dance are considered insane by those who cannot hear the music.
Fibonacci One
Fibonacci One
Quote:
Original post by jerm007
Edit: Do you create the class on the heap? More specifically, how are the objects being created after the window?
-Jeremiah

To start with, I'm using something very similar to the code given in some of the earlier NeHe tutorials to create my window. I make a call to create the window, then I create a Window class. Inside the Window constructor I do things like choose the clearColor and enable depth testing, then I create a
shader class. Inside the constructor for this class is where I have the code I had in my first post.

Quote:
Original post by terminate
Your card may not actually support GLSL as you are checking for the wrong extensions.
GL_ARB_shader_objects
GL_ARB_vertex_shader (not GL_ARB_vertex_program, GLSL uses _shader)
GL_ARB_fragment_shader (again, shader, not program)
It should also contain GL_ARB_shading_language_100 to signify it supports version 1.00 of GLSL.
-Evan

I have these as well. Thanks for pointing that out though, certainly saved me some trouble down the line.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.