Java Code Examples for android.opengl.GLES20#GL_LINES

The following examples show how to use android.opengl.GLES20#GL_LINES . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OGLESShaderRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/*********************************************************************\
|* Render Calls                                                      *|
\*********************************************************************/
public int convertElementMode(Mesh.Mode mode) {
    switch (mode) {
        case Points:
            return GLES20.GL_POINTS;
        case Lines:
            return GLES20.GL_LINES;
        case LineLoop:
            return GLES20.GL_LINE_LOOP;
        case LineStrip:
            return GLES20.GL_LINE_STRIP;
        case Triangles:
            return GLES20.GL_TRIANGLES;
        case TriangleFan:
            return GLES20.GL_TRIANGLE_FAN;
        case TriangleStrip:
            return GLES20.GL_TRIANGLE_STRIP;
        default:
            throw new UnsupportedOperationException("Unrecognized mesh mode: " + mode);
    }
}
 
Example 2
Source File: NewGridFeature.java    From geoar-app with Apache License 2.0 4 votes vote down vote up
public NewGridFeature(FeatureShader renderer) {
	this.totalSize = 200;
	this.gridSize = 2;
	this.drawingMode = GLES20.GL_LINES;
	this.renderer = renderer;
}
 
Example 3
Source File: ReferencedGridFeature.java    From geoar-app with Apache License 2.0 4 votes vote down vote up
public ReferencedGridFeature() {
	// HeightMap map = new HeightMap();
	// addChild(map);
	// setPosition(new float[]{0f,0.00001f,0f});
	int xLength = 64;
	int yLength = 64;

	final int floatsPerVertex = 3;
	final int floatsPerColor = 4;
	final int floatsPerNormal = 3;

	final float[] vertices = new float[xLength * yLength * floatsPerVertex];
	final float[] colors = new float[xLength * yLength * floatsPerColor];
	final float[] normals = new float[xLength * yLength * floatsPerNormal];

	int offset = 0;
	int normalOffSet = 0;
	int colorOffset = 0;

	for (int y = 0; y < yLength; y++) {
		for (int x = 0; x < xLength; x++) {
			final float xRatio = x / (float) (xLength - 1);

			// Build our heightmap from the top down, so that our
			// triangles are counter-clockwise.
			final float yRatio = 1f - (y / (float) (yLength - 1));

			final float xPosition = MIN_POSITION
					+ (xRatio * POSITION_RANGE);
			final float yPosition = MIN_POSITION
					+ (yRatio * POSITION_RANGE);

			vertices[offset++] = xPosition;
			vertices[offset++] = ((xPosition * xPosition) + (yPosition * yPosition)) / 20f;
			vertices[offset++] = yPosition;

			final float xSlope = (2 * xPosition) / 10f;
			final float ySlope = (2 * yPosition) / 10f;

			// Calculate the normal using the cross product of the
			// slopes.
			final float[] planeVectorX = { 1f, 0f, xSlope };
			final float[] planeVectorY = { 0f, 1f, ySlope };
			final float[] normalVector = {
					(planeVectorX[1] * planeVectorY[2])
							- (planeVectorX[2] * planeVectorY[1]),
					(planeVectorX[2] * planeVectorY[0])
							- (planeVectorX[0] * planeVectorY[2]),
					(planeVectorX[0] * planeVectorY[1])
							- (planeVectorX[1] * planeVectorY[0]) };

			// Normalize the normal
			final float length = Matrix.length(normalVector[0],
					normalVector[1], normalVector[2]);

			normals[normalOffSet++] = normalVector[0] / length;
			normals[normalOffSet++] = normalVector[1] / length;
			normals[normalOffSet++] = normalVector[2] / length;

			colors[colorOffset++] = 1.f;
			colors[colorOffset++] = 0.5f;
			colors[colorOffset++] = 0.5f;
			colors[colorOffset++] = 0.5f;
		}
	}

	// Now build the index data
	final int numStripsRequired = yLength - 1;
	final int numDegensRequired = 2 * (numStripsRequired - 1);
	final int verticesPerStrip = 2 * xLength - 1;

	final short[] heightMapIndexData = new short[(verticesPerStrip * verticesPerStrip)];

	offset = 0;

	for (int y = 0; y < yLength; y++) {
		for (int x = 0; x < xLength - 1; x++) {
			heightMapIndexData[offset++] = (short) ((y * yLength) + x);
			heightMapIndexData[offset++] = (short) ((y * yLength) + x + 1);
		}
	}

	for (int x = 0; x < xLength; x++) {
		for (int y = 0; y < yLength - 1; y++) {
			heightMapIndexData[offset++] = (short) ((y * yLength) + x);
			heightMapIndexData[offset++] = (short) (((y + 1) * yLength) + x);
		}
	}
	renderer = BilligerColorShader.getInstance();
	drawingMode = GLES20.GL_LINES;
	setRenderObjectives(vertices, colors, normals, null, heightMapIndexData);
}