本文整理汇总了Java中org.oscim.renderer.GLState.useProgram方法的典型用法代码示例。如果您正苦于以下问题:Java GLState.useProgram方法的具体用法?Java GLState.useProgram怎么用?Java GLState.useProgram使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.oscim.renderer.GLState
的用法示例。
在下文中一共展示了GLState.useProgram方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: render
import org.oscim.renderer.GLState; //导入方法依赖的package包/类
@Override
public void render(GLViewport v) {
// Use the program object
GLState.useProgram(mProgramObject);
GLState.blend(true);
GLState.test(false, false);
// unbind previously bound VBOs
gl.bindBuffer(GL.ARRAY_BUFFER, 0);
// Load the vertex data
//mVertices.position(0);
gl.vertexAttribPointer(hVertexPosition, 3, GL.FLOAT, false, 0, mVertices);
//mVertices.position(2);
//GL.vertexAttribPointer(hVertexPosition, 2, GL20.FLOAT, false, 4, mVertices);
GLState.enableVertexArrays(hVertexPosition, -1);
/* apply view and projection matrices */
// set mvp (tmp) matrix relative to mMapPosition
// i.e. fixed on the map
float ratio = 1f / mMap.getWidth();
v.mvp.setScale(ratio, ratio, 1);
v.mvp.multiplyLhs(v.proj);
v.mvp.setAsUniform(hMatrixPosition);
// Draw the triangle
gl.drawArrays(GL.TRIANGLE_STRIP, 0, 4);
GLUtils.checkGlError("...");
}
示例3: render
import org.oscim.renderer.GLState; //导入方法依赖的package包/类
@Override
public void render(MapPosition pos, Matrices m) {
// Use the program object
GLState.useProgram(mProgramObject);
GLState.blend(true);
GLState.test(false, false);
// unbind previously bound VBOs
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
// Load the vertex data
//mVertices.position(0);
GLES20.glVertexAttribPointer(hVertexPosition, 3, GLES20.GL_FLOAT, false, 0, mVertices);
//mVertices.position(2);
//GLES20.glVertexAttribPointer(hVertexPosition, 2, GLES20.GL_FLOAT, false, 4, mVertices);
GLState.enableVertexArrays(hVertexPosition, -1);
/* apply view and projection matrices */
// set mvp (tmp) matrix relative to mMapPosition
// i.e. fixed on the map
float ratio = 1f / mMapView.getWidth();
m.mvp.setScale(ratio, ratio, 1);
m.mvp.multiplyLhs(m.proj);
m.mvp.setAsUniform(hMatrixPosition);
// Draw the triangle
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
GlUtils.checkGlError("...");
}
示例4: setShader
import org.oscim.renderer.GLState; //导入方法依赖的package包/类
private static void setShader(int shader, Matrices m) {
//if (
GLState.useProgram(polygonProgram[shader]);
// ) {
GLState.enableVertexArrays(hPolygonVertexPosition[shader], -1);
glVertexAttribPointer(hPolygonVertexPosition[shader], 2, GL_SHORT,
false, 0, POLYGON_VERTICES_DATA_POS_OFFSET);
m.mvp.setAsUniform(hPolygonMatrix[shader]);
//}
}
示例5: debugDraw
import org.oscim.renderer.GLState; //导入方法依赖的package包/类
static void debugDraw(Matrix4 m, float[] coords, int color) {
GLState.test(false, false);
if (mDebugFill == null) {
mDebugFill = ByteBuffer.allocateDirect(32).order(ByteOrder.nativeOrder())
.asFloatBuffer();
mDebugFill.put(coords);
}
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
mDebugFill.position(0);
GLState.useProgram(polygonProgram[0]);
GLES20.glEnableVertexAttribArray(hPolygonVertexPosition[0]);
glVertexAttribPointer(hPolygonVertexPosition[0], 2, GLES20.GL_FLOAT,
false, 0, mDebugFill);
m.setAsUniform(hPolygonMatrix[0]);
if (color == 0)
glUniform4fv(hPolygonColor[0], 1, debugFillColor, 0);
else
glUniform4fv(hPolygonColor[0], 1, debugFillColor2, 0);
glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
GlUtils.checkGlError("draw debug");
}
示例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);
double x = mIndicatorPosition.x - v.pos.x;
double y = mIndicatorPosition.y - v.pos.y;
double tileScale = Tile.SIZE * v.pos.scale;
v.mvp.setTransScale((float) (x * tileScale), (float) (y * tileScale), 1);
v.mvp.multiplyMM(v.viewproj, v.mvp);
v.mvp.setAsUniform(hMatrixPosition);
gl.uniform1f(hScale, mScale);
if (mLocationIsVisible) {
animate(false);
gl.uniform1f(hPhase, 1);
float rotation = mBearing - 90;
if (rotation > 180)
rotation -= 360;
else if (rotation < -180)
rotation += 360;
gl.uniform2f(hDirection,
(float) Math.cos(Math.toRadians(rotation)),
(float) Math.sin(Math.toRadians(rotation)));
} else {
animate(true);
float phase = Math.abs(animPhase() - 0.5f) * 2;
phase = Interpolation.swing.apply(phase);
gl.uniform1f(hPhase, 0.8f + phase * 0.2f);
gl.uniform2f(hDirection, 0, 0);
}
// Pointer type
gl.uniform1f(hType, 0);
gl.drawArrays(GL.TRIANGLE_STRIP, 0, 4);
}
示例7: render
import org.oscim.renderer.GLState; //导入方法依赖的package包/类
@Override
public void render(GLViewport v) {
GLState.useProgram(shader);
GLState.blend(true);
GLState.test(false, false);
GL.glBindBuffer(GL20.GL_ARRAY_BUFFER, 0);
FloatBuffer mVertices;
final float[] mVerticesData = {
-0.4f, 0.0f, 0.0f,
-0.9f, 0.7f, 0.0f,
1.0f, 0.0f, 0.0f,
-0.9f, -0.7f, 0.0f,
};
mVertices = ByteBuffer.allocateDirect(mVerticesData.length * 4)
.order(ByteOrder.nativeOrder()).asFloatBuffer();
mVertices.clear();
mVertices.put(mVerticesData);
mVertices.flip();
GL.glVertexAttribPointer(vertexPosition, 3, GL20.GL_FLOAT, false, 0, mVertices);
GLState.enableVertexArrays(vertexPosition, -1);
GL.glUniform1f(rotation, degrees);
float scaleValue = SCALE_FACTOR * v.pos.getZoomLevel();
if (scaleValue > MAX_SCALE) {
scaleValue = MAX_SCALE;
} else if (scaleValue < MIN_SCALE) {
scaleValue = MIN_SCALE;
}
GL.glUniform1f(scale, scaleValue);
double x = indicatorPosition.x - v.pos.x;
double y = indicatorPosition.y - v.pos.y;
double tileScale = Tile.SIZE * v.pos.scale;
v.mvp.setTransScale((float) (x * tileScale), (float) (y * tileScale), 1);
v.mvp.multiplyMM(v.viewproj, v.mvp);
v.mvp.setAsUniform(matrixPosition);
if (visible > 1) {
GL.glDrawArrays(GL20.GL_TRIANGLE_FAN, 0, 4);
}
}
示例8: render
import org.oscim.renderer.GLState; //导入方法依赖的package包/类
@Override
public void render(GLViewport v) {
if (instances.size == 0)
return;
// GLUtils.checkGlError(">" + TAG);
gl.depthMask(true);
if (v.pos.zoomLevel < 17)
gl.clear(GL.DEPTH_BUFFER_BIT);
gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, 0);
// set state that is expected after modelBatch.end();
// modelBatch keeps track of its own state
GLState.enableVertexArrays(-1, -1);
GLState.bindTex2D(-1);
GLState.useProgram(-1);
GLState.test(false, false);
GLState.blend(false);
// GL.cullFace(GL20.BACK);
// GL.frontFace(GL20.CW);
cam.update(v);
long time = System.currentTimeMillis();
int cnt = 0;
int rnd = 0;
Viewport p = mMap.viewport();
p.getMapExtents(mBox, 10);
float scale = (float) (cam.mMapPosition.scale / v.pos.scale);
float dx =
(float) (cam.mMapPosition.x - v.pos.x)
* (Tile.SIZE << cam.mMapPosition.zoomLevel);
float dy =
(float) (cam.mMapPosition.y - v.pos.y)
* (Tile.SIZE << cam.mMapPosition.zoomLevel);
for (int i = 0; i < 8; i += 2) {
mBox[i] *= scale;
mBox[i] -= dx;
mBox[i + 1] *= scale;
mBox[i + 1] -= dy;
}
synchronized (this) {
modelBatch.begin(cam);
cnt = instances.size;
for (SharedModel instance : instances) {
instance.transform.getTranslation(tempVector);
tempVector.scl(0.9f, 0.9f, 1);
if (!GeometryUtils.pointInPoly(tempVector.x, tempVector.y, mBox, 8, 0))
continue;
modelBatch.render(instance);
rnd++;
}
modelBatch.end();
}
log.debug(">>> " + (System.currentTimeMillis() - time) + " " + cnt + "/" + rnd);
// GLUtils.checkGlError("<" + TAG);
gl.depthMask(false);
gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, 0);
gl.bindBuffer(GL.ARRAY_BUFFER, 0);
// GLState.bindTex2D(-1);
// GLState.useProgram(-1);
}
示例9: draw
import org.oscim.renderer.GLState; //导入方法依赖的package包/类
public static Layer draw(Layer layer, float scale, Matrices m) {
GLState.test(false, false);
GLState.blend(true);
GLState.useProgram(mTextureProgram);
GLState.enableVertexArrays(hTextureTexCoord, hTextureVertex);
TextureLayer tl = (TextureLayer) layer;
if (tl.fixed)
GLES20.glUniform1f(hTextureScale, (float) Math.sqrt(scale));
else
GLES20.glUniform1f(hTextureScale, 1);
GLES20.glUniform1f(hTextureScreenScale, 1f / GLRenderer.screenWidth);
m.proj.setAsUniform(hTextureProjMatrix);
m.mvp.setAsUniform(hTextureMVMatrix);
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, GLRenderer.getQuadIndicesVBO());
for (TextureItem ti = tl.textures; ti != null; ti = ti.next) {
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, ti.id);
int maxVertices = GLRenderer.maxQuads * INDICES_PER_SPRITE;
GLES20.glUniform2f(hTextureSize,
1f / (ti.width * COORD_SCALE),
1f / (ti.height * COORD_SCALE));
// draw up to maxVertices in each iteration
for (int i = 0; i < ti.vertices; i += maxVertices) {
// to.offset * (24(shorts) * 2(short-bytes) / 6(indices) == 8)
int off = (ti.offset + i) * 8 + tl.offset;
GLES20.glVertexAttribPointer(hTextureVertex, 4,
GLES20.GL_SHORT, false, 12, off);
GLES20.glVertexAttribPointer(hTextureTexCoord, 2,
GLES20.GL_SHORT, false, 12, off + 8);
int numVertices = ti.vertices - i;
if (numVertices > maxVertices)
numVertices = maxVertices;
GLES20.glDrawElements(GLES20.GL_TRIANGLES, numVertices,
GLES20.GL_UNSIGNED_SHORT, 0);
}
}
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0);
return layer.next;
}
示例10: 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, true);
float radius = CIRCLE_SIZE;
animate(true);
boolean viewShed = false;
if (!mLocationIsVisible /* || pos.zoomLevel < SHOW_ACCURACY_ZOOM */) {
//animate(true);
} else {
if (v.pos.zoomLevel >= SHOW_ACCURACY_ZOOM)
radius = (float) (mRadius * v.pos.scale);
viewShed = true;
//animate(false);
}
GL.glUniform1f(hScale, radius);
double x = mIndicatorPosition.x - v.pos.x;
double y = mIndicatorPosition.y - v.pos.y;
double tileScale = Tile.SIZE * v.pos.scale;
v.mvp.setTransScale((float) (x * tileScale), (float) (y * tileScale), 1);
v.mvp.multiplyMM(v.viewproj, v.mvp);
v.mvp.setAsUniform(hMatrixPosition);
if (!viewShed) {
float phase = Math.abs(animPhase() - 0.5f) * 2;
//phase = Interpolation.fade.apply(phase);
phase = Interpolation.swing.apply(phase);
GL.glUniform1f(hPhase, 0.8f + phase * 0.2f);
} else {
GL.glUniform1f(hPhase, 1);
}
if (viewShed && mLocationIsVisible) {
float rotation = mCompass.getRotation() - 90;
GL.glUniform2f(hDirection,
(float) Math.cos(Math.toRadians(rotation)),
(float) Math.sin(Math.toRadians(rotation)));
} else {
GL.glUniform2f(hDirection, 0, 0);
}
GL.glDrawArrays(GL20.GL_TRIANGLE_STRIP, 0, 4);
}
示例11: draw
import org.oscim.renderer.GLState; //导入方法依赖的package包/类
public static Layer draw(Layer layer, Matrices m, float scale, float alpha) {
//GLState.test(false, false);
GLState.blend(true);
GLState.useProgram(mTextureProgram);
GLState.enableVertexArrays(hTextureTexCoord, hTextureVertex);
TextureLayer tl = (TextureLayer) layer;
if (tl.fixed)
GLES20.glUniform1f(hTextureScale, (float) Math.sqrt(scale));
else
GLES20.glUniform1f(hTextureScale, 1);
GLES20.glUniform1f(hAlpha, alpha);
GLES20.glUniform1f(hTextureScreenScale, 1f / GLRenderer.screenWidth);
m.proj.setAsUniform(hTextureProjMatrix);
m.mvp.setAsUniform(hTextureMVMatrix);
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, GLRenderer.getQuadIndicesVBO());
for (TextureItem ti = tl.textures; ti != null; ti = ti.next) {
//Log.d(TAG, "render texture " + ti.id);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, ti.id);
int maxVertices = GLRenderer.maxQuads * INDICES_PER_SPRITE;
// draw up to maxVertices in each iteration
for (int i = 0; i < ti.vertices; i += maxVertices) {
// to.offset * (24(shorts) * 2(short-bytes) / 6(indices) == 8)
int off = (ti.offset + i) * 8 + tl.offset;
GLES20.glVertexAttribPointer(hTextureVertex, 4,
GLES20.GL_SHORT, false, 12, off);
GLES20.glVertexAttribPointer(hTextureTexCoord, 2,
GLES20.GL_SHORT, false, 12, off + 8);
int numVertices = ti.vertices - i;
if (numVertices > maxVertices)
numVertices = maxVertices;
GLES20.glDrawElements(GLES20.GL_TRIANGLES, numVertices,
GLES20.GL_UNSIGNED_SHORT, 0);
}
}
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0);
return layer.next;
}