當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。