29package com.jogamp.opengl.test.junit.jogl.acore;
31import java.io.IOException;
33import com.jogamp.opengl.GL;
34import com.jogamp.opengl.GL2ES2;
35import com.jogamp.opengl.GLCapabilities;
36import com.jogamp.opengl.GLContext;
37import com.jogamp.opengl.GLDebugListener;
38import com.jogamp.opengl.GLDebugMessage;
39import com.jogamp.opengl.GLDrawable;
40import com.jogamp.opengl.GLDrawableFactory;
41import com.jogamp.opengl.GLProfile;
43import org.junit.Assert;
45import org.junit.FixMethodOrder;
46import org.junit.runners.MethodSorters;
48import com.jogamp.newt.Display;
49import com.jogamp.newt.NewtFactory;
50import com.jogamp.newt.Screen;
51import com.jogamp.newt.Window;
52import com.jogamp.opengl.test.junit.util.UITestCase;
54@FixMethodOrder(MethodSorters.NAME_ASCENDING)
57 static String dbgTstMsg0 =
"Hello World";
58 static int dbgTstId0 = 42;
60 static GLProfile getGLProfile(
final String profile) {
62 System.err.println(
"Profile "+profile+
" n/a");
78 WindowContext createWindow(
final GLProfile glp,
final boolean debugGL) {
84 Assert.assertNotNull(display);
87 Assert.assertNotNull(screen);
90 Assert.assertNotNull(window);
96 Assert.assertNotNull(drawable);
101 Assert.assertNotNull(context);
108 return new WindowContext(window, context);
111 void destroyWindow(
final WindowContext winctx) {
112 final GLDrawable drawable = winctx.context.getGLDrawable();
114 Assert.assertNotNull(winctx.context);
115 winctx.context.destroy();
117 Assert.assertNotNull(drawable);
120 Assert.assertNotNull(winctx.window);
121 winctx.window.destroy();
125 void testX1GLDebugEnableDisable(
final GLProfile glp,
final boolean enable)
throws InterruptedException {
126 final WindowContext winctx = createWindow(glp, enable);
127 final String glDebugExt = winctx.context.getGLDebugMessageExtension();
128 System.err.println(
"glDebug extension: "+glDebugExt);
129 System.err.println(
"glDebug enabled: "+winctx.context.isGLDebugMessageEnabled());
130 System.err.println(
"glDebug sync: "+winctx.context.isGLDebugSynchronous());
131 System.err.println(
"context version: "+winctx.context.getGLVersion());
133 Assert.assertEquals((
null == glDebugExt) ?
false : enable, winctx.context.isGLDebugMessageEnabled());
135 destroyWindow(winctx);
144 testX1GLDebugEnableDisable(glp,
false);
153 testX1GLDebugEnableDisable(glp,
true);
162 testX1GLDebugEnableDisable(glp,
false);
171 testX1GLDebugEnableDisable(glp,
true);
174 void testX2GLDebugError(
final GLProfile glp)
throws InterruptedException {
175 final WindowContext winctx = createWindow(glp,
true);
177 final MyGLDebugListener myGLDebugListener =
new MyGLDebugListener(
181 winctx.context.addGLDebugListener(myGLDebugListener);
183 final GL gl = winctx.context.
getGL();
187 if( winctx.context.isGLDebugMessageEnabled() ) {
188 Assert.assertEquals(
true, myGLDebugListener.received());
191 destroyWindow(winctx);
200 testX2GLDebugError(glp);
209 testX2GLDebugError(glp);
212 void testX3GLDebugInsert(
final GLProfile glp)
throws InterruptedException {
213 final WindowContext winctx = createWindow(glp,
true);
214 final MyGLDebugListener myGLDebugListener =
new MyGLDebugListener(dbgTstMsg0, dbgTstId0);
215 winctx.context.addGLDebugListener(myGLDebugListener);
217 final String glDebugExt = winctx.context.getGLDebugMessageExtension();
218 Assert.assertEquals((
null == glDebugExt) ?
false :
true, winctx.context.isGLDebugMessageEnabled());
220 if( winctx.context.isGLDebugMessageEnabled() ) {
225 Assert.assertEquals(
true, myGLDebugListener.received());
228 destroyWindow(winctx);
237 testX3GLDebugInsert(glp);
246 testX3GLDebugInsert(glp);
249 public static void main(
final String args[])
throws IOException {
251 org.junit.runner.JUnitCore.
main(tstname);
261 boolean received =
false;
264 this.recSource = recSource;
265 this.recType = recType;
266 this.recSeverity = recSeverity;
274 this.recSeverity = -1;
275 this.recMsg = recMsg;
282 System.err.println(
"XXX: "+event);
283 if(
null != recMsg && recMsg.equals(event.
getDbgMsg()) && recId == event.
getDbgId()) {
285 }
else if(0 <= recSource && recSource == event.
getDbgSource() &&
static Display createDisplay(final String name)
Create a Display entity.
static Window createWindow(final CapabilitiesImmutable caps)
Create a top level Window entity on the default Display and default Screen.
static Screen createScreen(final Display display, final int index)
Create a Screen entity.
A screen may span multiple MonitorDevices representing their combined virtual size.
Specifies a set of OpenGL capabilities.
Abstraction for an OpenGL rendering context.
abstract int makeCurrent()
Makes this GLContext current on the calling thread.
static final int CONTEXT_CURRENT
Indicates that the context was made current during the last call to makeCurrent, value {@value}.
abstract void enableGLDebugMessage(boolean enable)
Enables or disables the GLDebugOutput feature of extension GLExtensions#ARB_debug_output or GLExtensi...
static final int CONTEXT_CURRENT_NEW
Indicates that a newly-created context was made current during the last call to makeCurrent,...
OpenGL debug message generated by the driver and delivered via GLDebugListener.
abstract GLDrawable createGLDrawable(NativeSurface target)
Returns an unrealized GLDrawable according to it's chosen GLCapabilitiesImmutable,...
static GLDrawableFactory getFactory(final GLProfile glProfile)
Returns the sole GLDrawableFactory instance.
Specifies the the OpenGL profile.
static boolean isAvailable(final AbstractGraphicsDevice device, final String profile)
Returns the availability of a profile on a device.
static final String GLES2
The embedded OpenGL profile ES 2.x, with x >= 0.
static final String GL2GL3
The intersection of the desktop GL3 and GL2 profile.
static GLProfile get(final AbstractGraphicsDevice device, String profile)
Returns a GLProfile object.
MyGLDebugListener(final String recMsg, final int recId)
void messageSent(final GLDebugMessage event)
Handle GLDebugMessage message sent from native GL implementation.
MyGLDebugListener(final int recSource, final int recType, final int recSeverity)
WindowContext(final Window w, final GLContext c)
void test02GL2GL3DebugEnabled()
void test13GLES2DebugError()
void test01GL2GL3DebugDisabled()
void test14GLES2DebugInsert()
void test11GLES2DebugDisabled()
void test12GLES2DebugEnabled()
void test04GL2GL3DebugInsert()
void test03GL2GL3DebugError()
static void main(final String args[])
Specifying NEWT's Window functionality:
void setSize(int width, int height)
Sets the size of the window's client area in window units, excluding decorations.
void setVisible(boolean visible)
Calls setVisible(true, visible), i.e.
static final int GL_DEBUG_SOURCE_APPLICATION
GL_KHR_debug, GL_ES_VERSION_3_2, GL_VERSION_4_3, GL_KHR_debug, GL_ARB_debug_output Alias for: GL_DEBU...
static final int GL_DEBUG_TYPE_OTHER
GL_KHR_debug, GL_ES_VERSION_3_2, GL_VERSION_4_3, GL_ARB_debug_output, GL_KHR_debug Alias for: GL_DEBU...
static final int GL_DEBUG_TYPE_ERROR
GL_KHR_debug, GL_ES_VERSION_3_2, GL_VERSION_4_3, GL_ARB_debug_output, GL_KHR_debug Alias for: GL_DEBU...
static final int GL_DEBUG_SEVERITY_MEDIUM
GL_KHR_debug, GL_ES_VERSION_3_2, GL_VERSION_4_3, GL_KHR_debug, GL_ARB_debug_output,...
static final int GL_DEBUG_SEVERITY_HIGH
GL_KHR_debug, GL_ES_VERSION_3_2, GL_VERSION_4_3, GL_ARB_debug_output, GL_KHR_debug,...
static final int GL_DEBUG_SOURCE_API
GL_KHR_debug, GL_ES_VERSION_3_2, GL_VERSION_4_3, GL_ARB_debug_output, GL_KHR_debug Alias for: GL_DEBU...
GL getGL()
Casts this object to the GL interface.
Listener for GLDebugMessages.
An abstraction for an OpenGL rendering target.
void setRealized(boolean realized)
Indicates to GLDrawable implementations whether the underlying surface has been created and can be dr...
GLContext createContext(GLContext shareWith)
Creates a new context for drawing to this drawable that will optionally share buffer objects,...
void glBindFramebuffer(int target, int framebuffer)
Entry point to C language function: void {@native glBindFramebuffer}(GLenum target,...