nicer gl api

- java class name should suffice as namespace
- also use import static gl instance seems to work now with Gwt
This commit is contained in:
Hannes Janetzek
2014-10-04 06:48:18 +02:00
parent b2008aa086
commit 846d90f9fe
43 changed files with 2839 additions and 1491 deletions

View File

@@ -16,11 +16,13 @@
*/
package org.oscim.test.renderer;
import static org.oscim.backend.GLAdapter.gl;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import org.oscim.backend.GL20;
import org.oscim.backend.GL;
import org.oscim.core.MapPosition;
import org.oscim.map.Map;
import org.oscim.renderer.GLShader;
@@ -95,13 +97,13 @@ public class CustomRenderer extends LayerRenderer {
GLState.test(false, false);
// unbind previously bound VBOs
GL.glBindBuffer(GL20.GL_ARRAY_BUFFER, 0);
gl.bindBuffer(GL.ARRAY_BUFFER, 0);
// Load the vertex data
//mVertices.position(0);
GL.glVertexAttribPointer(hVertexPosition, 3, GL20.GL_FLOAT, false, 0, mVertices);
gl.vertexAttribPointer(hVertexPosition, 3, GL.FLOAT, false, 0, mVertices);
//mVertices.position(2);
//GL.glVertexAttribPointer(hVertexPosition, 2, GL20.GL_FLOAT, false, 4, mVertices);
//GL.vertexAttribPointer(hVertexPosition, 2, GL20.FLOAT, false, 4, mVertices);
GLState.enableVertexArrays(hVertexPosition, -1);
@@ -116,7 +118,7 @@ public class CustomRenderer extends LayerRenderer {
v.mvp.setAsUniform(hMatrixPosition);
// Draw the triangle
GL.glDrawArrays(GL20.GL_TRIANGLE_STRIP, 0, 4);
gl.drawArrays(GL.TRIANGLE_STRIP, 0, 4);
GLUtils.checkGlError("...");
}
@@ -129,9 +131,9 @@ public class CustomRenderer extends LayerRenderer {
return false;
// Handle for vertex position in shader
hVertexPosition = GL.glGetAttribLocation(programObject, "a_pos");
hVertexPosition = gl.getAttribLocation(programObject, "a_pos");
hMatrixPosition = GL.glGetUniformLocation(programObject, "u_mvp");
hMatrixPosition = gl.getUniformLocation(programObject, "u_mvp");
// Store the program object
mProgramObject = programObject;

View File

@@ -1,8 +1,10 @@
package org.oscim.test.renderer;
import static org.oscim.backend.GLAdapter.gl;
import java.nio.FloatBuffer;
import org.oscim.backend.GL20;
import org.oscim.backend.GL;
import org.oscim.backend.canvas.Color;
import org.oscim.gdx.GdxMap;
import org.oscim.gdx.GdxMapApp;
@@ -80,7 +82,7 @@ public class HexagonRenderTest extends GdxMap {
FloatBuffer buf = MapRenderer.getFloatBuffer(12);
buf.put(vertices);
mVBO = BufferObject.get(GL20.GL_ARRAY_BUFFER, 0);
mVBO = BufferObject.get(GL.ARRAY_BUFFER, 0);
mVBO.loadBufferData(buf.flip(), 12 * 4);
setReady(true);
@@ -99,7 +101,7 @@ public class HexagonRenderTest extends GdxMap {
mVBO.bind();
// set VBO vertex layout
GL.glVertexAttribPointer(hVertexPosition, 2, GL20.GL_FLOAT, false, 0, 0);
gl.vertexAttribPointer(hVertexPosition, 2, GL.FLOAT, false, 0, 0);
GLState.enableVertexArrays(hVertexPosition, -1);
@@ -118,7 +120,7 @@ public class HexagonRenderTest extends GdxMap {
float xx = x * 2 + (y % 2 == 0 ? 1 : 0);
float yy = y * h + h / 2;
GL.glUniform2f(hCenterPosition, xx * (mCellScale * 1.5f), yy * mCellScale);
gl.uniform2f(hCenterPosition, xx * (mCellScale * 1.5f), yy * mCellScale);
//float alpha = 1 + (float) Math.log10(FastMath.clamp(
// (float) Math.sqrt(xx * xx + yy * yy) / offset_y, 0.0f, 1.0f)) * 2;
@@ -141,7 +143,7 @@ public class HexagonRenderTest extends GdxMap {
GLUtils.setColor(hColorPosition, c, alpha);
GL.glDrawArrays(GL20.GL_TRIANGLE_FAN, 0, 6);
gl.drawArrays(GL.TRIANGLE_FAN, 0, 6);
}
}
@@ -152,8 +154,8 @@ public class HexagonRenderTest extends GdxMap {
float xx = x * 2 + (y % 2 == 0 ? 1 : 0);
float yy = y * h + h / 2;
GL.glUniform2f(hCenterPosition, xx * (mCellScale * 1.5f), yy * mCellScale);
GL.glDrawArrays(GL20.GL_LINE_LOOP, 0, 6);
gl.uniform2f(hCenterPosition, xx * (mCellScale * 1.5f), yy * mCellScale);
gl.drawArrays(GL.LINE_LOOP, 0, 6);
}
}
@@ -168,13 +170,13 @@ public class HexagonRenderTest extends GdxMap {
return false;
// Handle for vertex position in shader
hVertexPosition = GL.glGetAttribLocation(programObject, "a_pos");
hVertexPosition = gl.getAttribLocation(programObject, "a_pos");
hMatrixPosition = GL.glGetUniformLocation(programObject, "u_mvp");
hMatrixPosition = gl.getUniformLocation(programObject, "u_mvp");
hColorPosition = GL.glGetUniformLocation(programObject, "u_color");
hColorPosition = gl.getUniformLocation(programObject, "u_color");
hCenterPosition = GL.glGetUniformLocation(programObject, "u_center");
hCenterPosition = gl.getUniformLocation(programObject, "u_center");
// Store the program object
mProgramObject = programObject;