本文整理汇总了Java中org.oscim.renderer.GLState类的典型用法代码示例。如果您正苦于以下问题:Java GLState类的具体用法?Java GLState怎么用?Java GLState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GLState类属于org.oscim.renderer包,在下文中一共展示了GLState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: draw
import org.oscim.renderer.GLState; //导入依赖的package包/类
public static RenderBucket draw(RenderBucket l, GLViewport v) {
GLState.blend(true);
Shader s = shader;
s.set(v);
for (; l != null && l.type == HAIRLINE; l = l.next) {
HairLineBucket ll = (HairLineBucket) l;
GLUtils.setColor(s.uColor, ll.line.color, 1);
gl.vertexAttribPointer(s.aPos, 2, GL.SHORT,
false, 0, ll.vertexOffset);
gl.drawElements(GL.LINES,
ll.numIndices,
GL.UNSIGNED_SHORT,
ll.indiceOffset);
}
//GL.lineWidth(1);
return l;
}
示例2: initTexture
import org.oscim.renderer.GLState; //导入依赖的package包/类
protected void initTexture(TextureItem t) {
GLState.bindTex2D(t.id);
gl.texParameterf(GL.TEXTURE_2D, GL.TEXTURE_MIN_FILTER,
GL.LINEAR);
gl.texParameterf(GL.TEXTURE_2D, GL.TEXTURE_MAG_FILTER,
GL.LINEAR);
if (t.repeat) {
gl.texParameterf(GL.TEXTURE_2D, GL.TEXTURE_WRAP_S,
GL.REPEAT);
gl.texParameterf(GL.TEXTURE_2D, GL.TEXTURE_WRAP_T,
GL.REPEAT);
} else {
gl.texParameterf(GL.TEXTURE_2D, GL.TEXTURE_WRAP_S,
GL.CLAMP_TO_EDGE);
gl.texParameterf(GL.TEXTURE_2D, GL.TEXTURE_WRAP_T,
GL.CLAMP_TO_EDGE);
}
}
示例3: setColor
import org.oscim.renderer.GLState; //导入依赖的package包/类
static void setColor(AreaStyle a, Shader s, MapPosition pos) {
float fade = a.getFade(pos.scale);
float blend = a.getBlend(pos.scale);
if (fade < 1.0f) {
GLState.blend(true);
GLUtils.setColor(s.uColor, a.color, fade);
} else if (blend > 0.0f) {
if (blend == 1.0f)
GLUtils.setColor(s.uColor, a.blendColor, 1);
else
GLUtils.setColorBlend(s.uColor, a.color,
a.blendColor, blend);
} else {
/* test if color contains alpha */
GLState.blend((a.color & OPAQUE) != OPAQUE);
GLUtils.setColor(s.uColor, a.color, 1);
}
}
示例4: render
import org.oscim.renderer.GLState; //导入依赖的package包/类
@Override
public synchronized void render(MapPosition pos, Matrices m) {
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, layers.vbo.id);
GLState.test(false, false);
float scale = (float) (mMapPosition.scale / pos.scale);
if (layers.baseLayers != null) {
setMatrix(pos, m, true);
for (Layer l = layers.baseLayers; l != null;) {
if (l.type == Layer.POLYGON) {
l = PolygonRenderer.draw(pos, l, m, true, 1, false);
} else {
float div = scale * (float) (pos.scale / (1 << pos.zoomLevel));
l = LineRenderer.draw(layers, l, pos, m, div, 0);
}
}
}
setMatrix(pos, m, false);
for (Layer l = layers.textureLayers; l != null;)
l = TextureRenderer.draw(l, scale, m);
}
示例5: render
import org.oscim.renderer.GLState; //导入依赖的package包/类
@Override
public synchronized void render(MapPosition pos, Matrices m) {
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, layers.vbo.id);
GLState.test(false, false);
float scale = (float) (mMapPosition.scale / pos.scale);
setMatrix(pos, m, true);
if (layers.baseLayers != null) {
for (Layer l = layers.baseLayers; l != null;) {
if (l.type == Layer.POLYGON) {
l = PolygonRenderer.draw(pos, l, m, true, 1, false);
} else {
float div = scale * (float) (pos.scale / (1 << pos.zoomLevel));
l = LineRenderer.draw(layers, l, pos, m, div, 0);
}
}
}
setMatrix(pos, m, false);
for (Layer l = layers.textureLayers; l != null;)
l = TextureRenderer.draw(l, scale, m);
}
示例6: render
import org.oscim.renderer.GLState; //导入依赖的package包/类
@Override
public void render(GLViewport v) {
GLState.useProgram(mShaderProgram);
GLState.blend(true);
GLState.test(false, false);
GLState.enableVertexArrays(hVertexPosition, -1);
MapRenderer.bindQuadVertexVBO(hVertexPosition);
if (mRunAnim) {
float alpha = 1f - animPhase();
if (alpha > mAlpha || alpha < 0.01f) {
mAlpha = 0f;
animate(false);
} else {
mAlpha = alpha;
}
}
v.mvp.setTransScale(0f, 0f, 1);
// use v.viewproj to honor rotation ant tilt, or v.proj otherwise
v.mvp.multiplyMM(v.proj, v.mvp);
v.mvp.setAsUniform(hMatrixPosition);
gl.uniform1f(hScale, mScale);
GLUtils.setColor(hColor, mColor, mAlpha);
gl.drawArrays(GL.TRIANGLE_STRIP, 0, 4);
}
示例7: set
import org.oscim.renderer.GLState; //导入依赖的package包/类
public void set(GLViewport v) {
useProgram();
GLState.enableVertexArrays(aPos, -1);
v.mvp.setAsUniform(uMVP);
gl.uniform2f(uScreen, v.getWidth() / 2, v.getHeight() / 2);
gl.uniform1f(uWidth, 1.5f);
gl.lineWidth(2);
}
示例8: setShader
import org.oscim.renderer.GLState; //导入依赖的package包/类
private static Shader setShader(Shader shader, GLMatrix mvp, boolean first) {
if (shader.useProgram() || first) {
GLState.enableVertexArrays(shader.aPos, -1);
gl.vertexAttribPointer(shader.aPos, 2,
GL.SHORT, false, 0, 0);
mvp.setAsUniform(shader.uMVP);
}
return shader;
}
示例9: drawOver
import org.oscim.renderer.GLState; //导入依赖的package包/类
/**
* Clear stencilbuffer for a tile region by drawing
* a quad with func 'always' and op 'zero'. Using 'color'
* and 'alpha' to fake a fade effect.
*/
public static void drawOver(GLMatrix mvp, int color, float alpha) {
/* TODO true could be avoided when same shader and vbo */
setShader(polyShader, mvp, true);
if (color == 0) {
gl.colorMask(false, false, false, false);
} else {
GLUtils.setColor(polyShader.uColor, color, alpha);
GLState.blend(true);
}
// TODO always pass stencil test: <-- only if not proxy?
//GL.stencilFunc(GL20.ALWAYS, 0x00, 0x00);
gl.stencilFunc(GL.EQUAL, CLIP_BIT, CLIP_BIT);
/* write to all bits */
gl.stencilMask(0xFF);
// FIXME uneeded probably
GLState.test(false, true);
/* zero out area to draw to */
gl.stencilOp(GL.KEEP, GL.KEEP, GL.ZERO);
gl.drawArrays(GL.TRIANGLE_STRIP, 0, 4);
if (color == 0)
gl.colorMask(true, true, true, true);
}
示例10: bind
import org.oscim.renderer.GLState; //导入依赖的package包/类
/**
* Bind Texture for rendering
* [on GL-Thread]
*/
public void bind() {
if (loaded)
GLState.bindTex2D(id);
else
upload();
}
示例11: uploadTexture
import org.oscim.renderer.GLState; //导入依赖的package包/类
private void uploadTexture(TextureItem t) {
if (t.bitmap == null)
throw new RuntimeException("Missing bitmap for texture");
if (t.id < 0) {
int[] textureIds = GLUtils.glGenTextures(1);
t.id = textureIds[0];
initTexture(t);
if (dbg)
log.debug("fill:" + getFill()
+ " count:" + mTexCnt
+ " new texture " + t.id);
mTexCnt++;
t.bitmap.uploadToTexture(false);
} else {
GLState.bindTex2D(t.id);
/* use faster subimage upload */
t.bitmap.uploadToTexture(true);
}
if (dbg)
GLUtils.checkGlError(TextureItem.class.getName());
if (mUseBitmapPool)
releaseBitmap(t);
}
示例12: init
import org.oscim.renderer.GLState; //导入依赖的package包/类
public static void init() {
shader = new Shader("linetex_layer");
int[] vboIds = GLUtils.glGenBuffers(1);
mVertexFlipID = vboIds[0];
/* bytes: 0, 1, 0, 1, 0, ... */
byte[] flip = new byte[MapRenderer.MAX_QUADS * 4];
for (int i = 0; i < flip.length; i++)
flip[i] = (byte) (i % 2);
ByteBuffer buf = ByteBuffer.allocateDirect(flip.length)
.order(ByteOrder.nativeOrder());
buf.put(flip);
buf.flip();
ShortBuffer sbuf = buf.asShortBuffer();
//GL.bindBuffer(GL20.ARRAY_BUFFER, mVertexFlipID);
GLState.bindVertexBuffer(mVertexFlipID);
gl.bufferData(GL.ARRAY_BUFFER, flip.length, sbuf,
GL.STATIC_DRAW);
GLState.bindVertexBuffer(0);
// mTexID = new int[10];
// byte[] stipple = new byte[2];
// stipple[0] = 32;
// stipple[1] = 32;
// mTexID[0] = GlUtils.loadStippleTexture(stipple);
}
示例13: useProgram
import org.oscim.renderer.GLState; //导入依赖的package包/类
@Override
public boolean useProgram() {
if (super.useProgram()) {
GLState.enableVertexArrays(aPos, aTexCoord);
return true;
}
return false;
}
示例14: draw
import org.oscim.renderer.GLState; //导入依赖的package包/类
public static RenderBucket draw(RenderBucket b, GLViewport v,
float scale, float alpha) {
GLState.blend(true);
Shader s = shader;
s.useProgram();
TextureBucket tb = (TextureBucket) b;
gl.uniform1f(s.uAlpha, alpha);
v.mvp.setAsUniform(s.uMVP);
bindQuadIndicesVBO();
for (TextureItem t = tb.textures; t != null; t = t.next) {
t.bind();
for (int i = 0; i < t.indices; i += MAX_INDICES) {
/* to.offset * (24(shorts) *
* 2(short-bytes) / 6(indices) == 8) */
int off = (t.offset + i) * 8 + tb.vertexOffset;
gl.vertexAttribPointer(s.aPos, 2,
GL.SHORT, false, 12, off);
gl.vertexAttribPointer(s.aTexCoord, 2,
GL.SHORT, false, 12, off + 8);
int numIndices = t.indices - i;
if (numIndices > MAX_INDICES)
numIndices = MAX_INDICES;
gl.drawElements(GL.TRIANGLES, numIndices,
GL.UNSIGNED_SHORT, 0);
}
}
return b.next;
}
示例15: draw
import org.oscim.renderer.GLState; //导入依赖的package包/类
public static RenderBucket draw(RenderBucket b, GLViewport v, float scale) {
GLState.test(false, false);
GLState.blend(true);
shader.useProgram();
TextureBucket tb = (TextureBucket) b;
gl.uniform1f(shader.uScale, tb.fixed ? 1 / scale : 1);
v.proj.setAsUniform(shader.uProj);
v.mvp.setAsUniform(shader.uMV);
MapRenderer.bindQuadIndicesVBO();
for (TextureItem t = tb.textures; t != null; t = t.next) {
gl.uniform2f(shader.uTexSize,
1f / (t.width * COORD_SCALE),
1f / (t.height * COORD_SCALE));
t.bind();
/* draw up to maxVertices in each iteration */
for (int i = 0; i < t.indices; i += MAX_INDICES) {
/* to.offset * (24(shorts) * 2(short-bytes)
* / 6(indices) == 8) */
int off = (t.offset + i) * 8 + tb.vertexOffset;
int numIndices = t.indices - i;
if (numIndices > MAX_INDICES)
numIndices = MAX_INDICES;
tb.render(off, numIndices);
}
}
return b.next;
}