Java Code Examples for android.opengl.GLES20#glLineWidth()

The following examples show how to use android.opengl.GLES20#glLineWidth() . 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: GLES20Canvas.java    From PhotoMovie with Apache License 2.0 6 votes vote down vote up
private void prepareDraw(int offset, int color, float lineWidth) {
    GLES20.glUseProgram(mDrawProgram);
    checkError();
    if (lineWidth > 0) {
        GLES20.glLineWidth(lineWidth);
        checkError();
    }
    float[] colorArray = getColor(color);
    boolean blendingEnabled = (colorArray[3] < 1f);
    enableBlending(blendingEnabled);
    if (blendingEnabled) {
        GLES20.glBlendColor(colorArray[0], colorArray[1], colorArray[2], colorArray[3]);
        checkError();
    }

    GLES20.glUniform4fv(mDrawParameters[INDEX_COLOR].handle, 1, colorArray, 0);
    setPosition(mDrawParameters, offset);
    checkError();
}
 
Example 2
Source File: GLES20Canvas.java    From android-openGL-canvas with Apache License 2.0 6 votes vote down vote up
private void prepareDraw(int offset, int color, float lineWidth) {
    GLES20.glUseProgram(mDrawProgram);
    checkError();
    if (lineWidth > 0) {
        GLES20.glLineWidth(lineWidth);
        checkError();
    }
    float[] colorArray = getColor(color);
    enableBlending(true);
    GLES20.glBlendColor(colorArray[0], colorArray[1], colorArray[2], colorArray[3]);
    checkError();

    GLES20.glUniform4fv(mDrawParameters[INDEX_COLOR].handle, 1, colorArray, 0);
    setPosition(mDrawParameters, offset);
    checkError();
}
 
Example 3
Source File: GLES20Canvas.java    From Trebuchet with GNU General Public License v3.0 6 votes vote down vote up
private void prepareDraw(int offset, int color, float lineWidth) {
    GLES20.glUseProgram(mDrawProgram);
    checkError();
    if (lineWidth > 0) {
        GLES20.glLineWidth(lineWidth);
        checkError();
    }
    float[] colorArray = getColor(color);
    boolean blendingEnabled = (colorArray[3] < 1f);
    enableBlending(blendingEnabled);
    if (blendingEnabled) {
        GLES20.glBlendColor(colorArray[0], colorArray[1], colorArray[2], colorArray[3]);
        checkError();
    }

    GLES20.glUniform4fv(mDrawParameters[INDEX_COLOR].handle, 1, colorArray, 0);
    setPosition(mDrawParameters, offset);
    checkError();
}
 
Example 4
Source File: GLES20Canvas.java    From TurboLauncher with Apache License 2.0 6 votes vote down vote up
private void prepareDraw(int offset, int color, float lineWidth) {
    GLES20.glUseProgram(mDrawProgram);
    checkError();
    if (lineWidth > 0) {
        GLES20.glLineWidth(lineWidth);
        checkError();
    }
    float[] colorArray = getColor(color);
    boolean blendingEnabled = (colorArray[3] < 1f);
    enableBlending(blendingEnabled);
    if (blendingEnabled) {
        GLES20.glBlendColor(colorArray[0], colorArray[1], colorArray[2], colorArray[3]);
        checkError();
    }

    GLES20.glUniform4fv(mDrawParameters[INDEX_COLOR].handle, 1, colorArray, 0);
    setPosition(mDrawParameters, offset);
    checkError();
}
 
Example 5
Source File: Trajectory.java    From ParaViewTangoRecorder with Apache License 2.0 6 votes vote down vote up
@Override
public void draw(float[] viewMatrix, float[] projectionMatrix) {
    GLES20.glUseProgram(mProgram);
    mVertexBuffer.position(0);

    // Compose the model, view, and projection matrices into a single m-v-p
    // matrix
    updateMvpMatrix(viewMatrix, projectionMatrix);

    // Load vertex attribute data
    mPosHandle = GLES20.glGetAttribLocation(mProgram, "vPosition");
    GLES20.glVertexAttribPointer(mPosHandle, COORDS_PER_VERTEX,
            GLES20.GL_FLOAT, false, 0, mVertexBuffer);
    GLES20.glEnableVertexAttribArray(mPosHandle);

    mMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix");
    GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, getMvpMatrix(), 0);

    mColorHandle = GLES20.glGetUniformLocation(mProgram, "aColor");
    GLES20.glUniform4f(mColorHandle, mColor[0], mColor[1], mColor[2],
            mColor[3]);
    GLES20.glLineWidth(mLineWidth);
    GLES20.glDrawArrays(GLES20.GL_LINE_STRIP, 0, mTrajectoryCount);
}
 
