29package com.jogamp.opengl.test.junit.jogl.acore;
31import java.awt.Component;
32import java.awt.Dimension;
33import java.awt.event.WindowAdapter;
34import java.awt.event.WindowEvent;
35import java.io.IOException;
36import java.lang.reflect.InvocationTargetException;
37import java.nio.FloatBuffer;
38import java.nio.IntBuffer;
39import java.util.HashSet;
41import java.util.concurrent.Semaphore;
42import java.util.concurrent.TimeUnit;
43import java.util.concurrent.atomic.AtomicInteger;
45import com.jogamp.opengl.GL;
46import com.jogamp.opengl.GL2;
47import com.jogamp.opengl.GLAutoDrawable;
48import com.jogamp.opengl.GLCapabilities;
49import com.jogamp.opengl.GLContext;
50import com.jogamp.opengl.GLDrawableFactory;
51import com.jogamp.opengl.GLEventListener;
52import com.jogamp.opengl.GLOffscreenAutoDrawable;
53import com.jogamp.opengl.GLProfile;
54import com.jogamp.opengl.awt.GLCanvas;
55import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
56import com.jogamp.opengl.fixedfunc.GLPointerFunc;
57import com.jogamp.opengl.glu.GLU;
58import javax.swing.Box;
59import javax.swing.BoxLayout;
60import javax.swing.JFrame;
61import javax.swing.JLabel;
62import javax.swing.JPanel;
63import javax.swing.JSlider;
64import javax.swing.SwingConstants;
65import javax.swing.SwingUtilities;
66import javax.swing.event.ChangeEvent;
67import javax.swing.event.ChangeListener;
69import org.junit.Assert;
70import org.junit.BeforeClass;
72import org.junit.FixMethodOrder;
73import org.junit.runners.MethodSorters;
75import com.jogamp.common.ExceptionUtils;
76import com.jogamp.common.nio.Buffers;
77import com.jogamp.newt.awt.NewtCanvasAWT;
78import com.jogamp.newt.opengl.GLWindow;
79import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
80import com.jogamp.opengl.test.junit.util.TestUtil;
81import com.jogamp.opengl.test.junit.util.TestUtil.WindowClosingListener;
82import com.jogamp.opengl.test.junit.util.UITestCase;
83import com.jogamp.opengl.util.Animator;
111@FixMethodOrder(MethodSorters.NAME_ASCENDING)
114 static long durationPerTest = 1000;
118 private static int initializationCounter;
122 private static Semaphore disposalCompleteSemaphore =
new Semaphore(0);
127 private static AtomicInteger sharedVertexBufferObjects =
new AtomicInteger(0);
128 private static AtomicInteger sharedIndexBufferObjects =
new AtomicInteger(0);
133 setTestSupported(
false);
139 Assert.assertNotNull(sharedDrawable);
143 Assert.assertNotNull(
"Shared drawable's ctx is null", ctx);
144 Assert.assertTrue(
"Shared drawable's ctx is not created", ctx.
isCreated());
145 return sharedDrawable;
149 if(
null != sharedDrawable) {
160 private static final float boundsRadius = 2f;
161 private float viewDistance;
162 private static float viewDistanceFactor = 1.0f;
163 private float xAxisRotation;
164 private float yAxisRotation;
165 private static final float viewFovDegrees = 15f;
170 private final int [] privateVertexBufferObjects = {0};
171 private final int [] privateIndexBufferObjects = {0};
173 public static int createVertexBuffer(
final GL2 gl2) {
174 final FloatBuffer vertexBuffer = Buffers.newDirectFloatBuffer(18);
175 vertexBuffer.put(
new float[]{
183 vertexBuffer.position(0);
185 final int[] vbo = { 0 };
186 gl2.glGenBuffers(1, vbo, 0);
187 gl2.glBindBuffer(GL.GL_ARRAY_BUFFER, vbo[0]);
188 gl2.glBufferData(GL.GL_ARRAY_BUFFER, vertexBuffer.capacity() * Buffers.SIZEOF_FLOAT, vertexBuffer, GL.GL_STATIC_DRAW);
189 gl2.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
192 public static int createVertexIndexBuffer(
final GL2 gl2) {
193 final IntBuffer indexBuffer = Buffers.newDirectIntBuffer(3);
194 indexBuffer.put(
new int[]{0, 1, 2});
195 indexBuffer.position(0);
197 final int[] vbo = { 0 };
198 gl2.glGenBuffers(1, vbo, 0);
199 gl2.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, vbo[0]);
200 gl2.glBufferData(GL.GL_ELEMENT_ARRAY_BUFFER, indexBuffer.capacity() * Buffers.SIZEOF_INT, indexBuffer, GL.GL_STATIC_DRAW);
201 gl2.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, 0);
205 TwoTriangles (
final int canvasWidth,
final int canvasHeight,
final boolean useShared) {
207 this.canvasWidth = canvasWidth;
208 this.canvasHeight = canvasHeight;
209 this.useShared = useShared;
212 public void setXAxisRotation(
final float xRot) {
213 xAxisRotation = xRot;
216 public void setYAxisRotation(
final float yRot) {
217 yAxisRotation = yRot;
220 public void setViewDistanceFactor(
final float factor) {
221 viewDistanceFactor = factor;
226 public void init(
final GLAutoDrawable drawable) {
227 final GL2 gl2 = drawable.getGL().getGL2();
229 System.err.println(
"INIT GL IS: " + gl2.getClass().getName());
232 gl2.setSwapInterval(0);
235 gl2.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
239 synchronized (
this) {
241 int [] vertexBufferObjects;
242 int [] indexBufferObjects;
245 System.err.println(
"Using shared VBOs on slave 0x"+Integer.toHexString(hashCode()));
246 privateVertexBufferObjects[0] = sharedVertexBufferObjects.get();
247 privateIndexBufferObjects[0] = sharedIndexBufferObjects.get();
249 System.err.println(
"Using local VBOs on slave 0x"+Integer.toHexString(hashCode()));
251 vertexBufferObjects = privateVertexBufferObjects;
252 indexBufferObjects = privateIndexBufferObjects;
256 if (vertexBufferObjects[0] == 0) {
257 System.err.println(
"Creating vertex VBO on slave 0x"+Integer.toHexString(hashCode()));
258 vertexBufferObjects[0] = createVertexBuffer(gl2);
260 sharedVertexBufferObjects.set(vertexBufferObjects[0]);
270 if (gl2.glIsBuffer(vertexBufferObjects[0])) {
271 gl2.glBindBuffer(GL.GL_ARRAY_BUFFER, vertexBufferObjects[0]);
273 gl2.glEnableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
274 gl2.glVertexPointer(3, GL.GL_FLOAT, 6 * Buffers.SIZEOF_FLOAT, 0);
276 gl2.glEnableClientState(GLPointerFunc.GL_NORMAL_ARRAY);
277 gl2.glNormalPointer(GL.GL_FLOAT, 6 * Buffers.SIZEOF_FLOAT, 3 * Buffers.SIZEOF_FLOAT);
279 System.err.println(
"Vertex VBO is not a buffer on slave 0x"+Integer.toHexString(hashCode()));
282 if (indexBufferObjects[0] == 0) {
283 System.err.println(
"Creating index VBO on slave 0x"+Integer.toHexString(hashCode()));
284 indexBufferObjects[0] = createVertexIndexBuffer(gl2);
286 sharedIndexBufferObjects.set(indexBufferObjects[0]);
291 if (gl2.glIsBuffer(indexBufferObjects[0])) {
292 gl2.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, indexBufferObjects[0]);
294 System.err.println(
"Index VBO is not a buffer on slave 0x"+Integer.toHexString(hashCode()));
297 gl2.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, 0);
298 gl2.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
299 gl2.glDisableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
300 gl2.glDisableClientState(GLPointerFunc.GL_NORMAL_ARRAY);
302 initializationCounter++;
307 public void dispose(
final GLAutoDrawable drawable) {
309 synchronized (
this) {
310 initializationCounter--;
312 final GL2 gl2 = drawable.getGL().getGL2();
315 if (initializationCounter == 0 || !useShared) {
317 int [] vertexBufferObjects;
318 int [] indexBufferObjects;
320 privateVertexBufferObjects[0] = sharedVertexBufferObjects.get();
321 privateIndexBufferObjects[0] = sharedIndexBufferObjects.get();
322 sharedVertexBufferObjects.set(0);
323 sharedIndexBufferObjects.set(0);
325 vertexBufferObjects = privateVertexBufferObjects;
326 indexBufferObjects = privateIndexBufferObjects;
328 gl2.glDeleteBuffers(1, vertexBufferObjects, 0);
329 logAnyErrorCodes(
this, gl2,
"dispose.2");
330 gl2.glDeleteBuffers(1, indexBufferObjects, 0);
331 logAnyErrorCodes(
this, gl2,
"dispose.3");
332 vertexBufferObjects[0] = 0;
333 indexBufferObjects[0] = 0;
337 disposalCompleteSemaphore.release();
342 public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) {
343 System.err.println(
"reshape: "+canvasWidth+
"x"+canvasHeight+
" -> "+width+
"x"+height+
", [drawable pixel "+drawable.getSurfaceWidth()+
"x"+drawable.getSurfaceHeight()+
"]");
345 canvasHeight = height;
346 final GL2 gl2 = drawable.getGL().getGL2();
347 viewDistance = setupViewFrustum(gl2, canvasWidth, canvasHeight, boundsRadius, 1.0f, viewFovDegrees);
351 public void display(
final GLAutoDrawable drawable) {
356 synchronized (
this) {
357 if (initializationCounter != 2) {
362 final GL2 gl2 = drawable.getGL().getGL2();
363 final GLU glu =
new GLU();
365 logAnyErrorCodes(
this, gl2,
"display.0");
368 gl2.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
370 gl2.glViewport(0, 0, canvasWidth, canvasHeight);
371 gl2.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
372 gl2.glLoadIdentity();
373 glu.gluPerspective(viewFovDegrees, (
float)canvasWidth/(
float)canvasHeight,
374 viewDistance*viewDistanceFactor-boundsRadius, viewDistance*viewDistanceFactor+boundsRadius);
377 gl2.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
378 gl2.glLoadIdentity();
381 gl2.glPushAttrib(GL2.GL_ALL_ATTRIB_BITS);
384 glu.gluLookAt(0, 0, 0 + viewDistance*viewDistanceFactor, 0, 0, 0, 0, 1, 0);
385 gl2.glRotatef(xAxisRotation, 1, 0, 0);
386 gl2.glRotatef(yAxisRotation, 0, 1, 0);
388 gl2.glDisable(GL.GL_CULL_FACE);
389 gl2.glEnable(GL.GL_DEPTH_TEST);
391 logAnyErrorCodes(
this, gl2,
"display.1");
394 drawTwoTriangles(gl2);
402 logAnyErrorCodes(
this, gl2,
"display.X");
405 public void drawTwoTriangles(
final GL2 gl2) {
408 gl2.glColor3f(1f, 0f, 0f);
409 gl2.glBegin(GL.GL_TRIANGLES);
410 gl2.glVertex3d(-1.5, -0.5, 0);
411 gl2.glNormal3d(0, 0, 1);
412 gl2.glVertex3d(-0.5, -0.5, 0);
413 gl2.glNormal3d(0, 0, 1);
414 gl2.glVertex3d(-0.75, 0.5, 0);
415 gl2.glNormal3d(0, 0, 1);
418 logAnyErrorCodes(
this, gl2,
"drawTwoTriangles.1");
425 boolean vboBound =
false;
427 int [] vertexBufferObjects;
428 int [] indexBufferObjects;
429 synchronized (
this) {
431 privateVertexBufferObjects[0] = sharedVertexBufferObjects.get();
432 privateIndexBufferObjects[0] = sharedIndexBufferObjects.get();
434 vertexBufferObjects = privateVertexBufferObjects;
435 indexBufferObjects = privateIndexBufferObjects;
444 final boolean isVBO1 = gl2.glIsBuffer(indexBufferObjects[0]);
445 final boolean isVBO2 = gl2.glIsBuffer(vertexBufferObjects[0]);
446 final boolean useVBO = isVBO1 && isVBO2;
448 gl2.glBindBuffer(GL.GL_ARRAY_BUFFER, vertexBufferObjects[0]);
449 gl2.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, indexBufferObjects[0]);
451 gl2.glEnableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
453 gl2.glEnableClientState(GLPointerFunc.GL_NORMAL_ARRAY);
459 logAnyErrorCodes(
this, gl2,
"drawTwoTriangles.2");
462 gl2.glColor3f(0f, 0f, 1f);
463 gl2.glDrawElements(GL.GL_TRIANGLES, 3, GL.GL_UNSIGNED_INT, 0);
464 gl2.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
465 gl2.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, 0);
466 gl2.glDisableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
467 gl2.glDisableClientState(GLPointerFunc.GL_NORMAL_ARRAY);
470 logAnyErrorCodes(
this, gl2,
"drawTwoTriangles.3");
473 public void displayChanged(
final GLAutoDrawable drawable,
final boolean modeChanged,
final boolean deviceChanged) {
478 private static final Set<String> errorSet =
new HashSet<String>();
483 final String errStr =
"GL-Error: "+prefix +
" on obj 0x"+Integer.toHexString(obj.hashCode())+
", OpenGL error: 0x" + Integer.toHexString(glError);
484 if( errorSet.add(errStr) ) {
485 System.err.println(errStr);
486 ExceptionUtils.dumpStack(System.err);
491 final String errStr =
"GL-Error: "+prefix +
" on obj 0x"+Integer.toHexString(obj.hashCode())+
", glCheckFramebufferStatus: 0x" + Integer.toHexString(status);
492 if( errorSet.add(errStr) ) {
493 System.err.println(errStr);
494 ExceptionUtils.dumpStack(System.err);
517 public static float setupViewFrustum(
final GL2 gl2,
final int width,
final int height,
final float boundsRadius,
final float zoomFactor,
final float viewFovDegrees) {
518 assert boundsRadius > 0.0f;
519 assert zoomFactor > 0.0f;
520 assert viewFovDegrees > 0.0f;
522 final GLU glu =
new GLU();
524 final float aspectRatio = (float) width / (
float) height;
525 final float boundRadiusAdjusted = boundsRadius / zoomFactor;
526 final float lowestFov = aspectRatio > 1.0f ? viewFovDegrees : aspectRatio * viewFovDegrees;
527 final float viewDist = (float) (boundRadiusAdjusted / Math.sin( (lowestFov / 2.0) * (Math.PI / 180.0) ));
531 glu.
gluPerspective(viewFovDegrees, aspectRatio, 0.1*viewDist, viewDist + boundRadiusAdjusted);
538 testContextSharingCreateVisibleDestroy(
false,
false);
543 testContextSharingCreateVisibleDestroy(
false,
true);
548 testContextSharingCreateVisibleDestroy(
true,
false);
553 testContextSharingCreateVisibleDestroy(
true,
true);
561 final JFrame frame =
new JFrame(
"JSlider with "+(shareContext?
"Shared":
"NonShared")+
" "+(useNewt?
"NEWT":
"AWT")+
"-OpenGL Widget");
574 sharedDrawable = initShared(glCapabilities);
576 sharedDrawable =
null;
579 final TwoTriangles eventListener1 =
new TwoTriangles(480, 480, shareContext);
580 final TwoTriangles eventListener2 =
new TwoTriangles(480, 480, shareContext);
582 final Component openGLComponent1;
583 final Component openGLComponent2;
590 glWindow1.setSharedAutoDrawable(sharedDrawable);
593 newtCanvasAWT1.setPreferredSize(
new Dimension(eventListener1.canvasWidth, eventListener1.canvasHeight));
598 glWindow2.setSharedAutoDrawable(sharedDrawable);
601 newtCanvasAWT2.setPreferredSize(
new Dimension(eventListener2.canvasWidth, eventListener2.canvasHeight));
604 openGLComponent1 = newtCanvasAWT1;
605 openGLComponent2 = newtCanvasAWT2;
606 openGLAutoDrawable1 = glWindow1;
607 openGLAutoDrawable2 = glWindow2;
616 canvas1 =
new GLCanvas(glCapabilities);
618 canvas2 =
new GLCanvas(glCapabilities);
621 canvas1 =
new GLCanvas(glCapabilities);
622 canvas2 =
new GLCanvas(glCapabilities);
625 canvas1.
setSize(eventListener1.canvasWidth, eventListener1.canvasHeight);
628 canvas2.
setSize(eventListener2.canvasWidth, eventListener2.canvasHeight);
631 openGLComponent1 = canvas1;
632 openGLComponent2 = canvas2;
633 openGLAutoDrawable1 = canvas1;
634 openGLAutoDrawable2 = canvas2;
639 final JSlider xAxisRotationSlider =
new JSlider(SwingConstants.VERTICAL, -180, 180, 1);
640 xAxisRotationSlider.setPaintTicks(
false);
641 xAxisRotationSlider.setPaintLabels(
false);
642 xAxisRotationSlider.setSnapToTicks(
false);
643 xAxisRotationSlider.addChangeListener(
new ChangeListener() {
646 public void stateChanged(
final ChangeEvent e) {
647 eventListener1.setXAxisRotation(xAxisRotationSlider.getValue());
648 eventListener2.setXAxisRotation(xAxisRotationSlider.getValue());
651 final JLabel xAxisRotationLabel =
new JLabel(
"X-Axis Rotation");
655 final JSlider yAxisRotationSlider =
new JSlider(SwingConstants.HORIZONTAL, -180, 180, 1);
656 yAxisRotationSlider.setPaintTicks(
false);
657 yAxisRotationSlider.setPaintLabels(
false);
658 yAxisRotationSlider.setSnapToTicks(
false);
659 yAxisRotationSlider.addChangeListener(
new ChangeListener() {
662 public void stateChanged(
final ChangeEvent e) {
663 eventListener1.setYAxisRotation(yAxisRotationSlider.getValue());
664 eventListener2.setYAxisRotation(yAxisRotationSlider.getValue());
667 final JLabel yAxisRotationLabel =
new JLabel(
"Y-Axis Rotation");
672 final JSlider viewDistanceFactorSlider =
new JSlider(SwingConstants.HORIZONTAL, 0, 100, 10);
673 viewDistanceFactorSlider.setPaintTicks(
false);
674 viewDistanceFactorSlider.setPaintLabels(
false);
675 viewDistanceFactorSlider.setSnapToTicks(
false);
676 viewDistanceFactorSlider.addChangeListener(
new ChangeListener() {
679 public void stateChanged(
final ChangeEvent e) {
680 eventListener1.setViewDistanceFactor(viewDistanceFactorSlider.getValue() / 10.0f);
681 eventListener2.setViewDistanceFactor(viewDistanceFactorSlider.getValue() / 10.0f);
684 final JLabel viewDistanceFactorLabel =
new JLabel(
"View Distance Factor");
687 final JPanel viewDistancePanel =
new JPanel();
688 viewDistancePanel.setLayout(
new BoxLayout(viewDistancePanel, BoxLayout.PAGE_AXIS));
689 viewDistancePanel.add(Box.createVerticalGlue());
690 viewDistancePanel.add(viewDistanceFactorSlider);
691 viewDistancePanel.add(viewDistanceFactorLabel);
692 viewDistancePanel.add(Box.createVerticalGlue());
695 final JPanel openGLPanel =
new JPanel();
696 openGLPanel.setLayout(
new BoxLayout(openGLPanel, BoxLayout.LINE_AXIS));
697 openGLPanel.add(openGLComponent1);
698 openGLPanel.add(Box.createHorizontalStrut(5));
699 openGLPanel.add(openGLComponent2);
702 final JPanel canvasAndYAxisPanel =
new JPanel();
703 canvasAndYAxisPanel.setLayout(
new BoxLayout(canvasAndYAxisPanel, BoxLayout.PAGE_AXIS));
704 canvasAndYAxisPanel.add(openGLPanel);
705 canvasAndYAxisPanel.add(Box.createVerticalGlue());
706 canvasAndYAxisPanel.add(yAxisRotationSlider);
707 canvasAndYAxisPanel.add(yAxisRotationLabel);
710 final JPanel xAxisPanel =
new JPanel();
711 xAxisPanel.setLayout(
new BoxLayout(xAxisPanel, BoxLayout.LINE_AXIS));
712 xAxisPanel.add(xAxisRotationSlider);
713 xAxisPanel.add(xAxisRotationLabel);
715 final JPanel mainPanel = (JPanel) frame.getContentPane();
716 mainPanel.setLayout(
new BoxLayout(mainPanel, BoxLayout.LINE_AXIS));
717 mainPanel.add(viewDistancePanel);
718 mainPanel.add(Box.createHorizontalGlue());
719 mainPanel.add(canvasAndYAxisPanel);
720 mainPanel.add(Box.createHorizontalGlue());
721 mainPanel.add(xAxisPanel);
723 final Animator animator =
new Animator(Thread.currentThread().getThreadGroup());
725 animator.
add(openGLAutoDrawable1);
726 animator.
add(openGLAutoDrawable2);
728 final Semaphore windowOpenSemaphore =
new Semaphore(0);
729 final Semaphore closingSemaphore =
new Semaphore(0);
736 closingSemaphore.release();
741 SwingUtilities.invokeLater(
new Runnable() {
745 frame.setVisible(
true);
746 windowOpenSemaphore.release();
752 final boolean windowOpened = windowOpenSemaphore.tryAcquire(5000, TimeUnit.MILLISECONDS);
753 Assert.assertEquals(
true, windowOpened);
754 }
catch (
final InterruptedException e) {
755 System.err.println(
"Closing wait interrupted: " + e.getMessage());
765 final boolean windowClosed = closingSemaphore.tryAcquire(5000, TimeUnit.MILLISECONDS);
766 Assert.assertEquals(
true, windowClosed);
767 }
catch (
final InterruptedException e) {
768 System.err.println(
"Closing wait interrupted: " + e.getMessage());
774 SwingUtilities.invokeLater(
new Runnable() {
777 frame.setVisible(
false);
783 closingSemaphore.release();
790 final boolean windowsDisposed = closingSemaphore.tryAcquire(5000, TimeUnit.MILLISECONDS);
791 Assert.assertEquals(
true, windowsDisposed);
792 }
catch (
final InterruptedException e) {
793 System.err.println(
"Closing wait interrupted: " + e.getMessage());
797 int disposalSuccesses = 0;
800 acquired = disposalCompleteSemaphore.tryAcquire(5000, TimeUnit.MILLISECONDS);
804 acquired = disposalCompleteSemaphore.tryAcquire(5000, TimeUnit.MILLISECONDS);
808 }
catch (
final InterruptedException e) {
809 System.err.println(
"Clean exit interrupted: " + e.getMessage());
812 Assert.assertEquals(
true, disposalSuccesses == 2);
814 releaseShared(sharedDrawable);
817 static int atoi(
final String a) {
820 i = Integer.parseInt(a);
821 }
catch (
final Exception ex) { ex.printStackTrace(); }
825 public static void main(
final String[] args)
throws IOException {
826 for(
int i=0; i<args.length; i++) {
827 if(args[i].equals(
"-time")) {
828 if (++i < args.length) {
829 durationPerTest = atoi(args[i]);
AWT Canvas containing a NEWT Window using native parenting.
NEWT Window events are provided for notification purposes ONLY.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
Specifies a set of OpenGL capabilities.
void setNumSamples(final int numSamples)
If sample buffers are enabled, indicates the number of buffers to be allocated.
final GLProfile getGLProfile()
Returns the GL profile you desire or used by the drawable.
void setSampleBuffers(final boolean enable)
Defaults to false.
Abstraction for an OpenGL rendering context.
final boolean isCreated()
Indicates whether the underlying native OpenGL context has been created.
abstract GLOffscreenAutoDrawable createOffscreenAutoDrawable(AbstractGraphicsDevice device, GLCapabilitiesImmutable caps, GLCapabilitiesChooser chooser, int width, int height)
Creates a realized GLOffscreenAutoDrawable incl it's offscreen NativeSurface with the given capabilit...
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 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.
A heavyweight AWT component which provides OpenGL rendering support.
final void setSharedAutoDrawable(final GLAutoDrawable sharedAutoDrawable)
Specifies an GLAutoDrawable, which OpenGL context shall be shared by this GLAutoDrawable's GLContext.
void addGLEventListener(final GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Provides access to the OpenGL Utility Library (GLU).
void gluPerspective(float fovy, float aspect, float zNear, float zFar)
TestSharedContextNewtAWTBug523.
void test01UseAWTNotShared()
static void logAnyErrorCodes(final Object obj, final GL gl, final String prefix)
void testContextSharingCreateVisibleDestroy(final boolean useNewt, final boolean shareContext)
Assemble the user interface and start the animator.
static float setupViewFrustum(final GL2 gl2, final int width, final int height, final float boundsRadius, final float zoomFactor, final float viewFovDegrees)
Sets the OpenGL projection matrix and front and back clipping planes for a viewport and returns the d...
void test11UseNEWTSharedContext()
void test10UseNEWTNotShared()
static void main(final String[] args)
void test02UseAWTSharedContext()
static TestUtil.WindowClosingListener addClosingListener(final java.awt.Window win)
static boolean closeWindow(final java.awt.Window win, final boolean willClose, final TestUtil.WindowClosingListener closingListener, final Runnable waitAction)
Programmatically issue windowClosing on AWT or NEWT.
final long getTotalFPSDuration()
final synchronized void add(final GLAutoDrawable drawable)
Adds a drawable to this animator's list of rendering drawables.
final void setUpdateFPSFrames(final int frames, final PrintStream out)
final synchronized boolean start()
Starts this animator, if not running.
final synchronized boolean stop()
Stops this animator.
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
GLContext getContext()
Returns the context associated with this drawable.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
Platform-independent GLAutoDrawable specialization, exposing offscreen functionality.
int glCheckFramebufferStatus(int target)
Entry point to C language function: GLenum {@native glCheckFramebufferStatus}(GLenum target) Part ...
static final int GL_NO_ERROR
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_NO_ERROR" with expres...
int glGetError()
Entry point to C language function: GLenum {@native glGetError}() Part of GL_ES_VERSION_2_0,...
static final int GL_FRAMEBUFFER_COMPLETE
GL_ES_VERSION_2_0, GL_ARB_framebuffer_object, GL_VERSION_3_0, GL_EXT_framebuffer_object,...
static final int GL_FRAMEBUFFER
GL_ES_VERSION_2_0, GL_ARB_framebuffer_object, GL_VERSION_3_0, GL_OES_framebuffer_object,...
void setSize(int width, int height)
Requests a new width and height for this AWTGLAutoDrawable.
Subset of OpenGL fixed function pipeline's matrix operations.
static final int GL_PROJECTION
Matrix mode projection.
void glLoadIdentity()
Load the current matrix with the identity matrix.
void glMatrixMode(int mode)
Sets the current matrix mode.