当前位置: 首页>>代码示例>>Java>>正文


Java GLES20.glUniformMatrix4fv方法代码示例

本文整理汇总了Java中android.opengl.GLES20.glUniformMatrix4fv方法的典型用法代码示例。如果您正苦于以下问题:Java GLES20.glUniformMatrix4fv方法的具体用法?Java GLES20.glUniformMatrix4fv怎么用?Java GLES20.glUniformMatrix4fv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.opengl.GLES20的用法示例。


在下文中一共展示了GLES20.glUniformMatrix4fv方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: draw

import android.opengl.GLES20; //导入方法依赖的package包/类
private void draw(float[] matrix, FloatBuffer vertexBuffer, FloatBuffer uvBuffer, ShortBuffer drawListBuffer, short[] indices) {
    texture.bindTexture(0);
    GLES20.glEnable(GLES20.GL_BLEND_COLOR);
    GLES20.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    GLES20.glDepthMask(false);
    int mPositionHandle = GLES20.glGetAttribLocation(SpriteKitGraphicTools.imageShaderProgram, "vPosition");
    GLES20.glEnableVertexAttribArray(mPositionHandle);
    GLES20.glVertexAttribPointer(mPositionHandle, 3,
            GLES20.GL_FLOAT, false,
            0, vertexBuffer);
    int mTexCoordLoc = GLES20.glGetAttribLocation(SpriteKitGraphicTools.imageShaderProgram, "a_texCoord");
    GLES20.glEnableVertexAttribArray(mTexCoordLoc);
    GLES20.glVertexAttribPointer(mTexCoordLoc, 2, GLES20.GL_FLOAT,
            false,
            0, uvBuffer);
    int mtrxhandle = GLES20.glGetUniformLocation(SpriteKitGraphicTools.imageShaderProgram, "uMVPMatrix");
    GLES20.glUniformMatrix4fv(mtrxhandle, 1, false, matrix, 0);
    int mSamplerLoc = GLES20.glGetUniformLocation(SpriteKitGraphicTools.imageShaderProgram, "s_texture");
    GLES20.glUniform1i(mSamplerLoc, 0);
    GLES20.glDrawElements(GLES20.GL_TRIANGLES, indices.length,
            GLES20.GL_UNSIGNED_SHORT, drawListBuffer);
    GLES20.glDisableVertexAttribArray(mPositionHandle);
    GLES20.glDisableVertexAttribArray(mTexCoordLoc);
    GLES20.glDisable(GLES20.GL_BLEND_COLOR);
}
 
开发者ID:sakkeerhussain,项目名称:SpriteKit-Android,代码行数:26,代码来源:Sprite.java

示例2: drawLight

import android.opengl.GLES20; //导入方法依赖的package包/类
private void drawLight() {
    final int pointMVPMatrixHandle = GLES20.glGetUniformLocation(mPointProgramHandle, "u_MVPMatrix");
    final int pointPositionHandle = GLES20.glGetAttribLocation(mPointProgramHandle, "a_Position");

    // Pass in the position.
    GLES20.glVertexAttrib3f(pointPositionHandle, mLightPosInModelSpace[0], mLightPosInModelSpace[1], mLightPosInModelSpace[2]);

    // Since we are not using a buffer object, disable vertex arrays for this attribute.
    GLES20.glDisableVertexAttribArray(pointPositionHandle);

    // Pass in the transformation matrix.
    Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mLightModelMatrix, 0);
    Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);
    GLES20.glUniformMatrix4fv(pointMVPMatrixHandle, 1, false, mMVPMatrix, 0);

    // Draw the point.
    GLES20.glDrawArrays(GLES20.GL_POINTS, 0, 1);
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:19,代码来源:LessonSixRenderer.java

示例3: updateFloatValue

import android.opengl.GLES20; //导入方法依赖的package包/类
private void updateFloatValue(float... value) {
    switch (value.length) {
        case 1:
            GLES20.glUniform1f(handle(), value[0]);
            break;
        case 2:
            GLES20.glUniform2f(handle(), value[0], value[1]);
            break;
        case 3:
            GLES20.glUniform3f(handle(), value[0], value[1], value[2]);
            break;
        case 4:
            GLES20.glUniform4f(handle(), value[0], value[1], value[2], value[3]);
            break;
        case 16:
            GLES20.glUniformMatrix4fv(handle(), 1, false, value, 0);
        default:
            break;
    }
}
 
