22package com.jogamp.opengl.test.junit.jogl.demos.es2;
24import com.jogamp.opengl.GL;
25import com.jogamp.opengl.GL2ES2;
26import com.jogamp.opengl.GLAutoDrawable;
27import com.jogamp.opengl.GLEventListener;
28import com.jogamp.opengl.GLUniformData;
29import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
31import com.jogamp.opengl.util.ImmModeSink;
32import com.jogamp.opengl.util.PMVMatrix;
33import com.jogamp.opengl.util.glsl.ShaderCode;
34import com.jogamp.opengl.util.glsl.ShaderProgram;
35import com.jogamp.opengl.util.glsl.ShaderState;
39 private boolean multisample, clearBuffers;
47 this.multisample = multisample;
48 this.clearBuffers =
true;
61 System.err.println(
"req. msaa: "+multisample);
65 System.err.println(
"has msaa: "+multisample);
69 "shader/bin",
"mgl_default_xxx",
true);
71 "shader/bin",
"mgl_default_xxx",
true);
76 sp0.
add(gl, vp0, System.err);
77 sp0.
add(gl, fp0, System.err);
82 st.
uniform(gl, pmvMatrixUniform);
85 final float eX = 0.5f;
86 final float eH = 0.98f;
125 immModeSink.
glEnd(gl,
false);
145 final float c = 0.9f;
154 immModeSink.
draw(gl,
true);
162 System.err.println(
"reshape ..");
166 final float left, right, bottom, top;
167 if( height > width ) {
168 final float a = (float)height / (
float)width;
174 final float a = (float)width / (
float)height;
182 pmvMatrix.
glOrthof(left, right, top, bottom, 0.0f, 10.0f);
187 st.
uniform(gl, pmvMatrixUniform);
final SyncMatrices4f getSyncPMv()
Returns SyncMatrices4f of 2 matrices within one FloatBuffer: P and Mv.
LineSquareXDemoES2(final boolean multisample)
void display(final GLAutoDrawable glad)
Called by the drawable to initiate OpenGL rendering by the client.
void dispose(final GLAutoDrawable glad)
Notifies the listener to perform the release of all OpenGL resources per GLContext,...
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.
void init(final GLAutoDrawable glad)
Called by the drawable immediately after the OpenGL context is initialized.
void setClearBuffers(final boolean v)
void displayChanged(final GLAutoDrawable drawable, final boolean modeChanged, final boolean deviceChanged)
final void glVertex3f(final float x, final float y, final float z)
void destroy(final GL gl)
static ImmModeSink createGLSL(final int initialElementCount, final int vComps, final int vDataType, final int cComps, final int cDataType, final int nComps, final int nDataType, final int tComps, final int tDataType, final int glBufferUsage, final ShaderState st)
Uses a GL2ES2 GLSL shader immediate mode sink, utilizing the given ShaderState.
void draw(final GL gl, final boolean disableBufferAfterDraw)
final void glColor4f(final float x, final float y, final float z, final float a)
final void glEnd(final GL gl)
PMVMatrix implements a subset of the fixed function pipeline GLMatrixFunc using PMVMatrix4f.
final void glMatrixMode(final int matrixName)
Sets the current matrix mode.
final void glOrthof(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar)
Multiply the current matrix with the orthogonal matrix.
final void glLoadIdentity()
Load the current matrix with the identity matrix.
Convenient shader code class to use and instantiate vertex or fragment programs.
final int defaultShaderCustomization(final GL2ES2 gl, final boolean preludeVersion, final boolean addDefaultPrecision)
Default customization of this shader source code.
static ShaderCode create(final GL2ES2 gl, final int type, final int count, final Class<?> context, final String[] sourceFiles, final boolean mutableStringBuilder)
Creates a complete ShaderCode object while reading all shader source of sourceFiles,...
synchronized void add(final ShaderCode shaderCode)
Adds a new shader to this program.
ShaderState allows to sharing data between shader programs, while updating the attribute and uniform ...
void setVerbose(final boolean v)
synchronized void useProgram(final GL2ES2 gl, final boolean on)
Turns the shader program on or off.
synchronized boolean attachShaderProgram(final GL2ES2 gl, final ShaderProgram prog, final boolean enable)
Attach or switch a shader program.
synchronized void destroy(final GL2ES2 gl)
Calls release(gl, true, true, true).
boolean uniform(final GL2ES2 gl, final GLUniformData data)
Set the uniform data, if it's location is valid, i.e.
void ownUniform(final GLUniformData uniform)
Bind the GLUniform lifecycle to this ShaderState.
CapabilitiesImmutable getRequestedCapabilities()
Return the capabilities used to choose this graphics configuration.
AbstractGraphicsConfiguration getGraphicsConfiguration()
Returns the graphics configuration corresponding to this window.
static final int GL_VERTEX_SHADER
GL_ES_VERSION_2_0, GL_VERSION_2_0, GL_EXT_vertex_shader, GL_ARB_vertex_shader Alias for: GL_VERTEX_SH...
static final int GL_FRAGMENT_SHADER
GL_ES_VERSION_2_0, GL_VERSION_2_0, GL_ATI_fragment_shader, GL_ARB_fragment_shader Alias for: GL_FRAGM...
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
GL2ES2 getGL2ES2()
Casts this object to the GL2ES2 interface.
int getNumSamples()
Returns the number of sample buffers to be allocated if sample buffers are enabled,...
GLCapabilitiesImmutable getChosenGLCapabilities()
Fetches the GLCapabilitiesImmutable corresponding to the chosen OpenGL capabilities (pixel format / v...
NativeSurface getNativeSurface()
Returns the associated NativeSurface of this NativeSurfaceHolder.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
static final int GL_MULTISAMPLE
Common in ES1, GL2 and GL3.
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 glEnable(int cap)
Entry point to C language function: void {@native glEnable}(GLenum cap) Part of GL_ES_VERSION_2_0,...
void glClear(int mask)
Entry point to C language function: void {@native glClear}(GLbitfield mask) Part of GL_ES_VERSION_...
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_LINES
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_LINES" with expressio...
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.