当前位置: 首页>>代码示例>>Java>>正文


Java GLState.blend方法代码示例

本文整理汇总了Java中org.oscim.renderer.GLState.blend方法的典型用法代码示例。如果您正苦于以下问题:Java GLState.blend方法的具体用法?Java GLState.blend怎么用?Java GLState.blend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.oscim.renderer.GLState的用法示例。


在下文中一共展示了GLState.blend方法的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;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:25,代码来源:HairLineBucket.java

示例2: 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);
	}
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:20,代码来源:MeshBucket.java

示例3: 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);
}
 
开发者ID:andreynovikov,项目名称:trekarta,代码行数:30,代码来源:CrosshairLayer.java

示例4: 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);
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:36,代码来源:PolygonBucket.java

示例5: 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;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:40,代码来源:BitmapBucket.java

示例6: 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;
		}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:38,代码来源:TextureBucket.java

示例7: 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("...");
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:36,代码来源:CustomRenderer.java

示例8: 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("...");
}
 
开发者ID:opensciencemap,项目名称:vtm-android,代码行数:36,代码来源:CustomRenderLayer.java

示例9: drawOver

import org.oscim.renderer.GLState; //导入方法依赖的package包/类
public static void drawOver(Matrices m, int color) {
	setShader(polyShader, m);

	/*
	 * clear stencilbuffer (tile region) by drawing
	 * a quad with func 'always' and op 'zero'
	 */

	if (color != 0) {
		GlUtils.setColor(hPolygonColor[0], color, 1);
		GLState.blend(true);
	} else {
		// disable drawing to framebuffer (will be re-enabled in fill)
		glColorMask(false, false, false, false);
	}
	// always pass stencil test:
	//glStencilFunc(GL_ALWAYS, 0x00, 0x00);
	glStencilFunc(GL_EQUAL, CLIP_BIT, CLIP_BIT);

	// write to all bits
	glStencilMask(0xFF);
	// zero out area to draw to
	glStencilOp(GLES20.GL_KEEP, GLES20.GL_KEEP, GLES20.GL_ZERO);

	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

	if (color == 0)
		glColorMask(true, true, true, true);
}
 
开发者ID:opensciencemap,项目名称:vtm-android,代码行数:30,代码来源:PolygonRenderer.java

示例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);

    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);
}
 
开发者ID:andreynovikov,项目名称:trekarta,代码行数:45,代码来源:LocationOverlay.java

示例11: 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);
    }
}
 
开发者ID:mapzen,项目名称:open,代码行数:50,代码来源:RouteLocationIndicator.java

示例12: draw

import org.oscim.renderer.GLState; //导入方法依赖的package包/类
public static RenderBucket draw(RenderBucket l, GLViewport v) {
	GLState.blend(true);

	Shader s = shader;

	s.useProgram();
	GLState.enableVertexArrays(s.aPos, -1);

	v.mvp.setAsUniform(s.uMVP);

	float heightOffset = 0;
	gl.uniform1f(s.uHeight, heightOffset);

	for (; l != null && l.type == MESH; l = l.next) {
		MeshBucket ml = (MeshBucket) l;

		if (ml.heightOffset != heightOffset) {
			heightOffset = ml.heightOffset;

			gl.uniform1f(s.uHeight, heightOffset /
			        MercatorProjection.groundResolution(v.pos));
		}

		if (ml.area == null)
			GLUtils.setColor(s.uColor, Color.BLUE, 0.4f);
		else {
			setColor(ml.area.current(), s, v.pos);
		}
		gl.vertexAttribPointer(s.aPos, 2, GL.SHORT,
		                       false, 0, ml.vertexOffset);

		gl.drawElements(GL.TRIANGLES,
		                ml.numIndices,
		                GL.UNSIGNED_SHORT,
		                ml.indiceOffset);

		if (dbgRender) {
			int c = (ml.area == null) ? Color.BLUE : ml.area.color;
			gl.lineWidth(1);
			//c = ColorUtil.shiftHue(c, 0.5);
			c = ColorUtil.modHsv(c, 1.1, 1.0, 0.8, true);
			GLUtils.setColor(s.uColor, c, 1);
			gl.drawElements(GL.LINES,
			                ml.numIndices,
			                GL.UNSIGNED_SHORT,
			                ml.vertexOffset);
		}
	}
	return l;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:51,代码来源:MeshBucket.java

示例13: 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);
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:76,代码来源:GdxRenderer3D2.java

