Example usage for android.opengl GLES20 glUniform3fv

List of usage examples for android.opengl GLES20 glUniform3fv

Introduction

In this page you can find the example usage for android.opengl GLES20 glUniform3fv.

Prototype

public static native void glUniform3fv(int location, int count, float[] v, int offset);

Source Link

Usage

From source file:com.ryandymock.consumptionvisualization.shader.WaterParticleMaterial.java

@Override
public void beginRender() {
    super.beginRender();

    // Specific uniforms to this material
    GLES20.glUniform1f(getUniformLocation("uPointSize"),
            Math.max(1.0f, mParticleSizeScale * ParticleRenderer.FB_SIZE
                    * (Renderer.PARTICLE_RADIUS / Renderer.getInstance().sRenderWorldHeight)));
    GLES20.glUniform3fv(getUniformLocation("uWeightParams"), 1, mWeightParams, 0);
}

From source file:com.google.fpl.liquidfunpaint.shader.WaterParticleMaterial.java

@Override
public void beginRender() {
    super.beginRender();

    float pSize = mParticleSizeScale * ParticleRenderer.FB_SIZE * (ParticleSystems.PARTICLE_RADIUS
            / Math.min(WorldLock.getInstance().sRenderWorldWidth, WorldLock.getInstance().sRenderWorldHeight));

    // Specific uniforms to this material
    GLES20.glUniform1f(getUniformLocation("uPointSize"), Math.max(1.0f, pSize));
    GLES20.glUniform3fv(getUniformLocation("uWeightParams"), 1, mWeightParams, 0);
}

From source file:com.google.vrtoolkit.cardboard.samples.treasurehunt.MainActivity.java

/**
 * Draw the cube./*from   ww  w  . j  av  a  2s.  c  om*/
 *
 * <p>We've set all of our transformation matrices. Now we simply pass them into the shader.
 */
public void drawCube() {
    GLES20.glUseProgram(cubeProgram);

    GLES20.glUniform3fv(cubeLightPosParam, 1, lightPosInEyeSpace, 0);

    // Set the Model in the shader, used to calculate lighting
    GLES20.glUniformMatrix4fv(cubeModelParam, 1, false, modelCube, 0);

    // Set the ModelView in the shader, used to calculate lighting
    GLES20.glUniformMatrix4fv(cubeModelViewParam, 1, false, modelView, 0);

    // Set the position of the cube
    GLES20.glVertexAttribPointer(cubePositionParam, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, 0, cubeVertices);

    // Set the ModelViewProjection matrix in the shader.
    GLES20.glUniformMatrix4fv(cubeModelViewProjectionParam, 1, false, modelViewProjection, 0);

    // Set the normal positions of the cube, again for shading
    GLES20.glVertexAttribPointer(cubeNormalParam, 3, GLES20.GL_FLOAT, false, 0, cubeNormals);
    GLES20.glVertexAttribPointer(cubeColorParam, 4, GLES20.GL_FLOAT, false, 0,
            isLookingAtObject() ? cubeFoundColors : cubeColors);

    GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 36);
    checkGLError("Drawing cube");
}

From source file:com.google.vrtoolkit.cardboard.samples.treasurehunt.MainActivity.java

public void drawMiniCube() {
    GLES20.glUseProgram(miniCubeProgram);

    GLES20.glUniform3fv(miniCubeLightPosParam, 1, lightPosInEyeSpace, 0);

    // Set the Model in the shader, used to calculate lighting
    GLES20.glUniformMatrix4fv(miniCubeModelParam, 1, false, modelMiniCube, 0);

    // Set the ModelView in the shader, used to calculate lighting
    GLES20.glUniformMatrix4fv(miniCubeModelViewParam, 1, false, modelView, 0);

    // Set the position of the miniCube
    GLES20.glVertexAttribPointer(miniCubePositionParam, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, 0,
            miniCubeVertices);/*  w  w w  .j a  v a2s  .  c  o m*/

    // Set the ModelViewProjection matrix in the shader.
    GLES20.glUniformMatrix4fv(miniCubeModelViewProjectionParam, 1, false, modelViewProjection, 0);

    // Set the normal positions of the miniCube, again for shading
    GLES20.glVertexAttribPointer(miniCubeNormalParam, 3, GLES20.GL_FLOAT, false, 0, miniCubeNormals);
    GLES20.glVertexAttribPointer(miniCubeColorParam, 4, GLES20.GL_FLOAT, false, 0, miniCubeColors);

    GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 36);
    checkGLError("Drawing miniCube");
}

From source file:com.google.vrtoolkit.cardboard.samples.treasurehunt.MainActivity.java

/**
 * Draw the floor.// w ww.  j a  va  2s .  co m
 *
 * <p>This feeds in data for the floor into the shader. Note that this doesn't feed in data about
 * position of the light, so if we rewrite our code to draw the floor first, the lighting might
 * look strange.
 */
public void drawFloor() {
    GLES20.glUseProgram(floorProgram);

    // Set ModelView, MVP, position, normals, and color.
    GLES20.glUniform3fv(floorLightPosParam, 1, lightPosInEyeSpace, 0);
    GLES20.glUniformMatrix4fv(floorModelParam, 1, false, modelFloor, 0);
    GLES20.glUniformMatrix4fv(floorModelViewParam, 1, false, modelView, 0);
    GLES20.glUniformMatrix4fv(floorModelViewProjectionParam, 1, false, modelViewProjection, 0);
    GLES20.glVertexAttribPointer(floorPositionParam, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, 0,
            floorVertices);
    GLES20.glVertexAttribPointer(floorNormalParam, 3, GLES20.GL_FLOAT, false, 0, floorNormals);
    GLES20.glVertexAttribPointer(floorColorParam, 4, GLES20.GL_FLOAT, false, 0, floorColors);

    GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 6);

    checkGLError("drawing floor");
}