28package com.jogamp.opengl.test.junit.jogl.acore;
30import java.awt.image.BufferedImage;
32import java.io.IOException;
33import java.util.Locale;
35import javax.imageio.ImageIO;
36import com.jogamp.opengl.GL;
37import com.jogamp.opengl.GLAutoDrawable;
38import com.jogamp.opengl.GLDrawable;
39import com.jogamp.opengl.GLEventListener;
41import com.jogamp.opengl.util.GLDrawableUtil;
42import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
43import com.jogamp.opengl.util.texture.TextureIO;
57 final boolean skipGLOrientationVerticalFlip;
58 boolean defAutoSwapMode;
59 boolean swapBuffersBeforeRead;
63 this.textRendererGLEL = textRendererGLEL;
64 this.glReadBufferUtil = glReadBufferUtil;
65 this.skipGLOrientationVerticalFlip = skipGLOrientationVerticalFlip;
66 this.defAutoSwapMode =
true;
67 this.swapBuffersBeforeRead =
false;
82 public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) { }
87 public void snapshot(
final int sn,
final GL gl,
final String fileSuffix,
final String destPath) {
89 final String postSNDetail = String.format((Locale)
null,
"awt-usr%03d", textRendererGLEL.
userCounter);
92 glReadBufferUtil.
hasAlpha(), fileSuffix, destPath);
93 if( swapBuffersBeforeRead ) {
102 final boolean awtOrientation = !( drawable.
isGLOriented() && skipGLOrientationVerticalFlip );
103 System.err.println(Thread.currentThread().getName()+
": ** screenshot: awtOrient/v-flip "+awtOrientation+
", swapBuffersBeforeRead "+swapBuffersBeforeRead+
", "+filenameAWT);
106 final File fout =
new File(filenameAWT);
108 ImageIO.write(image,
"png", fout);
109 }
catch (
final IOException e) {
abstract GLDrawable getGLReadDrawable()
Returns the read-Drawable this context uses for read framebuffer operations.
void display(final GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
void init(final GLAutoDrawable drawable)
Called by the drawable immediately after the OpenGL context is initialized.
void dispose(final GLAutoDrawable drawable)
Notifies the listener to perform the release of all OpenGL resources per GLContext,...
void snapshot(final int sn, final GL gl, final String fileSuffix, final String destPath)
void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height)
Called by the drawable during the first repaint after the component has been resized.
Test synchronous GLAutoDrawable display, swap-buffer and read-pixels including non-MSAA and MSAA fram...
Test synchronous GLAutoDrawable display, swap-buffer and read-pixels including non-MSAA and MSAA fram...
String getSnapshotFilename(final int sn, String postSNDetail, final GLCapabilitiesImmutable caps, final int width, final int height, final boolean sinkHasAlpha, String fileSuffix, final String destPath)
Providing utility functions dealing w/ GLDrawables, GLAutoDrawable and their GLEventListener.
static final boolean swapBuffersBeforeRead(final GLCapabilitiesImmutable chosenCaps)
Determines whether the chosen GLCapabilitiesImmutable requires a swap-buffers before reading pixels.
GLReadBufferUtil specialization allowing to read out a frambuffer to an AWT BufferedImage utilizing A...
BufferedImage readPixelsToBufferedImage(final GL gl, final boolean awtOrientation)
Read the drawable's pixels to TextureData and Texture, if requested at construction,...
static final String PNG
Constant which can be used as a file suffix to indicate a PNG file, value {@value}.
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
boolean getAutoSwapBufferMode()
Indicates whether automatic buffer swapping is enabled for this drawable.
void setAutoSwapBufferMode(boolean enable)
Enables or disables automatic buffer swapping for this drawable.
GLContext getContext()
Returns the GLContext associated which this GL object.
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 isGLOriented()
Returns true if the drawable is rendered in OpenGL's coordinate system, origin at bottom left.
int getSurfaceHeight()
Returns the height of this GLDrawable's surface client area in pixel units.
void swapBuffers()
Swaps the front and back buffers of this drawable.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
static final int GL_COLOR_BUFFER_BIT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_COLOR_BUFFER_BIT" wit...
void glClear(int mask)
Entry point to C language function: void {@native glClear}(GLbitfield mask) Part of GL_ES_VERSION_...
void glFinish()
Entry point to C language function: void {@native glFinish}() Part of GL_ES_VERSION_2_0,...