public final boolean detachFrom(GL2ES2 gl) { RenderState _rs = (RenderState) gl.getContext().getAttachedObject(RenderState.class.getName()); if (_rs == this) { gl.getContext().detachObject(RenderState.class.getName()); return true; } return false; }
void reshapeImpl( final GL2ES2 gl, final int tileX, final int tileY, final int tileWidth, final int tileHeight, final int imageWidth, final int imageHeight) { System.err.println( Thread.currentThread() + " RedSquareES2.reshape " + tileX + "/" + tileY + " " + tileWidth + "x" + tileHeight + " of " + imageWidth + "x" + imageHeight + ", swapInterval " + swapInterval + ", drawable 0x" + Long.toHexString(gl.getContext().getGLDrawable().getHandle()) + ", tileRendererInUse " + tileRendererInUse); // Thread.dumpStack(); if (!gl.hasGLSL()) { return; } st.useProgram(gl, true); // Set location in front of camera pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION); pmvMatrix.glLoadIdentity(); // compute projection parameters 'normal' perspective final float fovy = 45f; final float aspect2 = ((float) imageWidth / (float) imageHeight) / aspect; final float zNear = 1f; final float zFar = 100f; // compute projection parameters 'normal' frustum final float top = (float) Math.tan(fovy * ((float) Math.PI) / 360.0f) * zNear; final float bottom = -1.0f * top; final float left = aspect2 * bottom; final float right = aspect2 * top; final float w = right - left; final float h = top - bottom; // compute projection parameters 'tiled' final float l = left + tileX * w / imageWidth; final float r = l + tileWidth * w / imageWidth; final float b = bottom + tileY * h / imageHeight; final float t = b + tileHeight * h / imageHeight; pmvMatrix.glFrustumf(l, r, b, t, zNear, zFar); // pmvMatrix.glOrthof(-4.0f, 4.0f, -4.0f, 4.0f, 1.0f, 100.0f); st.uniform(gl, pmvMatrixUniform); st.useProgram(gl, false); System.err.println(Thread.currentThread() + " RedSquareES2.reshape FIN"); }
public static final RenderState getRenderState(GL2ES2 gl) { return (RenderState) gl.getContext().getAttachedObject(RenderState.class.getName()); }
public final RenderState attachTo(GL2ES2 gl) { return (RenderState) gl.getContext().attachObject(RenderState.class.getName(), this); }