Example 6
Source File: Grid.java    From ParaViewTangoRecorder with Apache License 2.0 6 votes vote down vote up
@Override
public void draw(float[] viewMatrix, float[] projectionMatrix) {
    GLES20.glUseProgram(mProgram);
    mVertexBuffer.position(0);

    // Compose the model, view, and projection matrices into a single m-v-p
    // matrix
    updateMvpMatrix(viewMatrix, projectionMatrix);

    // Load vertex attribute data
    mPosHandle = GLES20.glGetAttribLocation(mProgram, "vPosition");
    GLES20.glVertexAttribPointer(mPosHandle, COORDS_PER_VERTEX,
            GLES20.GL_FLOAT, false, 0, mVertexBuffer);
    GLES20.glEnableVertexAttribArray(mPosHandle);

    // Draw the Grid
    mMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix");
    GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, getMvpMatrix(), 0);
    GLES20.glLineWidth(1);
    GLES20.glDrawArrays(GLES20.GL_LINES, 0, (GRID_RANGE_M * 2 + 1) * 4);
}
 
Example 7
Source File: GLES20Canvas.java    From LB-Launcher with Apache License 2.0 6 votes vote down vote up
private void prepareDraw(int offset, int color, float lineWidth) {
    GLES20.glUseProgram(mDrawProgram);
    checkError();
    if (lineWidth > 0) {
        GLES20.glLineWidth(lineWidth);
        checkError();
    }
    float[] colorArray = getColor(color);
    boolean blendingEnabled = (colorArray[3] < 1f);
    enableBlending(blendingEnabled);
    if (blendingEnabled) {
        GLES20.glBlendColor(colorArray[0], colorArray[1], colorArray[2], colorArray[3]);
        checkError();
    }

    GLES20.glUniform4fv(mDrawParameters[INDEX_COLOR].handle, 1, colorArray, 0);
    setPosition(mDrawParameters, offset);
    checkError();
}
 
Example 8
Source File: OrientationView.java    From PanoramaGL with Apache License 2.0 5 votes vote down vote up
@Override
public final void onSurfaceChanged(GL10 gl, int width, int height) {
  // Camera.
  GLES20.glViewport(0, 0, width, height);
  Matrix.perspectiveM(projectionMatrix, 0, 90, (float) (width) / height, 1, 2 * VIEW_SIZE);

  // Styles.
  GLES20.glClearColor(1, 1, 1, 1);
  GLES20.glLineWidth(10);

  GLES20.glEnable(GLES20.GL_DEPTH_TEST);
}
 
Example 9
Source File: CameraFrustum.java    From ParaViewTangoRecorder with Apache License 2.0 5 votes vote down vote up
@Override
public void draw(float[] viewMatrix, float[] projectionMatrix) {
    GLES20.glUseProgram(mProgram);
    // updateViewMatrix(viewMatrix);

    // Compose the model, view, and projection matrices into a single mvp
    // matrix
    updateMvpMatrix(viewMatrix, projectionMatrix);

    // Load vertex attribute data
    mPosHandle = GLES20.glGetAttribLocation(mProgram, "vPosition");
    GLES20.glVertexAttribPointer(mPosHandle, COORDS_PER_VERTEX,
            GLES20.GL_FLOAT, false, 0, mVertexBuffer);
    GLES20.glEnableVertexAttribArray(mPosHandle);

    // Load color attribute data
    mColorHandle = GLES20.glGetAttribLocation(mProgram, "aColor");
    GLES20.glVertexAttribPointer(mColorHandle, 4, GLES20.GL_FLOAT, false,
            0, mColorBuffer);
    GLES20.glEnableVertexAttribArray(mColorHandle);

    // Draw the CameraFrustum
    mMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix");
    GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, getMvpMatrix(), 0);
    GLES20.glLineWidth(1);
    GLES20.glDrawArrays(GLES20.GL_LINES, 0, 16);
}
 