开发者ID:gplibs,项目名称:android-magic-surface-view,代码行数:21,代码来源:GLUniformParameter.java

示例4: onPreDrawElements

import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public void onPreDrawElements() {
    super.onPreDrawElements();
    glPassThroughProgram.use();
    plane.uploadTexCoordinateBuffer(glPassThroughProgram.getTextureCoordinateHandle());
    plane.uploadVerticesBuffer(glPassThroughProgram.getPositionHandle());
    GLES20.glUniformMatrix4fv(glPassThroughProgram.getMVPMatrixHandle(), 1, false, projectionMatrix, 0);
}
 
开发者ID:zhangyaqiang,项目名称:Fatigue-Detection,代码行数:9,代码来源:OrthoFilter.java

示例5: draw

import android.opengl.GLES20; //导入方法依赖的package包/类
/**
 * draw specific texture with specific texture matrix
 *
 * @param textureId texture ID
 * @param texMatrix texture matrix if this is null, the last one use(we don't check size of this array and needs at least 16 of float)
 */
public void draw(final int textureId, final float[] mvpMatrix, final float[] texMatrix) {
    // Select the program.
    GLES20.glUseProgram(hProgram);

    // Set the texture.
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(mTextureTarget, textureId);


    // Copy the texture transformation matrix over.
    GLES20.glUniformMatrix4fv(muTexMatrixLoc, 1, false, texMatrix, 0);

    // Copy the model / view / projection matrix over.
    GLES20.glUniformMatrix4fv(muMVPMatrixLoc, 1, false, mvpMatrix, 0);

    // Enable the "aPosition" vertex attribute.
    GLES20.glEnableVertexAttribArray(maPositionLoc);

    // Connect vertexBuffer to "aPosition".
    GLES20.glVertexAttribPointer(maPositionLoc, mCoordsPerVertex,
            GLES20.GL_FLOAT, false, mVertexStride, FULL_RECTANGLE_BUF);

    // Enable the "aTextureCoord" vertex attribute.
    GLES20.glEnableVertexAttribArray(maTextureCoordLoc);

    // Connect texBuffer to "aTextureCoord".
    GLES20.glVertexAttribPointer(maTextureCoordLoc, mCoordsPerVertex,
            GLES20.GL_FLOAT, false, mTexCoordStride, FULL_RECTANGLE_TEX_BUF);

    // Draw the rect.
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, mVertexCount);

    // Done -- disable vertex array, texture, and program.
    GLES20.glDisableVertexAttribArray(maPositionLoc);
    GLES20.glDisableVertexAttribArray(maTextureCoordLoc);
    GLES20.glBindTexture(mTextureTarget, 0);
}
 
开发者ID:LeonHover,项目名称:MediaCodecRecorder,代码行数:44,代码来源:GLSurfaceFilter.java

示例6: drawSelf

import android.opengl.GLES20; //导入方法依赖的package包/类
public void drawSelf() {
    //指定使用着色器程序
    GLES20.glUseProgram(mProgram);
    //初始化变换矩阵
    Matrix.setRotateM(mMMatrix , 0 , 0 , 0 , 1 , 0);
    //设置沿Z轴正方向唯一1
    Matrix.translateM(mMMatrix , 0 , 0 , 0 , 1);
    //设置绕Y轴旋转角度yAngle
    Matrix.rotateM(mMMatrix , 0 , yAngle , 0 , 1 , 0);
    //设置绕X轴旋转角度xAngle
    Matrix.rotateM(mMMatrix , 0 , xAngle , 1 , 0 , 0);
    //将最终变换矩阵传入渲染管线
    GLES20.glUniformMatrix4fv(muMVPMatrixHandle , 1 , false , MatrixState.getFinalMatrix(mMMatrix) , 0);
    GLES20.glVertexAttribPointer(maPositionHandle ,//顶点位置属性引用
                                 3 ,//每顶点一组的数据个数(X Y Z 坐标 所以是3)
                                 GLES20.GL_FLOAT ,//数据类型
                                 false ,//是否规格化
                                 3 * 4 ,//每组数据的尺寸,这里每组3个浮点数据,每个浮点4byte,所以是3*4
                                 mVertexBuffer//存放了数据的缓冲区
    );
    //把颜色数据传送进渲染管线
    GLES20.glVertexAttribPointer(maColorHandle , 4 , GLES20.GL_FLOAT , false , 4 * 4 , mColorBuffer);
    //启用顶点位置数据和颜色数据
    GLES20.glEnableVertexAttribArray(maPositionHandle);
    GLES20.glEnableVertexAttribArray(maColorHandle);

    //开始绘制,绘制三角形
    GLES20.glDrawArrays(GLES20.GL_TRIANGLES , 0 , vCount);
}
 
