Tabnine Logo
ShaderUtil
Code IndexAdd Tabnine to your IDE (free)

How to use
ShaderUtil
in
com.novoda.spikes.arcore.google.rendering

Best Java code snippets using com.novoda.spikes.arcore.google.rendering.ShaderUtil (Showing top 20 results out of 315)

origin: novoda/spikes

    ShaderUtil.loadGLShader(TAG, context, GLES20.GL_VERTEX_SHADER, VERTEX_SHADER_NAME);
int fragmentShader =
    ShaderUtil.loadGLShader(TAG, context, GLES20.GL_FRAGMENT_SHADER, FRAGMENT_SHADER_NAME);
GLES20.glUseProgram(quadProgram);
ShaderUtil.checkGLError(TAG, "Program creation");
ShaderUtil.checkGLError(TAG, "Program parameters");
origin: novoda/spikes

/**
 * Converts a raw text file, saved as a resource, into an OpenGL ES shader.
 *
 * @param type     The type of shader we will be creating.
 * @param filename The filename of the asset file about to be turned into a shader.
 * @return The shader object handler.
 */
public static int loadGLShader(String tag, Context context, int type, String filename)
    throws IOException {
  String code = readRawTextFileFromAssets(context, filename);
  int shader = GLES20.glCreateShader(type);
  GLES20.glShaderSource(shader, code);
  GLES20.glCompileShader(shader);
  // Get the compilation status.
  final int[] compileStatus = new int[1];
  GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compileStatus, 0);
  // If the compilation failed, delete the shader.
  if (compileStatus[0] == 0) {
    Log.e(tag, "Error compiling shader: " + GLES20.glGetShaderInfoLog(shader));
    GLES20.glDeleteShader(shader);
    shader = 0;
  }
  if (shader == 0) {
    throw new RuntimeException("Error creating shader.");
  }
  return shader;
}
origin: novoda/spikes

/**
 * 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");
}
origin: novoda/spikes

  ShaderUtil.loadGLShader(TAG, context, GLES20.GL_VERTEX_SHADER, "shaders/gpu_download.vert");
int fragmentShader =
  ShaderUtil.loadGLShader(
    TAG,
    context,
origin: novoda/spikes

/**
 * 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");
}
origin: novoda/spikes

    ShaderUtil.loadGLShader(TAG, context, GLES20.GL_VERTEX_SHADER, VERTEX_SHADER_NAME);
int fragmentShader =
    ShaderUtil.loadGLShader(TAG, context, GLES20.GL_FRAGMENT_SHADER, FRAGMENT_SHADER_NAME);
GLES20.glUseProgram(quadProgram);
ShaderUtil.checkGLError(TAG, "Program creation");
ShaderUtil.checkGLError(TAG, "Program parameters");
origin: novoda/spikes

 /**
  * 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");
 }
}
origin: novoda/spikes

/**
 * Converts a raw text file, saved as a resource, into an OpenGL ES shader.
 *
 * @param type     The type of shader we will be creating.
 * @param filename The filename of the asset file about to be turned into a shader.
 * @return The shader object handler.
 */
public static int loadGLShader(String tag, Context context, int type, String filename)
    throws IOException {
  String code = readRawTextFileFromAssets(context, filename);
  int shader = GLES20.glCreateShader(type);
  GLES20.glShaderSource(shader, code);
  GLES20.glCompileShader(shader);
  // Get the compilation status.
  final int[] compileStatus = new int[1];
  GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compileStatus, 0);
  // If the compilation failed, delete the shader.
  if (compileStatus[0] == 0) {
    Log.e(tag, "Error compiling shader: " + GLES20.glGetShaderInfoLog(shader));
    GLES20.glDeleteShader(shader);
    shader = 0;
  }
  if (shader == 0) {
    throw new RuntimeException("Error creating shader.");
  }
  return shader;
}
origin: novoda/spikes

ShaderUtil.checkGLError(TAG, "before create");
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
ShaderUtil.checkGLError(TAG, "buffer alloc");
  ShaderUtil.loadGLShader(TAG, context, GLES20.GL_VERTEX_SHADER, VERTEX_SHADER_NAME);
