/** * Enter a safe block ensuring that all the OpenGL state that slick * uses is safe before touching the GL state directly. */ public static void enterSafeBlock() { if (inSafe) { return; } Renderer.get().flush(); lastUsed = TextureImpl.getLastBind(); TextureImpl.bindNone(); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glPushClientAttrib(GL11.GL_ALL_CLIENT_ATTRIB_BITS); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); inSafe = true; }
/** * Check that we're in the right place to be doing GL operations */ public static void checkGLContext() { try { Renderer.get().glGetError(); } catch (NullPointerException e) { throw new RuntimeException("OpenGL based resources (images, fonts, sprites etc) must be loaded as part of init() or the game loop. They cannot be loaded before initialisation."); } }
/** * Entry point to our test * * @param argv The arguments to pass into the test */ public static void main(String[] argv) { try { Renderer.setRenderer(Renderer.VERTEX_ARRAY_RENDERER); AppGameContainer container = new AppGameContainer(new GradientTest()); container.setDisplayMode(800,600,false); container.start(); } catch (SlickException e) { e.printStackTrace(); } }
/** * Entry point to our test * * @param argv The arguments passed to the test */ public static void main(String[] argv) { try { Renderer.setRenderer(Renderer.VERTEX_ARRAY_RENDERER); AppGameContainer container = new AppGameContainer(new GeomTest()); container.setDisplayMode(800,600,false); container.start(); } catch (SlickException e) { e.printStackTrace(); } }
/** * Entry point to our test * * @param argv The arguments passed to the test */ public static void main(String[] argv) { try { Renderer.setRenderer(Renderer.VERTEX_ARRAY_RENDERER); AppGameContainer container = new AppGameContainer(new ShapeTest()); container.setDisplayMode(800,600,false); container.start(); } catch (SlickException e) { e.printStackTrace(); } }
/** * Entry point to our simple test * * @param argv The arguments passed in */ public static void main(String argv[]) { try { Renderer.setRenderer(Renderer.VERTEX_ARRAY_RENDERER); Renderer.setLineStripRenderer(Renderer.QUAD_BASED_LINE_STRIP_RENDERER); AppGameContainer container = new AppGameContainer(new InkscapeTest()); container.setDisplayMode(800,600,false); container.start(); } catch (SlickException e) { e.printStackTrace(); } }
/** * Entry point to our test * * @param argv The arguments passed to the test */ public static void main(String[] argv) { try { Renderer.setLineStripRenderer(Renderer.QUAD_BASED_LINE_STRIP_RENDERER); Renderer.getLineStripRenderer().setLineCaps(true); AppGameContainer container = new AppGameContainer(new LineRenderTest()); container.setDisplayMode(800,600,false); container.start(); } catch (SlickException e) { e.printStackTrace(); } }
/** * Reset the line width in use to the default for this graphics context */ public void resetLineWidth() { predraw(); Renderer.getLineStripRenderer().setWidth(1.0f); GL.glLineWidth(1.0f); GL.glPointSize(1.0f); postdraw(); }
/** * Uploads the pixel data to the given texture at the specified position. * This only needs to be called once, after the pixel data has changed. * * @param texture the texture to modify * @param x the x position to place the pixel data on the texture * @param y the y position to place the pixel data on the texture */ public void apply(Texture texture, int x, int y) { if (x+width > texture.getTextureWidth() || y+height > texture.getTextureHeight()) throw new IndexOutOfBoundsException("pixel data won't fit in given texture"); position(length()); pixels.flip(); int glFmt = format.getOGLType(); final SGL GL = Renderer.get(); texture.bind(); GL.glTexSubImage2D(SGL.GL_TEXTURE_2D, 0, x, y, width, height, glFmt, SGL.GL_UNSIGNED_BYTE, pixels); }