开发者ID:ynztlxdeai,项目名称:GLhexagram,代码行数:30,代码来源:Hexagram.java

示例7: drawTriangle

import android.opengl.GLES20; //导入方法依赖的package包/类
/**
 * Draws a triangle from the given vertex data.
 * 
 * @param aTriangleBuffer The buffer containing the vertex data.
 */
private void drawTriangle(final FloatBuffer aTriangleBuffer)
{		
	// Pass in the position information
	aTriangleBuffer.position(mPositionOffset);
       GLES20.glVertexAttribPointer(mPositionHandle, mPositionDataSize, GLES20.GL_FLOAT, false,
       		mStrideBytes, aTriangleBuffer);        
               
       GLES20.glEnableVertexAttribArray(mPositionHandle);        
       
       // Pass in the color information
       aTriangleBuffer.position(mColorOffset);
       GLES20.glVertexAttribPointer(mColorHandle, mColorDataSize, GLES20.GL_FLOAT, false,
       		mStrideBytes, aTriangleBuffer);        
       
       GLES20.glEnableVertexAttribArray(mColorHandle);
       
	// This multiplies the view matrix by the model matrix, and stores the result in the MVP matrix
       // (which currently contains model * view).
       Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mModelMatrix, 0);
       
       // This multiplies the modelview matrix by the projection matrix, and stores the result in the MVP matrix
       // (which now contains model * view * projection).
       Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);

       GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);
       GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 3);                               
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:33,代码来源:LessonOneRenderer.java

示例8: render

import android.opengl.GLES20; //导入方法依赖的package包/类
/**
 * draws the Triangles shape object
 * @param aMVPMatrix
 */
public void render(float[] aMVPMatrix){
    // disable culling to enable back faces.
    GLES20.glDisable(GLES20.GL_CULL_FACE);

    // Tell OpenGL to use this program when rendering.
    GLES20.glUseProgram(aTriangleProgramHandle);

    // Set program handles. These will later be used to pass in values to the program.
    aMVPMatrixHandle = GLES20.glGetUniformLocation(aTriangleProgramHandle, "u_MVPMatrix");
    aPositionHandle = GLES20.glGetAttribLocation(aTriangleProgramHandle, "a_Position");
    aColorHandle = GLES20.glGetAttribLocation(aTriangleProgramHandle, "a_Color");

    // Pass in the combined matrix.
    GLES20.glUniformMatrix4fv(aMVPMatrixHandle, 1, false, aMVPMatrix, 0);

    GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, aTrianglePositionsBufferIdx);
    GLES20.glEnableVertexAttribArray(aPositionHandle);
    GLES20.glVertexAttribPointer(aPositionHandle, POSITION_DATA_SIZE, GLES20.GL_FLOAT, false, 0, 0);

    GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, aTriangleColorsBufferIdx);
    GLES20.glEnableVertexAttribArray(aColorHandle);
    GLES20.glVertexAttribPointer(aColorHandle, COLOR_POSITION_DATA, GLES20.GL_FLOAT, false, 0, 0);

    // Clear the currently bound buffer (so future OpenGL calls do not use this buffer).
    GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);

    // Draw the triangle.
    GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, vertexCount);

}
 
开发者ID:regar007,项目名称:ShapesInOpenGLES2.0,代码行数:35,代码来源:Triangles.java

示例9: draw

import android.opengl.GLES20; //导入方法依赖的package包/类
/**
 * Encapsulates the OpenGL ES instructions for drawing this shape.
 *
 * @param mvpMatrix - The Model View Project matrix in which to draw
 * this shape.
 */