示例14: render

import org.oscim.renderer.GLState; //导入方法依赖的package包/类
/**
	 * Render all 'layers'
	 */
	@Override
	public synchronized void render(MapPosition curPos, Matrices m) {
		MapPosition pos = mMapPosition;

		float div = FastMath.pow(pos.zoomLevel - curPos.zoomLevel);

		GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, layers.vbo.id);
		GLState.test(false, false);
		GLState.blend(true);
		int simple = (curPos.tilt < 1 ? 1 : 0);

		if (layers.baseLayers != null) {
			setMatrix(curPos, m, true);

			for (Layer l = layers.baseLayers; l != null;) {
				switch (l.type) {
					case Layer.POLYGON:
						l = PolygonRenderer.draw(curPos, l, m, true, 1, false);
						break;

					case Layer.LINE:
						l = LineRenderer.draw(layers, l, curPos, m, div, simple);
						break;

					case Layer.TEXLINE:
						l = LineTexRenderer.draw(layers, l, curPos, m, div);
						break;
				}
			}
		}

		if (layers.textureLayers != null) {
			setMatrix(curPos, m, false);

			float scale = (float) (pos.scale / curPos.scale);

			for (Layer l = layers.textureLayers; l != null;) {
				switch (l.type) {
					case Layer.BITMAP:
						l = BitmapRenderer.draw(l, m, 1, 1);
						break;

//					case Layer.SYMBOL:
//						l = BitmapRenderer.draw(l, 1, m);
//						break;

					default:
						l = TextureRenderer.draw(l, scale, m);
				}
			}
		}
	}
 
开发者ID:opensciencemap,项目名称:vtm-android,代码行数:56,代码来源:BasicRenderLayer.java

示例15: fillPolygons

import org.oscim.renderer.GLState; //导入方法依赖的package包/类
private static void fillPolygons(Matrices m, int start, int end, int zoom, float scale,
		float div) {

	/* draw to framebuffer */
	glColorMask(true, true, true, true);

	/* do not modify stencil buffer */
	glStencilMask(0x00);
	int shader = polyShader;

	for (int c = start; c < end; c++) {
		Area a = mFillPolys[c].area;
		if (enableTexture && (a.color == 0xFFAFC5E3
				|| a.color == 0xffd1dbc7
				|| a.color == 0xffa3ca7b)) {
			shader = texShader;
			setShader(texShader, m);

			GLES20.glUniform2f(hPolygonScale[1], FastMath.clamp(scale - 1, 0, 1), div);
			if (a.color == 0xFFAFC5E3)
				GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexWater);
			else if (a.color == 0xffd1dbc7)
				GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexWood);
			else
				GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexGrass);
		} else if (a.fade >= zoom) {
			float f = 1.0f;
			/* fade in/out */
			if (a.fade >= zoom) {
				if (scale > FADE_START)
					f = scale - 1;
				else
					f = FADE_START - 1;
			}
			GLState.blend(true);

			GlUtils.setColor(hPolygonColor[shader], a.color, f);

		} else if (a.blend > 0 && a.blend <= zoom) {
			/* blend colors (not alpha) */
			GLState.blend(false);

			if (a.blend == zoom)
				GlUtils.setColorBlend(hPolygonColor[shader],
						a.color, a.blendColor, scale - 1.0f);
			else
				GlUtils.setColor(hPolygonColor[shader], a.blendColor, 1);

		} else {
			if (a.color < 0xff000000)
				GLState.blend(true);
			else
				GLState.blend(false);

			GlUtils.setColor(hPolygonColor[shader], a.color, 1);
		}

		// set stencil buffer mask used to draw this layer
		// also check that clip bit is set to avoid overdraw
		// of other tiles
		glStencilFunc(GL_EQUAL, 0xff, CLIP_BIT | 1 << c);

		/* draw tile fill coordinates */
		glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

		if (shader != polyShader) {
			setShader(polyShader, m);
			shader = polyShader;
		}
	}
}
 
开发者ID:opensciencemap,项目名称:vtm-android,代码行数:72,代码来源:PolygonRenderer.java


注:本文中的org.oscim.renderer.GLState.blend方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。