Login  Register

Re: Need Help Solving OpenGL/GLSL 4.4 Issues

Posted by jmaasing on Jul 22, 2014; 1:37pm
URL: https://forum.jogamp.org/Need-Help-Solving-OpenGL-GLSL-4-4-Issues-tp4032557p4032626.html

Vacation today so I had some time to test your code :-)

I haven't fixed it yet but there are two problems I saw right away, if you add

    public void init(GLAutoDrawable drawable) {
                drawable.setGL(new DebugGL4((GL4) drawable.getGL()));
        GL4 gl = (GL4) drawable.getGL();

You will see that OpenGL complains about invalid operation (at least on my platform):
Exception in thread "main-AWTAnimator" java.lang.RuntimeException: javax.media.opengl.GLException: Thread[AWT-EventQueue-0,6,main] glGetError() returned the following error codes after a call to glGenVertexArrays(<int> 0x1, <[I>, <int> 0x0): GL_INVALID_OPERATION ( 1282 0x502),

Also, your shaders are not correct (on strict drivers they would not even compile I guess) since you use doubles when they should be floats, this is how it ought to be written:

gl_Position = vec4(0.0f, 0.0f, 0.5f, 1.0f);

If you look at the sample code I posted I use JOGL classes (ShaderProgram et c) to compile the shaders, they can help in presenting the compilation/linking errors. If you want to use glCompileShader straight up you really should check for GL errors after each step to verify that the shader compiled/linked.

Note that there is a large difference in how "forgiving" drivers are with these kinds of errors, maybe your driver understands and compiles even though it strictly isn't correct. (another disclaimer; I'm stuck on Mac OpenGL 4.1 so maybe these things have changed in later versions).