Jump to content
  • Advertisement
Sign in to follow this  
jalway

OpenGL Can't get my GLSL shader to work in Windows

This topic is 807 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'm a beginner when it comes to shaders.    I'm stuck right at the start, because I can't get the basic shaders to work at all.
 
Some specs:
I have Windows 7, a four core desktop computer, with 4 gigs of ram.     My graphics card is a Raedon ASUS EAH6670, which supports OpenGL 4.1.    When I check to see what version of OpenGL I have, I get 4.2.
 
I'm trying the code from a youtube tutorial created by James King. Here is where he tells you where you can download his code.
https://www.youtube.com/watch?annotation_id=annotation_1911550921&feature=iv&src_vid=Dyue3MzJDss&v=KV78e10S0VA
 
I went to github and downloaded his code here https://github.com/1kingja/graphics
 
I compiled it and ran it, and right away I get the following errors, which I have not been able to solve:
 
"Vertex shader failed to compile with the following errors:
ERROR: 0:1 error(#106) Version number not supported by GL2
ERROR: error(#273) 1 compilation errors.  No code generated"
 
  I'm confused by this, because it seems to be saying I have OpenGL version 2, when I'm told elsewhere, both by the glGetString(GL_VERSION) function and by a stand alone application, that I have version 4.2.
 
  Does anyone here have an idea what I'm doing wrong?   
 
   Many thanks for any help!
 
...John

Share this post


Link to post
Share on other sites
Advertisement

It could be you have an OpenGL 2 context (even though your card happily supports higher). I looked for the initialisation code but it just uses Glew so I don't really know what version of the context it is creating. It is slightly odd that it doesn't 'just work' seen as this is presumably his code to go along with the video. 

void MeGlWindow::initializeGL()
{
	setMinimumSize(1200, 600);
	setMouseTracking(false);
	glewInit();
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_CULL_FACE);
	sendDataToOpenGL();
	installShaders();
}

It's hard to really know what context is being created there. You could try using some of these https://www.opengl.org/wiki/Get_Context_Info after glewInit() to work out what context you have. I am not sure though which will show the context version and which show the driver version etc (I find it quite confusing). There may be something in the link that helps. Once you know your context is correct or not you can narrow down your issue a bit more.

 

Another option might be to change the version number in the shader, it could well be that the version n umber doesn't need to be as high as it is and an older version will work fine. https://en.wikipedia.org/wiki/OpenGL_Shading_Language#Versions try progressively older ones until either it works or the version is too old to support some of the features being used. 

Share this post


Link to post
Share on other sites

It looks like he is using version GLSL 4.3 in his shader code.  Might not be the problem you have now, but it will become one.  Just change the version to 420 in all shader code.

 

I think his videos use OpenGL 3.1.  The code was not originally available.  He went back through the videos after some time had passed and wrote/updated the code for each video.  You may have some problems in this regard matching the downloaded code perfectly with the videos.

 

The biggest backward compatibility issue you might run into is a required VAO.  Just put this code in after you create your context and all should be good.

 

GLuint VertexArrayID;
glGenVertexArrays(1, &VertexArrayID);
glBindVertexArray(VertexArrayID);

 

This is probably added in his recent (4.3 compatible?) code, but it is good to know anyway.

 

It is a good set of videos BTW. I started with his engine playlist (uses modern rudimentary OpenGL) and did the OpenGL list second.

 

If you haven't updated your video card drivers in a couple of years, you may get a higher version of OpenGL by updating.  Not really necessary if you're OK with what you have.

Edited by fleabay

Share this post


Link to post
Share on other sites

Thanks to both of you!    I was able to get it working!   Fleabay said it required Opengl 4.3, so I decided to download to another machine.  I have a Surface 3 with Open GL 4.4.    I put the code on that machine, compiled, and it worked right away, so my version was not high enough.  Strange how the error message read "GL2".  Of course, I prefer working on my desktop with the 27 inch screen, so I'll do something to get it over there. Maybe an upgrade.

 

:-) 

 

...John

Share this post


Link to post
Share on other sites

Update your drivers. That card should run just fine.

 

Also, it seems to me its hijacking a Qt widget to do the context creation? Probably Qt has some initialization code that asks for the highest compatibility profile it can get, or maybe defaults to GL2 for some reason. Point being, you cant directly control it, which sucks. So I'm not sure that way of working with OpenGL will be of much help.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!