public void draw(float[] mvpMatrix) {
    // Add program to OpenGL environment
    GLES20.glUseProgram(mProgram);

    // get handle to vertex shader's vPosition member
    mPositionHandle = GLES20.glGetAttribLocation(mProgram, "vPosition");

    // Enable a handle to the triangle vertices
    GLES20.glEnableVertexAttribArray(mPositionHandle);

    // Prepare the triangle coordinate data
    GLES20.glVertexAttribPointer(
            mPositionHandle, COORDS_PER_VERTEX,
            GLES20.GL_FLOAT, false,
            vertexStride, vertexBuffer);

    // get handle to fragment shader's vColor member
    mColorHandle = GLES20.glGetUniformLocation(mProgram, "vColor");

    // Set color for drawing the triangle
    GLES20.glUniform4fv(mColorHandle, 1, color, 0);

    // get handle to shape's transformation matrix
    mMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix");
    MyGLRenderer.checkGlError("glGetUniformLocation");

    // Apply the projection and view transformation
    GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mvpMatrix, 0);
    MyGLRenderer.checkGlError("glUniformMatrix4fv");

    // Draw the triangle
    GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, vertexCount);

    // Disable vertex array
    GLES20.glDisableVertexAttribArray(mPositionHandle);
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:43,代码来源:Triangle.java

示例10: bindGLSLValues

import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
protected void bindGLSLValues(float[] mvpMatrix, FloatBuffer vertexBuffer, int coordsPerVertex,
        int vertexStride, float[] texMatrix, FloatBuffer texBuffer, int texStride) {

    GLES20.glUniformMatrix4fv(muMVPMatrixLoc, 1, false, mvpMatrix, 0);
    GLES20.glUniformMatrix4fv(muTexMatrixLoc, 1, false, texMatrix, 0);
    GLES20.glEnableVertexAttribArray(maPositionLoc);
    GLES20.glVertexAttribPointer(maPositionLoc, coordsPerVertex, GLES20.GL_FLOAT, false,
            vertexStride, vertexBuffer);
    GLES20.glEnableVertexAttribArray(maTextureCoordLoc);
    GLES20.glVertexAttribPointer(maTextureCoordLoc, 2, GLES20.GL_FLOAT, false, texStride,
            texBuffer);
}
 
开发者ID:hoanganhtuan95ptit,项目名称:EditPhoto,代码行数:14,代码来源:CameraFilter.java

示例11: draw

import android.opengl.GLES20; //导入方法依赖的package包/类
/**
 * Renders the point cloud.
 *
 * @param pose              the current point cloud pose, from {@link Frame#getPointCloudPose()}.
 * @param cameraView        the camera view matrix for this frame, typically from
 *                          {@link Frame#getViewMatrix(float[], int)}.
 * @param cameraPerspective the camera projection matrix for this frame, typically from
 *                          {@link Session#getProjectionMatrix(float[], int, float, float)}.
 */
public void draw(Pose pose, float[] cameraView, float[] cameraPerspective) {
    float[] modelMatrix = new float[16];
    pose.toMatrix(modelMatrix, 0);

    float[] modelView = new float[16];
    float[] modelViewProjection = new float[16];
    Matrix.multiplyMM(modelView, 0, cameraView, 0, modelMatrix, 0);
    Matrix.multiplyMM(modelViewProjection, 0, cameraPerspective, 0, modelView, 0);

    ShaderUtil.checkGLError(TAG, "Before draw");

    GLES20.glUseProgram(mProgramName);
    GLES20.glEnableVertexAttribArray(mPositionAttribute);
    GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mVbo);
    GLES20.glVertexAttribPointer(
            mPositionAttribute, 4, GLES20.GL_FLOAT, false, BYTES_PER_POINT, 0);
    GLES20.glUniform4f(mColorUniform, 31.0f / 255.0f, 188.0f / 255.0f, 210.0f / 255.0f, 1.0f);
    GLES20.glUniformMatrix4fv(mModelViewProjectionUniform, 1, false, modelViewProjection, 0);
    GLES20.glUniform1f(mPointSizeUniform, 5.0f);

    GLES20.glDrawArrays(GLES20.GL_POINTS, 0, mNumPoints);
    GLES20.glDisableVertexAttribArray(mPositionAttribute);
    GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);

    ShaderUtil.checkGLError(TAG, "Draw");
}
 
