JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
Issue326Test1.java
Go to the documentation of this file.
1package com.jogamp.opengl.test.bugs;
2
3import java.awt.Frame;
4import java.awt.event.KeyEvent;
5import java.awt.event.KeyListener;
6import java.awt.event.MouseEvent;
7import java.awt.event.MouseListener;
8import java.awt.event.WindowAdapter;
9import java.awt.event.WindowEvent;
10import java.util.Random;
11
12import com.jogamp.opengl.GL;
13import com.jogamp.opengl.GL2;
14import com.jogamp.opengl.GLAutoDrawable;
15import com.jogamp.opengl.GLEventListener;
16import com.jogamp.opengl.awt.GLCanvas;
17import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
18import com.jogamp.opengl.glu.GLU;
19
20import com.jogamp.opengl.util.Animator;
21import com.jogamp.opengl.util.awt.TextRenderer;
22
23/**
24 * Demonstrates corruption with older versions of TextRenderer. Two
25 * problems: errors when punting from glyph-based renderer to
26 * string-by-string renderer, and failure of glyph-based renderer when
27 * backing store was NPOT using GL_ARB_texture_rectangle.
28 *
29 * @author emzic
30 */
31
32public class Issue326Test1 extends Frame implements GLEventListener {
33
34 int width, height;
35
36 public static void main(final String[] args) {
37 new Issue326Test1();
38 }
39
40 GLCanvas canvas;
41 TextRenderer tr ;
42
43 public Issue326Test1() {
44 super("TextTest");
45 this.setSize(800, 800);
46 canvas = new GLCanvas();
47 canvas.addGLEventListener(this);
48 add(canvas);
49
50 setVisible(true);
51 addWindowListener(new WindowAdapter() {
52 public void windowClosing(final WindowEvent e) {
53 System.exit(0);
54 }
55 });
56 }
57
58 public void display(final GLAutoDrawable drawable) {
59 final GL2 gl = drawable.getGL().getGL2();
60 gl.glClearColor(0, 0, 0, 0);
62
63
65 gl.glLoadIdentity();
66 //new GLU().gluPerspective(45f, (float)width/(float)height, 0.1f, 1000f);
67 gl.glOrtho(0.0, 800, 0.0, 800, -100.0, 100.0);
69 gl.glLoadIdentity();
70
71 tr.beginRendering(800,800);
72 tr.draw( "die Marktwirtschaft. Da regelt sich � angeblich", 16, 32);
73 tr.draw( "Hello World! This text is scrambled", 16, 16);
74 tr.endRendering();
75
76 }
77
78 public void init(final GLAutoDrawable arg0) {
79 tr = new TextRenderer(new java.awt.Font("Verdana", java.awt.Font.PLAIN, 12), true, false, null, false);
80 tr.setColor(1, 1, 1 ,1);
81 }
82
83 public void reshape(final GLAutoDrawable arg0, final int arg1, final int arg2, final int arg3, final int arg4) {
84 width = arg3;
85 height = arg4;
86 final GL2 gl = arg0.getGL().getGL2();
87 gl.glViewport(0, 0, width, height);
89 gl.glLoadIdentity();
90 gl.glOrtho(0.0, 800, 0.0, 200, -100.0, 100.0);
92 gl.glLoadIdentity();
93 }
94
95 public void dispose(final GLAutoDrawable drawable) {}
96}
A heavyweight AWT component which provides OpenGL rendering support.
Definition: GLCanvas.java:170
void addGLEventListener(final GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Definition: GLCanvas.java:1065
Demonstrates corruption with older versions of TextRenderer.
void reshape(final GLAutoDrawable arg0, final int arg1, final int arg2, final int arg3, final int arg4)
Called by the drawable during the first repaint after the component has been resized.
void display(final GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
void init(final GLAutoDrawable arg0)
Called by the drawable immediately after the OpenGL context is initialized.
void dispose(final GLAutoDrawable drawable)
Notifies the listener to perform the release of all OpenGL resources per GLContext,...
static void main(final String[] args)
Renders bitmapped Java 2D text into an OpenGL window with high performance, full Unicode support,...
void beginRendering(final int width, final int height)
Begins rendering with this TextRenderer into the current OpenGL drawable, pushing the projection and ...
void endRendering()
Ends a render cycle with this TextRenderer.
void draw(final CharSequence str, final int x, final int y)
Draws the supplied CharSequence at the desired location using the renderer's current color.
void setColor(final Color color)
Changes the current color of this TextRenderer to the supplied one.
void glOrtho(double left, double right, double bottom, double top, double near_val, double far_val)
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
GL2 getGL2()
Casts this object to the GL2 interface.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
static final int GL_COLOR_BUFFER_BIT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_COLOR_BUFFER_BIT" wit...
Definition: GL.java:390
void glClearColor(float red, float green, float blue, float alpha)
Entry point to C language function: void {@native glClearColor}(GLfloat red, GLfloat green,...
void glClear(int mask)
Entry point to C language function: void {@native glClear}(GLbitfield mask) Part of GL_ES_VERSION_...
void glViewport(int x, int y, int width, int height)
Entry point to C language function: void {@native glViewport}(GLint x, GLint y, GLsizei width,...
static final int GL_DEPTH_BUFFER_BIT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_DEPTH_BUFFER_BIT" wit...
Definition: GL.java:738
Subset of OpenGL fixed function pipeline's matrix operations.
static final int GL_PROJECTION
Matrix mode projection.
static final int GL_MODELVIEW
Matrix mode modelview.
void glLoadIdentity()
Load the current matrix with the identity matrix.
void glMatrixMode(int mode)
Sets the current matrix mode.