gl_VertexID in GLSL Vertex Shader

classic Classic list List threaded Threaded
4 messages Options
JD
Reply | Threaded
Open this post in threaded view
|

gl_VertexID in GLSL Vertex Shader

JD
When I try to access gl_VertexID in my vertex shader, I get a compilation error saying it is an undefined variable. As near as I can tell, that has been available since version 110 of GLSL. My program is 120 (apparently the latest I can run in this version of JOGL). Any ideas why that is?
Reply | Threaded
Open this post in threaded view
|

Re: gl_VertexID in GLSL Vertex Shader

gouessej
Administrator
Hi

I've already successfully used shaders with JMonkeyEngine 3, Ardor3D and JOGL 2. The GLSL version supported by your program doesn't depend on the JOGL version you use but rather on your OpenGL driver and your graphics card. I confirm that gl_VertexID is an input variable available since GLSL 1.10 (but later in the core, see here) as you can see here.

At first, keep in mind that you don't have to declare gl_VertexID as it is a variable of the language. Secondly, this input is available if and only if GL_EXT_gpu_shader4 is supported on your hardware. Thirdly, you have to use VBOs and no display list otherwise this variable might be undefined.
Julien Gouesse | Personal blog | Website
JD
Reply | Threaded
Open this post in threaded view
|

Re: gl_VertexID in GLSL Vertex Shader

JD
Enabling GL_EXT_gpu_shader4 did the trick. Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: gl_VertexID in GLSL Vertex Shader

gouessej
Administrator
You're welcome. I'm not that bad with shaders now :p
Julien Gouesse | Personal blog | Website