public static void requireNoErrors( GL gl ) { int error = gl.glGetError( ); if ( error != GL_NO_ERROR ) { throw new RuntimeException( gluErrorString( error ) ); } }
private static int checkPreGLError(final GL gl) { final int glerr = gl.glGetError(); if(DEBUG && GL.GL_NO_ERROR != glerr) { System.err.println("Pre-existing GL error: "+toHexString(glerr)); Thread.dumpStack(); } return glerr; }
protected TextureFrame[] createTexFrames(final GL gl, final int count) { final int[] texNames = new int[count]; gl.glGenTextures(count, texNames, 0); final int err = gl.glGetError(); if( GL.GL_NO_ERROR != err ) { throw new RuntimeException("TextureNames creation failed (num: "+count+"): err "+toHexString(err)); } final TextureFrame[] texFrames = new TextureFrame[count]; for(int i=0; i<count; i++) { texFrames[i] = createTexImage(gl, texNames[i]); } return texFrames; } protected abstract TextureFrame createTexImage(GL gl, int texName);
private boolean validateTexID(final GL gl, final boolean throwException) { if( 0 == texID ) { if( null != gl ) { final int[] tmp = new int[1]; gl.glGenTextures(1, tmp, 0); texID = tmp[0]; if ( 0 == texID && throwException ) { throw new GLException("Create texture ID invalid: texID "+texID+", glerr 0x"+Integer.toHexString(gl.glGetError())); } } else if ( throwException ) { throw new GLException("No GL context given, can't create texture ID"); } } return 0 != texID; }
/** * Queries OpenGL for errors in the fragment program. Errors are logged as SEVERE, noting both the line number and * message. */ private static void checkProgramError() { final GL gl = GLContext.getCurrentGL(); if (gl.glGetError() == GL.GL_INVALID_OPERATION) { // retrieve the error position final IntBuffer errorloc = BufferUtils.createIntBuffer(16); gl.glGetIntegerv(GL2.GL_PROGRAM_ERROR_POSITION_ARB, errorloc); // TODO Check for integer logger.severe("Error " + gl.glGetString(GL2.GL_PROGRAM_ERROR_STRING_ARB) + " in fragment program on line " + errorloc.get(0)); } }
/** * Queries OpenGL for errors in the vertex program. Errors are logged as SEVERE, noting both the line number and * message. */ private static void checkProgramError() { final GL gl = GLContext.getCurrentGL(); if (gl.glGetError() == GL.GL_INVALID_OPERATION) { // retrieve the error position final IntBuffer errorloc = BufferUtils.createIntBuffer(16); gl.glGetIntegerv(GL2.GL_PROGRAM_ERROR_POSITION_ARB, errorloc); // TODO Check for integer logger.severe("Error " + gl.glGetString(GL2.GL_PROGRAM_ERROR_STRING_ARB) + " in vertex program on line " + errorloc.get(0)); } }
/** * Returns the maximum number of FBO RENDERBUFFER samples * if {@link #hasFullFBOSupport() full FBO is supported}, otherwise false. */ public final int getMaxRenderbufferSamples() { if( hasFullFBOSupport() ) { final GL gl = getGL(); final int[] val = new int[] { 0 } ; try { gl.glGetIntegerv(GL2ES3.GL_MAX_SAMPLES, val, 0); final int glerr = gl.glGetError(); if(GL.GL_NO_ERROR == glerr) { return val[0]; } else if(DEBUG) { System.err.println("GLContext.getMaxRenderbufferSamples: GL_MAX_SAMPLES query GL Error 0x"+Integer.toHexString(glerr)); } } catch (final GLException gle) { gle.printStackTrace(); } } return 0; }
final int bufferName, final long size, final Buffer data, final int mutableUsage, final int immutableFlags, final CreateStorageDispatch dispatch, final long glProcAddress) throws GLException { final int glerrPre = caller.glGetError(); // clear if (DEBUG && GL.GL_NO_ERROR != glerrPre) { System.err.printf("%s.%s glerr-pre 0x%X%n", msgClazzName, msgCreateNamed, glerrPre); final int glerrPost = caller.glGetError(); // be safe, catch failure! if(GL.GL_NO_ERROR != glerrPost) { throw new GLException(String.format("GL-Error 0x%X while creating %s storage for buffer %d of size %d with data %s",
final int target, final long size, final Buffer data, final int mutableUsage, final int immutableFlags, final CreateStorageDispatch dispatch, final long glProcAddress) throws GLException { final int glerrPre = caller.glGetError(); // clear if (DEBUG && GL.GL_NO_ERROR != glerrPre) { System.err.printf("%s.%s glerr-pre 0x%X%n", msgClazzName, msgCreateBound, glerrPre); final int glerrPost = caller.glGetError(); // be safe, catch failure! if(GL.GL_NO_ERROR != glerrPost) { throw new GLException(String.format("GL-Error 0x%X while creating %s storage for target 0x%X -> buffer %d of size %d with data %s",
private final void reshape(final GLEventListener listener, final GLAutoDrawable drawable, final int x, final int y, final int width, final int height, final boolean setViewport, final boolean checkInit) { if(checkInit) { // GLEventListener may need to be init, // in case this one is added after the realization of the GLAutoDrawable synchronized(listenersLock) { if( listenersToBeInit.remove(listener) ) { listener.init(drawable); } } } if(setViewport) { final GL gl = drawable.getGL(); final int glerr0 = gl.glGetError(); if( GL.GL_NO_ERROR != glerr0 ) { System.err.println("Info: GLDrawableHelper.reshape: pre-exisiting GL error 0x"+Integer.toHexString(glerr0)); if(DEBUG) { Thread.dumpStack(); } } drawable.getGL().glViewport(x, y, width, height); } listener.reshape(drawable, x, y, width, height); }
final int glerrPre = caller.glGetError(); // clear caller.glGetIntegerv(queryTarget, bufTmp, 0); final int glerrPost = caller.glGetError(); // be safe, e.g. GL '3.0 Mesa 8.0.4' may produce an error querying GL_PIXEL_UNPACK_BUFFER_BINDING, ignore value if(GL.GL_NO_ERROR == glerrPost) { value = bufTmp[0];
public void checkCardError() throws Ardor3dException { final GL gl = GLContext.getCurrentGL(); final GLU glu = new GLU(); try { final int errorCode = gl.glGetError(); if (errorCode != GL.GL_NO_ERROR) { throw new GLException(glu.gluErrorString(errorCode)); } } catch (final GLException exception) { throw new Ardor3dException("Error in opengl: " + exception.getMessage(), exception); } }
checkNoError(null, gl.glGetError(), "FBObject Init.pre"); // throws GLException if error checkNoError(gl, gl.glGetError(), "FBObject Init.bindFB"); // throws GLException if error if(!gl.glIsFramebuffer(fbName)) { checkNoError(gl, GL.GL_INVALID_VALUE, "FBObject Init.isFB"); // throws GLException
gl.glBindTexture(textureTarget, texName); final int err = gl.glGetError(); if( GL.GL_NO_ERROR != err ) { throw new RuntimeException("Couldn't bind textureName "+toHexString(texName)+" to 2D target, err "+toHexString(err)); final int err = gl.glGetError(); if( GL.GL_NO_ERROR != err ) { throw new RuntimeException("Couldn't create TexImage2D RGBA "+tWidth+"x"+tHeight+", target "+toHexString(textureTarget)+
int glerr = gl.glGetError(); if(GL.GL_NO_ERROR == glerr) { preTexImage2D = false; gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, format, getWidth(), getHeight(), 0, dataFormat, dataType, null); glerr = gl.glGetError();
protected boolean readPixelsImpl(final GLDrawable drawable, final GL gl, final int inX, final int inY, final int width, final int height, final boolean mustFlipVertically) { final int glerr0 = gl.glGetError(); if(GL.GL_NO_ERROR != glerr0) { System.err.println("Info: GLReadBufferUtil.readPixels: pre-exisiting GL error 0x"+Integer.toHexString(glerr0)); readPixelBuffer.position( readPixelSize ); readPixelBuffer.flip(); final int glerr1 = gl.glGetError(); if(GL.GL_NO_ERROR != glerr1) { System.err.println("GLReadBufferUtil.readPixels: readPixels error 0x"+Integer.toHexString(glerr1)+
@Override public boolean initialize(final GL gl) throws GLException { final boolean init = 0 == getName(); if( init ) { checkPreGLError(gl); final int[] name = new int[] { -1 }; gl.glGenRenderbuffers(1, name, 0); setName(name[0]); gl.glBindRenderbuffer(GL.GL_RENDERBUFFER, getName()); if( samples > 0 ) { ((GL2ES3)gl).glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, samples, format, getWidth(), getHeight()); } else { gl.glRenderbufferStorage(GL.GL_RENDERBUFFER, format, getWidth(), getHeight()); } final int glerr = gl.glGetError(); if(GL.GL_NO_ERROR != glerr) { gl.glDeleteRenderbuffers(1, name, 0); setName(0); throw new GLException("GL Error "+toHexString(glerr)+" while creating "+this); } if(DEBUG) { System.err.println("Attachment.init.X: "+this); } } return init; }
final int glErrX = gl.glGetError(); // clear GL error, maybe caused by above operations
checkNoError(null, gl.glGetError(), "FBObject syncSampleSink"); // throws GLException if error } else { modified = false;
image.getData(0), w, h, pixDataType, scaledImage); if (error != 0) { final int errorCode = gl.glGetError(); if (errorCode != GL.GL_NO_ERROR) { throw new GLException(glu.gluErrorString(errorCode));