• Advertisement
Sign in to follow this  

Getting pointers to glsl functions? (solved)

This topic is 4726 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
lets not forget glew (i personally use glee and love it, but lets not hide the competition :-p)

-Dan

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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 =)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement