28package com.jogamp.opengl.test.junit.jogl.glsl;
30import com.jogamp.opengl.util.GLArrayDataServer;
31import com.jogamp.opengl.util.glsl.ShaderState;
33import com.jogamp.opengl.GL;
34import com.jogamp.opengl.GL2ES2;
35import com.jogamp.opengl.GLBufferStorage;
36import com.jogamp.opengl.GLDrawable;
38import org.junit.Assert;
45 final int[] qi =
new int[1];
48 if(st.shaderProgram().
linked()) {
60 Assert.assertEquals(
"GLBufferStorage size mismatch, storage "+glStore, data.
getByteCount(),
null != glStore ? glStore.
getSize() : -1);
63 public static void pause(
final long ms)
throws InterruptedException {
64 final long t0 = System.currentTimeMillis();
65 while( System.currentTimeMillis() - t0 < ms) {
72 final boolean postDisable,
final int num,
final long postDelay)
73 throws InterruptedException
75 System.err.println(
"screen #"+num);
77 vertices.enableBuffer(gl,
true);
79 colors.enableBuffer(gl,
true);
86 Assert.assertTrue(vertices.enabled());
87 Assert.assertTrue(colors.enabled());
95 vertices.enableBuffer(gl,
false);
96 colors.enableBuffer(gl,
false);
97 Assert.assertTrue(!vertices.enabled());
98 Assert.assertTrue(!colors.enabled());
101 drawable.swapBuffers();
102 if(postDelay>0) {
pause(postDelay); }
107 vertices.enableBuffer(gl,
true);
108 colors.enableBuffer(gl,
true);
113 vertices.enableBuffer(gl,
false);
114 colors.enableBuffer(gl,
false);
116 drawable.swapBuffers();
120 if(
null != st && 0 != shaderProgram) {
121 throw new InternalError(
"Use either ShaderState _or_ shader-program, not both");
123 if(
null == st && 0 == shaderProgram) {
124 throw new InternalError(
"Pass a valid ShaderState _xor_ shader-program, not none");
135 vDataArray.
setLocation(gl, shaderProgram, location);
140 Assert.assertTrue(vDataArray.
isVBO());
143 Assert.assertTrue(!vDataArray.
sealed());
145 vDataArray.
putf(vertices[i++]); vDataArray.
putf(vertices[i++]); vDataArray.
putf(vertices[i++]);
146 vDataArray.
putf(vertices[i++]); vDataArray.
putf(vertices[i++]); vDataArray.
putf(vertices[i++]);
147 vDataArray.
putf(vertices[i++]); vDataArray.
putf(vertices[i++]); vDataArray.
putf(vertices[i++]);
148 vDataArray.
putf(vertices[i++]); vDataArray.
putf(vertices[i++]); vDataArray.
putf(vertices[i++]);
149 vDataArray.
seal(gl,
true);
151 Assert.assertTrue(vDataArray.
sealed());
158 public static final float[]
vertices0 =
new float[] { -2f, 2f, 0f,
163 public static final float[]
vertices1 =
new float[] { -2f, 1f, 0f,
169 if(
null != st && 0 != shaderProgram) {
170 throw new InternalError(
"Use either ShaderState _or_ shader-program, not both");
172 if(
null == st && 0 == shaderProgram) {
173 throw new InternalError(
"Pass a valid ShaderState _xor_ shader-program, not none");
183 cDataArray.
setLocation(gl, shaderProgram, location);
189 cDataArray.
putf(colors[i++]); cDataArray.
putf(colors[i++]); cDataArray.
putf(colors[i++]); cDataArray.
putf(colors[i++]);
190 cDataArray.
putf(colors[i++]); cDataArray.
putf(colors[i++]); cDataArray.
putf(colors[i++]); cDataArray.
putf(colors[i++]);
191 cDataArray.
putf(colors[i++]); cDataArray.
putf(colors[i++]); cDataArray.
putf(colors[i++]); cDataArray.
putf(colors[i++]);
192 cDataArray.
putf(colors[i++]); cDataArray.
putf(colors[i++]); cDataArray.
putf(colors[i++]); cDataArray.
putf(colors[i++]);
193 cDataArray.
seal(gl,
true);
194 Assert.assertTrue(cDataArray.
isVBO());
197 Assert.assertTrue(cDataArray.
sealed());
203 public static final float[]
colors0 =
new float[] { 1f, 0f, 0f, 1f,
208 public static final float[]
colors1 =
new float[] { 1f, 0f, 1f, 1f,
OpenGL buffer storage object reflecting it's.
final long getSize()
Return the buffer's storage size.
static final float[] vertices0
static final int frames_perftest
static void validateGLArrayDataServerState(final GL2ES2 gl, final ShaderState st, final GLArrayDataServer data)
static final float[] colors0
static GLArrayDataServer createColors(final GL2ES2 gl, final ShaderState st, final int shaderProgram, final int location, final float[] colors)
static final float[] vertices1
static GLArrayDataServer createVertices(final GL2ES2 gl, final ShaderState st, final int shaderProgram, final int location, final float[] vertices)
static void pause(final long ms)
static final int frames_warmup
static void displayVCArrays(final GLDrawable drawable, final GL2ES2 gl, final ShaderState st, final boolean preEnable, final GLArrayDataServer vertices, final GLArrayDataServer colors, final boolean postDisable, final int num, final long postDelay)
static final float[] colors1
static void displayVCArraysNoChecks(final GLDrawable drawable, final GL2ES2 gl, final boolean preEnable, final GLArrayDataServer vertices, final GLArrayDataServer colors, final boolean postDisable)
final boolean isVBOWritten()
Is the buffer written to the VBO ?
void seal(final GL gl, final boolean seal)
Convenience method calling seal(boolean) and enableBuffer(GL, boolean).
static GLArrayDataServer createGLSL(final String name, final int compsPerElement, final int dataType, final boolean normalized, final int initialElementCount, final int vboUsage)
Create a VBO, using a custom GLSL array attribute name and starting with a new created Buffer object ...
final boolean isVBO()
Determines whether the data is server side (VBO) and enabled, or a client side array (false).
final int getByteCount()
Returns the byte position (written elements) if not sealed() or the byte limit (available to read) af...
final int getElemCount()
Returns the element position (written elements) if not sealed() or the element limit (available to re...
final boolean isVertexAttribute()
Returns true if this data set is intended for a GLSL vertex shader attribute, otherwise false,...
final int setLocation(final int v)
Sets the given location of the shader attribute.
final String getName()
The name of the reflecting shader array attribute.
final int getVBOName()
The VBO name or 0 if not a VBO.
final int getLocation()
Returns the shader attribute location for this name, -1 if not yet determined.
int program()
Returns the shader program name, which is non zero if valid.
ShaderState allows to sharing data between shader programs, while updating the attribute and uniform ...
void ownAttribute(final GLArrayData attribute, final boolean own)
Binds or unbinds the GLArrayData lifecycle to this ShaderState.
int getAttribLocation(final GL2ES2 gl, final String name)
Gets the location of a shader attribute with given name.
int getCachedAttribLocation(final String name)
Gets the cached location of a shader attribute.
GLArrayData getAttribute(final String name)
Get the previous cached vertex attribute data.
void bindAttribLocation(final GL2ES2 gl, final int location, final String name)
Binds a shader attribute to a location.
void glGetVertexAttribiv(int index, int pname, IntBuffer params)
Entry point to C language function: void {@native glGetVertexAttribiv}(GLuint index,...
int glGetAttribLocation(int program, String name)
Entry point to C language function: GLint {@native glGetAttribLocation}(GLuint program,...
static final int GL_VERTEX_ATTRIB_ARRAY_ENABLED
GL_ES_VERSION_2_0, GL_VERSION_2_0, GL_ARB_vertex_program Alias for: GL_VERTEX_ATTRIB_ARRAY_ENABLED_AR...
static final int GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING
GL_VERSION_1_5, GL_ES_VERSION_2_0, GL_ARB_vertex_buffer_object Alias for: GL_VERTEX_ATTRIB_ARRAY_BUFF...
int getBoundBuffer(int target)
GLBufferStorage getBufferStorage(int bufferName)
An abstraction for an OpenGL rendering target.
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_NO_ERROR
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_NO_ERROR" with expres...
int glGetError()
Entry point to C language function: GLenum {@native glGetError}() Part of GL_ES_VERSION_2_0,...
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...
static final int GL_FALSE
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_FALSE" with expressio...
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_TRUE
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_TRUE" with expression...
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_ARRAY_BUFFER
GL_VERSION_1_5, GL_ES_VERSION_2_0, GL_VERSION_ES_1_0, GL_ARB_vertex_buffer_object Alias for: GL_ARRAY...