JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
GLReadBuffer00Base.java
Go to the documentation of this file.
1/**
2 * Copyright 2014 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 */
28package com.jogamp.opengl.test.junit.jogl.acore;
29
30import java.io.IOException;
31import java.lang.reflect.InvocationTargetException;
32
33import com.jogamp.opengl.GL2ES2;
34import com.jogamp.opengl.GLAutoDrawable;
35import com.jogamp.opengl.GLCapabilities;
36import com.jogamp.opengl.GLCapabilitiesImmutable;
37import com.jogamp.opengl.GLProfile;
38
39import org.junit.BeforeClass;
40import org.junit.FixMethodOrder;
41import org.junit.Test;
42import org.junit.runners.MethodSorters;
43
44import com.jogamp.graph.curve.Region;
45import com.jogamp.graph.curve.opengl.GLRegion;
46import com.jogamp.graph.curve.opengl.RegionRenderer;
47import com.jogamp.graph.font.Font;
48import com.jogamp.graph.font.FontScale;
49import com.jogamp.opengl.test.junit.graph.TextRendererGLELBase;
50import com.jogamp.opengl.test.junit.util.UITestCase;
51
52/**
53 * Test synchronous GLAutoDrawable display, swap-buffer and read-pixels
54 * including non-MSAA and MSAA framebuffer.
55 * <p>
56 * Analyzes behavior of reported bugs
57 * <ul>
58 * <li>Bug 841 - GLJPanel "lagging" by one frame, https://jogamp.org/bugzilla/show_bug.cgi?id=841</li>
59 * <li>Bug 975 - GLJPanel's OffscreenDrawable shall not double swap (custom swap by GLEventListener using [AWT]GLReadBufferUtil),
60 * https://jogamp.org/bugzilla/show_bug.cgi?id=975</li>
61 * <li>Bug 1020 - First frame on a mac nvidia card not antialiased, https://jogamp.org/bugzilla/show_bug.cgi?id=841</li>
62 * </ul>
63 * </p>
64 *
65 */
66@FixMethodOrder(MethodSorters.NAME_ASCENDING)
67public abstract class GLReadBuffer00Base extends UITestCase {
68
69 public static class TextRendererGLEL extends TextRendererGLELBase {
70 final Font font = getFont(0, 0, 0);
71 public int frameNo = 0;
72 public int userCounter = 0;
73 private final GLRegion regionFPS;
74
75 public TextRendererGLEL(final GLProfile glp) {
76 // FIXME: Graph TextRenderer does not AA well w/o MSAA and FBO
77 super(Region.VBAA_RENDERING_BIT, new int[] { 4 });
79 regionFPS = GLRegion.create(glp, renderModes, null, 0, 0);
80
81 staticRGBAColor[0] = 0.9f;
82 staticRGBAColor[1] = 0.9f;
83 staticRGBAColor[2] = 0.9f;
84 staticRGBAColor[3] = 0.99f;
85 }
86
87 @Override
88 public void dispose(final GLAutoDrawable drawable) {
89 regionFPS.destroy(drawable.getGL().getGL2ES2());
90 super.dispose(drawable);
91 }
92
93 @Override
94 public void display(final GLAutoDrawable drawable) {
95 final String text = String.format("Frame %04d (%03d): %04dx%04d", frameNo, userCounter, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
96 System.err.println("TextRendererGLEL.display: "+text);
97 if( null != renderer ) {
98 final float pixelSize = FontScale.toPixels(14f, dpiH);
99 final GL2ES2 gl = drawable.getGL().getGL2ES2();
100 gl.glClearColor(1f, 1f, 1f, 0f);
101 renderString(drawable, font, pixelSize, text, 0 /* col */, 0 /* row */, 0, 0, -1, regionFPS.clear(gl));
102 } else {
103 System.err.println(text);
104 }
105 frameNo++;
106 }
107 }
108
109 @BeforeClass
110 public static void initClass() throws IOException {
112 }
113
114 protected abstract void test(final GLCapabilitiesImmutable caps, final boolean useSwingDoubleBuffer, final boolean skipGLOrientationVerticalFlip);
115
116 @Test
117 public void test00_MSAA0_DefFlip() throws InterruptedException, InvocationTargetException {
118 test(new GLCapabilities(null), false /*useSwingDoubleBuffer*/, false /* skipGLOrientationVerticalFlip */);
119 }
120
121 @Test
122 public void test01_MSAA0_UsrFlip() throws InterruptedException, InvocationTargetException {
123 test(new GLCapabilities(null), false /*useSwingDoubleBuffer*/, true /* skipGLOrientationVerticalFlip */);
124 }
125
126 @Test
127 public void test10_MSAA8_DefFlip() throws InterruptedException, InvocationTargetException {
128 final GLCapabilities caps = new GLCapabilities(null);
129 caps.setNumSamples(8);
130 caps.setSampleBuffers(true);
131 test(caps, false /*useSwingDoubleBuffer*/, false /* skipGLOrientationVerticalFlip */);
132 }
133
134 @Test
135 public void test11_MSAA8_UsrFlip() throws InterruptedException, InvocationTargetException {
136 final GLCapabilities caps = new GLCapabilities(null);
137 caps.setNumSamples(8);
138 caps.setSampleBuffers(true);
139 test(caps, false /*useSwingDoubleBuffer*/, true /* skipGLOrientationVerticalFlip */);
140 }
141
142 static long duration = 500; // ms
143}
Abstract Outline shape representation define the method an OutlineShape(s) is bound and rendered.
Definition: Region.java:62
static final int VBAA_RENDERING_BIT
Rendering-Mode bit for Region.
Definition: Region.java:115
A GLRegion is the OGL binding of one or more OutlineShapes Defined by its vertices and generated tria...
Definition: GLRegion.java:70
final GLRegion clear(final GL2ES2 gl)
Clears all buffers, i.e.
Definition: GLRegion.java:436
final void destroy(final GL2ES2 gl)
Delete and clear the associated OGL objects.
Definition: GLRegion.java:460
static GLRegion create(final GLProfile glp, int renderModes, final TextureSequence colorTexSeq, final int pass2TexUnit, final int initialVerticesCount, final int initialIndicesCount)
Create a GLRegion using the passed render mode.
Definition: GLRegion.java:109
static final GLCallback defaultBlendDisable
Default GL#GL_BLEND disable GLCallback, simply turning-off the GL#GL_BLEND state and turning-on depth...
static final GLCallback defaultBlendEnable
Default GL#GL_BLEND enable GLCallback, turning-off depth writing via GL#glDepthMask(boolean) if Rende...
Simple static font scale methods for unit conversions.
Definition: FontScale.java:37
static float toPixels(final float points, final float res_dpi)
Converts typical font size in points and screen resolution in dpi (pixels-per-inch) to font size in p...
Definition: FontScale.java:76
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.
Specifies the the OpenGL profile.
Definition: GLProfile.java:77
static void initSingleton()
Static initialization of JOGL.
Definition: GLProfile.java:204
void dispose(final GLAutoDrawable drawable)
Notifies the listener to perform the release of all OpenGL resources per GLContext,...
void display(final GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
Test synchronous GLAutoDrawable display, swap-buffer and read-pixels including non-MSAA and MSAA fram...
abstract void test(final GLCapabilitiesImmutable caps, final boolean useSwingDoubleBuffer, final boolean skipGLOrientationVerticalFlip)
Interface wrapper for font implementation.
Definition: Font.java:60
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
GL2ES2 getGL2ES2()
Casts this object to the GL2ES2 interface.
Specifies an immutable set of OpenGL capabilities.
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.
void glClearColor(float red, float green, float blue, float alpha)
Entry point to C language function: void {@native glClearColor}(GLfloat red, GLfloat green,...