aboutsummaryrefslogtreecommitdiffstats
path: root/src/ru/olamedia/geom/Mesh.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/ru/olamedia/geom/Mesh.java')
-rw-r--r--src/ru/olamedia/geom/Mesh.java26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/ru/olamedia/geom/Mesh.java b/src/ru/olamedia/geom/Mesh.java
index 7e25666..1ae7734 100644
--- a/src/ru/olamedia/geom/Mesh.java
+++ b/src/ru/olamedia/geom/Mesh.java
@@ -148,6 +148,7 @@ public class Mesh {
interleaved.addGLSLSubArray("mesh_vertices", 3, GL.GL_ARRAY_BUFFER);
interleaved.addGLSLSubArray("mesh_colors", 4, GL.GL_ARRAY_BUFFER);
interleaved.addGLSLSubArray("mesh_texCoord", 2, GL.GL_ARRAY_BUFFER);
+ interleaved.associate(getShader().getState(), true);
arrays.put(m, interleaved);
}
for (int n = 0; n < vertexCount; n++) {
@@ -272,10 +273,12 @@ public class Mesh {
if (useVbo) {
GL2ES2 gl = glx.getGL2ES2();
// GL2 gl = glx.getGL2();
- getShader().enable();
+ final Shader shader = getShader();
+ final ShaderState shaderState = shader.getState();
+ shader.enable();
Game.client.getScene().dayTime.getClearColor();
- getShader().getState().uniform(gl, pmvMatrixUniform);
- getShader().getState().uniform(gl, sunColor);
+ shaderState.uniform(gl, pmvMatrixUniform);
+ shaderState.uniform(gl, sunColor);
for (Integer m : materials.keySet()) {
gl.glActiveTexture(GL.GL_TEXTURE0);
gl.glBindTexture(GL.GL_TEXTURE_2D, (int) m);
@@ -287,15 +290,24 @@ public class Mesh {
// GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
// gl.glTexParameteri(GL.GL_TEXTURE_2D,
// GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR_MIPMAP_LINEAR);
- arrays.get(m).enableBuffer(gl, true);
+ final GLArrayDataServer ad = arrays.get(m);
+ ad.enableBuffer(gl, true);
gl.glEnable(GL.GL_CULL_FACE);
gl.glEnable(GL.GL_DEPTH_TEST);
// gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2.GL_FILL);
- gl.glDrawArrays(GL2.GL_QUADS, 0, arrays.get(m).getElementCount());
- arrays.get(m).enableBuffer(gl, false);
+ // FIXME: Use GL.GL_TRIANGLE_FAN or GL.GL_TRIANGLE_STRIP !!
+ final int vElems = ad.getElementCount();
+ if ( !gl.isGL2() ) {
+ for (int j = 0; j < vElems - 3; j += 4) {
+ gl.glDrawArrays(GL.GL_TRIANGLE_FAN, j, 4);
+ }
+ } else {
+ gl.glDrawArrays(GL2.GL_QUADS, 0, vElems);
+ }
+ ad.enableBuffer(gl, false);
// System.exit(0);
}
- getShader().disable();
+ shader.disable();
} else {
GL2 gl = glx.getGL2();
if (useDisplayList) {