/** Draws an orthographically projected rectangle containing all of the underlying texture to the specified location on the screen. All (x, y) coordinates are specified relative to the lower left corner of either the texture image or the current OpenGL drawable. This method is equivalent to <code>drawOrthoRect(screenx, screeny, 0, 0, getWidth(), getHeight());</code>. @param screenx the on-screen x coordinate at which to draw the rectangle @param screeny the on-screen y coordinate (relative to lower left) at which to draw the rectangle @throws GLException If an OpenGL context is not current when this method is called */ public void drawOrthoRect(final int screenx, final int screeny) throws GLException { drawOrthoRect(screenx, screeny, 0, 0, getWidth(), getHeight()); }
getBackingStore().markDirty(0, 0, getBackingStore().getWidth(), getBackingStore().getHeight());
@Override public void display(final GLAutoDrawable drawable) { final GL2 gl = GLContext.getCurrentGL().getGL2(); gl.glClear(GL.GL_DEPTH_BUFFER_BIT | GL.GL_COLOR_BUFFER_BIT); if (packer == null) { return; } final TextureRenderer rend = getBackingStore(); final int w = rend.getWidth(); final int h = rend.getHeight(); rend.beginOrthoRendering(w, h); rend.drawOrthoRect(0, 0); rend.endOrthoRendering(); if ((frame.getWidth() != w) || (frame.getHeight() != h)) { EventQueue.invokeLater(new Runnable() { @Override public void run() { frame.setSize(w, h); } }); } }
newRenderer.markDirty(0, 0, newRenderer.getWidth(), newRenderer.getHeight());
private void validateRenderer() { if (renderer == null) { renderer = new TextureRenderer(drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), true); contentsLost = true; } else if (renderer.getWidth() != drawable.getSurfaceWidth() || renderer.getHeight() != drawable.getSurfaceHeight()) { renderer.setSize(drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); contentsLost = true; } else { contentsLost = false; } } }
final int height = (int) origRect.getHeight(); final float tx1 = xScale * texturex / renderer.getWidth(); final float ty1 = yScale * (1.0f - ((float) texturey / (float) renderer.getHeight())); final float tx2 = xScale * (texturex + width) / renderer.getWidth(); final float ty2 = yScale * (1.0f - ((float) (texturey + height) / (float) renderer.getHeight()));