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:
@@ -1,6 +1,8 @@
|
||||
package org.oscim.test.gdx.poi3d;
|
||||
|
||||
import org.oscim.backend.GL20;
|
||||
import static org.oscim.backend.GLAdapter.gl;
|
||||
|
||||
import org.oscim.backend.GL;
|
||||
import org.oscim.core.Tile;
|
||||
import org.oscim.map.Map;
|
||||
import org.oscim.map.Viewport;
|
||||
@@ -93,12 +95,12 @@ public class GdxModelRenderer extends LayerRenderer {
|
||||
|
||||
// GLUtils.checkGlError(">" + TAG);
|
||||
|
||||
GL.glDepthMask(true);
|
||||
gl.depthMask(true);
|
||||
|
||||
if (v.pos.zoomLevel < 16)
|
||||
GL.glClear(GL20.GL_DEPTH_BUFFER_BIT);
|
||||
gl.clear(GL.DEPTH_BUFFER_BIT);
|
||||
|
||||
GL.glBindBuffer(GL20.GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, 0);
|
||||
|
||||
// set state that is expected after modelBatch.end();
|
||||
// modelBatch keeps track of its own state
|
||||
@@ -168,9 +170,9 @@ public class GdxModelRenderer extends LayerRenderer {
|
||||
//renderContext.end();
|
||||
}
|
||||
|
||||
GL.glDepthMask(false);
|
||||
GL.glBindBuffer(GL20.GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
GL.glBindBuffer(GL20.GL_ARRAY_BUFFER, 0);
|
||||
gl.depthMask(false);
|
||||
gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, 0);
|
||||
gl.bindBuffer(GL.ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
// @Override
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.oscim.test.gdx.poi3d;
|
||||
|
||||
import org.oscim.backend.GL20;
|
||||
import static org.oscim.backend.GLAdapter.gl;
|
||||
|
||||
import org.oscim.backend.GL;
|
||||
import org.oscim.core.Tile;
|
||||
import org.oscim.map.Map;
|
||||
import org.oscim.map.Viewport;
|
||||
@@ -94,12 +96,12 @@ public class GdxRenderer3D extends LayerRenderer {
|
||||
|
||||
// GLUtils.checkGlError(">" + TAG);
|
||||
|
||||
GL.glDepthMask(true);
|
||||
gl.depthMask(true);
|
||||
|
||||
// if (position.zoomLevel < 17)
|
||||
// GL.glClear(GL20.GL_DEPTH_BUFFER_BIT);
|
||||
// GL.clear(GL20.DEPTH_BUFFER_BIT);
|
||||
|
||||
GL.glBindBuffer(GL20.GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, 0);
|
||||
|
||||
// set state that is expected after modelBatch.end();
|
||||
// modelBatch keeps track of its own state
|
||||
@@ -182,9 +184,9 @@ public class GdxRenderer3D extends LayerRenderer {
|
||||
}
|
||||
log.debug(">>> " + (System.currentTimeMillis() - time) + " " + cnt + "/" + rnd);
|
||||
|
||||
GL.glDepthMask(false);
|
||||
GL.glBindBuffer(GL20.GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
GL.glBindBuffer(GL20.GL_ARRAY_BUFFER, 0);
|
||||
gl.depthMask(false);
|
||||
gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, 0);
|
||||
gl.bindBuffer(GL.ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
// @Override
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.oscim.test.gdx.poi3d;
|
||||
|
||||
import org.oscim.backend.GL20;
|
||||
import static org.oscim.backend.GLAdapter.gl;
|
||||
|
||||
import org.oscim.backend.GL;
|
||||
import org.oscim.core.Tile;
|
||||
import org.oscim.map.Map;
|
||||
import org.oscim.map.Viewport;
|
||||
@@ -84,12 +86,12 @@ public class GdxRenderer3D2 extends LayerRenderer {
|
||||
|
||||
// GLUtils.checkGlError(">" + TAG);
|
||||
|
||||
GL.glDepthMask(true);
|
||||
gl.depthMask(true);
|
||||
|
||||
if (v.pos.zoomLevel < 17)
|
||||
GL.glClear(GL20.GL_DEPTH_BUFFER_BIT);
|
||||
gl.clear(GL.DEPTH_BUFFER_BIT);
|
||||
|
||||
GL.glBindBuffer(GL20.GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, 0);
|
||||
|
||||
// set state that is expected after modelBatch.end();
|
||||
// modelBatch keeps track of its own state
|
||||
@@ -99,8 +101,8 @@ public class GdxRenderer3D2 extends LayerRenderer {
|
||||
GLState.test(false, false);
|
||||
GLState.blend(false);
|
||||
|
||||
// GL.glCullFace(GL20.GL_BACK);
|
||||
// GL.glFrontFace(GL20.GL_CW);
|
||||
// GL.cullFace(GL20.BACK);
|
||||
// GL.frontFace(GL20.CW);
|
||||
|
||||
cam.update(v);
|
||||
long time = System.currentTimeMillis();
|
||||
@@ -145,9 +147,9 @@ public class GdxRenderer3D2 extends LayerRenderer {
|
||||
|
||||
// GLUtils.checkGlError("<" + TAG);
|
||||
|
||||
GL.glDepthMask(false);
|
||||
GL.glBindBuffer(GL20.GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
GL.glBindBuffer(GL20.GL_ARRAY_BUFFER, 0);
|
||||
gl.depthMask(false);
|
||||
gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, 0);
|
||||
gl.bindBuffer(GL.ARRAY_BUFFER, 0);
|
||||
|
||||
// GLState.bindTex2D(-1);
|
||||
// GLState.useProgram(-1);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user