28package com.jogamp.opengl.test.junit.jogl.demos.gl4;
30import java.nio.FloatBuffer;
32import com.jogamp.opengl.GL;
33import com.jogamp.opengl.GL2ES2;
34import com.jogamp.opengl.GL2ES3;
35import com.jogamp.opengl.GL2GL3;
36import com.jogamp.opengl.GL3ES3;
37import com.jogamp.opengl.GL4;
38import com.jogamp.opengl.GLAutoDrawable;
39import com.jogamp.opengl.GLEventListener;
40import com.jogamp.opengl.GLException;
42import com.jogamp.opengl.util.glsl.ShaderCode;
43import com.jogamp.opengl.util.glsl.ShaderProgram;
55 private static final double ANIMATION_RATE = 950.0;
58 private final int[] vertexArray =
new int[1];
59 private FloatBuffer vertexOffset;
60 private FloatBuffer backgroundColor;
66 program = createProgram(auto);
67 if(
null == program ) {
71 final double theta = System.currentTimeMillis() / ANIMATION_RATE;
72 vertexOffset = FloatBuffer.allocate(4);
73 vertexOffset.put(0, (
float)(Math.sin(theta) * 0.5f));
74 vertexOffset.put(1, (
float)(Math.cos(theta) * 0.6f));
75 vertexOffset.put(2, 0.0f);
76 vertexOffset.put(3, 0.0f);
78 backgroundColor = FloatBuffer.allocate(4);
79 backgroundColor.put(0, 0.25f);
80 backgroundColor.put(1, 0.25f);
81 backgroundColor.put(2, 0.25f);
82 backgroundColor.put(3, 1.0f);
92 if(
null == program ) {
96 final double value = System.currentTimeMillis() / ANIMATION_RATE;
99 vertexOffset.put(0, (
float)(Math.sin(value) * 0.5f));
100 vertexOffset.put(1, (
float)(Math.cos(value) * 0.6f));
107 if(
null == program ) {
120 static final String shaderBasename =
"tess_example01";
129 "shader",
"shader/bin", shaderBasename,
true);
131 "shader",
"shader/bin", shaderBasename,
true);
133 "shader",
"shader/bin", shaderBasename,
true);
135 "shader",
"shader/bin", shaderBasename,
true);
142 sp.
add(gl, vs, System.err);
143 sp.
add(gl, tcs, System.err);
144 sp.
add(gl, tes, System.err);
145 sp.
add(gl, fs, System.err);
147 if( !sp.
link(gl, System.err) ) {
148 System.err.println(
"[error] Couldn't link program: "+sp);
JOGL Tessellation ShaderCode GL4 test case.
void reshape(final GLAutoDrawable auto, 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 auto)
Called by the drawable to initiate OpenGL rendering by the client.
void init(final GLAutoDrawable auto)
Called by the drawable immediately after the OpenGL context is initialized.
void dispose(final GLAutoDrawable auto)
Notifies the listener to perform the release of all OpenGL resources per GLContext,...
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,...
int program()
Returns the shader program name, which is non zero if valid.
synchronized void destroy(final GL2ES2 gl)
Detaches all shader codes and deletes the program.
synchronized boolean link(final GL2ES2 gl, final PrintStream verboseOut)
Links the shader code to the program.
synchronized void add(final ShaderCode shaderCode)
Adds a new shader to this program.
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...
void glVertexAttrib4fv(int index, FloatBuffer v)
Entry point to C language function: void {@native glVertexAttrib4fv}(GLuint index,...
void glUseProgram(int program)
Entry point to C language function: void {@native glUseProgram}(GLuint program) Part of GL_ES_VERS...
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...
void glGenVertexArrays(int n, IntBuffer arrays)
Entry point to C language function: void {@native glGenVertexArrays}(GLsizei n, GLuint * arrays) P...
void glBindVertexArray(int array)
Entry point to C language function: void {@native glBindVertexArray}(GLuint array) Part of GL_ARB_...
void glClearBufferfv(int buffer, int drawbuffer, FloatBuffer value)
Entry point to C language function: void {@native glClearBufferfv}(GLenum buffer,...
static final int GL_COLOR
GL_ES_VERSION_3_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_EXT_discard_framebuffer Alias for: GL_COLOR_EXT...
void glDeleteVertexArrays(int n, IntBuffer arrays)
Entry point to C language function: void {@native glDeleteVertexArrays}(GLsizei n,...
void glPolygonMode(int face, int mode)
Entry point to C language function: void {@native glPolygonMode}(GLenum face, GLenum mode) Part of...
static final int GL_LINE
GL_VERSION_1_1, GL_VERSION_1_0, GL_NV_polygon_mode Alias for: GL_LINE_NV Define "GL_LINE" with expre...
void glPatchParameteri(int pname, int value)
Entry point to C language function: void {@native glPatchParameteri}(GLenum pname,...
static final int GL_PATCHES
GL_ARB_tessellation_shader, GL_ES_VERSION_3_2, GL_VERSION_4_0, GL_OES_tessellation_shader,...
static final int GL_TESS_EVALUATION_SHADER
GL_ARB_tessellation_shader, GL_ES_VERSION_3_2, GL_VERSION_4_0, GL_EXT_tessellation_shader,...
static final int GL_TESS_CONTROL_SHADER
GL_ARB_tessellation_shader, GL_ES_VERSION_3_2, GL_VERSION_4_0, GL_EXT_tessellation_shader,...
static final int GL_PATCH_VERTICES
GL_ARB_tessellation_shader, GL_ES_VERSION_3_2, GL_VERSION_4_0, GL_OES_tessellation_shader,...
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
GL4 getGL4()
Casts this object to the GL4 interface.
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_FRONT_AND_BACK
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_FRONT_AND_BACK" with ...