本文整理汇总了Java中android.opengl.GLES20.glUniform1fv方法的典型用法代码示例。如果您正苦于以下问题:Java GLES20.glUniform1fv方法的具体用法?Java GLES20.glUniform1fv怎么用?Java GLES20.glUniform1fv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.opengl.GLES20
的用法示例。
在下文中一共展示了GLES20.glUniform1fv方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: draw
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* Issues the draw call. Does the full setup on every call.
*
* @param mvpMatrix The 4x4 projection matrix.
* @param vertexBuffer Buffer with vertex position data.
* @param firstVertex Index of first vertex to use in vertexBuffer.
* @param vertexCount Number of vertices in vertexBuffer.
* @param coordsPerVertex The number of coordinates per vertex (e.g. x,y is 2).
* @param vertexStride Width, in bytes, of the position data for each vertex (often
* vertexCount * sizeof(float)).
* @param texMatrix A 4x4 transformation matrix for texture coords. (Primarily intended
* for use with SurfaceTexture.)
* @param texBuffer Buffer with vertex texture data.
* @param texStride Width, in bytes, of the texture data for each vertex.
*/
public void draw(float[] mvpMatrix, FloatBuffer vertexBuffer, int firstVertex,
int vertexCount, int coordsPerVertex, int vertexStride,
float[] texMatrix, FloatBuffer texBuffer, int textureId, int texStride) {
GlUtil.checkGlError("draw start");
// Select the program.
GLES20.glUseProgram(mProgramHandle);
GlUtil.checkGlError("glUseProgram");
// Set the texture.
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(mTextureTarget, textureId);
// Copy the model / view / projection matrix over.
GLES20.glUniformMatrix4fv(muMVPMatrixLoc, 1, false, mvpMatrix, 0);
GlUtil.checkGlError("glUniformMatrix4fv");
// Copy the texture transformation matrix over.
GLES20.glUniformMatrix4fv(muTexMatrixLoc, 1, false, texMatrix, 0);
GlUtil.checkGlError("glUniformMatrix4fv");
// Enable the "aPosition" vertex attribute.
GLES20.glEnableVertexAttribArray(maPositionLoc);
GlUtil.checkGlError("glEnableVertexAttribArray");
// Connect vertexBuffer to "aPosition".
GLES20.glVertexAttribPointer(maPositionLoc, coordsPerVertex,
GLES20.GL_FLOAT, false, vertexStride, vertexBuffer);
GlUtil.checkGlError("glVertexAttribPointer");
// Enable the "aTextureCoord" vertex attribute.
GLES20.glEnableVertexAttribArray(maTextureCoordLoc);
GlUtil.checkGlError("glEnableVertexAttribArray");
// Connect texBuffer to "aTextureCoord".
GLES20.glVertexAttribPointer(maTextureCoordLoc, 2,
GLES20.GL_FLOAT, false, texStride, texBuffer);
GlUtil.checkGlError("glVertexAttribPointer");
// Populate the convolution kernel, if present.
if (muKernelLoc >= 0) {
GLES20.glUniform1fv(muKernelLoc, KERNEL_SIZE, mKernel, 0);
GLES20.glUniform2fv(muTexOffsetLoc, KERNEL_SIZE, mTexOffset, 0);
GLES20.glUniform1f(muColorAdjustLoc, mColorAdjust);
}
// Draw the rect.
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, firstVertex, vertexCount);
GlUtil.checkGlError("glDrawArrays");
// Done -- disable vertex array, texture, and program.
GLES20.glDisableVertexAttribArray(maPositionLoc);
GLES20.glDisableVertexAttribArray(maTextureCoordLoc);
GLES20.glBindTexture(mTextureTarget, 0);
GLES20.glUseProgram(0);
}
示例2: draw
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* Issues the draw call. Does the full setup on every call.
*
* @param mvpMatrix The 4x4 projection matrix.
* @param vertexBuffer Buffer with vertex position data.
* @param firstVertex Index of first vertex to use in vertexBuffer.
* @param vertexCount Number of vertices in vertexBuffer.
* @param coordsPerVertex The numbermatrix of coordinates per vertex (e.g. x,y is 2).
* @param vertexStride Width, in bytes, of the position data for each vertex (often
* vertexCount * sizeof(float)).
* @param texMatrix A 4x4 transformation matrix for texture coords. (Primarily intended
* for use with SurfaceTexture.)
* @param texBuffer Buffer with vertex texture data.
* @param texStride Width, in bytes, of the texture data for each vertex.
*/
public void draw(float[] mvpMatrix, FloatBuffer vertexBuffer, int firstVertex,
int vertexCount, int coordsPerVertex, int vertexStride,
float[] texMatrix, FloatBuffer texBuffer, int textureId, int texStride) {
GlUtil.checkGlError("draw start");
// Select the program.
GLES20.glUseProgram(mProgramHandle);
GlUtil.checkGlError("glUseProgram");
// Set the texture.
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(mTextureTarget, textureId);
// Copy the model / view / projection matrix over.
GLES20.glUniformMatrix4fv(muMVPMatrixLoc, 1, false, mvpMatrix, 0);
GlUtil.checkGlError("glUniformMatrix4fv");
// Copy the texture transformation matrix over.
GLES20.glUniformMatrix4fv(muTexMatrixLoc, 1, false, texMatrix, 0);
GlUtil.checkGlError("glUniformMatrix4fv");
// Enable the "aPosition" vertex attribute.
GLES20.glEnableVertexAttribArray(maPositionLoc);
GlUtil.checkGlError("glEnableVertexAttribArray");
// Connect vertexBuffer to "aPosition".
GLES20.glVertexAttribPointer(maPositionLoc, coordsPerVertex,
GLES20.GL_FLOAT, false, vertexStride, vertexBuffer);
GlUtil.checkGlError("glVertexAttribPointer");
// Enable the "aTextureCoord" vertex attribute.
GLES20.glEnableVertexAttribArray(maTextureCoordLoc);
GlUtil.checkGlError("glEnableVertexAttribArray");
// Connect texBuffer to "aTextureCoord".
GLES20.glVertexAttribPointer(maTextureCoordLoc, 2,
GLES20.GL_FLOAT, false, texStride, texBuffer);
GlUtil.checkGlError("glVertexAttribPointer");
// Populate the convolution kernel, if present.
if (muKernelLoc >= 0) {
GLES20.glUniform1fv(muKernelLoc, KERNEL_SIZE, mKernel, 0);
GLES20.glUniform2fv(muTexOffsetLoc, KERNEL_SIZE, mTexOffset, 0);
GLES20.glUniform1f(muColorAdjustLoc, mColorAdjust);
}
// Draw the rect.
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, firstVertex, vertexCount);
GlUtil.checkGlError("glDrawArrays");
// Done -- disable vertex array, texture, and program.
GLES20.glDisableVertexAttribArray(maPositionLoc);
GLES20.glDisableVertexAttribArray(maTextureCoordLoc);
GLES20.glBindTexture(mTextureTarget, 0);
GLES20.glUseProgram(0);
}