1package com.jogamp.opengl.test.junit.jogl.demos.es1;
3import com.jogamp.common.nio.Buffers;
7import com.jogamp.opengl.*;
8import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
9import com.jogamp.opengl.fixedfunc.GLPointerFunc;
11import com.jogamp.opengl.JoglVersion;
12import com.jogamp.opengl.util.TileRendererBase;
13import com.jogamp.opengl.util.glsl.fixedfunc.*;
19 private boolean debugFFPEmu =
false;
20 private boolean verboseFFPEmu =
false;
21 private boolean traceFFPEmu =
false;
22 private boolean forceFFPEmu =
false;
23 private boolean debug = false ;
24 private boolean trace = false ;
25 private int swapInterval = 0;
26 private final float aspect = 1.0f;
27 private boolean doRotate =
true;
29 private boolean doRotateBeforePrinting;
30 private boolean flipVerticalInGLOrientation =
false;
36 this.swapInterval = swapInterval;
40 this.swapInterval = 1;
45 tileRendererInUse = tr;
46 doRotateBeforePrinting = doRotate;
51 tileRendererInUse =
null;
56 System.err.println(
"RedSquareES1.startTileRendering: "+tr);
60 System.err.println(
"RedSquareES1.endTileRendering: "+tr);
63 public void setDoRotation(
final boolean rotate) { this.doRotate = rotate; }
64 public void setForceFFPEmu(
final boolean forceFFPEmu,
final boolean verboseFFPEmu,
final boolean debugFFPEmu,
final boolean traceFFPEmu) {
65 this.forceFFPEmu = forceFFPEmu;
66 this.verboseFFPEmu = verboseFFPEmu;
67 this.debugFFPEmu = debugFFPEmu;
68 this.traceFFPEmu = traceFFPEmu;
79 private FloatBuffer colors;
80 private FloatBuffer vertices;
84 System.err.println(Thread.currentThread()+
" RedSquareES1.init ...");
103 }
catch (
final Exception e) {e.printStackTrace();}
109 }
catch (
final Exception e) {e.printStackTrace();}
112 System.err.println(
"RedSquareES1 init on "+Thread.currentThread());
113 System.err.println(
"Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
114 System.err.println(
"INIT GL IS: " + gl.getClass().getName());
118 colors = Buffers.newDirectFloatBuffer(16);
119 vertices = Buffers.newDirectFloatBuffer(12);
121 colors.put( 0, 1); colors.put( 1, 0); colors.put( 2, 0); colors.put( 3, 1);
122 colors.put( 4, 0); colors.put( 5, 0); colors.put( 6, 1); colors.put( 7, 1);
123 colors.put( 8, 1); colors.put( 9, 0); colors.put(10, 0); colors.put(11, 1);
124 colors.put(12, 1); colors.put(13, 0); colors.put(14, 0); colors.put(15, 1);
125 vertices.put(0, -2); vertices.put( 1, 2); vertices.put( 2, 0);
126 vertices.put(3, 2); vertices.put( 4, 2); vertices.put( 5, 0);
127 vertices.put(6, -2); vertices.put( 7, -2); vertices.put( 8, 0);
128 vertices.put(9, 2); vertices.put(10, -2); vertices.put(11, 0);
130 gl.glVertexPointer(3,
GL.
GL_FLOAT, 0, vertices);
136 startTime = System.currentTimeMillis();
138 System.err.println(Thread.currentThread()+
" RedSquareES1.init FIN");
145 reshapeImpl(gl, x, y, width, height, width, height);
150 final int tileX,
final int tileY,
final int tileWidth,
final int tileHeight,
151 final int imageWidth,
final int imageHeight) {
154 reshapeImpl(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight);
157 void reshapeImpl(
final GL2ES1 gl,
final int tileX,
final int tileY,
final int tileWidth,
final int tileHeight,
final int imageWidth,
final int imageHeight) {
158 System.err.println(Thread.currentThread()+
" RedSquareES1.reshape "+tileX+
"/"+tileY+
" "+tileWidth+
"x"+tileHeight+
" of "+imageWidth+
"x"+imageHeight+
", swapInterval "+swapInterval+
", drawable 0x"+Long.toHexString(gl.
getContext().
getGLDrawable().
getHandle())+
", tileRendererInUse "+tileRendererInUse);
168 final float fovy=45f;
169 final float aspect2 = ( (float) imageWidth / (
float) imageHeight ) / aspect;
170 final float zNear=1f;
171 final float zFar=100f;
174 final float top=(float)Math.tan(fovy*((
float)Math.PI)/360.0f)*zNear;
175 final float bottom=-1.0f*top;
176 final float left=aspect2*bottom;
177 final float right=aspect2*top;
178 final float w = right - left;
179 final float h = top - bottom;
182 final float l = left + tileX * w / imageWidth;
183 final float r = l + tileWidth * w / imageWidth;
184 final float b = bottom + tileY * h / imageHeight;
185 final float t = b + tileHeight * h / imageHeight;
193 System.err.println(Thread.currentThread()+
" RedSquareES1.reshape FIN");
198 curTime = System.currentTimeMillis();
200 if(
null != tileRendererInUse ) {
211 final float ang = doRotate ? ((curTime - startTime) * 360.0f) / 4000.0f : 1f;
225 System.err.println(Thread.currentThread()+
" RedSquareES1.dispose ... ");
233 System.err.println(Thread.currentThread()+
" RedSquareES1.dispose FIN");
abstract GLDrawable getGLDrawable()
Returns the write-drawable this context uses for framebuffer operations.
abstract GL setGL(GL gl)
Sets the GL pipeline object for this GLContext.
Factory for pipelining GL instances.
static final GL create(final String pipelineClazzBaseName, final Class<?> reqInterface, final GL downstream, final Object[] additionalArgs)
Creates a pipelined GL instance using the given downstream downstream and optional arguments addition...
static StringBuilder getGLStrings(final GL gl, final StringBuilder sb)
static boolean useAnimator
void addTileRendererNotify(final TileRendererBase tr)
The owning GLAutoDrawable is attached to the given TileRendererBase instance.
void setForceFFPEmu(final boolean forceFFPEmu, final boolean verboseFFPEmu, final boolean debugFFPEmu, final boolean traceFFPEmu)
void startTileRendering(final TileRendererBase tr)
Called by the TileRendererBase during tile-rendering after TileRendererBase#beginTile(GL) and before ...
void dispose(final GLAutoDrawable drawable)
Notifies the listener to perform the release of all OpenGL resources per GLContext,...
void removeTileRendererNotify(final TileRendererBase tr)
The owning GLAutoDrawable is detached from the given TileRendererBase instance.
void setDoRotation(final boolean rotate)
void reshapeTile(final TileRendererBase tr, final int tileX, final int tileY, final int tileWidth, final int tileHeight, final int imageWidth, final int imageHeight)
Called by the TileRendererBase during tile-rendering via an attached GLAutoDrawable's GLAutoDrawable#...
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 reshape(final GLAutoDrawable glad, 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.
RedSquareES1(final int swapInterval)
void endTileRendering(final TileRendererBase tr)
Called by the TileRenderer during tile-rendering after TileRendererBase#endTile(GL) and GLAutoDrawabl...
void setFlipVerticalInGLOrientation(final boolean v)
A fairly direct port of Brian Paul's tile rendering library, found at http://www.mesa3d....
final GLAutoDrawable getAttachedDrawable()
Returns a previously attached GLAutoDrawable, null if none is attached.
Tool to pipeline GL2ES2 into a fixed function emulation implementing GL2ES1.
static final GL2ES1 wrapFixedFuncEmul(final GL gl, final ShaderSelectionMode mode, final PMVMatrix pmvMatrix, final boolean force, final boolean verbose)
AUTO
Auto shader selection, based upon FFP states.
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
GL2ES1 getGL2ES1()
Casts this object to the GL2ES1 interface.
void setSwapInterval(int interval)
Set the swap interval of the current context and attached onscreen GLDrawable.
GLContext getContext()
Returns the GLContext associated which this GL object.
long getHandle()
Returns the GL drawable handle, guaranteed to be valid after realization and while it's surface is be...
boolean isGLOriented()
Returns true if the drawable is rendered in OpenGL's coordinate system, origin at bottom left.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
void glDrawArrays(int mode, int first, int count)
Entry point to C language function: void {@native glDrawArrays}(GLenum mode, GLint first,...
static final int GL_FLOAT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_FLOAT" with expressio...
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,...
void glEnable(int cap)
Entry point to C language function: void {@native glEnable}(GLenum cap) Part of GL_ES_VERSION_2_0,...
static final int GL_DEPTH_TEST
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_DEPTH_TEST" with expr...
void glClear(int mask)
Entry point to C language function: void {@native glClear}(GLbitfield mask) Part of GL_ES_VERSION_...
static final int GL_TRIANGLE_STRIP
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_TRIANGLE_STRIP" with ...
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.
void glFrustumf(float left, float right, float bottom, float top, float zNear, float zFar)
Multiply the current matrix with the frustum matrix.
void glTranslatef(float x, float y, float z)
Translate the current matrix.
void glRotatef(float angle, float x, float y, float z)
Rotate the current matrix.
static final int GL_MODELVIEW
Matrix mode modelview.
void glScalef(float x, float y, float z)
Scale the current matrix.
void glLoadIdentity()
Load the current matrix with the identity matrix.
void glMatrixMode(int mode)
Sets the current matrix mode.
static final int GL_COLOR_ARRAY
void glEnableClientState(int arrayName)
void glDisableClientState(int arrayName)
static final int GL_VERTEX_ARRAY