GLState: State DISABLED = -1 (readability).
This commit is contained in:
parent
f07de4c910
commit
63cd462109
@ -86,7 +86,7 @@ public class GdxSpriteBatchTest extends GdxMapApp {
|
|||||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT | (Gdx.graphics.getBufferFormat().coverageSampling ?
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT | (Gdx.graphics.getBufferFormat().coverageSampling ?
|
||||||
GL20.GL_COVERAGE_BUFFER_BIT_NV : 0));
|
GL20.GL_COVERAGE_BUFFER_BIT_NV : 0));
|
||||||
|
|
||||||
GLState.enableVertexArrays(-1, -1);
|
GLState.enableVertexArrays(GLState.DISABLED, GLState.DISABLED);
|
||||||
|
|
||||||
gl.viewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
gl.viewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
gl.frontFace(GL.CW);
|
gl.frontFace(GL.CW);
|
||||||
|
@ -104,9 +104,9 @@ public class GdxModelRenderer extends LayerRenderer {
|
|||||||
|
|
||||||
// set state that is expected after modelBatch.end();
|
// set state that is expected after modelBatch.end();
|
||||||
// modelBatch keeps track of its own state
|
// modelBatch keeps track of its own state
|
||||||
GLState.enableVertexArrays(-1, -1);
|
GLState.enableVertexArrays(GLState.DISABLED, GLState.DISABLED);
|
||||||
GLState.bindTex2D(-1);
|
GLState.bindTex2D(GLState.DISABLED);
|
||||||
GLState.useProgram(-1);
|
GLState.useProgram(GLState.DISABLED);
|
||||||
GLState.test(false, false);
|
GLState.test(false, false);
|
||||||
GLState.blend(false);
|
GLState.blend(false);
|
||||||
|
|
||||||
|
@ -105,9 +105,9 @@ public class GdxRenderer3D extends LayerRenderer {
|
|||||||
|
|
||||||
// set state that is expected after modelBatch.end();
|
// set state that is expected after modelBatch.end();
|
||||||
// modelBatch keeps track of its own state
|
// modelBatch keeps track of its own state
|
||||||
GLState.enableVertexArrays(-1, -1);
|
GLState.enableVertexArrays(GLState.DISABLED, GLState.DISABLED);
|
||||||
GLState.bindTex2D(-1);
|
GLState.bindTex2D(GLState.DISABLED);
|
||||||
GLState.useProgram(-1);
|
GLState.useProgram(GLState.DISABLED);
|
||||||
GLState.test(false, false);
|
GLState.test(false, false);
|
||||||
GLState.blend(false);
|
GLState.blend(false);
|
||||||
|
|
||||||
|
@ -95,9 +95,9 @@ public class GdxRenderer3D2 extends LayerRenderer {
|
|||||||
|
|
||||||
// set state that is expected after modelBatch.end();
|
// set state that is expected after modelBatch.end();
|
||||||
// modelBatch keeps track of its own state
|
// modelBatch keeps track of its own state
|
||||||
GLState.enableVertexArrays(-1, -1);
|
GLState.enableVertexArrays(GLState.DISABLED, GLState.DISABLED);
|
||||||
GLState.bindTex2D(-1);
|
GLState.bindTex2D(GLState.DISABLED);
|
||||||
GLState.useProgram(-1);
|
GLState.useProgram(GLState.DISABLED);
|
||||||
GLState.test(false, false);
|
GLState.test(false, false);
|
||||||
GLState.blend(false);
|
GLState.blend(false);
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ public class CustomRenderer extends LayerRenderer {
|
|||||||
//mVertices.position(2);
|
//mVertices.position(2);
|
||||||
//GL.vertexAttribPointer(hVertexPosition, 2, GL20.FLOAT, false, 4, mVertices);
|
//GL.vertexAttribPointer(hVertexPosition, 2, GL20.FLOAT, false, 4, mVertices);
|
||||||
|
|
||||||
GLState.enableVertexArrays(hVertexPosition, -1);
|
GLState.enableVertexArrays(hVertexPosition, GLState.DISABLED);
|
||||||
|
|
||||||
/* apply view and projection matrices */
|
/* apply view and projection matrices */
|
||||||
// set mvp (tmp) matrix relative to mMapPosition
|
// set mvp (tmp) matrix relative to mMapPosition
|
||||||
|
@ -119,7 +119,7 @@ public class HexagonRenderTest extends GdxMapApp {
|
|||||||
// set VBO vertex layout
|
// set VBO vertex layout
|
||||||
gl.vertexAttribPointer(hVertexPosition, 2, GL.FLOAT, false, 0, 0);
|
gl.vertexAttribPointer(hVertexPosition, 2, GL.FLOAT, false, 0, 0);
|
||||||
|
|
||||||
GLState.enableVertexArrays(hVertexPosition, -1);
|
GLState.enableVertexArrays(hVertexPosition, GLState.DISABLED);
|
||||||
|
|
||||||
/* apply view and projection matrices */
|
/* apply view and projection matrices */
|
||||||
// set mvp (tmp) matrix relative to mMapPosition
|
// set mvp (tmp) matrix relative to mMapPosition
|
||||||
|
@ -112,7 +112,7 @@ public abstract class ExtrusionRenderer extends LayerRenderer {
|
|||||||
|
|
||||||
Shader s = mShader;
|
Shader s = mShader;
|
||||||
s.useProgram();
|
s.useProgram();
|
||||||
GLState.enableVertexArrays(s.aPos, -1);
|
GLState.enableVertexArrays(s.aPos, GLState.DISABLED);
|
||||||
|
|
||||||
/* only use face-culling when it's unlikely
|
/* only use face-culling when it's unlikely
|
||||||
* that one'moves through the building' */
|
* that one'moves through the building' */
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 Hannes Janetzek
|
* Copyright 2013 Hannes Janetzek
|
||||||
* Copyright 2016 devemux86
|
* Copyright 2016 devemux86
|
||||||
|
* Copyright 2018 Gustl22
|
||||||
*
|
*
|
||||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||||
*
|
*
|
||||||
@ -27,6 +28,8 @@ import static org.oscim.backend.GLAdapter.gl;
|
|||||||
public class GLState {
|
public class GLState {
|
||||||
static final Logger log = LoggerFactory.getLogger(GLState.class);
|
static final Logger log = LoggerFactory.getLogger(GLState.class);
|
||||||
|
|
||||||
|
public final static int DISABLED = -1;
|
||||||
|
|
||||||
private final static boolean[] vertexArray = {false, false};
|
private final static boolean[] vertexArray = {false, false};
|
||||||
private static boolean blend = false;
|
private static boolean blend = false;
|
||||||
private static boolean depth = false;
|
private static boolean depth = false;
|
||||||
@ -44,10 +47,10 @@ public class GLState {
|
|||||||
blend = false;
|
blend = false;
|
||||||
depth = false;
|
depth = false;
|
||||||
stencil = false;
|
stencil = false;
|
||||||
shader = -1;
|
shader = DISABLED;
|
||||||
currentTexId = -1;
|
currentTexId = DISABLED;
|
||||||
glVertexBuffer = -1;
|
glVertexBuffer = DISABLED;
|
||||||
glIndexBuffer = -1;
|
glIndexBuffer = DISABLED;
|
||||||
clearColor = null;
|
clearColor = null;
|
||||||
|
|
||||||
gl.disable(GL.STENCIL_TEST);
|
gl.disable(GL.STENCIL_TEST);
|
||||||
@ -57,7 +60,7 @@ public class GLState {
|
|||||||
|
|
||||||
public static boolean useProgram(int shaderProgram) {
|
public static boolean useProgram(int shaderProgram) {
|
||||||
if (shaderProgram < 0) {
|
if (shaderProgram < 0) {
|
||||||
shader = -1;
|
shader = DISABLED;
|
||||||
} else if (shaderProgram != shader) {
|
} else if (shaderProgram != shader) {
|
||||||
gl.useProgram(shaderProgram);
|
gl.useProgram(shaderProgram);
|
||||||
shader = shaderProgram;
|
shader = shaderProgram;
|
||||||
@ -111,6 +114,13 @@ public class GLState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable or disable vertex arrays.
|
||||||
|
* Valid values are
|
||||||
|
* -1: {@link #DISABLED},
|
||||||
|
* 0: enable first,
|
||||||
|
* 1: enable second.
|
||||||
|
*/
|
||||||
public static void enableVertexArrays(int va1, int va2) {
|
public static void enableVertexArrays(int va1, int va2) {
|
||||||
if (va1 > 1 || va2 > 1)
|
if (va1 > 1 || va2 > 1)
|
||||||
log.debug("FIXME: enableVertexArrays...");
|
log.debug("FIXME: enableVertexArrays...");
|
||||||
|
@ -225,7 +225,7 @@ public class LocationRenderer extends LayerRenderer {
|
|||||||
GLState.blend(true);
|
GLState.blend(true);
|
||||||
GLState.test(false, false);
|
GLState.test(false, false);
|
||||||
|
|
||||||
GLState.enableVertexArrays(hVertexPosition, -1);
|
GLState.enableVertexArrays(hVertexPosition, GLState.DISABLED);
|
||||||
MapRenderer.bindQuadVertexVBO(hVertexPosition/*, true*/);
|
MapRenderer.bindQuadVertexVBO(hVertexPosition/*, true*/);
|
||||||
|
|
||||||
float radius = CIRCLE_SIZE * mScale;
|
float radius = CIRCLE_SIZE * mScale;
|
||||||
|
@ -297,7 +297,7 @@ public class LocationTextureRenderer extends BucketRenderer {
|
|||||||
GLState.blend(true);
|
GLState.blend(true);
|
||||||
GLState.test(false, false);
|
GLState.test(false, false);
|
||||||
|
|
||||||
GLState.enableVertexArrays(hVertexPosition, -1);
|
GLState.enableVertexArrays(hVertexPosition, GLState.DISABLED);
|
||||||
MapRenderer.bindQuadVertexVBO(hVertexPosition/*, true*/);
|
MapRenderer.bindQuadVertexVBO(hVertexPosition/*, true*/);
|
||||||
|
|
||||||
float radius = 10;
|
float radius = 10;
|
||||||
|
@ -117,10 +117,10 @@ public class MapRenderer {
|
|||||||
|
|
||||||
GLState.test(false, false);
|
GLState.test(false, false);
|
||||||
GLState.blend(false);
|
GLState.blend(false);
|
||||||
GLState.bindTex2D(-1);
|
GLState.bindTex2D(GLState.DISABLED);
|
||||||
GLState.useProgram(-1);
|
GLState.useProgram(GLState.DISABLED);
|
||||||
GLState.bindElementBuffer(-1);
|
GLState.bindElementBuffer(GLState.DISABLED);
|
||||||
GLState.bindVertexBuffer(-1);
|
GLState.bindVertexBuffer(GLState.DISABLED);
|
||||||
|
|
||||||
mViewport.setFrom(mMap);
|
mViewport.setFrom(mMap);
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ public class MapRenderer {
|
|||||||
|
|
||||||
if (location >= 0) {
|
if (location >= 0) {
|
||||||
GLState.bindVertexBuffer(mQuadVerticesID);
|
GLState.bindVertexBuffer(mQuadVerticesID);
|
||||||
GLState.enableVertexArrays(location, -1);
|
GLState.enableVertexArrays(location, GLState.DISABLED);
|
||||||
gl.vertexAttribPointer(location, 2, GL.FLOAT, false, 0, 0);
|
gl.vertexAttribPointer(location, 2, GL.FLOAT, false, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ public class CircleBucket extends RenderBucket {
|
|||||||
|
|
||||||
public void set(GLViewport v) {
|
public void set(GLViewport v) {
|
||||||
useProgram();
|
useProgram();
|
||||||
GLState.enableVertexArrays(aPos, -1);
|
GLState.enableVertexArrays(aPos, GLState.DISABLED);
|
||||||
|
|
||||||
v.mvp.setAsUniform(uMVP);
|
v.mvp.setAsUniform(uMVP);
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ public class HairLineBucket extends RenderBucket {
|
|||||||
|
|
||||||
public void set(GLViewport v) {
|
public void set(GLViewport v) {
|
||||||
useProgram();
|
useProgram();
|
||||||
GLState.enableVertexArrays(aPos, -1);
|
GLState.enableVertexArrays(aPos, GLState.DISABLED);
|
||||||
|
|
||||||
v.mvp.setAsUniform(uMVP);
|
v.mvp.setAsUniform(uMVP);
|
||||||
|
|
||||||
|
@ -523,7 +523,7 @@ public class LineBucket extends RenderBucket {
|
|||||||
@Override
|
@Override
|
||||||
public boolean useProgram() {
|
public boolean useProgram() {
|
||||||
if (super.useProgram()) {
|
if (super.useProgram()) {
|
||||||
GLState.enableVertexArrays(aPos, -1);
|
GLState.enableVertexArrays(aPos, GLState.DISABLED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -353,7 +353,7 @@ public final class LineTexBucket extends LineBucket {
|
|||||||
GLState.blend(true);
|
GLState.blend(true);
|
||||||
shader.useProgram();
|
shader.useProgram();
|
||||||
|
|
||||||
GLState.enableVertexArrays(-1, -1);
|
GLState.enableVertexArrays(GLState.DISABLED, GLState.DISABLED);
|
||||||
|
|
||||||
int aLen0 = shader.aLen0;
|
int aLen0 = shader.aLen0;
|
||||||
int aLen1 = shader.aLen1;
|
int aLen1 = shader.aLen1;
|
||||||
|
@ -174,7 +174,7 @@ public class MeshBucket extends RenderBucket {
|
|||||||
Shader s = shader;
|
Shader s = shader;
|
||||||
|
|
||||||
s.useProgram();
|
s.useProgram();
|
||||||
GLState.enableVertexArrays(s.aPos, -1);
|
GLState.enableVertexArrays(s.aPos, GLState.DISABLED);
|
||||||
|
|
||||||
v.mvp.setAsUniform(s.uMVP);
|
v.mvp.setAsUniform(s.uMVP);
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ public final class PolygonBucket extends RenderBucket {
|
|||||||
|
|
||||||
private static Shader setShader(Shader shader, GLMatrix mvp, boolean first) {
|
private static Shader setShader(Shader shader, GLMatrix mvp, boolean first) {
|
||||||
if (shader.useProgram() || first) {
|
if (shader.useProgram() || first) {
|
||||||
GLState.enableVertexArrays(shader.aPos, -1);
|
GLState.enableVertexArrays(shader.aPos, GLState.DISABLED);
|
||||||
|
|
||||||
gl.vertexAttribPointer(shader.aPos, 2,
|
gl.vertexAttribPointer(shader.aPos, 2,
|
||||||
GL.SHORT, false, 0, 0);
|
GL.SHORT, false, 0, 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user