int passthroughShader =
  ShaderUtil.loadGLShader(TAG, context, GLES20.GL_FRAGMENT_SHADER, FRAGMENT_SHADER_NAME);
GLES20.glUseProgram(programName);
ShaderUtil.checkGLError(TAG, "program");
pointSizeUniform = GLES20.glGetUniformLocation(programName, "u_PointSize");
ShaderUtil.checkGLError(TAG, "program  params");
origin: novoda/spikes

 /**
  * 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");
 }
}
origin: novoda/spikes

ShaderUtil.checkGLError(TAG, "before create");
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
ShaderUtil.checkGLError(TAG, "buffer alloc");
  ShaderUtil.loadGLShader(TAG, context, GLES20.GL_VERTEX_SHADER, VERTEX_SHADER_NAME);
int passthroughShader =
  ShaderUtil.loadGLShader(TAG, context, GLES20.GL_FRAGMENT_SHADER, FRAGMENT_SHADER_NAME);
GLES20.glUseProgram(programName);
ShaderUtil.checkGLError(TAG, "program");
pointSizeUniform = GLES20.glGetUniformLocation(programName, "u_PointSize");
ShaderUtil.checkGLError(TAG, "program  params");
origin: novoda/spikes

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");
}
origin: novoda/spikes

  ShaderUtil.loadGLShader(TAG, context, GLES20.GL_VERTEX_SHADER, VERTEX_SHADER_NAME);
int passthroughShader =
  ShaderUtil.loadGLShader(TAG, context, GLES20.GL_FRAGMENT_SHADER, FRAGMENT_SHADER_NAME);
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");
origin: novoda/spikes

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");
}
origin: novoda/spikes

  ShaderUtil.loadGLShader(TAG, context, GLES20.GL_VERTEX_SHADER, VERTEX_SHADER_NAME);
int passthroughShader =
  ShaderUtil.loadGLShader(TAG, context, GLES20.GL_FRAGMENT_SHADER, FRAGMENT_SHADER_NAME);
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");
origin: novoda/spikes

ShaderUtil.checkGLError(TAG, "Setting up to draw planes");
GLES20.glDepthMask(true);
ShaderUtil.checkGLError(TAG, "Cleaning up after drawing planes");
origin: novoda/spikes

 throws IOException {
final int vertexShader =
  ShaderUtil.loadGLShader(TAG, context, GLES20.GL_VERTEX_SHADER, VERTEX_SHADER_NAME);
final int fragmentShader =
  ShaderUtil.loadGLShader(TAG, context, GLES20.GL_FRAGMENT_SHADER, FRAGMENT_SHADER_NAME);
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");
origin: novoda/spikes

ShaderUtil.checkGLError(TAG, "Setting up to draw planes");
GLES20.glDepthMask(true);
ShaderUtil.checkGLError(TAG, "Cleaning up after drawing planes");
origin: novoda/spikes

 throws IOException {
final int vertexShader =
  ShaderUtil.loadGLShader(TAG, context, GLES20.GL_VERTEX_SHADER, VERTEX_SHADER_NAME);
final int fragmentShader =
  ShaderUtil.loadGLShader(TAG, context, GLES20.GL_FRAGMENT_SHADER, FRAGMENT_SHADER_NAME);
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");
origin: novoda/spikes

GLES20.glEnable(GLES20.GL_DEPTH_TEST);
ShaderUtil.checkGLError(TAG, "Draw");
com.novoda.spikes.arcore.google.renderingShaderUtil

Javadoc

Shader helper functions.

Most used methods

  • checkGLError
    Checks if we've had an error inside of OpenGL ES, and if so what that error is.
  • loadGLShader
    Converts a raw text file, saved as a resource, into an OpenGL ES shader.
  • readRawTextFileFromAssets
    Converts a raw text file into a string.

Popular in Java

  • Start an intent from android
  • setRequestProperty (URLConnection)
  • compareTo (BigDecimal)
  • addToBackStack (FragmentTransaction)
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • JComboBox (javax.swing)
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now