/** * Initializes the appropriate OpenGL offscreen surface based on the value of the type parameter. * If the surface creation fails for any reason, an OutOfMemoryError will be thrown. */ protected void initSurface(final int width, final int height) { OGLRenderQueue rq = OGLRenderQueue.getInstance(); rq.lock(); try { switch (type) { case TEXTURE: case PBUFFER: case FBOBJECT: // need to make sure the context is current before // creating the texture (or pbuffer, or fbobject) OGLContext.setScratchSurface(graphicsConfig); break; default: break; } rq.flushAndInvokeNow( new Runnable() { public void run() { initSurfaceNow(width, height); } }); } finally { rq.unlock(); } }