Reputation: 21
I am working in OpenGL.
Tao Bindings.
XP Pro 64.
VS 2008 in VB.NET
I have built dozens of simple tools and test apps and even 2 large apps using Opengl to render with.
Why is it that all at once in only one project am I seeing this at run time? It builds with no errors.. which is normal for this sort a thing. The thing is, its only this soultion that im working on thats crapping out.
Unable to find an entry point named 'glCreateShader' in DLL 'opengl32.dll'.
I've tried changing all sorts of settings in the IDE (BUT IT WORKS WITH OTHER CODE FINE SO THIS SEEMS IDIOTIC!)
I've tried replacing the opengl32.dll but.. then NO built solutions would run.
1) It's NOT the opengl32.dll (It works fine in other builds)
2) The settings are the same in VS2008 as any other OpenGL app I have built.
3) I have looked at the code for hours and.. even searched to see if the varaibles name was some way used by accident. I can not see anything that could be causing this.
4) Yes.. Im compiling to x86 (Tao wont run in 64bit).. As I mentioned.. I have had no issues until now.
This is the line that's protesting:
vertexObject = Gl.glCreateShader(Gl.GL_VERTEX_SHADER)
Upvotes: 2
Views: 4270
Reputation: 149
Ok folks... I found the problem.
If and I'm not sure this is true on all versions of Win out there but for XP Pro 64...
Changing the screen to full size causes Tao to loose its bearings.
From the text in the Tao Class:
This class contains all OpenGL enums and functions defined in the 2.1 specification. The official .spec files can be found at: http://opengl.org/registry/. We rely on static initialization to obtain the entry points for OpenGL functions. Please ensure that a valid OpenGL context has been made current in the pertinent thread before any OpenGL functions are called (toolkits like GLUT, SDL or GLFW will automatically take care of the context initialization process). Without a valid OpenGL context, we will only be able to retrieve statically exported entry points (typically corresponding to OpenGL version 1.1 under Windows, 1.3 under Linux and 1.4 under Windows Vista), and extension methods will need to be loaded manually.*
If you prefer to have more control on extension loading, you can use the ReloadFunctions or ReloadFunction methods to manually force the initialisation of OpenGL entry points. The ReloadFunctions method should be called whenever you change an existing visual or pixelformat. This generally happens when you change the color/stencil/depth buffer associated with a window (but probably not the resolution). This may or may not be necessary under Linux/MacOS, but is generally required for Windows.
I'm sure the above is (c) by Tao..
I'm sorry If I sounded grumpy.. I was :(
Anyway.. I needed to add this....
Gl.ReloadFunctions()
....after I set up the device context.
So this is the order that works now:
If Not (Wgl.wglMakeCurrent(ghDC, hRC)) Then
MessageBox.Show("Unable to make rendering context current")
End
End If
Glut.glutInit()
Glut.glutInitDisplayMode(GLUT_RGBA Or GLUT_DOUBLE)
Gl.ReloadFunctions() 'New Line that reloads the extensions.
build_shaders() ' where shaders are created and complied
So there ya have it :)
Thanks again everyone!
Upvotes: 4
Reputation: 162164
glCreateShader
is a function introduced with OpenGL-2 and was part of an extension before. Windows' opengl32.dll only covers OpenGL-1.1, anything beyond that only accessible as extensions. So the entry point to glCreateShader
must be retrieved through the exension mechanism. OpenGL.org has a FAQ on this
http://www.opengl.org/resources/faq/technical/extensions.htm
23.070 How can I call extension routines on Microsoft Windows?
Your application may find some extensions already available through Microsoft's opengl32.lib. However, depending on your OpenGL device and device driver, a particular vendor-specific extension may or may not be present at link time. If it's not present in opengl32.lib, you'll need to obtain the address of the extension's entry points at run time from the device's ICD. Here's an example code segment that demonstrates obtaining function pointers for the ARB_multitexture extension:
/* Include the header that defines the extension. This may be a vendor-specific .h file, or GL/glExt.h as shown here, which contains definitions for all extensions. */ #include "GL/glExt.h" /* Declare function pointers */ PFNGLACTIVETEXTUREARBPROC glActiveTextureARB; PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB; ... /* Obtain the address of the extension entry points. */ glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress("glActiveTextureARB"); glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC) wglGetProcAddress("glMultiTexCoord2fARB");
After you obtain the entry point addresses of the extension functions you wish to use, simply call through them as normal function pointers:
/* Set texture unit 0 min and mag filters */ (*glActiveTextureARB) (GL_TEXTURE0_ARB); glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); ... /* Draw multi textured quad */ glBegin (GL_QUADS); (*glMultiTexCoord2fARB) (GL_TEXTURE0_ARB, 0.f, 0.f); (*glMultiTexCoord2fARB) (GL_TEXTURE1_ARB, 0.f, 0.f); glVertex3f (32.f,32.f, 0.f); ... glEnd();
More information on wglGetProcAddress() is available through the MSDN documentation.
In the case of language bindings, like Tao or OpenTK, it is the binding's job to properly setup and provide all extensions available. Now you're using Tao which is terribly outdated (last release was Nov 2005). I recommend switching to OpenTK.
Upvotes: 1
Reputation: 2518
I would first use 'nm' and 'objdump -CDx' to check if the function is defined and contains code.
dumpbin /symbols library.lib
Then I would verify that
FARPROC WINAPI GetProcAddress(
__in HMODULE hModule,
__in LPCSTR lpProcName
);
actually can find the function pointer and use GetLastError if to figure out what the error is.
Upvotes: 0