开发者ID:nimbl3,项目名称:nimbl3-arcore,代码行数:36,代码来源:PointCloudRenderer.java

示例12: drawFrame

import android.opengl.GLES20; //导入方法依赖的package包/类
public void drawFrame(SurfaceTexture st) {
    checkGlError("onDrawFrame start");
    st.getTransformMatrix(mSTMatrix);
    GLES20.glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
    GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
    GLES20.glUseProgram(mProgram);
    checkGlError("glUseProgram");
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTextureID);
    mTriangleVertices.position(TRIANGLE_VERTICES_DATA_POS_OFFSET);
    GLES20.glVertexAttribPointer(maPositionHandle, 3, GLES20.GL_FLOAT, false,
            TRIANGLE_VERTICES_DATA_STRIDE_BYTES, mTriangleVertices);
    checkGlError("glVertexAttribPointer maPosition");
    GLES20.glEnableVertexAttribArray(maPositionHandle);
    checkGlError("glEnableVertexAttribArray maPositionHandle");
    mTriangleVertices.position(TRIANGLE_VERTICES_DATA_UV_OFFSET);
    GLES20.glVertexAttribPointer(maTextureHandle, 2, GLES20.GL_FLOAT, false,
            TRIANGLE_VERTICES_DATA_STRIDE_BYTES, mTriangleVertices);
    checkGlError("glVertexAttribPointer maTextureHandle");
    GLES20.glEnableVertexAttribArray(maTextureHandle);
    checkGlError("glEnableVertexAttribArray maTextureHandle");
    Matrix.setIdentityM(mMVPMatrix, 0);
    GLES20.glUniformMatrix4fv(muMVPMatrixHandle, 1, false, mMVPMatrix, 0);
    GLES20.glUniformMatrix4fv(muSTMatrixHandle, 1, false, mSTMatrix, 0);
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
    checkGlError("glDrawArrays");
    GLES20.glFinish();
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:29,代码来源:TextureRender.java

示例13: newShader

import android.opengl.GLES20; //导入方法依赖的package包/类
/** Create a shader */
public static void newShader(@NonNull int[] attrs) {
    if (attrs.length != 5) {
        throw new IllegalArgumentException("Must be 5 int-array");
    }

    /*
     * 0 - Program
     * 1 - Vertex Shader
     * 2 - Fragment Shader
     * 3 - Position Handle
     * 4 - Texture Handle
     **/

    attrs[0] = GLES20.glCreateProgram();
    checkError();

    GLES20.glAttachShader(attrs[0], (attrs[1] = loadShader(GLES20.GL_VERTEX_SHADER, VSHADER)));
    GLES20.glAttachShader(attrs[0], (attrs[2] = loadShader(GLES20.GL_FRAGMENT_SHADER, FSHADER)));
    GLES20.glLinkProgram(attrs[0]); GLES20.glUseProgram(attrs[0]);
    checkError();

    attrs[3] = GLES20.glGetAttribLocation(attrs[0], V_POSITION);
    attrs[4] = GLES20.glGetAttribLocation(attrs[0], V_COORDINATE);
    final int uMVPMatrixHandle = GLES20.glGetUniformLocation(attrs[0], V_MVP_MATRIX);
    final int uSTMatrixHandle = GLES20.glGetUniformLocation(attrs[0], V_ST_MATRIX);
    checkError();

    TRIANGLE_VERTICES.position(TRIANGLE_VERTICES_DATA_POS_OFFSET);
    GLES20.glVertexAttribPointer(attrs[3], 3, GLES20.GL_FLOAT, false,
            TRIANGLE_VERTICES_DATA_STRIDE_BYTES, TRIANGLE_VERTICES);
    checkError();

    TRIANGLE_VERTICES.position(TRIANGLE_VERTICES_DATA_UV_OFFSET);
    GLES20.glVertexAttribPointer(attrs[4], 4, GLES20.GL_FLOAT, false,
            TRIANGLE_VERTICES_DATA_STRIDE_BYTES, TRIANGLE_VERTICES);
    checkError();

    GLES20.glEnableVertexAttribArray(attrs[3]);
    GLES20.glEnableVertexAttribArray(attrs[4]);
    checkError();

    float[] MVPMatrix = new float[16]; Matrix.setIdentityM(MVPMatrix, 0);
    GLES20.glUniformMatrix4fv(uMVPMatrixHandle, 1, false, MVPMatrix, 0);
    float[] STMatrix = new float[16]; Matrix.setIdentityM(STMatrix, 0);
    GLES20.glUniformMatrix4fv(uSTMatrixHandle, 1, false, STMatrix, 0);
    checkError();

    logDebug("Shader created");
}
 