Example 10
Source File: CameraFrustumAndAxis.java    From ParaViewTangoRecorder with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void draw(float[] viewMatrix, float[] projectionMatrix) {
    GLES20.glUseProgram(mProgram);

    // Compose the model, view, and projection matrices into a single m-v-p
    // matrix
    updateMvpMatrix(viewMatrix, projectionMatrix);

    // Load vertex attribute data
    mPosHandle = GLES20.glGetAttribLocation(mProgram, "vPosition");
    GLES20.glVertexAttribPointer(mPosHandle, COORDS_PER_VERTEX,
            GLES20.GL_FLOAT, false, 0, mVertexBuffer);
    GLES20.glEnableVertexAttribArray(mPosHandle);

    // Load color attribute data
    mColorHandle = GLES20.glGetAttribLocation(mProgram, "aColor");
    GLES20.glVertexAttribPointer(mColorHandle, 4, GLES20.GL_FLOAT, false,
            0, mColorBuffer);
    GLES20.glEnableVertexAttribArray(mColorHandle);

    // Draw the CameraFrustumAndAxis
    mMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix");
    GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, getMvpMatrix(), 0);
    GLES20.glLineWidth(3);
    GLES20.glDrawArrays(GLES20.GL_LINES, 0, mVertices.length / 3);

}
 
Example 11
Source File: OGLESShaderRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void renderMesh(Mesh mesh, int lod, int count) {
        if (context.pointSize != mesh.getPointSize()) {

            if (verboseLogging) {
                logger.log(Level.INFO, "GLES10.glPointSize({0})", mesh.getPointSize());
            }

            GLES10.glPointSize(mesh.getPointSize());
            context.pointSize = mesh.getPointSize();
        }
        if (context.lineWidth != mesh.getLineWidth()) {

            if (verboseLogging) {
                logger.log(Level.INFO, "GLES20.glLineWidth({0})", mesh.getLineWidth());
            }

            GLES20.glLineWidth(mesh.getLineWidth());
            context.lineWidth = mesh.getLineWidth();
        }

        statistics.onMeshDrawn(mesh, lod);
//        if (GLContext.getCapabilities().GL_ARB_vertex_array_object){
//            renderMeshVertexArray(mesh, lod, count);
//        }else{

        if (useVBO) {
            if (verboseLogging) {
                logger.info("RENDERING A MESH USING VertexBufferObject");
            }

            renderMeshDefault(mesh, lod, count);
        } else {
            if (verboseLogging) {
                logger.info("RENDERING A MESH USING VertexArray");
            }

            renderMeshVertexArray(mesh, lod, count);
        }

//        }
    }
 
Example 12
Source File: GLState.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
public void lineWidth(final float pLineWidth) {
	if(this.mLineWidth  != pLineWidth) {
		this.mLineWidth = pLineWidth;
		GLES20.glLineWidth(pLineWidth);
	}
}
 
Example 13
Source File: ReferencedGridFeature.java    From geoar-app with Apache License 2.0 4 votes vote down vote up
@Override
public void onPreRender() {
	GLES20.glLineWidth(2f);

}
 
Example 14
Source File: NewGridFeature.java    From geoar-app with Apache License 2.0 4 votes vote down vote up
@Override
public void onPreRender() {
	GLES20.glLineWidth(thickness);
}
 
Example 15
Source File: GLState.java    From tilt-game-android with MIT License 4 votes vote down vote up
public void lineWidth(final float pLineWidth) {
	if (this.mLineWidth != pLineWidth) {
		this.mLineWidth = pLineWidth;
		GLES20.glLineWidth(pLineWidth);
	}
}
 
Example 16
Source File: AndroidGL.java    From trekarta with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void lineWidth(float width) {
    GLES20.glLineWidth(width);

}
 
