GLEW, what to check when using GLSL?

Started by
4 comments, last by Gorax 18 years ago
Using GLEW, I want to check if GLSL (2.0) is supported. For example, if checking for ARB_vertex_program's this is done (from the GLEW website): if (GLEW_ARB_vertex_program) { /* It is safe to use the ARB_vertex_program extension here. */ glGenProgramsARB(...); } What do I need here???: if (GLEW_???????) { program = glCreateProgramObjectARB(); unsigned int vertex_object = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB); glShaderSourceARB(vertex_object, 1, (const char**) &vertex_data, NULL); glCompileShaderARB(vertex_object); glAttachObjectARB(program, vertex_object); glDeleteObjectARB(vertex_object); ... and so on... ... } else { glAlert("Sorry, no shaders!"); } Thanks all in advance!!!
Advertisement
Checking for GLEW_VERSION_2_0 will let you know if the video card supports OpenGL 2.0. Since GLSL was added in GL 2.0, you should be able to use that functionality.
What you're using there is the ARB_shader_objects extension. So most probably GLEW has something like if (GLEW_ARB_shader_objects) // do stuff; but I can't of course be sure, so try it out.

Edit--
Dorvo: He isn't actually using the core GL 2.0 functions, those would be glCreateShader, glDeleteShader etc without the trailing ARB
True; but, he did want to check if 2.0 was supported. Is there really any difference between the core functions and the ARB versions?
Quote:Original post by Dorvo
True; but, he did want to check if 2.0 was supported. Is there really any difference between the core functions and the ARB versions?

Not really but there is a difference in the object model: in the ARB extension everything was an 'object' but in the 2.0 API shaders and program objects have been separated completely. eg. earlier you would use glGetInfoLogARB to get both the link and compile logs, but now we use glGetProgramInfoLog for the linker log and glGetShaderInfoLog for the compile log.

I prefer (and would also suggest if asked) the 2.0 core functions, if your hardware (as well as the hardware you are targetting) has 2.0 drivers.
While deavik's got the right idea, nVidia tells people if you can't find the extension in the list, it wont be hardware accelerated. This seems to hold true, since my GeForce 2 supports Open GL 1.5, but it doesn't use hardware acceleration for things like 3D textures, which are in the 1.3 core.

This topic is closed to new replies.

Advertisement