GLSL + QT4 + Visual Studio Express

Hi all,

I’m a noob trying to get some simple shader demos working. When I try to compile my project, I get undefined symbols for shader-related code (but if I revert to old skool openGL, it compiles fine).

I am using QT4 to handle windows and contexts and such, so I created my own widget class that inherits from QGLWidget and overrides virtual methods as needed. Again, it all works fine until I start adding shader-related code. For example, this method


  void initializeGL()
  {
    glClearColor( 0.0, 0.03f, 0.09f, 0.0 );
    glEnable( GL_DEPTH_TEST );
    timer.start( 20 );
    angle = 0;

    // Try making a vertex shader
    std::string vertShadeSrc;
    if( loadTextFile( "VShaderWhite.fx", vertShadeSrc ) )
    {
      GLuint vertShade 
          = glCreateShaderARB( GL_VERTEX_SHADER );
      int numStrings = 1;
      glShaderSource( vertShade, 
                      &( vertShadeSrc.c_str() ), 
                      &numStrings );
      glCompileShader( vertShade );
    }
  }

gives the following errors:

1>c:\users\dave\documents\code\glext_test\glext_test\myglwidget.h(57): error C3861: ‘glCreateShaderARB’: identifier not found
1>c:\users\dave\documents\code\glext_test\glext_test\myglwidget.h(59): error C3861: ‘glShaderSource’: identifier not found
1>c:\users\dave\documents\code\glext_test\glext_test\myglwidget.h(60): error C3861: ‘glCompileShader’: identifier not found

My includes at the top of the file are:


#include <QGLWidget>
#include <QTimer>

#include <gl/GLU.h>
#include <gl/glext.h>

#include <iostream>

#include <fstream>
#include <sstream>

My development environment is Visual C++ 2010 Express, which apparently doesn’t come with its own headers for glext, so I downloaded them here:
http://www.opengl.org/registry/

Alas, that doesn’t solve the problem. So, what do I have to download/install to get shaders working in VC++ Express?

Thanks.

How about using the correct headers ?
Those are normal openGL calls, so guess what you need to #include ?

I’d love to use the correct header. Problem is that I’m a noob and don’t know what the correct header is.

I think you are implying that I should include gl.h, though correct me if I am wrong. I am already including glu.h, which includes gl.h. Besides, the version of gl.h that comes with VC++ Express 2010 doesn’t define any of the symbols that are missing. I did a search on my whole machine for any header that defines glCreateShaderARB, and I got nothing. So it seems that I have to download something.

Have you considered looking at our wiki? For the step you are on, you have two choices: use an OpenGL loading library, or write the loading code yourself. I strongly suggest you use a loading library.

Also, never use glCreateShader[b]ARB[/b]. Always use the core functionality (the version without the ARB). If you’re reading from a tutorial or example that uses the ARB version, it is too old to be useful; use something else.

I’ll add that in the case of mixing core with -ARB where this particular API is concerned, things can misbehave quite spectacularly on certain hardware/driver combos. The -ARB versions are definitely to be avoided unless you absolutely know that you specifically need to target hardware where the driver doesn’t support the core version (does such an animal even exist?)

Thanks, guys. QT has a few classes to deal with shaders, so I tried using those, and it seems to work more or less nicely. I suspect that this will put some limitations on how I can use shaders, but I am not yet so sophisticated that I notice any problems.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.