/** Draws the specified sub-rectangle of the overlay at the specified x and y coordinate on top of the OpenGL drawable. {@link #beginRendering} and {@link #endRendering} must be used in conjunction with this method to achieve proper rendering results. This method should be called while the OpenGL context for the drawable is current, and after your OpenGL scene has been rendered. @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 @param overlayx the x coordinate of the pixel in the overlay of the lower left portion of the rectangle to draw @param overlayy the y coordinate of the pixel in the overlay (relative to lower left) of the lower left portion of the rectangle to draw @param width the width of the rectangle to draw @param height the height of the rectangle to draw @throws GLException If an OpenGL context is not current when this method is called */ public void draw(final int screenx, final int screeny, final int overlayx, final int overlayy, final int width, final int height) throws GLException { renderer.drawOrthoRect(screenx, screeny, overlayx, overlayy, width, height); }
/** 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()); }
@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); } }); } }