Re: blank screen by shader render
Posted by
Wade Walker on
Mar 22, 2012; 1:07pm
URL: https://forum.jogamp.org/blank-screen-by-shader-render-tp3848071p3848410.html
I noticed that in glBufferData, you're passing the number of floats as the size, but it should be the size in bytes instead (so number of floats * 4). There's the same problem with your index buffer (should be number of shorts * 2).
You might also want to check the GL error status after every GL call that might set it. This can find errors that might leave you puzzled for a very long time

I usually define a function like this:
/**
* Checks if there have been any GL errors. Throws an exception with the
* error codes in the message if there have been.
* @param gl Used to make GL calls.
* @param sFuncName Name of GL function we're checking for errors after.
*/
public static void checkGLError( GL2ES2 gl, String sFuncName ) {
int iError;
StringBuilder sb = null;
do {
iError = gl.glGetError();
if( iError != GL.GL_NO_ERROR ) {
if( sb == null )
sb = new StringBuilder();
sb.append( sFuncName + " failed, GL error: 0x" + Integer.toHexString( iError ) + "\n" );
}
}
while( iError != GL.GL_NO_ERROR );
if( sb != null )
Assert.assertTrue( sb.toString(), false );
}
and call it after every GL function that can set an error code.