28package com.jogamp.opengl.test.junit.jogl.caps;
32import com.jogamp.opengl.GL;
33import com.jogamp.opengl.GL2;
34import com.jogamp.opengl.GLAutoDrawable;
35import com.jogamp.opengl.GLCapabilities;
36import com.jogamp.opengl.GLCapabilitiesImmutable;
37import com.jogamp.opengl.GLDrawableFactory;
38import com.jogamp.opengl.GLEventListener;
39import com.jogamp.opengl.GLException;
40import com.jogamp.opengl.GLProfile;
41import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
43import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
44import com.jogamp.opengl.util.texture.TextureIO;
46import java.awt.image.BufferedImage;
48import org.junit.Assert;
50import org.junit.FixMethodOrder;
51import org.junit.runners.MethodSorters;
53import com.jogamp.opengl.test.junit.util.UITestCase;
55@FixMethodOrder(MethodSorters.NAME_ASCENDING)
90 final String fname = getSnapshotFilename(0,
null, caps, width, height,
false,
TextureIO.
PNG,
null);
91 final BufferedImage image;
94 screenshot.
write(
new File(fname));
98 testFlipped(image, width, height);
102 final GL gl = drawable.
getGL();
107 public void reshape(
final GLAutoDrawable glDrawable,
final int x,
final int y,
final int w,
final int h) {}
108 public void displayChanged(
final GLAutoDrawable drawable,
final boolean modeChanged,
final boolean deviceChanged) {}
114 static final int green = 0x0000ff00;
115 static final int red = 0x00ff0000;
117 private void testFlipped(
final BufferedImage image,
final int width,
final int height) {
120 final int below = image.getRGB(0, height-1) & 0x00ffffff;
121 System.err.println(
"below: 0x"+Integer.toHexString(below));
123 final int above = image.getRGB(0, 0) & 0x00ffffff;
124 System.err.println(
"above: 0x"+Integer.toHexString(above));
126 if (above == green && below == red) {
127 System.out.println(
"Image right side up");
128 }
else if (above == red && below == green) {
129 Assert.assertTrue(
"Image is flipped",
false);
131 Assert.assertTrue(
"Error in test",
false);
139 final FlippedImageTest tglel =
new FlippedImageTest();
187 public static void main(
final String[] args) {
Specifies a set of OpenGL capabilities.
void setPBuffer(final boolean enable)
Requesting offscreen pbuffer mode.
void setAccumRedBits(final int accumRedBits)
Sets the number of bits requested for the accumulation buffer's red component.
void setStencilBits(final int stencilBits)
Sets the number of bits requested for the stencil buffer.
void setAccumGreenBits(final int accumGreenBits)
Sets the number of bits requested for the accumulation buffer's green component.
void setFBO(final boolean enable)
Requesting offscreen FBO mode.
void setAccumBlueBits(final int accumBlueBits)
Sets the number of bits requested for the accumulation buffer's blue component.
final String getGLVersion()
Returns a valid OpenGL version string, ie
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.
A generic exception for OpenGL errors used throughout the binding as a substitute for RuntimeExceptio...
Specifies the the OpenGL profile.
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.
void test01DefaultPBuffer()
void test01AccumStencilPBuffer()
static void main(final String[] args)
void write(final File dest)
Write the TextureData filled by readPixels(GLAutoDrawable, boolean) to file.
void dispose(final GL gl)
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}.
static final int GL_ACCUM_BUFFER_BIT
GL_VERSION_1_0 Define "GL_ACCUM_BUFFER_BIT" with expression '0x00000200', CType: int
static final int GL_ACCUM
GL_VERSION_1_0 Define "GL_ACCUM" with expression '0x0100', CType: int
static final int GL_RETURN
GL_VERSION_1_0 Define "GL_RETURN" with expression '0x0102', CType: int
void glAccum(int op, float value)
Entry point to C language function: void {@native glAccum}(GLenum op, GLfloat value) Part of GL_VE...
void glColor3f(float red, float green, float blue)
Entry point to C language function: void {@native glColor3f}(GLfloat red, GLfloat green,...
void glRectf(float x1, float y1, float x2, float y2)
Entry point to C language function: void {@native glRectf}(GLfloat x1, GLfloat y1,...
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
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.
GL2 getGL2()
Casts this object to the GL2 interface.
Specifies an immutable set of OpenGL capabilities.
int getAccumGreenBits()
Returns the number of bits for the accumulation buffer's green component.
GLProfile getGLProfile()
Returns the GL profile you desire or used by the drawable.
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.
int getSurfaceHeight()
Returns the height of this GLDrawable's surface client area in pixel units.
GLProfile getGLProfile()
Fetches the GLProfile for this drawable.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
static final int GL_VERSION
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_VERSION" with express...
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 glClearColor(float red, float green, float blue, float alpha)
Entry point to C language function: void {@native glClearColor}(GLfloat red, GLfloat green,...
String glGetString(int name)
Entry point to C language function: const GLubyte * {@native glGetString}(GLenum name) Part of GL_...
static final int GL_RENDERER
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_RENDERER" with expres...
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,...
static final int GL_STENCIL_BUFFER_BIT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_STENCIL_BUFFER_BIT" w...
static final int GL_DEPTH_BUFFER_BIT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_DEPTH_BUFFER_BIT" wit...
Subset of OpenGL fixed function pipeline's matrix operations.
static final int GL_PROJECTION
Matrix mode projection.
static final int GL_MODELVIEW
Matrix mode modelview.
void glLoadIdentity()
Load the current matrix with the identity matrix.
void glMatrixMode(int mode)
Sets the current matrix mode.