JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
Issue326Test2.java
Go to the documentation of this file.
1package com.jogamp.opengl.test.bugs;
2
3import java.awt.Font;
4import java.awt.Frame;
5import java.awt.event.*;
6
7import com.jogamp.opengl.GL;
8import com.jogamp.opengl.GL2;
9import com.jogamp.opengl.GLAutoDrawable;
10import com.jogamp.opengl.GLEventListener;
11import com.jogamp.opengl.awt.GLCanvas;
12import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
13
14import com.jogamp.opengl.util.awt.*;
15
16/**
17 * Another test case demonstrating corruption with older version of
18 * TextRenderer when glyphs were too big for backing store. Font and
19 * text courtesy of Patrick Murris. Adapted from Issue326Test1.
20 */
21
22public class Issue326Test2 extends Frame implements GLEventListener {
23
24 int width, height;
25
26 public static void main(final String[] args) {
27 new Issue326Test2();
28 }
29
30 GLCanvas canvas;
31 TextRenderer tr;
32
33 public Issue326Test2() {
34 super("");
35 this.setSize(800, 800);
36 canvas = new GLCanvas();
37 canvas.addGLEventListener(this);
38 add(canvas);
39
40 setVisible(true);
41 addWindowListener(new WindowAdapter() {
42 public void windowClosing(final WindowEvent e) {
43 System.exit(0);
44 }
45 });
46 }
47
48 public void display(final GLAutoDrawable drawable) {
49 final GL2 gl = drawable.getGL().getGL2();
50 gl.glClearColor(0, 0, 0, 0);
52
53 tr.beginRendering(drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
54 tr.draw("LA CLAPI\u00c8RE \nAlt: 1100-1700m \nGlissement de terrain majeur", 16, 80);
55 tr.draw("dans la haute Tin\u00e9e, sur un flanc du Parc du Mercantour.", 16, 16);
56 tr.endRendering();
57
58 }
59
60 public void init(final GLAutoDrawable arg0) {
61 tr = new TextRenderer(Font.decode("Arial-BOLD-64"));
62 tr.setColor(1, 1, 1 ,1);
63 }
64
65 public void reshape(final GLAutoDrawable arg0, final int x, final int y, final int w, final int h) {
66 final GL2 gl = arg0.getGL().getGL2();
68 gl.glLoadIdentity();
69 gl.glOrtho(0.0, w, 0.0, h, -1, 1);
71 gl.glLoadIdentity();
72 }
73
74 public void dispose(final GLAutoDrawable drawable) {}
75}
76
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
Another test case demonstrating corruption with older version of TextRenderer when glyphs were too bi...
static void main(final String[] args)
void dispose(final GLAutoDrawable drawable)
Notifies the listener to perform the release of all OpenGL resources per GLContext,...
void reshape(final GLAutoDrawable arg0, final int x, final int y, final int w, final int h)
Called by the drawable during the first repaint after the component has been resized.
void init(final GLAutoDrawable arg0)
Called by the drawable immediately after the OpenGL context is initialized.
void display(final GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
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.
int getSurfaceWidth()
Returns the width of this GLDrawable's surface client area in pixel units.
int getSurfaceHeight()
Returns the height of this GLDrawable's surface client area in pixel units.
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_...
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.