JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
TestAWTTextRendererUseVertexArrayBug464.java
Go to the documentation of this file.
1/**
2 * Copyright 2011 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28
29package com.jogamp.opengl.test.junit.jogl.awt.text;
30
31import com.jogamp.opengl.GLProfile;
32import com.jogamp.opengl.GLCapabilities;
33import com.jogamp.opengl.awt.GLCanvas;
34import com.jogamp.opengl.util.Animator;
35import com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3;
36import com.jogamp.opengl.test.junit.util.UITestCase;
37
38import java.awt.Frame;
39import java.io.IOException;
40
41import org.junit.Assert;
42import org.junit.Assume;
43import org.junit.Before;
44import org.junit.BeforeClass;
45import org.junit.After;
46import org.junit.Test;
47import org.junit.FixMethodOrder;
48import org.junit.runners.MethodSorters;
49
50/*
51 * Unit tests for Bug464
52 * Some ATI-Drivers crash the JVM if VBO-related glFunctions are called. This test checks
53 * if TextRenderer calls any of these functions while it's useVertexArray variable is set
54 * to false.
55 * 2D- and 3D-TextRendering is tested by creating a GLCanvas showing a simple line of text
56 * while filtering all glFunction calls by using a modified version of TraceGL2.
57 * VBO-related function are logged to the disallowedMethodCalls String of the GLEventListener
58 * instead of being executed (to prevent JVM crashes). Therefore, if the
59 * disallowedMethodCalls isn't an empty String after the test, the test fails.
60 *
61 * Other classes related to this test:
62 * TestTextRendererGLEventListener01
63 * TestTextRendererTraceGL2Mock01
64 */
65
66@FixMethodOrder(MethodSorters.NAME_ASCENDING)
68 static GLProfile glp;
69 static GLCapabilities caps;
70
71 private GLCanvas glCanvas;
72 private Frame frame;
73
74 @BeforeClass
75 public static void initClass() {
77 Assert.assertNotNull(glp);
78 caps = new GLCapabilities(glp);
79 Assert.assertNotNull(caps);
80 }
81
82 @Before
83 public void initTest() {
84 glCanvas = new GLCanvas(caps);
85
86 frame = new Frame("TextRenderer Test");
87 Assert.assertNotNull(frame);
88 frame.add(glCanvas);
89 try {
90 javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
91 public void run() {
92 frame.setSize(512, 512);
93 frame.setVisible(true);
94 }});
95 } catch( final Throwable throwable ) {
96 throwable.printStackTrace();
97 Assume.assumeNoException( throwable );
98 }
99 }
100
101 @After
102 public void cleanupTest() {
103 try {
104 javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
105 public void run() {
106 frame.setVisible(false);
107 frame.remove(glCanvas);
108 frame.dispose();
109 }});
110 } catch( final Throwable throwable ) {
111 throwable.printStackTrace();
112 Assume.assumeNoException( throwable );
113 }
114 glCanvas=null;
115 frame=null;
116 }
117
118 @Test
119 public void testTextRendererDraw2D() throws InterruptedException {
120
122 Assert.assertNotNull(listener);
123 glCanvas.addGLEventListener(listener);
124 final Animator animator = new Animator(glCanvas);
125
126 animator.start();
127
128 Thread.sleep(500); // 500 ms
129
130 animator.stop();
131
132 final String disallowedMethods = listener.getDisallowedMethodCalls();
133 if (!disallowedMethods.equals("")) {
134 Assert.fail("Following VBO-related glMethods have been called: "+ disallowedMethods);
135 }
136 }
137
138 @Test
139 public void testTextRendererDraw3D() throws InterruptedException {
140
142 Assert.assertNotNull(listener);
143 glCanvas.addGLEventListener(listener);
144 final Animator animator = new Animator(glCanvas);
145
146 animator.start();
147
148 Thread.sleep(500); // 500 ms
149
150 animator.stop();
151
152 final String disallowedMethods = listener.getDisallowedMethodCalls();
153 if (!disallowedMethods.equals("")) {
154 Assert.fail("Following VBO-related glMethods have been called: "+ disallowedMethods);
155 }
156 }
157
158 public static void main(final String args[]) throws IOException {
159 org.junit.runner.JUnitCore.main(TestAWTTextRendererUseVertexArrayBug464.class.getName());
160 }
161}
Specifies a set of OpenGL capabilities.
Specifies the the OpenGL profile.
Definition: GLProfile.java:77
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
static final String GL2
The desktop OpenGL profile 1.x up to 3.0.
Definition: GLProfile.java:579
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
final synchronized boolean start()
Starts this animator, if not running.
Definition: Animator.java:344
final synchronized boolean stop()
Stops this animator.
Definition: Animator.java:368