Example 17
Source File: PointsMatrix.java    From MegviiFacepp-Android-SDK with Apache License 2.0 4 votes vote down vote up
public void draw(float[] mvpMatrix) {
		// Add program to OpenGL environment
		GLES20.glUseProgram(mProgram);

		// get handle to vertex shader's vPosition member
		mPositionHandle = GLES20.glGetAttribLocation(mProgram, "vPosition");

		// get handle to fragment shader's vColor member
		mColorHandle = GLES20.glGetUniformLocation(mProgram, "vColor");

		// get handle to shape's transformation matrix
		mMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix");
		checkGlError("glGetUniformLocation");

		// Apply the projection and view transformation
		GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mvpMatrix, 0);
		checkGlError("glUniformMatrix4fv");
		// Enable a handle to the triangle vertices
		GLES20.glEnableVertexAttribArray(mPositionHandle);
		// Set color for drawing the triangle
		GLES20.glUniform4fv(mColorHandle, 1, color_rect, 0);

		synchronized (this) {
			for (int i = 0; i < vertexBuffers.size(); i++) {
				FloatBuffer vertexBuffer = vertexBuffers.get(i);
				if (vertexBuffer != null) {
					// Prepare the triangle coordinate data
					GLES20.glVertexAttribPointer(mPositionHandle, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false,
							vertexStride, vertexBuffer);
					// Draw the square

					GLES20.glDrawElements(GLES20.GL_TRIANGLES, drawOrder.length, GLES20.GL_UNSIGNED_SHORT,
							drawListBuffer);
				}
			}
		}

		GLES20.glUniform4fv(mColorHandle, 1, color, 0);

		if (!isFaceCompare&&!isShowFaceRect){    //这里在绘制判断,需要调用api判断
			synchronized (this) {
				for (int i = 0; i < points.size(); i++) {
					ArrayList<FloatBuffer> triangleVBList = points.get(i);
					for (int j = 0; j < triangleVBList.size(); j++) {
						FloatBuffer fb = triangleVBList.get(j);
						if (fb != null) {
							GLES20.glVertexAttribPointer(mPositionHandle, 3, GLES20.GL_FLOAT, false, 0, fb);
							// Draw the point
							GLES20.glDrawArrays(GLES20.GL_POINTS, 0, 1);
						}
					}
				}
			}
		}


		synchronized (this) {
			if (bottomVertexBuffer != null) {
				GLES20.glVertexAttribPointer(mPositionHandle, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, vertexStride,
						bottomVertexBuffer);
//				GLES20.glUniform4fv(mColorHandle, 1, color_megvii[1], 0);
//				GLES20.glDrawElements(GLES20.GL_TRIANGLES, drawOrder.length, GLES20.GL_UNSIGNED_SHORT,
//						drawListBuffer);
//				GLES20.glUniform4fv(mColorHandle, 1, color_megvii[0], 0);
//				GLES20.glDrawElements(GLES20.GL_LINES, drawLineOrder.length, GLES20.GL_UNSIGNED_SHORT,
//						drawLineListBuffer);
				// Draw the square
				GLES20.glLineWidth(4.0f);
				for (int i = 0; i < cubeOrders.length; ++i) {
					GLES20.glUniform4fv(mColorHandle, 1, color_megvii[i + 2], 0);
					GLES20.glDrawElements(GLES20.GL_LINES, cubeOrders[i].length, GLES20.GL_UNSIGNED_SHORT,
							cubeListBuffer[i]);
				}
			}
		}


		synchronized (this){
			if (faceRects != null && faceRects.size()>0){
				GLES20.glLineWidth(4.0f);
				GLES20.glUniform4f(mColorHandle, 1.0f, 0.0f, 0.0f, 1.0f);

				for(int i = 0; i < faceRects.size(); i++){
					FloatBuffer buffer = faceRects.get(i);
					GLES20.glVertexAttribPointer(mPositionHandle, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, 0, buffer);
					GLES20.glDrawElements(GLES20.GL_LINES, drawFaceRectOrder.length, GLES20.GL_UNSIGNED_SHORT, faceRectListBuffer);

				}
			}
		}



			// Disable vertex array
		GLES20.glDisableVertexAttribArray(mPositionHandle);
	}