29package com.jogamp.opengl.test.junit.jogl.glu;
32import java.nio.ByteBuffer;
34import com.jogamp.opengl.GL;
35import com.jogamp.opengl.GLAutoDrawable;
36import com.jogamp.opengl.GLCapabilities;
37import com.jogamp.opengl.GLEventListener;
38import com.jogamp.opengl.GLProfile;
39import com.jogamp.opengl.awt.GLCanvas;
40import com.jogamp.opengl.glu.GLU;
42import org.junit.Assume;
44import org.junit.FixMethodOrder;
45import org.junit.runners.MethodSorters;
47import com.jogamp.common.nio.Buffers;
48import com.jogamp.opengl.test.junit.util.UITestCase;
49import com.jogamp.opengl.util.GLBuffers;
50import com.jogamp.opengl.util.GLPixelStorageModes;
56@FixMethodOrder(MethodSorters.NAME_ASCENDING)
70 System.err.println(
"Using GLU "+glu.getClass().getName());
71 testGLUScaleImage(gl, glu, 0);
72 testGLUScaleImage(gl, glu, 1);
73 testGLUScaleImage(gl, glu, 4);
74 testGLUScaleImage(gl, glu, 8);
78 boolean testDone =
false;
80 private void testGLUScaleImage(
final GL gl,
final GLU glu,
final int unpackAlignment) {
82 if(0 < unpackAlignment) {
86 final int widthin = 213;
87 final int heightin = 213;
89 final int widthout = 256;
90 final int heightout = 256;
94 final int tmp[] =
new int[1];
96 final int unpackSizeInLen =
GLBuffers.
sizeof(gl, tmp, glFormat, glType, widthin, heightin, 1,
false);
97 final int unpackSizeOutLen =
GLBuffers.
sizeof(gl, tmp, glFormat, glType, widthout, heightout, 1,
false);
99 System.err.println(
"Unpack-Alignment "+unpackAlignment+
": in-size "+unpackSizeInLen);
100 System.err.println(
"Unpack-Alignment "+unpackAlignment+
": out-size "+unpackSizeOutLen);
102 final ByteBuffer bufferIn = Buffers.newDirectByteBuffer(unpackSizeInLen);
103 final ByteBuffer bufferOut = Buffers.newDirectByteBuffer(unpackSizeOutLen);
109 if(0 < unpackAlignment) {
124 public void test01() throws InterruptedException {
130 final Frame frame =
new Frame(
"Test");
132 frame.setSize(256, 256);
136 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
138 frame.setVisible(
true);
140 }
catch (
final Throwable t) {
142 Assume.assumeNoException(t);
150 javax.swing.SwingUtilities.invokeAndWait(
new Runnable() {
152 frame.setVisible(
false);
153 frame.remove(canvas);
156 }
catch (
final Throwable t) {
158 Assume.assumeNoException(t);
162 public static void main(
final String args[]) {
Specifies a set of OpenGL capabilities.
Specifies the the OpenGL profile.
static GLProfile getDefault(final AbstractGraphicsDevice device)
Returns a default GLProfile object, reflecting the best for the running platform.
A heavyweight AWT component which provides OpenGL rendering support.
void addGLEventListener(final GLEventListener listener)
Adds the given listener to the end of this drawable queue.
Provides access to the OpenGL Utility Library (GLU).
int gluScaleImage(int format, int widthin, int heightin, int typein, java.nio.Buffer datain, int widthout, int heightout, int typeout, java.nio.Buffer dataout)
Optional, throws GLException if not available in profile.
static final GLU createGLU()
Instantiates a GLU implementation object in respect to the given GL profile of this thread current GL...
Demonstrates how to use GLBuffers#sizeof(GL, int[], int, int, int, int, int, boolean) to determine th...
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.
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,...
static void main(final String args[])
Utility routines for dealing with direct buffers.
static final int sizeof(final GL gl, final int tmp[], final int bytesPerPixel, int width, int height, int depth, final boolean pack)
Returns the number of bytes required to read/write a memory buffer via OpenGL using the current GL pi...
Utility to safely set and restore the PACK and UNPACK pixel storage mode, regardless of the GLProfile...
final void setUnpackAlignment(final GL gl, final int unpackAlignment)
Sets the GL#GL_UNPACK_ALIGNMENT.
final void restore(final GL gl)
Restores PACK and UNPACK pixel storage mode previously saved w/ saveAll(GL) or savePack(GL) and saveU...
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
static final int GL_LUMINANCE
GL_ES_VERSION_2_0, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_LUMINANCE" with expression '0x1909',...
static final int GL_UNSIGNED_BYTE
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_UNSIGNED_BYTE" with e...