Posted by
rmnoon on
Aug 14, 2011; 1:45am
URL: https://forum.jogamp.org/GLJPanel-in-Lion-tp3250682p3252841.html
I seem to have narrowed it down, but I don't know how to fix it.
The issue seems to be a shader bug. Specifically, the y component of gl_FragCoord is different (and inverted or wrong or something) on the GLJPanel vs the GLCanvas.
Here's a minimal test case:
vertex shader:
#version 120
uniform vec2 screenSize;
void main(void)
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
frag shader:
#version 120
uniform vec2 screenSize;
void main(void)
{
vec4 testcolor = vec4(0.0, 0.0, 0.0, 1.0);
if (gl_FragCoord.x > screenSize.x/2.0) testcolor.x += 0.5;
if (gl_FragCoord.y > screenSize.y/2.0) testcolor.z += 0.5;
gl_FragColor = testcolor;
}
screenSize is just a uniform that's set every draw call.
Here's what I'd expect this shader to draw (and this is what it draws with GLCanvas):

Here's what the exact same code in the GLJPanel does:

From fiddling with the second if statement I've figured out that at the top of the frame (which is 578px tall here) gl_FragCoord.y is about 450, and grows downwards (so the vertical middle is ~739). Thus, a shader like this:
if (gl_FragCoord.x > screenSize.x/2.0) testcolor.x += 0.5;
if (gl_FragCoord.y > 739) testcolor.z += 0.5;
Produces this:

Any ideas on where to go next? This happens on both software and hardware mode on both intel and amd cards.