@Override public void drawString(float x, float y, String s, Color3f color) { text.beginRendering(panel.getWidth(), panel.getHeight()); text.setColor(color.x, color.y, color.z, 1); text.draw(s, (int) x, panel.getHeight() - (int) y); text.endRendering(); } }
text = text.trim(); renderer.beginRendering(drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
renderer.beginRendering(drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
/** Begins rendering of 2D text in 3D with this {@link TextRenderer TextRenderer} into the current OpenGL drawable. Assumes the end user is responsible for setting up the modelview and projection matrices, and will render text using the {@link #draw3D draw3D} method. This method pushes some OpenGL state bits, binds and enables the internal OpenGL texture object, sets the texture environment mode to GL_MODULATE, and changes the current color to the last color set with this TextRenderer via {@link #setColor setColor}. @throws GLException If an OpenGL context is not current when this method is called */ public void begin3DRendering() throws GLException { beginRendering(false, 0, 0, false); }
/** Begins rendering with this {@link TextRenderer TextRenderer} into the current OpenGL drawable, pushing the projection and modelview matrices and some state bits and setting up a two-dimensional orthographic projection with (0, 0) as the lower-left coordinate and (width, height) as the upper-right coordinate. Binds and enables the internal OpenGL texture object, sets the texture environment mode to GL_MODULATE, and changes the current color to the last color set with this TextRenderer via {@link #setColor setColor}. This method disables the depth test and is equivalent to beginRendering(width, height, true). @param width the width of the current on-screen OpenGL drawable @param height the height of the current on-screen OpenGL drawable @throws javax.media.opengl.GLException If an OpenGL context is not current when this method is called */ public void beginRendering(final int width, final int height) throws GLException { beginRendering(width, height, true); }
/** Begins rendering with this {@link TextRenderer TextRenderer} into the current OpenGL drawable, pushing the projection and modelview matrices and some state bits and setting up a two-dimensional orthographic projection with (0, 0) as the lower-left coordinate and (width, height) as the upper-right coordinate. Binds and enables the internal OpenGL texture object, sets the texture environment mode to GL_MODULATE, and changes the current color to the last color set with this TextRenderer via {@link #setColor setColor}. Disables the depth test if the disableDepthTest argument is true. @param width the width of the current on-screen OpenGL drawable @param height the height of the current on-screen OpenGL drawable @param disableDepthTest whether to disable the depth test @throws GLException If an OpenGL context is not current when this method is called */ public void beginRendering(final int width, final int height, final boolean disableDepthTest) throws GLException { beginRendering(true, width, height, disableDepthTest); }
public void draw(TextRenderer renderer, GLAutoDrawable drawable, Rect rect) { int width = (int) (rect.maxX - rect.minX); int height = (int) (rect.maxY - rect.minY); int screenWidth = drawable.getSurfaceWidth(); float widthRatio = (float) screenWidth / (float) width; int screenHeight = drawable.getSurfaceHeight(); float heightRatio = (float) screenHeight / (float) height; renderer.beginRendering(screenWidth, screenHeight); renderer.setColor(color.getRed()/255.f, color.getGreen()/255.f, color.getBlue()/255.f, color.getAlpha()/255.f); renderer.draw(text, (int) ((x - rect.minX) * widthRatio) , (int) ((y - rect.minY) * heightRatio)); renderer.endRendering(); }
@Override void renderContents(GL2 gl) { // Get text bounds. Rectangle2D bounds = renderer.getBounds(getMessage()); // Render message background: final float bx1 = .45f * (float) (width - bounds.getWidth()); final float bx2 = .55f * (float) (width + bounds.getWidth()); final float by1 = .45f * (float) (height - bounds.getHeight()); final float by2 = .55f * (float) (height + bounds.getHeight()); gl.glBegin(GL2.GL_QUADS); gl.glColor4f(0f, 0f, 0f, .75f); gl.glVertex2f(bx1, by1); gl.glVertex2f(bx1, by2); gl.glVertex2f(bx2, by2); gl.glVertex2f(bx2, by1); gl.glEnd(); // Render message renderer.beginRendering(width, height); renderer.setColor(1f, 1f, 1f, 1f); renderer.setColor(1f, 1f, 1f, 1f); renderer.draw(getMessage(), (width - (int) bounds.getWidth()) >> 1, (height - (int) bounds.getHeight()) >> 1); renderer.endRendering(); }
private void drawFrameRate(GLAutoDrawable drawable, int now) { if (this.statusWidth == 0) { // Place it at a fixed offset wrt the upper right corner this.statusWidth = (int) this.textRenderer.getBounds("FPS: 10000.00").getWidth(); } // Calculate text location and color int x = drawable.getSurfaceWidth() - this.statusWidth - 5; int y = drawable.getSurfaceHeight() - 30; // Render the text this.textRenderer.setColor(Color.DARK_GRAY); this.textRenderer.beginRendering(drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); this.textRenderer.draw(Time.writeTime(now, ':'), x, y); this.textRenderer.endRendering(); }
renderer.beginRendering(width, height); renderer.setColor(1f, 1f, 1f, 1f);
_renderer.beginRendering(w,h); _renderer.setColor(_color); int x,y;