/** * @see org.newdawn.slick.Graphics#disable() */ protected void disable() { GL.flush(); // Bind the texture after rendering. GL.glBindTexture(GL11.GL_TEXTURE_2D, image.getTexture().getTextureID()); pbuffer.bindTexImage(Pbuffer.FRONT_LEFT_BUFFER); try { Display.makeCurrent(); } catch (LWJGLException e) { Log.error(e); } SlickCallable.leaveSafeBlock(); }
/** * @see org.newdawn.slick.Graphics#enable() */ protected void enable() { SlickCallable.enterSafeBlock(); try { if (pbuffer.isBufferLost()) { pbuffer.destroy(); init(); } pbuffer.makeCurrent(); } catch (Exception e) { Log.error("Failed to recreate the PBuffer"); throw new RuntimeException(e); } // Put the renderer contents to the texture GL.glBindTexture(GL11.GL_TEXTURE_2D, image.getTexture().getTextureID()); pbuffer.releaseTexImage(Pbuffer.FRONT_LEFT_BUFFER); TextureImpl.unbind(); initGL(); }
/** * @see org.newdawn.slick.Graphics#enable() */ protected void enable() { if (!valid) { throw new RuntimeException("Attempt to use a destroy()ed offscreen graphics context."); } SlickCallable.enterSafeBlock(); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glPushClientAttrib(GL11.GL_ALL_CLIENT_ATTRIB_BITS); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); bind(); initGL(); }
/** * @see org.newdawn.slick.Graphics#disable() */ protected void disable() { // Bind the texture after rendering. GL11.glBindTexture(GL11.GL_TEXTURE_2D, image.getTexture().getTextureID()); GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, 0, 0, image.getTexture().getTextureWidth(), image.getTexture().getTextureHeight(), 0); try { Display.makeCurrent(); } catch (LWJGLException e) { Log.error(e); } SlickCallable.leaveSafeBlock(); }
/** * @see org.newdawn.slick.Graphics#enable() */ protected void enable() { SlickCallable.enterSafeBlock(); try { if (pbuffer.isBufferLost()) { pbuffer.destroy(); init(); } pbuffer.makeCurrent(); } catch (Exception e) { Log.error("Failed to recreate the PBuffer"); Log.error(e); throw new RuntimeException(e); } // Put the renderer contents to the texture TextureImpl.unbind(); initGL(); }
/** * @see org.newdawn.slick.Game#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public final void render(GameContainer container, Graphics g) throws SlickException { int yoffset = 0; int xoffset = 0; if (targetHeight < container.getHeight()) { yoffset = (container.getHeight() - targetHeight) / 2; } if (targetWidth < container.getWidth()) { xoffset = (container.getWidth() - targetWidth) / 2; } SlickCallable.enterSafeBlock(); g.setClip(xoffset, yoffset, targetWidth, targetHeight); GL.glTranslatef(xoffset, yoffset, 0); g.scale(targetWidth / normalWidth, targetHeight / normalHeight); GL.glPushMatrix(); held.render(container, g); GL.glPopMatrix(); g.clearClip(); SlickCallable.leaveSafeBlock(); renderOverlay(container, g); }
/** * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void render(GameContainer container, Graphics g) throws SlickException { g.scale(2,2); g.fillRect(0, 0, 800, 600, back, 0, 0); g.resetTransform(); g.drawImage(image,100,100); image.draw(100,200,80,200); font.drawString(100,200,"Text Drawn before the callable"); SlickCallable callable = new SlickCallable() { protected void performGLOperations() throws SlickException { renderGL(); } }; callable.call(); homer.draw(450,250,80,200); font.drawString(150,300,"Text Drawn after the callable"); }
/** * @see org.newdawn.slick.Game#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public final void render(GameContainer container, Graphics g) throws SlickException { int yoffset = 0; int xoffset = 0; if (targetHeight < container.getHeight()) { yoffset = (container.getHeight() - targetHeight) / 2; } if (targetWidth < container.getWidth()) { xoffset = (container.getWidth() - targetWidth) / 2; } SlickCallable.enterSafeBlock(); g.setClip(xoffset, yoffset, targetWidth, targetHeight); GL.glTranslatef(xoffset, yoffset, 0); GL.glScalef(targetWidth / normalWidth, targetHeight / normalHeight,0); GL.glPushMatrix(); held.render(container, g); GL.glPopMatrix(); g.clearClip(); SlickCallable.leaveSafeBlock(); renderOverlay(container, g); }