org.newdawn.slick.opengl.renderer.Renderer Java Examples
The following examples show how to use
org.newdawn.slick.opengl.renderer.Renderer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SlickCallable.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * 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; }
Example #2
Source File: GLUtils.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 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."); } }
Example #3
Source File: Graphics.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 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(); }
Example #4
Source File: GradientTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 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(); } }
Example #5
Source File: GeomTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 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(); } }
Example #6
Source File: ShapeTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 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(); } }
Example #7
Source File: InkscapeTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 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(); } }
Example #8
Source File: LineRenderTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 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(); } }
Example #9
Source File: BufferedImageUtil.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Load a texture into OpenGL from a BufferedImage * * @param resourceName * The location of the resource to load * @param resourceimage * The BufferedImage we are converting * @param target * The GL target to load the texture against * @param dstPixelFormat * The pixel format of the screen * @param minFilter * The minimising filter * @param magFilter * The magnification filter * @return The loaded texture * @throws IOException * Indicates a failure to access the resource */ public static Texture getTexture(String resourceName, BufferedImage resourceimage, int target, int dstPixelFormat, int minFilter, int magFilter) throws IOException { ImageIOImageData data = new ImageIOImageData();int srcPixelFormat = 0; // create the texture ID for this texture int textureID = InternalTextureLoader.createTextureID(); TextureImpl texture = new TextureImpl(resourceName, target, textureID); // Enable texturing Renderer.get().glEnable(SGL.GL_TEXTURE_2D); // bind this texture Renderer.get().glBindTexture(target, textureID); BufferedImage bufferedImage = resourceimage; texture.setWidth(bufferedImage.getWidth()); texture.setHeight(bufferedImage.getHeight()); if (bufferedImage.getColorModel().hasAlpha()) { srcPixelFormat = SGL.GL_RGBA; } else { srcPixelFormat = SGL.GL_RGB; } // convert that image into a byte buffer of texture data ByteBuffer textureBuffer = data.imageToByteBuffer(bufferedImage, false, false, null); texture.setTextureHeight(data.getTexHeight()); texture.setTextureWidth(data.getTexWidth()); texture.setAlpha(data.getDepth() == 32); if (target == SGL.GL_TEXTURE_2D) { Renderer.get().glTexParameteri(target, SGL.GL_TEXTURE_MIN_FILTER, minFilter); Renderer.get().glTexParameteri(target, SGL.GL_TEXTURE_MAG_FILTER, magFilter); if (Renderer.get().canTextureMirrorClamp()) { Renderer.get().glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_S, SGL.GL_MIRROR_CLAMP_TO_EDGE_EXT); Renderer.get().glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_T, SGL.GL_MIRROR_CLAMP_TO_EDGE_EXT); } else { Renderer.get().glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_S, SGL.GL_CLAMP); Renderer.get().glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_T, SGL.GL_CLAMP); } } Renderer.get().glTexImage2D(target, 0, dstPixelFormat, texture.getTextureWidth(), texture.getTextureHeight(), 0, srcPixelFormat, SGL.GL_UNSIGNED_BYTE, textureBuffer); return texture; }