开发者ID:Nik-Gleb,项目名称:mpeg-encoder,代码行数:51,代码来源:GLTools.java

示例14: valueM4

import android.opengl.GLES20; //导入方法依赖的package包/类
public void valueM4(float[] value) {
	GLES20.glUniformMatrix4fv(location, 1, false, value, 0);
}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:4,代码来源:Uniform.java

示例15: render

import android.opengl.GLES20; //导入方法依赖的package包/类
/**
     * draws Sphere objects
     * @param aMVPMatrix
     */
    public void render(float[] aMVPMatrix) {

        if(BLENDING) {
            // Enable blending
            GLES20.glEnable(GLES20.GL_BLEND);
//            GLES20.glBlendFuncSeparate(GLES20.GL_ONE_MINUS_SRC_COLOR, GLES20.GL_ONE_MINUS_DST_COLOR, GLES20.GL_ONE_MINUS_SRC_ALPHA, GLES20.GL_ONE_MINUS_DST_ALPHA);
            GLES20.glBlendFunc( GLES20.GL_ONE_MINUS_SRC_ALPHA, GLES20.GL_ONE_MINUS_DST_ALPHA);

//            GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
        }
        // Set our per-vertex lighting program.
        GLES20.glUseProgram(aSphereProgramHandle);

        int aSphereMVPMatrixHandle = GLES20.glGetUniformLocation(aSphereProgramHandle, "u_MVPMatrix");
        int aSpherePositionHandle = GLES20.glGetAttribLocation(aSphereProgramHandle, "a_Position");
        int aSphereColorHandle = GLES20.glGetAttribLocation(aSphereProgramHandle, "a_Color");

        // Pass in the combined matrix.
        //GLES20.glUniformMatrix4fv(aMVPMatrixHandle, 1, false, aMVPMatrix, 0);
        GLES20.glUniformMatrix4fv(aSphereMVPMatrixHandle, 1, false, aMVPMatrix, 0);

        GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, aSpheresVerticesBufferIdx);
        GLES20.glEnableVertexAttribArray(aSpherePositionHandle);
        GLES20.glVertexAttribPointer(aSpherePositionHandle, POSITION_DATA_SIZE, GLES20.GL_FLOAT, false, 0, 0);

        GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, aSpheresColorsBufferIdx);
        GLES20.glEnableVertexAttribArray(aSphereColorHandle);
        GLES20.glVertexAttribPointer(aSphereColorHandle, COLOR_DATA_SIZE , GLES20.GL_FLOAT, false, 0, 0);

        GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);

        // Draw the vertices.
        GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, vertexCount);

        // draw the vertices using indices
//            GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, aSphereIndicesBufferIdx);
//            GLES20.glDrawElements(GLES20.GL_TRIANGLE_STRIP, indexCount, GLES20.GL_UNSIGNED_SHORT, 0);

        // Clear the currently bound buffer (so future OpenGL calls do not use this buffer).
//            GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0);

        if(BLENDING) {
            // Enable blending
            GLES20.glDisable(GLES20.GL_BLEND);
//            GLES20.glBlendFuncSeparate(GLES20.GL_ONE_MINUS_SRC_COLOR, GLES20.GL_ONE_MINUS_DST_COLOR, GLES20.GL_ONE_MINUS_SRC_ALPHA, GLES20.GL_ONE_MINUS_DST_ALPHA);

//            GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
        }
    }
 
开发者ID:regar007,项目名称:ShapesInOpenGLES2.0,代码行数:54,代码来源:Spheres.java


注:本文中的android.opengl.GLES20.glUniformMatrix4fv方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。