28package com.jogamp.opengl.test.junit.graph;
31import java.io.IOException;
33import com.jogamp.opengl.GL;
34import com.jogamp.opengl.GL2ES2;
35import com.jogamp.opengl.GLAutoDrawable;
36import com.jogamp.opengl.GLCapabilities;
37import com.jogamp.opengl.GLCapabilitiesImmutable;
38import com.jogamp.opengl.GLException;
39import com.jogamp.opengl.GLProfile;
40import com.jogamp.opengl.JoglVersion;
42import jogamp.common.os.PlatformPropsImpl;
44import org.junit.Assert;
45import org.junit.BeforeClass;
47import org.junit.FixMethodOrder;
48import org.junit.runners.MethodSorters;
50import com.jogamp.common.os.Platform;
51import com.jogamp.common.util.VersionUtil;
52import com.jogamp.graph.curve.Region;
53import com.jogamp.graph.font.Font;
54import com.jogamp.graph.font.FontFactory;
55import com.jogamp.newt.opengl.GLWindow;
56import com.jogamp.opengl.test.junit.util.UITestCase;
57import com.jogamp.opengl.util.caps.NonFSAAGLCapsChooser;
66@FixMethodOrder(MethodSorters.NAME_ASCENDING)
68 static final boolean DEBUG =
false;
69 static final boolean TRACE =
false;
70 static long duration = 100;
71 static int win_width = 1024;
72 static int win_height = 640;
73 static int[] aaQualitySet =
new int[] { 0, 1 };
74 static int[] sampleSet =
new int[] { 4 };
75 static Font[] fontSet =
new Font[] { };
79 if( fontSet.length == 0 ) {
82 }
catch (
final IOException e) {
88 static int atoi(
final String a) {
90 return Integer.parseInt(a);
91 }
catch (
final Exception ex) {
throw new RuntimeException(ex); }
94 public static void main(
final String args[])
throws IOException {
95 for(
int i=0; i<args.length; i++) {
96 if(args[i].equals(
"-time")) {
98 duration = atoi(args[i]);
99 }
else if(args[i].equals(
"-width")) {
101 win_width = atoi(args[i]);
102 }
else if(args[i].equals(
"-height")) {
104 win_height = atoi(args[i]);
105 }
else if(args[i].equals(
"-font")) {
108 }
else if(args[i].equals(
"-samples")) {
110 sampleSet =
new int[] { atoi(args[i]) };
111 }
else if(args[i].equals(
"-aaq")) {
113 aaQualitySet =
new int[] { atoi(args[i]) };
117 org.junit.runner.JUnitCore.
main(tstname);
120 static void sleep() {
122 System.err.println(
"** new frame ** (sleep: "+duration+
"ms)");
123 Thread.sleep(duration);
124 }
catch (
final InterruptedException ie) {}
127 static void destroyWindow(
final GLWindow window) {
133 static GLWindow createWindow(
final String title,
final GLCapabilitiesImmutable caps,
final int width,
final int height) {
134 Assert.assertNotNull(caps);
136 final GLWindow window = GLWindow.create(caps);
137 if( !caps.getSampleBuffers() ) {
140 window.setCapabilitiesChooser(
new NonFSAAGLCapsChooser(
true));
142 window.setSize(width, height);
143 window.setPosition(10, 10);
144 window.setTitle(title);
145 Assert.assertNotNull(window);
146 window.setVisible(
true);
153 if(Platform.CPUFamily.X86 != PlatformPropsImpl.CPU_ARCH.family) {
155 System.err.println(
"disabled on non desktop (x86) arch for now ..");
162 System.err.println(
"Requested: "+caps);
164 final GLWindow window = createWindow(
"TTRN20", caps, win_width, win_height);
166 System.err.println(VersionUtil.getPlatformInfo());
171 textGLListener.attachInputListenerTo(window);
173 textGLListener.setHeadBox(2,
true);
178 final Runnable action_per_font =
new Runnable() {
181 textGLListener.setHeadBox(1,
false);
183 textGLListener.printScreenOnGLThread(window,
"./", window.
getTitle(),
"",
false);
186 textGLListener.setHeadBox(2,
false);
188 textGLListener.printScreenOnGLThread(window,
"./", window.
getTitle(),
"",
false);
192 for(
final Font f : fontSet) {
193 if( textGLListener.setFont(f) ) {
194 for(
final int aaQuality : aaQualitySet ) {
195 textGLListener.getRenderer().setAAQuality(aaQuality);
196 for(
final int sampleCount : sampleSet ) {
197 textGLListener.getRenderer().setSampleCount(sampleCount);
198 action_per_font.run();
203 destroyWindow(window);
208 if(Platform.CPUFamily.X86 != PlatformPropsImpl.CPU_ARCH.family) {
210 System.err.println(
"disabled on non desktop (x86) arch for now ..");
217 System.err.println(
"Requested: "+caps);
219 final GLWindow window = createWindow(
"TTRN20", caps, win_width, win_height);
224 textGLListener.attachInputListenerTo(window);
226 textGLListener.setHeadBox(2,
true);
231 final Runnable action_per_font =
new Runnable() {
234 textGLListener.setHeadBox(1,
false);
236 textGLListener.printScreenOnGLThread(window,
"./", window.
getTitle(),
"",
false);
239 textGLListener.setHeadBox(2,
false);
241 textGLListener.printScreenOnGLThread(window,
"./", window.
getTitle(),
"",
false);
245 for(
final Font f : fontSet) {
246 if( textGLListener.setFont(f) ) {
247 for(
final int sampleCount : sampleSet ) {
248 textGLListener.getRenderer().setSampleCount(sampleCount);
249 action_per_font.run();
253 destroyWindow(window);
263 System.err.println(
"Requested: "+caps);
265 final GLWindow window = createWindow(
"TTRN20", caps, win_width, win_height);
270 textGLListener.attachInputListenerTo(window);
272 textGLListener.setHeadBox(2,
true);
275 final Runnable action_per_font =
new Runnable() {
278 textGLListener.setHeadBox(1,
false);
280 textGLListener.printScreenOnGLThread(window,
"./", window.
getTitle(),
"",
false);
283 textGLListener.setHeadBox(2,
false);
285 textGLListener.printScreenOnGLThread(window,
"./", window.
getTitle(),
"",
false);
289 for(
final Font f : fontSet) {
290 if( textGLListener.setFont(f) ) {
291 action_per_font.run();
294 destroyWindow(window);
302 System.err.println(
"Requested: "+caps);
304 final GLWindow window = createWindow(
"TTRN20", caps, win_width, win_height);
309 textGLListener.attachInputListenerTo(window);
311 textGLListener.setHeadBox(2,
true);
314 final Runnable action_per_font =
new Runnable() {
317 textGLListener.setHeadBox(1,
false);
319 textGLListener.printScreenOnGLThread(window,
"./", window.
getTitle(),
"",
false);
322 textGLListener.setHeadBox(2,
false);
324 textGLListener.printScreenOnGLThread(window,
"./", window.
getTitle(),
"",
false);
328 for(
final Font f : fontSet) {
329 if( textGLListener.setFont(f) ) {
330 action_per_font.run();
333 destroyWindow(window);
337 public TextGLListener(
final GLProfile glp,
final int type,
final int aaQuality,
final int sampleCount,
final boolean debug,
final boolean trace) {
338 super(glp, type, aaQuality, sampleCount,
true, debug, trace);
342 public void attachInputListenerTo(
final GLWindow window) {
343 super.attachInputListenerTo(window);
348 super.init(drawable);
354 MSAATool.dump(drawable);
356 getRenderer().setColorStatic(0.1f, 0.1f, 0.1f, 1.0f);
361 super.display(drawable);
Abstract Outline shape representation define the method an OutlineShape(s) is bound and rendered.
static final int MSAA_RENDERING_BIT
Rendering-Mode bit for Region.
static final int DEFAULT_AA_QUALITY
Default pass2 AA-quality rendering {@value} for Graph Region AA render-modes: VBAA_RENDERING_BIT.
static final int NORM_RENDERING_BIT
Rendering-Mode bit for Region.
static final int VBAA_RENDERING_BIT
Rendering-Mode bit for Region.
The optional property jogamp.graph.font.ctor allows user to specify the FontConstructor implementatio...
static final FontSet get(final int font)
void setAlphaBits(final int alphaBits)
Sets the number of bits requested for the color buffer's alpha component.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
Specifies a set of OpenGL capabilities.
void setNumSamples(final int numSamples)
If sample buffers are enabled, indicates the number of buffers to be allocated.
void setSampleBuffers(final boolean enable)
Defaults to false.
A generic exception for OpenGL errors used throughout the binding as a substitute for RuntimeExceptio...
Specifies the the OpenGL profile.
static final String GL2ES2
The intersection of the desktop GL3, GL2 and embedded ES2 profile.
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
static GLProfile getGL2ES2(final AbstractGraphicsDevice device)
Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.
static StringBuilder getGLInfo(final GL gl, final StringBuilder sb)
GPURendererListenerBase01 Keys:
TestTextRendererNEWT20 Variant.
void test30TextRendererNoSampling()
static void main(final String args[])
void test10TextRendererMSAA01()
void test00TextRendererVBAA01()
void test20TextRendererFSAA01()
Interface wrapper for font implementation.
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
GL2ES2 getGL2ES2()
Casts this object to the GL2ES2 interface.
void setSwapInterval(int interval)
Set the swap interval of the current context and attached onscreen GLDrawable.
GLCapabilitiesImmutable getChosenGLCapabilities()
Fetches the GLCapabilitiesImmutable corresponding to the chosen OpenGL capabilities (pixel format / v...
void glEnable(int cap)
Entry point to C language function: void {@native glEnable}(GLenum cap) Part of GL_ES_VERSION_2_0,...
static final int GL_DEPTH_TEST
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_DEPTH_TEST" with expr...