List of usage examples for android.opengl GLES20 glUniform1i
public static native void glUniform1i(int location, int x);
From source file:com.tumblr.cardboard.Tumblr3DActivity.java
/** * Draw the rect. We've set all of our transformation matrices. Now we simply pass them into * the shader.//from ww w .jav a2s. com */ public void drawRect(int texIndex) { if (mRectTextureIds[texIndex] < INVALID_TEXTURE) { // can't draw this rectangle return; } // This is not the floor! GLES20.glUniform1f(mIsFloorParam, 0f); // Set the active texture unit GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + texIndex); // Bind the texture to this unit. GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mRectTextureIds[texIndex]); // Tell the texture uniform sampler to use this texture in the shader by binding to texture unit 0. GLES20.glUniform1i(mRectTextureUniformParam, texIndex); // Set the Model in the shader, used to calculate lighting GLES20.glUniformMatrix4fv(mModelParam, 1, false, mModelRect[texIndex], 0); // Set the ModelView in the shader, used to calculate lighting GLES20.glUniformMatrix4fv(mModelViewParam, 1, false, mModelView, 0); // Set the position of the rect GLES20.glVertexAttribPointer(mPositionParam, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, 0, mRectVertices); // Set the ModelViewProjection matrix in the shader. GLES20.glUniformMatrix4fv(mModelViewProjectionParam, 1, false, mModelViewProjection, 0); // Set the normal positions of the rect, again for shading GLES20.glVertexAttribPointer(mNormalParam, 3, GLES20.GL_FLOAT, false, 0, mRectNormals); // Connect texBuffer to "aTextureCoord". GLES20.glVertexAttribPointer(mRectTextureCoordinateParam, 2, GLES20.GL_FLOAT, false, 0, mRectTexCoords); // Enable the "aTextureCoord" vertex attribute. GLES20.glEnableVertexAttribArray(mRectTextureCoordinateParam); if (texIndex == mSelectedTexIndex || isLookingAtObject(texIndex)) { GLES20.glVertexAttribPointer(mColorParam, 4, GLES20.GL_FLOAT, false, 0, mRectFoundColors); } else { GLES20.glVertexAttribPointer(mColorParam, 4, GLES20.GL_FLOAT, false, 0, mRectColors); } GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, WorldLayoutData.RECT_COORDS.length / 3); // 3 b/c triangles checkGLError("Drawing rect"); }