Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
JOGL Debug is reporting a GL_INVALID_OPERATION error when I'm trying to upload a FloatBuffer containing 4x4 matrix data to a shader uniform. I can't figure out what the problem is?
Looking at the OpenGL C docs, GL_INVALID_OPERATION can be reported for quite a few reasons: http://www.opengl.org/sdk/docs/man4/xhtml/glUniform.xml The FloatBuffer is of size 16 floats, and I tested the actual computed matrix data (it's an ortho-projection matrix) in a mat4 constant on the vertex shader - it worked. So, the problem is only occurring with the upload process. I set the uniform matrix via the following call: gl.glUniformMatrix4fv(getLocation(name), 1, false, values); // values = the non-null, capacity 16, // zero position FloatBuffer The getLocation(String) method is: private int getLocation(String uniform) { return gl.glGetUniformLocation(progId, uniform); } The name variable is the mat4 uniform's name on the vertex shader. It's declared in the shader as: uniform mat4 ortho; And used as: gl_Position = ortho * pos; // where pos is a vec4 containing the passed vertex attribute Any help is appreciated. I really have no idea what's wrong :( Edit: Addendum - Full error message: GLDebugEvent[ id 0x502 type Error severity High: dangerous undefined behavior source GL API msg GL_INVALID_OPERATION error generated. Uniform not found. when 1390875845182 source 4.3 (Compat profile, arb, debug, ES2 compat, ES3 compat, FBO, hardware) - 4.3.0 NVIDIA 310.44 - hash 0x2e1c3062] glGetError() returned the following error codes after a call to glUniformMatrix4fv(<int> 0x3E, <int> 0x1, <boolean> false, <java.nio.FloatBuffer> java.nio.DirectFloatBufferU[pos=0 lim=16 cap=16]): GL_INVALID_OPERATION ( 1282 0x502), ----------------------------------- Additional edit: I just noticed that "Uniform not found" message. I double checked. The name being passed matches how it's declared in the vertex shader. Do I have to do something to the buffer or method call to match the mat4 properly? |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
It looks right, the only difference from my code is that I use float[] instead of buffers but that shouldn't make a difference. Given the error description I would bet that it is a typo somewhere :-)
Is the shader linked without errors? Are you sure you actually pass in the correct programId? That's where I would start looking after checking the obvious things you already checked. |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
The shader does link without errors, and glGetUniformLocation returns a valid value for the location of the uniform specified by 'name'. I can't find any typos.
The program id is correct. It's the only one available in the class :) I really have no idea. Maybe I should just try using an array instead? |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Or maybe you forgot to glUseProgram before you try to set the uniform value. That could be one cause.
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
Free forum by Nabble | Edit this page |