/** * @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() { 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(); }
/** * Draw the outline of the given shape. Only the vertices are set. * The colour has to be set independently of this method. * * @param shape The shape to draw. */ public static final void draw(Shape shape) { Texture t = TextureImpl.getLastBind(); TextureImpl.bindNone(); float points[] = shape.getPoints(); LSR.start(); for(int i=0;i<points.length;i+=2) { LSR.vertex(points[i], points[i + 1]); } if (shape.closed()) { LSR.vertex(points[0], points[1]); } LSR.end(); if (t == null) { TextureImpl.bindNone(); } else { t.bind(); } }
/** * Draw the outline of the given shape. Only the vertices are set. * The colour has to be set independently of this method. * * @param shape The shape to draw. */ public static final void draw(@Nonnull Shape shape) { Texture t = TextureImpl.getLastBind(); TextureImpl.bindNone(); float points[] = shape.getPoints(); LSR.start(); for(int i=0;i<points.length;i+=2) { LSR.vertex(points[i], points[i + 1]); } if (shape.closed()) { LSR.vertex(points[0], points[1]); } LSR.end(); if (t == null) { TextureImpl.bindNone(); } else { t.bind(); } }
/** * Draw the the given shape filled in. Only the vertices are set. * The colour has to be set independently of this method. * * @param shape The shape to fill. */ public static final void fill(@Nonnull Shape shape) { if (!validFill(shape)) { return; } Texture t = TextureImpl.getLastBind(); TextureImpl.bindNone(); fill(shape, (shape1, x, y) -> null); if (t == null) { TextureImpl.bindNone(); } else { t.bind(); } }
/** * Draw the the given shape filled in with a texture. Only the vertices are set. * The colour has to be set independently of this method. * * @param shape The shape to texture. * @param image The image to tile across the shape * @param gen The texture coordinate generator to create coordiantes for the shape */ public static final void texture(@Nonnull final Shape shape, @Nonnull Image image, @Nonnull final TexCoordGenerator gen) { Texture t = TextureImpl.getLastBind(); image.getTexture().bind(); shape.getCenter(); fill(shape, (shape1, x, y) -> { Vector2f tex = gen.getCoordFor(x, y); GL.glTexCoord2f(tex.x, tex.y); return new float[] {x,y}; }); if (t == null) { TextureImpl.bindNone(); } else { t.bind(); } }
private void registerClasses(Kryo kryo){ kryo.register(float[].class); kryo.register(int[].class); kryo.register(HashMap.class); kryo.register(String[].class); kryo.register(String[][].class); kryo.register(ArrayList.class); kryo.register(Player.class); kryo.register(Image.class); kryo.register(byte[].class); kryo.register(TextureImpl.class); kryo.register(Point2D.Float.class); kryo.register(NetworkFormat.class); kryo.register(List.class); kryo.register(Chat.class); }
public void renderPlayerText(@Nonnull String text, int x, int y, @Nonnull Color color) { if (playerFont == null || nifty == null) { // Without nifty, use slick with its default font Graph.g.setColor(new org.newdawn.slick.Color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha())); Graph.g.drawString(text, x, y); } else { TextureImpl.unbind(); nifty.getRenderEngine().setColor(color); nifty.getRenderEngine().setFont(playerFont); nifty.getRenderEngine().renderText(text, x, y, -1, -1, Color.NONE); nifty.getRenderEngine().setColor(Color.WHITE); Graph.g.setColor(org.newdawn.slick.Color.white); TextureImpl.unbind(); } }
/** * Render the diagram to the given graphics context * * @param g The graphics context to which we should render the diagram */ public void render(Graphics g) { // last list generation if (list == -1) { list = GL.glGenLists(1); GL.glNewList(list, SGL.GL_COMPILE); render(g, diagram); GL.glEndList(); } GL.glCallList(list); TextureImpl.bindNone(); }
/** * Render this particle */ public void render() { if ((engine.usePoints() && (usePoints == INHERIT_POINTS)) || (usePoints == USE_POINTS)) { TextureImpl.bindNone(); GL.glEnable(SGL.GL_POINT_SMOOTH); GL.glPointSize(size / 2); color.bind(); GL.glBegin(SGL.GL_POINTS); GL.glVertex2f(x, y); GL.glEnd(); } else if (oriented || scaleY != 1.0f) { GL.glPushMatrix(); GL.glTranslatef(x, y, 0f); if (oriented) { float angle = (float) (Math.atan2(y, x) * 180 / Math.PI); GL.glRotatef(angle, 0f, 0f, 1.0f); } // scale GL.glScalef(1.0f, scaleY, 1.0f); image.draw((int) (-(size / 2)), (int) (-(size / 2)), (int) size, (int) size, color); GL.glPopMatrix(); } else { color.bind(); image.drawEmbedded((int) (x - (size / 2)), (int) (y - (size / 2)), (int) size, (int) size); } }
/** * Draw the outline of the given shape. * * @param shape * The shape to draw. * @param fill * The fill type to apply */ public void draw(Shape shape, ShapeFill fill) { predraw(); TextureImpl.bindNone(); ShapeRenderer.draw(shape, fill); currentColor.bind(); postdraw(); }
/** * Draw the outline of the given shape. * * @param shape * The shape to draw. */ public void draw(Shape shape) { predraw(); TextureImpl.bindNone(); currentColor.bind(); ShapeRenderer.draw(shape); postdraw(); }
/** * Draw the the given shape filled in. * * @param shape * The shape to fill. */ public void fill(Shape shape) { predraw(); TextureImpl.bindNone(); currentColor.bind(); ShapeRenderer.fill(shape); postdraw(); }
/** * Draw the the given shape filled in with a texture * * @param shape * The shape to texture. * @param image * The image to tile across the shape * @param scaleX * The scale to apply on the x axis for texturing * @param scaleY * The scale to apply on the y axis for texturing * @param fit * True if we want to fit the image on to the shape */ public void texture(Shape shape, Image image, float scaleX, float scaleY, boolean fit) { predraw(); TextureImpl.bindNone(); currentColor.bind(); if (fit) { ShapeRenderer.textureFit(shape, image, scaleX, scaleY); } else { ShapeRenderer.texture(shape, image, scaleX, scaleY); } postdraw(); }