29package com.jogamp.opengl.test.junit.jogl.acore;
31import java.io.IOException;
33import com.jogamp.nativewindow.CapabilitiesImmutable;
34import com.jogamp.opengl.GLCapabilities;
35import com.jogamp.opengl.GLCapabilitiesImmutable;
36import com.jogamp.opengl.GLContext;
37import com.jogamp.opengl.GLDrawable;
38import com.jogamp.opengl.GLDrawableFactory;
39import com.jogamp.opengl.GLEventListener;
40import com.jogamp.opengl.GLProfile;
42import jogamp.opengl.GLGraphicsConfigurationUtil;
44import org.junit.Assert;
46import org.junit.FixMethodOrder;
47import org.junit.runners.MethodSorters;
49import com.jogamp.newt.NewtFactory;
50import com.jogamp.newt.Window;
51import com.jogamp.newt.event.WindowAdapter;
52import com.jogamp.newt.event.WindowEvent;
53import com.jogamp.newt.event.WindowUpdateEvent;
54import com.jogamp.opengl.GLAutoDrawableDelegate;
55import com.jogamp.opengl.JoglVersion;
56import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
57import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
58import com.jogamp.opengl.test.junit.util.GLTestUtil;
59import com.jogamp.opengl.test.junit.util.NewtTestUtil;
60import com.jogamp.opengl.test.junit.util.UITestCase;
74@FixMethodOrder(MethodSorters.NAME_ASCENDING)
76 static final int widthStep = 800/4;
77 static final int heightStep = 600/4;
78 volatile int szStep = 2;
82 System.err.println(
"Profile "+profile+
" n/a");
89 System.out.println(
"Requested GL Caps: "+reqGLCaps);
91 final GLCapabilitiesImmutable expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, factory,
null);
92 System.out.println(
"Expected GL Caps: "+expGLCaps);
97 Assert.assertNotNull(window);
98 window.
setSize(widthStep*szStep, heightStep*szStep);
102 System.out.println(
"Window: "+window.getClass().getName());
106 System.out.println(
"Window Caps Pre_GL: "+chosenCaps);
107 Assert.assertNotNull(chosenCaps);
117 Assert.assertNotNull(drawable);
118 System.out.println(
"Drawable Pre-GL(0): "+drawable.getClass().getName()+
", "+drawable.
getNativeSurface().getClass().getName());
125 System.out.println(
"Drawable Post-GL(1): "+drawable.getClass().getName()+
", "+drawable.
getNativeSurface().getClass().getName());
135 System.out.println(
"Chosen GL Caps(1): "+chosenGLCaps01);
136 Assert.assertNotNull(chosenGLCaps01);
138 Assert.assertEquals(expGLCaps.
isFBO(), chosenGLCaps01.
isFBO());
143 Assert.assertNotNull(context);
150 System.out.println(
"Chosen GL Caps(2): "+chosenGLCaps02);
151 System.out.println(
"Chosen GL CTX (2): "+context.
getGLVersion());
152 System.out.println(
"Drawable Post-GL(2): "+drawable.getClass().getName()+
", "+drawable.
getNativeSurface().getClass().getName());
153 Assert.assertNotNull(chosenGLCaps02);
156 Assert.assertTrue(chosenGLCaps02.
getRedBits()>5);
159 Assert.assertEquals(expGLCaps.
isFBO(), chosenGLCaps02.
isFBO());
170 protected void destroyImplInLock() {
202 Assert.assertTrue(
"Surface Size not reached: Expected "+expSurfaceSize[0]+
"x"+expSurfaceSize[1]+
", Is "+glad.
getSurfaceWidth()+
"x"+glad.
getSurfaceHeight(),
209 window.
setSize(widthStep*szStep, heightStep*szStep);
210 expSurfaceSize[0] = widthStep*szStep;
211 expSurfaceSize[1] = heightStep*szStep;
213 Assert.assertTrue(
"Surface Size not reached: Expected "+expSurfaceSize[0]+
"x"+expSurfaceSize[1]+
", Is "+glad.
getSurfaceWidth()+
"x"+glad.
getSurfaceHeight(),
220 window.
setSize(widthStep*szStep, heightStep*szStep);
221 expSurfaceSize[0] = widthStep*szStep;
222 expSurfaceSize[1] = heightStep*szStep;
224 Assert.assertTrue(
"Surface Size not reached: Expected "+expSurfaceSize[0]+
"x"+expSurfaceSize[1]+
", Is "+glad.
getSurfaceWidth()+
"x"+glad.
getSurfaceHeight(),
232 System.out.println(
"Fin Drawable: "+drawable);
233 System.out.println(
"Fin Window: "+window);
251 if(
null == reqGLCaps)
return;
259 if(
null == reqGLCaps)
return;
266 if(
null == reqGLCaps)
return;
274 if(
null == reqGLCaps)
return;
284 if(
null == reqGLCaps)
return;
293 if(
null == reqGLCaps)
return;
302 if(
null == reqGLCaps)
return;
312 if(
null == reqGLCaps)
return;
316 doTest(reqGLCaps,
new Gears(1));
322 if(
null == reqGLCaps)
return;
330 if(
null == reqGLCaps)
return;
337 if(
null == reqGLCaps)
return;
345 if(
null == reqGLCaps)
return;
355 if(
null == reqGLCaps)
return;
364 if(
null == reqGLCaps)
return;
373 if(
null == reqGLCaps)
return;
392 public static void main(
final String args[])
throws IOException {
void setBitmap(final boolean enable)
Requesting offscreen bitmap mode.
void setOnscreen(final boolean onscreen)
Sets whether the surface shall be on- or offscreen.
static Window createWindow(final CapabilitiesImmutable caps)
Create a top level Window entity on the default Display and default Screen.
NEWT Window events are provided for notification purposes ONLY.
Fully functional GLAutoDrawable implementation utilizing already created GLDrawable and GLContext ins...
final void windowResizedOp(final int newWidth, final int newHeight)
Handling resize events from the windowing system.
final void windowDestroyNotifyOp()
Implementation to handle destroy notifications from the windowing system.
final void windowRepaintOp()
Default implementation to handle repaint events from the windowing system.
final void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext....
Specifies a set of OpenGL capabilities.
void setPBuffer(final boolean enable)
Requesting offscreen pbuffer mode.
void setDoubleBuffered(final boolean enable)
Enables or disables double buffering.
void setFBO(final boolean enable)
Requesting offscreen FBO mode.
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 release()
Releases control of this GLContext from the current thread.
static final int CONTEXT_CURRENT_NEW
Indicates that a newly-created context was made current during the last call to makeCurrent,...
final String getGLVersion()
Returns a valid OpenGL version string, ie
abstract AbstractGraphicsDevice getDefaultDevice()
Retrieve the default device connection, unit ID and unique ID name.
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 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.
static StringBuilder getDefaultOpenGLInfo(AbstractGraphicsDevice device, StringBuilder sb, final boolean withCapabilitiesInfo)
Tests using a NEWT Window for on- and offscreen cases.
void testES2OffScreenPbufferDblBuf()
void testES2OffScreenPbufferSglBuf()
void testGL2OnScreenSglBuf()
void testGL2OnScreenDblBuf()
void testES2OffScreenFBOSglBuf()
void testES2OffScreenAutoDblBuf()
void testGL2OffScreenPbufferSglBuf()
void testGL2OffScreenAutoDblBuf()
void testGL2OffScreenFBOSglBuf()
void testGL2OffScreenPbufferDblBuf()
void testGL2OffScreenFBODblBuf()
void testES2OffScreenFBODblBuf()
static void main(final String args[])
Not implemented ! @Test public void testES2OffScreenBitmapDblBuf() throws InterruptedException { if(!...
void testGL2OffScreenBitmapSglBuf()
void testES2OnScreenSglBuf()
void testES2OnScreenDblBuf()
Gears.java author: Brian Paul (converted to Java by Ron Cemer and Sven Gothel)
static boolean waitForSize(final GLDrawable drawable, final int width, final int height, final Runnable waitAction)
static boolean waitForRealized(final Screen screen, final boolean realized, final Runnable waitAction)
static boolean waitForVisible(final Window win, final boolean visible, final Runnable waitAction)
CapabilitiesImmutable getChosenCapabilities()
Return the capabilities reflecting this graphics configuration, which may differ from the capabilitie...
Specifies an immutable set of capabilities that a window's rendering context must support,...
int getBlueBits()
Returns the number of bits for the color buffer's blue component.
boolean isBitmap()
Returns whether bitmap offscreen mode is requested, available or chosen.
int getRedBits()
Returns the number of bits for the color buffer's red component.
int getGreenBits()
Returns the number of bits for the color buffer's green component.
boolean isOnscreen()
Returns whether an on- or offscreen surface is requested, available or chosen.
int getSurfaceWidth()
Returns the width of the client area excluding insets (window decorations) in pixel units.
AbstractGraphicsConfiguration getGraphicsConfiguration()
Returns the graphics configuration corresponding to this window.
int[] convertToPixelUnits(final int[] windowUnitsAndResult)
Converts the given window units into pixel units in place.
int getSurfaceHeight()
Returns the height of the client area excluding insets (window decorations) in pixel units.
Specifying NEWT's Window functionality:
void addWindowListener(WindowListener l)
Appends the given com.jogamp.newt.event.WindowListener to the end of the list.
void setWindowDestroyNotifyAction(Runnable r)
Set a custom action handling destruction issued by a toolkit triggered window destroy replacing the d...
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.
void destroy()
Destroys this window incl.releasing all related resources.
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Specifies an immutable set of OpenGL capabilities.
int getDepthBits()
Returns the number of depth buffer bits.
boolean isPBuffer()
Returns whether pbuffer offscreen mode is requested, available or chosen.
GLProfile getGLProfile()
Returns the GL profile you desire or used by the drawable.
boolean isFBO()
Returns whether FBO offscreen mode is requested, available or chosen.
An abstraction for an OpenGL rendering target.
GLCapabilitiesImmutable getChosenGLCapabilities()
Fetches the GLCapabilitiesImmutable corresponding to the chosen OpenGL capabilities (pixel format / v...
int getSurfaceWidth()
Returns the width of this GLDrawable's surface client area in pixel units.
boolean isRealized()
Returns true if this drawable is realized, otherwise false.
NativeSurface getNativeSurface()
Returns the associated NativeSurface of this NativeSurfaceHolder.
void setRealized(boolean realized)
Indicates to GLDrawable implementations whether the underlying surface has been created and can be dr...
int getSurfaceHeight()
Returns the height of this GLDrawable's surface client area in pixel units.
GLContext createContext(GLContext shareWith)
Creates a new context for drawing to this drawable that will optionally share buffer objects,...
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.