Jump to content
  • Advertisement
Sign in to follow this  
Frederick

OpenGL Cant query a shader program for vertex attributes

This topic is 3516 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, at the moment I am experiencing the more frustrating side of a programmers life... I have rewritten my rendersystem so that it is possible to source vertex attributes from any number of vertex buffers. The binding is performed dynamically per attribute - quite nice, if it would work. I am really getting mad because something as simple as glGetAttribLocation suddenly refuses to work (it worked in an older version of my project). It will always return "-1" and GL_INVALID_OPERATION. I don´t know why, but I know I get angry when such trivial things suddenly stop working :- I really can´t understand what goes wrong, it would be very kind if anybody would feel like taking a quick glimpse on my glIntercept log:
glEnable(GL_DEPTH_TEST)
glEnable(GL_TEXTURE_2D)
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,10497.000000)
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,10497.000000)
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,8448.000000)
glDepthFunc(GL_LESS)
glDisable(GL_CULL_FACE)
glGetIntegerv(GL_MAX_ELEMENTS_VERTICES,0x3006090)
glGetString(GL_VENDOR)="NVIDIA Corporation" 
glViewport(0,0,640,480)
glClearColor(0.000000,0.000000,0.500000,0.000000)

//Fill vertex/index buffers
glGenBuffers(1,0x90fc08)
glBindBuffer(GL_ARRAY_BUFFER,1)
glBufferData(GL_ARRAY_BUFFER,192,0x2aee000,GL_STATIC_DRAW)
glGenBuffers(1,0x90fc08)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,2)
glBufferData(GL_ELEMENT_ARRAY_BUFFER,144,0x2aef000,GL_STATIC_DRAW)

//Shaders
glCreateShader(GL_VERTEX_SHADER)=1 
glGetError()=GL_NO_ERROR 
glCreateShader(GL_FRAGMENT_SHADER)=2 
glGetError()=GL_NO_ERROR 
glShaderSource(1,1,0x90fbac,0x0000)
glGetError()=GL_NO_ERROR 
glShaderSource(2,1,0x90fbb0,0x0000)
glGetError()=GL_NO_ERROR 
glCompileShader(1)
glGetError()=GL_NO_ERROR 
glCompileShader(2)
glGetError()=GL_NO_ERROR 
glCreateProgram()=3 
glGetError()=GL_NO_ERROR 
glAttachShader(3,1)
glAttachShader(3,2)
glLinkProgram(3)
glGetError()=GL_NO_ERROR 
glGetError()=GL_NO_ERROR 

//The misery begins
glGetAttribLocation(3,"position")=-1  glGetError() =GL_INVALID_OPERATION
glGetError()=GL_INVALID_OPERATION 
glGetError()=GL_NO_ERROR 
glGetAttribLocation(3,"position")=-1  glGetError() =GL_INVALID_OPERATION
glGetError()=GL_INVALID_OPERATION 
glGetError()=GL_NO_ERROR 
glGetAttribLocation(3,"color")=-1  glGetError() =GL_INVALID_OPERATION
glGetError()=GL_INVALID_OPERATION 
glGetUniformLocation(3,"modelview")=-1  glGetError() =GL_INVALID_OPERATION
Btw. the shader has the uniformAttribute (querying doesn´t work as well) "modelview" and the vertex attributes "position" and "color". I really can´t see what goes wrong, although I have at least some experience in using OpenGL by now. Thank you !!! Frederick [EDIT] The docs on OpenGL.org tell that glGetAttribLocation returns GL_INVALID_OPERATION in the following cases: -if program is not a value generated byOpenGL. -if program is not a program object. -if program has not been successfully linked. -if glGetAttribLocation is executed between the execution of glBegin and the corresponding execution of glEnd. I can´t see that any of these case applies to me. [\EDIT]

Share this post


Link to post
Share on other sites
Advertisement
Okay,

I am sorry this one is too silly to be true.
But one lesson may be learned here:

glGetError will not return any GLSL compilation errors. I renamed a vertex attribute with caused a compilation error. Unfortunately glGetError does not report this - you should try something like this:


char log[1000];
GLsizei length;
glGetProgramInfoLog( shaderProgram, sizeof(log), &length, (GLchar*)&log);

if(length > 0)
{
std::cout << log << std::endl; //Alternatively throw exception
}
[\code]

Everything is fine - sorry to bother you !

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!