29package com.jogamp.opengl.test.junit.jogl.offscreen;
33import com.jogamp.math.FloatUtil;
34import com.jogamp.opengl.*;
35import com.jogamp.opengl.fixedfunc.*;
37import com.jogamp.opengl.util.*;
39import com.jogamp.opengl.fixedfunc.GLPointerFunc;
40import com.jogamp.opengl.util.texture.TextureCoords;
41import com.jogamp.opengl.util.GLArrayDataClient;
42import com.jogamp.opengl.util.GLArrayDataServer;
48 boolean enableBufferAlways =
false;
49 boolean enableBufferVBO =
true;
63 final float f_edge = 1f;
64 if(
null==readTextureVertices) {
72 final FloatBuffer vb = (FloatBuffer)readTextureVertices.
getBuffer();
73 vb.put(-f_edge); vb.put(-f_edge);
74 vb.put( f_edge); vb.put(-f_edge);
75 vb.put(-f_edge); vb.put( f_edge);
76 vb.put( f_edge); vb.put( f_edge);
78 readTextureVertices.
seal(gl,
true);
79 System.out.println(readTextureVertices);
87 public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) {
88 super.reshape(drawable, x, y, width, height);
102 throw new GLException(
"ES2 currently unhandled .. ");
126 super.dispose(drawable);
129 void renderOffscreenTexture(
final GL gl) {
130 if(!readBufferUtil.
isValid())
return;
141 updateTextureCoords(gl,
false);
144 if(
null!=readTextureCoords) {
157 void updateTextureCoords(
final GL gl,
final boolean force) {
158 if(force ||
null==readTextureCoords) {
165 final FloatBuffer cb = (FloatBuffer)readTextureCoords.
getBuffer();
166 cb.put(coords.left()); cb.put(coords.bottom());
167 cb.put(coords.right()); cb.put(coords.bottom());
168 cb.put(coords.left()); cb.put(coords.top());
169 cb.put(coords.right()); cb.put(coords.top());
171 readTextureCoords.
seal(gl,
true);
172 System.out.println(readTextureCoords);
178 super.display(drawable);
180 final GL gl = drawable.
getGL();
187 renderOffscreenTexture(gl);
Basic Float math utility functions.
static final float QUARTER_PI
The value PI/4, i.e.
final SyncMatrix4f getSyncMv()
Returns the SyncMatrix of modelview matrix (Mv).
final SyncMatrix4f getSyncP()
Returns the SyncMatrix of projection matrix (P).
A generic exception for OpenGL errors used throughout the binding as a substitute for RuntimeExceptio...
ReadBuffer2Screen(final GLDrawable externalRead)
void dispose(final GLAutoDrawable drawable)
Notifies the listener to perform the release of all OpenGL resources per GLContext,...
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 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 seal(final GL gl, final boolean seal)
Convenience method calling seal(boolean) and enableBuffer(GL, boolean).
void enableBuffer(final GL gl, final boolean enable)
Enables the buffer if enable is true, and transfers the data if required.
void setEnableAlways(final boolean always)
Affects the behavior of 'enableBuffer'.
static GLArrayDataServer createFixed(final int index, final int compsPerElement, final int dataType, final boolean normalized, final int stride, final Buffer buffer, final int vboUsage)
Create a VBO, using a predefined fixed function array index and starting with a given Buffer object i...
final int getElemCount()
Returns the element position (written elements) if not sealed() or the element limit (available to re...
void setVBOEnabled(final boolean vboEnabled)
Enable or disable use of VBO.
Buffer getBuffer()
The Buffer holding the data, may be null if a GPU buffer without client bound data.
PMVMatrix implements a subset of the fixed function pipeline GLMatrixFunc using PMVMatrix4f.
final void glTranslatef(final float x, final float y, final float z)
Translate the current matrix.
final void glMatrixMode(final int matrixName)
Sets the current matrix mode.
final void gluPerspective(final float fovy_rad, final float aspect, final float zNear, final float zFar)
Multiply the current matrix with the perspective/frustum matrix.
final void glLoadIdentity()
Load the current matrix with the identity matrix.
TextureCoords getImageTexCoords()
Returns the set of texture coordinates corresponding to the entire image.
void bind(final GL gl)
Binds this texture to the given GL context.
void disable(final GL gl)
Disables this texture's target (e.g., GL_TEXTURE_2D) in the given GL state.
void enable(final GL gl)
Enables this texture's target (e.g., GL_TEXTURE_2D) in the given GL context's state.
FloatBuffer getSyncFloats()
Return the FloatBuffer after synchronizing it w/ the underlying getMatrix().
static final int GL_MODULATE
GL_VERSION_ES_1_0, GL_VERSION_1_0 Define "GL_MODULATE" with expression '0x2100', CType: int
static final int GL_TEXTURE_ENV_MODE
GL_VERSION_ES_1_0, GL_VERSION_1_0 Define "GL_TEXTURE_ENV_MODE" with expression '0x2200',...
void glTexEnvi(int target, int pname, int param)
Entry point to C language function: void {@native glTexEnvi}(GLenum target, GLenum pname,...
static final int GL_TEXTURE_ENV
GL_VERSION_ES_1_0, GL_VERSION_1_0 Define "GL_TEXTURE_ENV" with expression '0x2300',...
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
boolean isGL2ES1()
Indicates whether this GL object conforms to a GL2ES1 compatible profile.
GL2ES1 getGL2ES1()
Casts this object to the GL2ES1 interface.
An abstraction for an OpenGL rendering target.
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_STATIC_DRAW
GL_VERSION_1_5, GL_ES_VERSION_2_0, GL_VERSION_ES_1_0, GL_ARB_vertex_buffer_object Alias for: GL_STATI...
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 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 ...
void glViewport(int x, int y, int width, int height)
Entry point to C language function: void {@native glViewport}(GLint x, GLint y, GLsizei width,...
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...
static final int GL_SMOOTH
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 glLoadMatrixf(java.nio.FloatBuffer m)
Load the current matrix w/ the provided one.
void glMatrixMode(int mode)
Sets the current matrix mode.
static final int GL_TEXTURE_COORD_ARRAY
static final int GL_VERTEX_ARRAY