Jump to content
  • Advertisement
Sign in to follow this  
pixelhead

OpenGL [GLSL] get version in c code?

This topic is 4026 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

Hi - I'm trying to make a program compatible with older OpenGL versions and am running into problems with GLSL. I need to detect if the GLSL code will run since if it doesn't I have to turn on some features in software. My basic question is, how does one query the GLSL version from C code? I have tried adding the #version 110 macro into my shader and it causes a compile error (unknown directive). The test machine has OpenGL 1.5.1 and probably GLSL < 1.1 (#version was added in GLSL 1.1 right?). Without the #version, it compiles fine but the rendering is not quite right. I didn't think I was doing anything too complicated: <code> vec3 normal, lightDir, viewVector, halfVector; vec4 diffuse, ambient, globalAmbient, specular = vec4(0.0); float NdotL,NdotHV; normal = normalize(gl_NormalMatrix * gl_Normal); lightDir = normalize(vec3(gl_LightSource[0].position)); NdotL = max(dot(normal, lightDir), 0.0); // set color gl_FrontColor = NdotL * gl_Color; </code> Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
how does one query the GLSL version from C code?

glGetString( GL_VERSION )
glGetString( GL_SHADING_LANGUAGE_VERSION_ARB )

Share this post


Link to post
Share on other sites
Thanks zedz for the info! Thought it might be something simple.

I dug around a bit more and you can query the GL_ARB_shading_language_100 extension for GLSL support and the glGetString() method for version.

For more details:

http://www.opengl.org/sdk/docs/tutorials/ClockworkCoders/extensions_part2.php

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!