GL renderer with direct buffers working on Android

This commit is contained in:
codeanticode
2012-12-10 19:30:19 +00:00
parent 30a6a4b408
commit ecd810eb7b
4 changed files with 933 additions and 381 deletions
+337 -111
View File
@@ -27,6 +27,7 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
import java.util.Arrays;
import processing.core.PApplet;
@@ -356,24 +357,24 @@ public class PGL {
// Texture rendering
protected boolean loadedTexShader = false;
protected int texShaderProgram;
protected int texVertShader;
protected int texFragShader;
protected static boolean loadedTexShader = false;
protected static int texShaderProgram;
protected static int texVertShader;
protected static int texFragShader;
protected int texVertLoc;
protected int texTCoordLoc;
protected static int texVertLoc;
protected static int texTCoordLoc;
protected float[] texCoords = {
protected static float[] texCoords = {
// X, Y, U, V
-1.0f, -1.0f, 0.0f, 0.0f,
+1.0f, -1.0f, 1.0f, 0.0f,
-1.0f, +1.0f, 0.0f, 1.0f,
+1.0f, +1.0f, 1.0f, 1.0f
};
protected FloatBuffer texData;
protected static FloatBuffer texData;
protected String texVertShaderSource =
protected static String texVertShaderSource =
"attribute vec2 inVertex;" +
"attribute vec2 inTexcoord;" +
"varying vec2 vertTexcoord;" +
@@ -382,7 +383,7 @@ public class PGL {
" vertTexcoord = inTexcoord;" +
"}";
protected String texFragShaderSource =
protected static String texFragShaderSource =
SHADER_PREPROCESSOR_DIRECTIVE +
"uniform sampler2D textureSampler;" +
"varying vec2 vertTexcoord;" +
@@ -392,7 +393,10 @@ public class PGL {
///////////////////////////////////////////////////////////
// 1-pixel color, depth, stencil buffers
// Utilities
protected ByteBuffer byteBuffer;
protected IntBuffer intBuffer;
protected IntBuffer colorBuffer;
protected FloatBuffer depthBuffer;
@@ -409,6 +413,12 @@ public class PGL {
if (glu == null) {
glu = new PGLU();
}
if (byteBuffer == null) {
byteBuffer = allocateDirectByteBuffer(1);
}
if (intBuffer == null) {
intBuffer = allocateDirectIntBuffer(1);
}
initialized = false;
}
@@ -728,31 +738,57 @@ public class PGL {
}
public void getIntegerv(int name, int[] values, int offset) {
// public void getIntegerv(int name, int[] values, int offset) {
// if (-1 < name) {
// GLES20.glGetIntegerv(name, values, offset);
// } else {
// Arrays.fill(values, 0);
// }
// }
public void getIntegerv(int name, IntBuffer values) {
if (-1 < name) {
GLES20.glGetIntegerv(name, values, offset);
GLES20.glGetIntegerv(name, values);
} else {
Arrays.fill(values, 0);
fillBuffer(values, 0, values.capacity() - 1, 0);
}
}
public void getFloatv(int name, float[] values, int offset) {
// public void getFloatv(int name, float[] values, int offset) {
// if (-1 < name) {
// GLES20.glGetFloatv(name, values, offset);
// } else {
// Arrays.fill(values, 0);
// }
// }
public void getFloatv(int name, FloatBuffer values) {
if (-1 < name) {
GLES20.glGetFloatv(name, values, offset);
GLES20.glGetFloatv(name, values);
} else {
Arrays.fill(values, 0);
fillBuffer(values, 0, values.capacity() - 1, 0);
}
}
public void getBooleanv(int name, boolean[] values, int offset) {
// public void getBooleanv(int name, boolean[] values, int offset) {
// if (-1 < name) {
// GLES20.glGetBooleanv(name, values, offset);
// } else {
// Arrays.fill(values, false);
// }
// }
public void getBooleanv(int name, IntBuffer values) {
if (-1 < name) {
GLES20.glGetBooleanv(name, values, offset);
GLES20.glGetBooleanv(name, values);
} else {
Arrays.fill(values, false);
fillBuffer(values, 0, values.capacity() - 1, 0);
}
}
}
///////////////////////////////////////////////////////////
@@ -834,13 +870,20 @@ public class PGL {
// Textures
public void genTextures(int n, int[] ids, int offset) {
GLES20.glGenTextures(n, ids, offset);
// public void genTextures(int n, int[] ids, int offset) {
// GLES20.glGenTextures(n, ids, offset);
// }
public void genTextures(int n, IntBuffer ids) {
GLES20.glGenTextures(n, ids);
}
// public void deleteTextures(int n, int[] ids, int offset) {
// GLES20.glDeleteTextures(n, ids, offset);
// }
public void deleteTextures(int n, int[] ids, int offset) {
GLES20.glDeleteTextures(n, ids, offset);
public void deleteTextures(int n, IntBuffer ids) {
GLES20.glDeleteTextures(n, ids);
}
@@ -883,9 +926,14 @@ public class PGL {
}
public void getTexParameteriv(int target, int param, int[] values,
int offset) {
GLES20.glGetTexParameteriv(target, param, values, offset);
// public void getTexParameteriv(int target, int param, int[] values,
// int offset) {
// GLES20.glGetTexParameteriv(target, param, values, offset);
// }
public void getTexParameteriv(int target, int param, IntBuffer values) {
GLES20.glGetTexParameteriv(target, param, values);
}
@@ -899,13 +947,23 @@ public class PGL {
// Vertex Buffers
public void genBuffers(int n, int[] ids, int offset) {
GLES20.glGenBuffers(n, ids, offset);
// public void genBuffers(int n, int[] ids, int offset) {
// GLES20.glGenBuffers(n, ids, offset);
// }
public void genBuffers(int n, IntBuffer ids) {
GLES20.glGenBuffers(n, ids);
}
public void deleteBuffers(int n, int[] ids, int offset) {
GLES20.glDeleteBuffers(n, ids, offset);
// public void deleteBuffers(int n, int[] ids, int offset) {
// GLES20.glDeleteBuffers(n, ids, offset);
// }
public void deleteBuffers(int n, IntBuffer ids) {
GLES20.glDeleteBuffers(n, ids);
}
@@ -979,23 +1037,32 @@ public class PGL {
// Framebuffers, renderbuffers
public void genFramebuffers(int n, int[] ids, int offset) {
GLES20.glGenFramebuffers(n, ids, offset);
// public void genFramebuffers(int n, int[] ids, int offset) {
// GLES20.glGenFramebuffers(n, ids, offset);
// }
//
//
// public void deleteFramebuffers(int n, int[] ids, int offset) {
// GLES20.glDeleteFramebuffers(n, ids, offset);
// }
//
//
// public void genRenderbuffers(int n, int[] ids, int offset) {
// GLES20.glGenRenderbuffers(n, ids, offset);
// }
//
//
// public void deleteRenderbuffers(int n, int[] ids, int offset) {
// GLES20.glDeleteRenderbuffers(n, ids, offset);
// }
public void genFramebuffers(int n, IntBuffer ids) {
GLES20.glGenFramebuffers(n, ids);
}
public void deleteFramebuffers(int n, int[] ids, int offset) {
GLES20.glDeleteFramebuffers(n, ids, offset);
}
public void genRenderbuffers(int n, int[] ids, int offset) {
GLES20.glGenRenderbuffers(n, ids, offset);
}
public void deleteRenderbuffers(int n, int[] ids, int offset) {
GLES20.glDeleteRenderbuffers(n, ids, offset);
public void deleteFramebuffers(int n, IntBuffer ids) {
GLES20.glDeleteFramebuffers(n, ids);
}
@@ -1004,6 +1071,16 @@ public class PGL {
}
public void genRenderbuffers(int n, IntBuffer ids) {
GLES20.glGenRenderbuffers(n, ids);
}
public void deleteRenderbuffers(int n, IntBuffer ids) {
GLES20.glDeleteRenderbuffers(n, ids);
}
public void blitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1,
int dstX0, int dstY0, int dstX1, int dstY1,
int mask, int filter) {
@@ -1138,61 +1215,120 @@ public class PGL {
}
public void uniform1iv(int loc, int count, int[] v, int offset) {
GLES20.glUniform1iv(loc, count, v, offset);
// public void uniform1iv(int loc, int count, int[] v, int offset) {
// GLES20.glUniform1iv(loc, count, v, offset);
// }
//
//
// public void uniform2iv(int loc, int count, int[] v, int offset) {
// GLES20.glUniform2iv(loc, count, v, offset);
// }
//
//
// public void uniform3iv(int loc, int count, int[] v, int offset) {
// GLES20.glUniform3iv(loc, count, v, offset);
// }
//
//
// public void uniform4iv(int loc, int count, int[] v, int offset) {
// GLES20.glUniform4iv(loc, count, v, offset);
// }
//
//
// public void uniform1fv(int loc, int count, float[] v, int offset) {
// GLES20.glUniform1fv(loc, count, v, offset);
// }
//
//
// public void uniform2fv(int loc, int count, float[] v, int offset) {
// GLES20.glUniform2fv(loc, count, v, offset);
// }
//
//
// public void uniform3fv(int loc, int count, float[] v, int offset) {
// GLES20.glUniform3fv(loc, count, v, offset);
// }
//
//
// public void uniform4fv(int loc, int count, float[] v, int offset) {
// GLES20.glUniform4fv(loc, count, v, offset);
// }
//
//
// public void uniformMatrix2fv(int loc, int count, boolean transpose,
// float[] mat, int offset) {
// GLES20.glUniformMatrix2fv(loc, count, transpose, mat, offset);
// }
//
//
// public void uniformMatrix3fv(int loc, int count, boolean transpose,
// float[] mat, int offset) {
// GLES20.glUniformMatrix3fv(loc, count, transpose, mat, offset);
// }
//
//
// public void uniformMatrix4fv(int loc, int count, boolean transpose,
// float[] mat, int offset) {
// GLES20.glUniformMatrix4fv(loc, count, transpose, mat, offset);
// }
public void uniform1iv(int loc, int count, IntBuffer v) {
GLES20.glUniform1iv(loc, count, v);
}
public void uniform2iv(int loc, int count, int[] v, int offset) {
GLES20.glUniform2iv(loc, count, v, offset);
public void uniform2iv(int loc, int count, IntBuffer v) {
GLES20.glUniform2iv(loc, count, v);
}
public void uniform3iv(int loc, int count, int[] v, int offset) {
GLES20.glUniform3iv(loc, count, v, offset);
public void uniform3iv(int loc, int count, IntBuffer v) {
GLES20.glUniform3iv(loc, count, v);
}
public void uniform4iv(int loc, int count, int[] v, int offset) {
GLES20.glUniform4iv(loc, count, v, offset);
public void uniform4iv(int loc, int count, IntBuffer v) {
GLES20.glUniform4iv(loc, count, v);
}
public void uniform1fv(int loc, int count, float[] v, int offset) {
GLES20.glUniform1fv(loc, count, v, offset);
public void uniform1fv(int loc, int count, FloatBuffer v) {
GLES20.glUniform1fv(loc, count, v);
}
public void uniform2fv(int loc, int count, float[] v, int offset) {
GLES20.glUniform2fv(loc, count, v, offset);
public void uniform2fv(int loc, int count, FloatBuffer v) {
GLES20.glUniform2fv(loc, count, v);
}
public void uniform3fv(int loc, int count, float[] v, int offset) {
GLES20.glUniform3fv(loc, count, v, offset);
public void uniform3fv(int loc, int count, FloatBuffer v) {
GLES20.glUniform3fv(loc, count, v);
}
public void uniform4fv(int loc, int count, float[] v, int offset) {
GLES20.glUniform4fv(loc, count, v, offset);
public void uniform4fv(int loc, int count, FloatBuffer v) {
GLES20.glUniform4fv(loc, count, v);
}
public void uniformMatrix2fv(int loc, int count, boolean transpose,
float[] mat, int offset) {
GLES20.glUniformMatrix2fv(loc, count, transpose, mat, offset);
FloatBuffer mat) {
GLES20.glUniformMatrix2fv(loc, count, transpose, mat);
}
public void uniformMatrix3fv(int loc, int count, boolean transpose,
float[] mat, int offset) {
GLES20.glUniformMatrix3fv(loc, count, transpose, mat, offset);
FloatBuffer mat) {
GLES20.glUniformMatrix3fv(loc, count, transpose, mat);
}
public void uniformMatrix4fv(int loc, int count, boolean transpose,
float[] mat, int offset) {
GLES20.glUniformMatrix4fv(loc, count, transpose, mat, offset);
FloatBuffer mat) {
GLES20.glUniformMatrix4fv(loc, count, transpose, mat);
}
@@ -1217,23 +1353,42 @@ public class PGL {
}
public void vertexAttrib1fv(int loc, float[] v, int offset) {
GLES20.glVertexAttrib1fv(loc, v, offset);
// public void vertexAttrib1fv(int loc, float[] v, int offset) {
// GLES20.glVertexAttrib1fv(loc, v, offset);
// }
//
//
// public void vertexAttrib2fv(int loc, float[] v, int offset) {
// GLES20.glVertexAttrib2fv(loc, v, offset);
// }
//
//
// public void vertexAttrib3fv(int loc, float[] v, int offset) {
// GLES20.glVertexAttrib3fv(loc, v, offset);
// }
//
//
// public void vertexAttrib4fv(int loc, float[] v, int offset) {
// GLES20.glVertexAttrib4fv(loc, v, offset);
// }
public void vertexAttrib1fv(int loc, FloatBuffer v) {
GLES20.glVertexAttrib1fv(loc, v);
}
public void vertexAttrib2fv(int loc, float[] v, int offset) {
GLES20.glVertexAttrib2fv(loc, v, offset);
public void vertexAttrib2fv(int loc, FloatBuffer v) {
GLES20.glVertexAttrib2fv(loc, v);
}
public void vertexAttrib3fv(int loc, float[] v, int offset) {
GLES20.glVertexAttrib3fv(loc, v, offset);
public void vertexAttrib3fv(int loc, FloatBuffer v) {
GLES20.glVertexAttrib3fv(loc, v);
}
public void vertexAttrib4fv(int loc, float[] v, int offset) {
GLES20.glVertexAttrib4fv(loc, v, offset);
public void vertexAttri4fv(int loc, FloatBuffer v) {
GLES20.glVertexAttrib4fv(loc, v);
}
@@ -1252,8 +1407,13 @@ public class PGL {
}
public void getShaderiv(int shader, int pname, int[] params, int offset) {
GLES20.glGetShaderiv(shader, pname, params, offset);
// public void getShaderiv(int shader, int pname, int[] params, int offset) {
// GLES20.glGetShaderiv(shader, pname, params, offset);
// }
public void getShaderiv(int shader, int pname, IntBuffer params) {
GLES20.glGetShaderiv(shader, pname, params);
}
@@ -1262,8 +1422,13 @@ public class PGL {
}
public void getProgramiv(int prog, int pname, int[] params, int offset) {
GLES20.glGetProgramiv(prog, pname, params, offset);
// public void getProgramiv(int prog, int pname, int[] params, int offset) {
// GLES20.glGetProgramiv(prog, pname, params, offset);
// }
public void getProgramiv(int prog, int pname, IntBuffer params) {
GLES20.glGetProgramiv(prog, pname, params);
}
@@ -1593,22 +1758,29 @@ public class PGL {
texVertLoc = getAttribLocation(texShaderProgram, "inVertex");
texTCoordLoc = getAttribLocation(texShaderProgram, "inTexcoord");
}
texData = allocateDirectFloatBuffer(texCoords.length);
loadedTexShader = true;
}
if (texData == null) {
texData = allocateDirectFloatBuffer(texCoords.length);
}
if (intBuffer == null) {
intBuffer = allocateDirectIntBuffer(1);
}
if (0 < texShaderProgram) {
// The texture overwrites anything drawn earlier.
boolean[] depthTest = new boolean[1];
getBooleanv(DEPTH_TEST, depthTest, 0);
getBooleanv(DEPTH_TEST, intBuffer);
boolean depthTest = intBuffer.get(0) == 0 ? false : true;
disable(DEPTH_TEST);
// When drawing the texture we don't write to the
// depth mask, so the texture remains in the background
// and can be occluded by anything drawn later, even if
// if it is behind it.
boolean[] depthMask = new boolean[1];
getBooleanv(DEPTH_WRITEMASK, depthMask, 0);
getBooleanv(DEPTH_WRITEMASK, intBuffer);
boolean depthMask = intBuffer.get(0) == 0 ? false : true;
depthMask(false);
useProgram(texShaderProgram);
@@ -1673,12 +1845,12 @@ public class PGL {
useProgram(0);
if (depthTest[0]) {
if (depthTest) {
enable(DEPTH_TEST);
} else {
disable(DEPTH_TEST);
}
depthMask(depthMask[0]);
depthMask(depthMask);
}
}
@@ -2017,9 +2189,9 @@ public class PGL {
if (shader != 0) {
shaderSource(shader, source);
compileShader(shader);
int[] compiled = new int[1];
getShaderiv(shader, COMPILE_STATUS, compiled, 0);
if (compiled[0] == FALSE) {
getShaderiv(shader, COMPILE_STATUS, intBuffer);
boolean compiled = intBuffer.get(0) == 0 ? false : true;
if (!compiled) {
System.err.println("Could not compile shader " + shaderType + ":");
System.err.println(getShaderInfoLog(shader));
deleteShader(shader);
@@ -2036,9 +2208,9 @@ public class PGL {
attachShader(program, vertexShader);
attachShader(program, fragmentShader);
linkProgram(program);
int[] linked = new int[1];
getProgramiv(program, LINK_STATUS, linked, 0);
if (linked[0] == FALSE) {
getProgramiv(program, LINK_STATUS, intBuffer);
boolean linked = intBuffer.get(0) == 0 ? false : true;
if (!linked) {
System.err.println("Could not link program: ");
System.err.println(getProgramInfoLog(program));
deleteProgram(program);
@@ -2077,24 +2249,6 @@ public class PGL {
}
protected static ByteBuffer allocateDirectByteBuffer(int size) {
return ByteBuffer.allocateDirect(size * SIZEOF_BYTE).
order(ByteOrder.nativeOrder());
}
protected static IntBuffer allocateDirectIntBuffer(int size) {
return ByteBuffer.allocateDirect(size * SIZEOF_INT).
order(ByteOrder.nativeOrder()).asIntBuffer();
}
protected static FloatBuffer allocateDirectFloatBuffer(int size) {
return ByteBuffer.allocateDirect(size * SIZEOF_FLOAT).
order(ByteOrder.nativeOrder()).asFloatBuffer();
}
protected int[] getGLVersion() {
String version = GLES20.glGetString(GLES20.GL_VERSION).trim();
int[] res = {0, 0, 0};
@@ -2122,6 +2276,78 @@ public class PGL {
}
protected static ByteBuffer allocateDirectByteBuffer(int size) {
return ByteBuffer.allocateDirect(size * SIZEOF_BYTE).
order(ByteOrder.nativeOrder());
}
protected static ShortBuffer allocateDirectShortBuffer(int size) {
return ByteBuffer.allocateDirect(size * SIZEOF_SHORT).
order(ByteOrder.nativeOrder()).asShortBuffer();
}
protected static IntBuffer allocateDirectIntBuffer(int size) {
return ByteBuffer.allocateDirect(size * SIZEOF_INT).
order(ByteOrder.nativeOrder()).asIntBuffer();
}
protected static FloatBuffer allocateDirectFloatBuffer(int size) {
return ByteBuffer.allocateDirect(size * SIZEOF_FLOAT).
order(ByteOrder.nativeOrder()).asFloatBuffer();
}
protected static void fillBuffer(ByteBuffer buf, int i0, int i1, byte val) {
int n = i1 - i0 + 1;
byte[] temp = new byte[n];
Arrays.fill(temp, 0, n, val);
buf.position(i0);
buf.limit(i1 + 1);
buf.put(temp, 0, n);
buf.position(0);
buf.limit(buf.capacity());
}
protected static void fillBuffer(ShortBuffer buf, int i0, int i1, short val) {
int n = i1 - i0 + 1;
short[] temp = new short[n];
Arrays.fill(temp, 0, n, val);
buf.position(i0);
buf.limit(i1 + 1);
buf.put(temp, 0, n);
buf.position(0);
buf.limit(buf.capacity());
}
protected static void fillBuffer(IntBuffer buf, int i0, int i1, int val) {
int n = i1 - i0 + 1;
int[] temp = new int[n];
Arrays.fill(temp, 0, n, val);
buf.position(i0);
buf.limit(i1 + 1);
buf.put(temp, 0, n);
buf.position(0);
buf.limit(buf.capacity());
}
protected static void fillBuffer(FloatBuffer buf, int i0, int i1, float val) {
int n = i1 - i0 + 1;
float[] temp = new float[n];
Arrays.fill(temp, 0, n, val);
buf.position(i0);
buf.limit(i1 + 1);
buf.put(temp, 0, n);
buf.position(0);
buf.limit(buf.capacity());
}
///////////////////////////////////////////////////////////
// Android specific stuff
File diff suppressed because it is too large Load Diff
+82 -35
View File
@@ -27,6 +27,8 @@ import processing.core.*;
import java.io.IOException;
import java.net.URL;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.util.HashMap;
/**
@@ -79,6 +81,9 @@ public class PShader {
protected int firstTexUnit;
protected int lastTexUnit;
// Direct buffers to pass shader dat to GL
protected IntBuffer intBuffer;
protected FloatBuffer floatBuffer;
public PShader() {
parent = null;
@@ -97,6 +102,9 @@ public class PShader {
firstTexUnit = 0;
intBuffer = PGL.allocateDirectIntBuffer(1);
floatBuffer = PGL.allocateDirectFloatBuffer(1);
bound = false;
}
@@ -132,6 +140,9 @@ public class PShader {
glProgram = 0;
glVertex = 0;
glFragment = 0;
intBuffer = PGL.allocateDirectIntBuffer(1);
floatBuffer = PGL.allocateDirectFloatBuffer(1);
}
/**
@@ -151,6 +162,9 @@ public class PShader {
glProgram = 0;
glVertex = 0;
glFragment = 0;
intBuffer = PGL.allocateDirectIntBuffer(1);
floatBuffer = PGL.allocateDirectFloatBuffer(1);
}
@@ -460,14 +474,15 @@ public class PShader {
protected void setUniformVector(int loc, int[] vec, int ncoords,
int length) {
if (-1 < loc) {
copyToIntBuffer(vec);
if (ncoords == 1) {
pgl.uniform1iv(loc, length, vec, 0);
pgl.uniform1iv(loc, length, intBuffer);
} else if (ncoords == 2) {
pgl.uniform2iv(loc, length, vec, 0);
pgl.uniform2iv(loc, length, intBuffer);
} else if (ncoords == 3) {
pgl.uniform3iv(loc, length, vec, 0);
pgl.uniform3iv(loc, length, intBuffer);
} else if (ncoords == 4) {
pgl.uniform3iv(loc, length, vec, 0);
pgl.uniform3iv(loc, length, intBuffer);
}
}
}
@@ -476,14 +491,15 @@ public class PShader {
protected void setUniformVector(int loc, float[] vec, int ncoords,
int length) {
if (-1 < loc) {
copyToFloatBuffer(vec);
if (ncoords == 1) {
pgl.uniform1fv(loc, length, vec, 0);
pgl.uniform1fv(loc, length, floatBuffer);
} else if (ncoords == 2) {
pgl.uniform2fv(loc, length, vec, 0);
pgl.uniform2fv(loc, length, floatBuffer);
} else if (ncoords == 3) {
pgl.uniform3fv(loc, length, vec, 0);
pgl.uniform3fv(loc, length, floatBuffer);
} else if (ncoords == 4) {
pgl.uniform4fv(loc, length, vec, 0);
pgl.uniform4fv(loc, length, floatBuffer);
}
}
}
@@ -491,12 +507,13 @@ public class PShader {
protected void setUniformMatrix(int loc, float[] mat) {
if (-1 < loc) {
copyToFloatBuffer(mat);
if (mat.length == 4) {
pgl.uniformMatrix2fv(loc, 1, false, mat, 0);
pgl.uniformMatrix2fv(loc, 1, false, floatBuffer);
} else if (mat.length == 9) {
pgl.uniformMatrix3fv(loc, 1, false, mat, 0);
pgl.uniformMatrix3fv(loc, 1, false, floatBuffer);
} else if (mat.length == 16) {
pgl.uniformMatrix4fv(loc, 1, false, mat, 0);
pgl.uniformMatrix4fv(loc, 1, false, floatBuffer);
}
}
}
@@ -587,37 +604,48 @@ public class PShader {
pgl.uniform4f(loc, v[0], v[1], v[2], v[3]);
} else if (val.type == UniformValue.INT1VEC) {
int[] v = ((int[])val.value);
pgl.uniform1iv(loc, v.length, v, 0);
copyToIntBuffer(v);
pgl.uniform1iv(loc, v.length, intBuffer);
} else if (val.type == UniformValue.INT2VEC) {
int[] v = ((int[])val.value);
pgl.uniform2iv(loc, v.length / 2, v, 0);
copyToIntBuffer(v);
pgl.uniform2iv(loc, v.length / 2, intBuffer);
} else if (val.type == UniformValue.INT3VEC) {
int[] v = ((int[])val.value);
pgl.uniform3iv(loc, v.length / 3, v, 0);
copyToIntBuffer(v);
pgl.uniform3iv(loc, v.length / 3, intBuffer);
} else if (val.type == UniformValue.INT4VEC) {
int[] v = ((int[])val.value);
pgl.uniform4iv(loc, v.length / 4, v, 0);
copyToIntBuffer(v);
pgl.uniform4iv(loc, v.length / 4, intBuffer);
} else if (val.type == UniformValue.FLOAT1VEC) {
float[] v = ((float[])val.value);
pgl.uniform1fv(loc, v.length, v, 0);
copyToFloatBuffer(v);
pgl.uniform1fv(loc, v.length, floatBuffer);
} else if (val.type == UniformValue.FLOAT2VEC) {
float[] v = ((float[])val.value);
pgl.uniform2fv(loc, v.length / 2, v, 0);
copyToFloatBuffer(v);
pgl.uniform2fv(loc, v.length / 2, floatBuffer);
} else if (val.type == UniformValue.FLOAT3VEC) {
float[] v = ((float[])val.value);
pgl.uniform3fv(loc, v.length / 3, v, 0);
copyToFloatBuffer(v);
pgl.uniform3fv(loc, v.length / 3, floatBuffer);
} else if (val.type == UniformValue.FLOAT4VEC) {
float[] v = ((float[])val.value);
pgl.uniform4fv(loc, v.length / 4, v, 0);
copyToFloatBuffer(v);
pgl.uniform4fv(loc, v.length / 4, floatBuffer);
} else if (val.type == UniformValue.MAT2) {
float[] v = ((float[])val.value);
pgl.uniformMatrix2fv(loc, 1, false, v, 0);
copyToFloatBuffer(v);
pgl.uniformMatrix2fv(loc, 1, false, floatBuffer);
} else if (val.type == UniformValue.MAT3) {
float[] v = ((float[])val.value);
pgl.uniformMatrix3fv(loc, 1, false, v, 0);
copyToFloatBuffer(v);
pgl.uniformMatrix3fv(loc, 1, false, floatBuffer);
} else if (val.type == UniformValue.MAT4) {
float[] v = ((float[])val.value);
pgl.uniformMatrix4fv(loc, 1, false, v, 0);
copyToFloatBuffer(v);
pgl.uniformMatrix4fv(loc, 1, false, floatBuffer);
} else if (val.type == UniformValue.SAMPLER2D) {
PImage img = (PImage)val.value;
Texture tex = pgMain.getTexture(img);
@@ -634,6 +662,26 @@ public class PShader {
}
protected void copyToIntBuffer(int[] vec) {
if (intBuffer.capacity() < vec.length) {
intBuffer = PGL.allocateDirectIntBuffer(vec.length);
}
intBuffer.rewind();
intBuffer.put(vec, 0, vec.length);
intBuffer.rewind();
}
protected void copyToFloatBuffer(float[] vec) {
if (floatBuffer.capacity() < vec.length) {
floatBuffer = PGL.allocateDirectFloatBuffer(vec.length);
}
floatBuffer.rewind();
floatBuffer.put(vec, 0, vec.length);
floatBuffer.rewind();
}
protected void bindTextures() {
if (textures != null) {
for (int unit: textures.keySet()) {
@@ -701,18 +749,17 @@ public class PShader {
}
pgl.linkProgram(glProgram);
int[] linked = new int[1];
pgl.getProgramiv(glProgram, PGL.LINK_STATUS, linked, 0);
if (linked[0] == PGL.FALSE) {
pgl.getProgramiv(glProgram, PGL.LINK_STATUS, intBuffer);
boolean linked = intBuffer.get(0) == 0 ? false : true;
if (!linked) {
PGraphics.showException("Cannot link shader program:\n" +
pgl.getProgramInfoLog(glProgram));
}
pgl.validateProgram(glProgram);
int[] validated = new int[1];
pgl.getProgramiv(glProgram, PGL.VALIDATE_STATUS, validated, 0);
if (validated[0] == PGL.FALSE) {
pgl.getProgramiv(glProgram, PGL.VALIDATE_STATUS, intBuffer);
boolean validated = intBuffer.get(0) == 0 ? false : true;
if (!validated) {
PGraphics.showException("Cannot validate shader program:\n" +
pgl.getProgramInfoLog(glProgram));
}
@@ -801,9 +848,9 @@ public class PShader {
pgl.shaderSource(glVertex, vertexShaderSource);
pgl.compileShader(glVertex);
int[] compiled = new int[1];
pgl.getShaderiv(glVertex, PGL.COMPILE_STATUS, compiled, 0);
if (compiled[0] == PGL.FALSE) {
pgl.getShaderiv(glVertex, PGL.COMPILE_STATUS, intBuffer);
boolean compiled = intBuffer.get(0) == 0 ? false : true;
if (!compiled) {
PGraphics.showException("Cannot compile vertex shader:\n" +
pgl.getShaderInfoLog(glVertex));
return false;
@@ -822,9 +869,9 @@ public class PShader {
pgl.shaderSource(glFragment, fragmentShaderSource);
pgl.compileShader(glFragment);
int[] compiled = new int[1];
pgl.getShaderiv(glFragment, PGL.COMPILE_STATUS, compiled, 0);
if (compiled[0] == PGL.FALSE) {
pgl.getShaderiv(glFragment, PGL.COMPILE_STATUS, intBuffer);
boolean compiled = intBuffer.get(0) == 0 ? false : true;
if (!compiled) {
PGraphics.showException("Cannot compile fragment shader:\n" +
pgl.getShaderInfoLog(glFragment));
return false;
@@ -39,9 +39,6 @@ import processing.opengl.PGraphicsOpenGL.InGeometry;
import processing.opengl.PGraphicsOpenGL.TessGeometry;
import processing.opengl.PGraphicsOpenGL.Tessellator;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
import java.util.Arrays;
import java.util.HashSet;
@@ -1662,7 +1659,7 @@ public class PShapeOpenGL extends PShape {
PGL.javaToNativeARGB(ambientColor));
if (shapeEnded && tessellated && hasPolys) {
if (is3D()) {
Arrays.fill(tessGeo.polyAmbient, firstPolyVertex, lastPolyVertex = 1,
Arrays.fill(tessGeo.polyAmbient, firstPolyVertex, lastPolyVertex + 1,
PGL.javaToNativeARGB(ambientColor));
root.setModifiedPolyAmbient(firstPolyVertex, lastPolyVertex);
} else if (is2D()) {
@@ -3450,62 +3447,63 @@ public class PShapeOpenGL extends PShape {
int sizef = size * PGL.SIZEOF_FLOAT;
int sizei = size * PGL.SIZEOF_INT;
tessGeo.updatePolyVerticesBuffer();
glPolyVertex = pg.createVertexBufferObject(context.id());
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyVertex);
pgl.bufferData(PGL.ARRAY_BUFFER, 4 * sizef,
FloatBuffer.wrap(tessGeo.polyVertices, 0, 4 * size),
tessGeo.polyVerticesBuffer,
PGL.STATIC_DRAW);
tessGeo.updatePolyColorsBuffer();
glPolyColor = pg.createVertexBufferObject(context.id());
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyColor);
pgl.bufferData(PGL.ARRAY_BUFFER, sizei,
IntBuffer.wrap(tessGeo.polyColors, 0, size),
PGL.STATIC_DRAW);
tessGeo.polyColorsBuffer, PGL.STATIC_DRAW);
tessGeo.updatePolyNormalsBuffer();
glPolyNormal = pg.createVertexBufferObject(context.id());
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyNormal);
pgl.bufferData(PGL.ARRAY_BUFFER, 3 * sizef,
FloatBuffer.wrap(tessGeo.polyNormals, 0, 3 * size),
PGL.STATIC_DRAW);
tessGeo.polyNormalsBuffer, PGL.STATIC_DRAW);
tessGeo.updatePolyTexcoordsBuffer();
glPolyTexcoord = pg.createVertexBufferObject(context.id());
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyTexcoord);
pgl.bufferData(PGL.ARRAY_BUFFER, 2 * sizef,
FloatBuffer.wrap(tessGeo.polyTexcoords, 0, 2 * size),
PGL.STATIC_DRAW);
tessGeo.polyTexcoordsBuffer, PGL.STATIC_DRAW);
tessGeo.updatePolyAmbientBuffer();
glPolyAmbient = pg.createVertexBufferObject(context.id());
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyAmbient);
pgl.bufferData(PGL.ARRAY_BUFFER, sizei,
IntBuffer.wrap(tessGeo.polyAmbient, 0, size),
PGL.STATIC_DRAW);
tessGeo.polyAmbientBuffer, PGL.STATIC_DRAW);
tessGeo.updatePolySpecularBuffer();
glPolySpecular = pg.createVertexBufferObject(context.id());
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolySpecular);
pgl.bufferData(PGL.ARRAY_BUFFER, sizei,
IntBuffer.wrap(tessGeo.polySpecular, 0, size),
PGL.STATIC_DRAW);
tessGeo.polySpecularBuffer, PGL.STATIC_DRAW);
tessGeo.updatePolyEmissiveBuffer();
glPolyEmissive = pg.createVertexBufferObject(context.id());
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyEmissive);
pgl.bufferData(PGL.ARRAY_BUFFER, sizei,
IntBuffer.wrap(tessGeo.polyEmissive, 0, size),
PGL.STATIC_DRAW);
tessGeo.polyEmissiveBuffer, PGL.STATIC_DRAW);
tessGeo.updatePolyShininessBuffer();
glPolyShininess = pg.createVertexBufferObject(context.id());
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyShininess);
pgl.bufferData(PGL.ARRAY_BUFFER, sizef,
FloatBuffer.wrap(tessGeo.polyShininess, 0, size),
PGL.STATIC_DRAW);
tessGeo.polyShininessBuffer, PGL.STATIC_DRAW);
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
tessGeo.updatePolyIndicesBuffer();
glPolyIndex = pg.createVertexBufferObject(context.id());
pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, glPolyIndex);
pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER,
tessGeo.polyIndexCount * PGL.SIZEOF_INDEX,
ShortBuffer.wrap(tessGeo.polyIndices, 0,
tessGeo.polyIndexCount), PGL.STATIC_DRAW);
tessGeo.polyIndicesBuffer, PGL.STATIC_DRAW);
pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0);
}
@@ -3516,32 +3514,32 @@ public class PShapeOpenGL extends PShape {
int sizef = size * PGL.SIZEOF_FLOAT;
int sizei = size * PGL.SIZEOF_INT;
tessGeo.updateLineVerticesBuffer();
glLineVertex = pg.createVertexBufferObject(context.id());
pgl.bindBuffer(PGL.ARRAY_BUFFER, glLineVertex);
pgl.bufferData(PGL.ARRAY_BUFFER, 4 * sizef,
FloatBuffer.wrap(tessGeo.lineVertices, 0, 4 * size),
PGL.STATIC_DRAW);
tessGeo.lineVerticesBuffer, PGL.STATIC_DRAW);
tessGeo.updateLineColorsBuffer();
glLineColor = pg.createVertexBufferObject(context.id());
pgl.bindBuffer(PGL.ARRAY_BUFFER, glLineColor);
pgl.bufferData(PGL.ARRAY_BUFFER, sizei,
IntBuffer.wrap(tessGeo.lineColors, 0, size),
PGL.STATIC_DRAW);
tessGeo.lineColorsBuffer, PGL.STATIC_DRAW);
tessGeo.updateLineAttribsBuffer();
glLineAttrib = pg.createVertexBufferObject(context.id());
pgl.bindBuffer(PGL.ARRAY_BUFFER, glLineAttrib);
pgl.bufferData(PGL.ARRAY_BUFFER, 4 * sizef,
FloatBuffer.wrap(tessGeo.lineAttribs, 0, 4 * size),
PGL.STATIC_DRAW);
tessGeo.lineAttribsBuffer, PGL.STATIC_DRAW);
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
tessGeo.updateLineIndicesBuffer();
glLineIndex = pg.createVertexBufferObject(context.id());
pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, glLineIndex);
pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER,
tessGeo.lineIndexCount * PGL.SIZEOF_INDEX,
ShortBuffer.wrap(tessGeo.lineIndices, 0,
tessGeo.lineIndexCount), PGL.STATIC_DRAW);
tessGeo.lineIndicesBuffer, PGL.STATIC_DRAW);
pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0);
}
@@ -3552,32 +3550,32 @@ public class PShapeOpenGL extends PShape {
int sizef = size * PGL.SIZEOF_FLOAT;
int sizei = size * PGL.SIZEOF_INT;
tessGeo.updatePointVerticesBuffer();
glPointVertex = pg.createVertexBufferObject(context.id());
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPointVertex);
pgl.bufferData(PGL.ARRAY_BUFFER, 4 * sizef,
FloatBuffer.wrap(tessGeo.pointVertices, 0, 4 * size),
PGL.STATIC_DRAW);
tessGeo.pointVerticesBuffer, PGL.STATIC_DRAW);
tessGeo.updatePointColorsBuffer();
glPointColor = pg.createVertexBufferObject(context.id());
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPointColor);
pgl.bufferData(PGL.ARRAY_BUFFER, sizei,
IntBuffer.wrap(tessGeo.pointColors, 0, size),
PGL.STATIC_DRAW);
tessGeo.pointColorsBuffer, PGL.STATIC_DRAW);
tessGeo.updatePointAttribsBuffer();
glPointAttrib = pg.createVertexBufferObject(context.id());
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPointAttrib);
pgl.bufferData(PGL.ARRAY_BUFFER, 2 * sizef,
FloatBuffer.wrap(tessGeo.pointAttribs, 0, 2 * size),
PGL.STATIC_DRAW);
tessGeo.pointAttribsBuffer, PGL.STATIC_DRAW);
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
tessGeo.updatePointIndicesBuffer();
glPointIndex = pg.createVertexBufferObject(context.id());
pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, glPointIndex);
pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER,
tessGeo.pointIndexCount * PGL.SIZEOF_INDEX,
ShortBuffer.wrap(tessGeo.pointIndices, 0,
tessGeo.pointIndexCount), PGL.STATIC_DRAW);
tessGeo.pointIndicesBuffer, PGL.STATIC_DRAW);
pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0);
}
@@ -3882,134 +3880,127 @@ public class PShapeOpenGL extends PShape {
protected void copyPolyVertices(int offset, int size) {
tessGeo.updatePolyVerticesBuffer(offset, size);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyVertex);
pgl.bufferSubData(PGL.ARRAY_BUFFER, 4 * offset * PGL.SIZEOF_FLOAT,
4 * size * PGL.SIZEOF_FLOAT,
FloatBuffer.wrap(tessGeo.polyVertices,
4 * offset, 4 * size));
4 * size * PGL.SIZEOF_FLOAT, tessGeo.polyVerticesBuffer);
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
}
protected void copyPolyColors(int offset, int size) {
tessGeo.updatePolyColorsBuffer(offset, size);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyColor);
pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT,
size * PGL.SIZEOF_INT,
IntBuffer.wrap(tessGeo.polyColors, offset, size));
size * PGL.SIZEOF_INT, tessGeo.polyColorsBuffer);
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
}
protected void copyPolyNormals(int offset, int size) {
tessGeo.updatePolyNormalsBuffer(offset, size);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyNormal);
pgl.bufferSubData(PGL.ARRAY_BUFFER, 3 * offset * PGL.SIZEOF_FLOAT,
3 * size * PGL.SIZEOF_FLOAT,
FloatBuffer.wrap(tessGeo.polyNormals,
3 * offset, 3 * size));
3 * size * PGL.SIZEOF_FLOAT, tessGeo.polyNormalsBuffer);
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
}
protected void copyPolyTexcoords(int offset, int size) {
tessGeo.updatePolyTexcoordsBuffer(offset, size);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyTexcoord);
pgl.bufferSubData(PGL.ARRAY_BUFFER, 2 * offset * PGL.SIZEOF_FLOAT,
2 * size * PGL.SIZEOF_FLOAT,
FloatBuffer.wrap(tessGeo.polyTexcoords,
2 * offset, 2 * size));
2 * size * PGL.SIZEOF_FLOAT, tessGeo.polyTexcoordsBuffer);
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
}
protected void copyPolyAmbient(int offset, int size) {
tessGeo.updatePolyAmbientBuffer(offset, size);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyAmbient);
pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT,
size * PGL.SIZEOF_INT,
IntBuffer.wrap(tessGeo.polyAmbient, offset, size));
size * PGL.SIZEOF_INT, tessGeo.polyAmbientBuffer);
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
}
protected void copyPolySpecular(int offset, int size) {
tessGeo.updatePolySpecularBuffer(offset, size);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolySpecular);
pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT,
size * PGL.SIZEOF_INT,
IntBuffer.wrap(tessGeo.polySpecular, offset, size));
size * PGL.SIZEOF_INT, tessGeo.polySpecularBuffer);
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
}
protected void copyPolyEmissive(int offset, int size) {
tessGeo.updatePolyEmissiveBuffer(offset, size);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyEmissive);
pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT,
size * PGL.SIZEOF_INT,
IntBuffer.wrap(tessGeo.polyEmissive, offset, size));
size * PGL.SIZEOF_INT, tessGeo.polyEmissiveBuffer);
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
}
protected void copyPolyShininess(int offset, int size) {
tessGeo.updatePolyShininessBuffer(offset, size);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyShininess);
pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_FLOAT,
size * PGL.SIZEOF_FLOAT,
FloatBuffer.wrap(tessGeo.polyShininess, offset, size));
size * PGL.SIZEOF_FLOAT, tessGeo.polyShininessBuffer);
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
}
protected void copyLineVertices(int offset, int size) {
tessGeo.updateLineVerticesBuffer(offset, size);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glLineVertex);
pgl.bufferSubData(PGL.ARRAY_BUFFER, 4 * offset * PGL.SIZEOF_FLOAT,
4 * size * PGL.SIZEOF_FLOAT,
FloatBuffer.wrap(tessGeo.lineVertices,
4 * offset, 4 * size));
4 * size * PGL.SIZEOF_FLOAT, tessGeo.lineVerticesBuffer);
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
}
protected void copyLineColors(int offset, int size) {
tessGeo.updateLineColorsBuffer(offset, size);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glLineColor);
pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT,
size * PGL.SIZEOF_INT,
IntBuffer.wrap(tessGeo.lineColors, offset, size));
size * PGL.SIZEOF_INT, tessGeo.lineColorsBuffer);
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
}
protected void copyLineAttributes(int offset, int size) {
tessGeo.updateLineAttribsBuffer(offset, size);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glLineAttrib);
pgl.bufferSubData(PGL.ARRAY_BUFFER, 4 * offset * PGL.SIZEOF_FLOAT,
4 * size * PGL.SIZEOF_FLOAT,
FloatBuffer.wrap(tessGeo.lineAttribs,
4 * offset, 4 * size));
4 * size * PGL.SIZEOF_FLOAT, tessGeo.lineAttribsBuffer);
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
}
protected void copyPointVertices(int offset, int size) {
tessGeo.updatePointVerticesBuffer(offset, size);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPointVertex);
pgl.bufferSubData(PGL.ARRAY_BUFFER, 4 * offset * PGL.SIZEOF_FLOAT,
4 * size * PGL.SIZEOF_FLOAT,
FloatBuffer.wrap(tessGeo.pointVertices,
4 * offset, 4 * size));
4 * size * PGL.SIZEOF_FLOAT, tessGeo.pointVerticesBuffer);
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
}
protected void copyPointColors(int offset, int size) {
tessGeo.updatePointColorsBuffer(offset, size);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPointColor);
pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT,
size * PGL.SIZEOF_INT,
IntBuffer.wrap(tessGeo.pointColors, offset, size));
size * PGL.SIZEOF_INT,tessGeo.pointColorsBuffer);
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
}
protected void copyPointAttributes(int offset, int size) {
tessGeo.updatePointAttribsBuffer(offset, size);
pgl.bindBuffer(PGL.ARRAY_BUFFER, glPointAttrib);
pgl.bufferSubData(PGL.ARRAY_BUFFER, 2 * offset * PGL.SIZEOF_FLOAT,
2 * size * PGL.SIZEOF_FLOAT,
FloatBuffer.wrap(tessGeo.pointAttribs,
2 * offset, 2 * size));
2 * size * PGL.SIZEOF_FLOAT, tessGeo.pointAttribsBuffer);
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
}