GLES20.glUseProgram(quadProgram); ShaderUtil.checkGLError(TAG, "Program creation"); ShaderUtil.checkGLError(TAG, "Program parameters");
GLES20.glUseProgram(quadProgram); ShaderUtil.checkGLError(TAG, "Program creation"); ShaderUtil.checkGLError(TAG, "Program parameters");
/** * Updates the OpenGL buffer contents to the provided point. Repeated calls with the same point * cloud will be ignored. */ public void update(PointCloud cloud) { if (lastPointCloud == cloud) { // Redundant call. return; } ShaderUtil.checkGLError(TAG, "before update"); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vbo); lastPointCloud = cloud; // If the VBO is not large enough to fit the new point cloud, resize it. numPoints = lastPointCloud.getPoints().remaining() / FLOATS_PER_POINT; if (numPoints * BYTES_PER_POINT > vboSize) { while (numPoints * BYTES_PER_POINT > vboSize) { vboSize *= 2; } GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, vboSize, null, GLES20.GL_DYNAMIC_DRAW); } GLES20.glBufferSubData( GLES20.GL_ARRAY_BUFFER, 0, numPoints * BYTES_PER_POINT, lastPointCloud.getPoints()); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0); ShaderUtil.checkGLError(TAG, "after update"); }
/** * Updates the OpenGL buffer contents to the provided point. Repeated calls with the same point * cloud will be ignored. */ public void update(PointCloud cloud) { if (lastPointCloud == cloud) { // Redundant call. return; } ShaderUtil.checkGLError(TAG, "before update"); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vbo); lastPointCloud = cloud; // If the VBO is not large enough to fit the new point cloud, resize it. numPoints = lastPointCloud.getPoints().remaining() / FLOATS_PER_POINT; if (numPoints * BYTES_PER_POINT > vboSize) { while (numPoints * BYTES_PER_POINT > vboSize) { vboSize *= 2; } GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, vboSize, null, GLES20.GL_DYNAMIC_DRAW); } GLES20.glBufferSubData( GLES20.GL_ARRAY_BUFFER, 0, numPoints * BYTES_PER_POINT, lastPointCloud.getPoints()); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0); ShaderUtil.checkGLError(TAG, "after update"); }
ShaderUtil.checkGLError(TAG, "before create"); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0); ShaderUtil.checkGLError(TAG, "buffer alloc"); GLES20.glUseProgram(programName); ShaderUtil.checkGLError(TAG, "program"); pointSizeUniform = GLES20.glGetUniformLocation(programName, "u_PointSize"); ShaderUtil.checkGLError(TAG, "program params");
ShaderUtil.checkGLError(TAG, "before create"); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0); ShaderUtil.checkGLError(TAG, "buffer alloc"); GLES20.glUseProgram(programName); ShaderUtil.checkGLError(TAG, "program"); pointSizeUniform = GLES20.glGetUniformLocation(programName, "u_PointSize"); ShaderUtil.checkGLError(TAG, "program params");
/** * Renders the point cloud. ArCore point cloud is given in world space. * * @param cameraView the camera view matrix for this frame, typically from {@link * com.google.ar.core.Camera#getViewMatrix(float[], int)}. * @param cameraPerspective the camera projection matrix for this frame, typically from {@link * com.google.ar.core.Camera#getProjectionMatrix(float[], int, float, float)}. */ public void draw(float[] cameraView, float[] cameraPerspective) { float[] modelViewProjection = new float[16]; Matrix.multiplyMM(modelViewProjection, 0, cameraPerspective, 0, cameraView, 0); ShaderUtil.checkGLError(TAG, "Before draw"); GLES20.glUseProgram(programName); GLES20.glEnableVertexAttribArray(positionAttribute); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vbo); GLES20.glVertexAttribPointer(positionAttribute, 4, GLES20.GL_FLOAT, false, BYTES_PER_POINT, 0); GLES20.glUniform4f(colorUniform, 31.0f / 255.0f, 188.0f / 255.0f, 210.0f / 255.0f, 1.0f); GLES20.glUniformMatrix4fv(modelViewProjectionUniform, 1, false, modelViewProjection, 0); GLES20.glUniform1f(pointSizeUniform, 5.0f); GLES20.glDrawArrays(GLES20.GL_POINTS, 0, numPoints); GLES20.glDisableVertexAttribArray(positionAttribute); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0); ShaderUtil.checkGLError(TAG, "Draw"); } }
/** * Renders the point cloud. ArCore point cloud is given in world space. * * @param cameraView the camera view matrix for this frame, typically from {@link * com.google.ar.core.Camera#getViewMatrix(float[], int)}. * @param cameraPerspective the camera projection matrix for this frame, typically from {@link * com.google.ar.core.Camera#getProjectionMatrix(float[], int, float, float)}. */ public void draw(float[] cameraView, float[] cameraPerspective) { float[] modelViewProjection = new float[16]; Matrix.multiplyMM(modelViewProjection, 0, cameraPerspective, 0, cameraView, 0); ShaderUtil.checkGLError(TAG, "Before draw"); GLES20.glUseProgram(programName); GLES20.glEnableVertexAttribArray(positionAttribute); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vbo); GLES20.glVertexAttribPointer(positionAttribute, 4, GLES20.GL_FLOAT, false, BYTES_PER_POINT, 0); GLES20.glUniform4f(colorUniform, 31.0f / 255.0f, 188.0f / 255.0f, 210.0f / 255.0f, 1.0f); GLES20.glUniformMatrix4fv(modelViewProjectionUniform, 1, false, modelViewProjection, 0); GLES20.glUniform1f(pointSizeUniform, 5.0f); GLES20.glDrawArrays(GLES20.GL_POINTS, 0, numPoints); GLES20.glDisableVertexAttribArray(positionAttribute); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0); ShaderUtil.checkGLError(TAG, "Draw"); } }
GLES20.glUseProgram(planeProgram); ShaderUtil.checkGLError(TAG, "Program creation"); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); ShaderUtil.checkGLError(TAG, "Texture loading"); planeUvMatrixUniform = GLES20.glGetUniformLocation(planeProgram, "u_PlaneUvMatrix"); ShaderUtil.checkGLError(TAG, "Program parameters");
GLES20.glUseProgram(planeProgram); ShaderUtil.checkGLError(TAG, "Program creation"); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); ShaderUtil.checkGLError(TAG, "Texture loading"); planeUvMatrixUniform = GLES20.glGetUniformLocation(planeProgram, "u_PlaneUvMatrix"); ShaderUtil.checkGLError(TAG, "Program parameters");
GLES20.glUseProgram(program); ShaderUtil.checkGLError(TAG, "Program creation"); GLES20.glGetUniformLocation(program, "u_ColorCorrectionParameters"); ShaderUtil.checkGLError(TAG, "Program parameters"); ShaderUtil.checkGLError(TAG, "Texture loading"); GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0); ShaderUtil.checkGLError(TAG, "OBJ buffer load");
private void draw(float[] cameraView, float[] cameraPerspective) { // Build the ModelView and ModelViewProjection matrices // for calculating cube position and light. Matrix.multiplyMM(modelViewMatrix, 0, cameraView, 0, modelMatrix, 0); Matrix.multiplyMM(modelViewProjectionMatrix, 0, cameraPerspective, 0, modelViewMatrix, 0); // Set the position of the plane vertexBuffer.rewind(); GLES20.glVertexAttribPointer( planeXZPositionAlphaAttribute, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, BYTES_PER_FLOAT * COORDS_PER_VERTEX, vertexBuffer); // Set the Model and ModelViewProjection matrices in the shader. GLES20.glUniformMatrix4fv(planeModelUniform, 1, false, modelMatrix, 0); GLES20.glUniformMatrix4fv( planeModelViewProjectionUniform, 1, false, modelViewProjectionMatrix, 0); indexBuffer.rewind(); GLES20.glDrawElements( GLES20.GL_TRIANGLE_STRIP, indexBuffer.limit(), GLES20.GL_UNSIGNED_SHORT, indexBuffer); ShaderUtil.checkGLError(TAG, "Drawing plane"); }
private void draw(float[] cameraView, float[] cameraPerspective) { // Build the ModelView and ModelViewProjection matrices // for calculating cube position and light. Matrix.multiplyMM(modelViewMatrix, 0, cameraView, 0, modelMatrix, 0); Matrix.multiplyMM(modelViewProjectionMatrix, 0, cameraPerspective, 0, modelViewMatrix, 0); // Set the position of the plane vertexBuffer.rewind(); GLES20.glVertexAttribPointer( planeXZPositionAlphaAttribute, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, BYTES_PER_FLOAT * COORDS_PER_VERTEX, vertexBuffer); // Set the Model and ModelViewProjection matrices in the shader. GLES20.glUniformMatrix4fv(planeModelUniform, 1, false, modelMatrix, 0); GLES20.glUniformMatrix4fv( planeModelViewProjectionUniform, 1, false, modelViewProjectionMatrix, 0); indexBuffer.rewind(); GLES20.glDrawElements( GLES20.GL_TRIANGLE_STRIP, indexBuffer.limit(), GLES20.GL_UNSIGNED_SHORT, indexBuffer); ShaderUtil.checkGLError(TAG, "Drawing plane"); }
ShaderUtil.checkGLError(TAG, "Setting up to draw planes"); GLES20.glDepthMask(true); ShaderUtil.checkGLError(TAG, "Cleaning up after drawing planes");
ShaderUtil.checkGLError(TAG, "Setting up to draw planes"); GLES20.glDepthMask(true); ShaderUtil.checkGLError(TAG, "Cleaning up after drawing planes");
GLES20.glEnable(GLES20.GL_DEPTH_TEST); ShaderUtil.checkGLError(TAG, "Draw");
GLES20.glEnable(GLES20.GL_DEPTH_TEST); ShaderUtil.checkGLError(TAG, "Draw");
ShaderUtil.checkGLError(TAG, "Before draw"); ShaderUtil.checkGLError(TAG, "After draw");
ShaderUtil.checkGLError(TAG, "Before draw"); ShaderUtil.checkGLError(TAG, "After draw");
ShaderUtil.checkGLError(TAG, "Before draw"); ShaderUtil.checkGLError(TAG, "After draw");