You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Available as of 2.5, based on AWT drawString method, which is applied on top of the image containing the complete OpenGL scene. This is hence not a real OpenGL implementation of text management, but it provides a simple an easy way to quickly draw text with a larger font support than the one provided by OpenGL1.
/** * Print string at the specified 2d position. * * This method is not following exactly the GLUT interface. * Printing text in OpenGL usually requires such code : * * <pre><code> * gl.glColor3f(r, g, b); * gl.glRasterPos3f(x, y, z); * glut.glutBitmapString(font, string); * </code></pre> * * In our case, one need to first perform model-to-screen projection to get * x,y coordinates, and then call glutBitmapString. * * @see {@link #glutBitmapString(Font, String, float, float, float, float, float, float) to avoid doing the model-to-screen projection. */publicvoidglutBitmapString(Fontfont, Stringstring, floatx, floaty) {
JavaGL.appendTextToDraw(font, string, (int)x, (int)y);
}
/** * Print string at the specified 3d position. * * This method is not following exactly the GLUT interface. * Printing text in OpenGL usually requires such code : * * <pre><code> * gl.glColor3f(r, g, b); * gl.glRasterPos3f(x, y, z); * glut.glutBitmapString(int font, string); * </code></pre> * * Here we provide a convenient function that does all in one pass * <pre><code> * glut.glutBitmapString(java.awt.Font, java.lang.String, x, y, z, r, g, b); * </code></pre> * * Behind the scene it makes the model-to-screen conversion and then * provide all data to {@link GL#appendTextToDraw(Font, String, int, int, float, float, float)} * that will handle the text rendering in {@link GL#glFlush()} */publicvoidglutBitmapString(Fontfont, Stringstring, floatx, floaty, floatz, floatr, floatg, floatb) {
double[] win = modelToScreen(x, y, z);
doublewinX = win[0];
doublewinY = JavaGL.Context.Viewport.Height - win[1];
JavaGL.appendTextToDraw(font, string, (int)winX, (int)winY, r, g, b);
}
No description provided.
The text was updated successfully, but these errors were encountered: