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


Java GLES30.glGetUniformLocation方法代码示例

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


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

示例1: drawFloor

import android.opengl.GLES30; //导入方法依赖的package包/类
/**
 * Draw the floor.
 *
 * <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(float[] modelViewProjection, float[] modelFloor, float[] modelView, float[] lightPosInEyeSpace ) {
    GLES30.glUseProgram(mProgramObject);
    floorModelParam = GLES30.glGetUniformLocation(mProgramObject, "u_Model");
    floorModelViewParam = GLES30.glGetUniformLocation(mProgramObject, "u_MVMatrix");
    floorModelViewProjectionParam = GLES30.glGetUniformLocation(mProgramObject, "u_MVP");
    floorLightPosParam = GLES30.glGetUniformLocation(mProgramObject, "u_LightPos");

    floorPositionParam = GLES30.glGetAttribLocation(mProgramObject, "a_Position");
    floorNormalParam = GLES30.glGetAttribLocation(mProgramObject, "a_Normal");
    floorColorParam = GLES30.glGetAttribLocation(mProgramObject, "a_Color");

    GLES30.glEnableVertexAttribArray(floorPositionParam);
    GLES30.glEnableVertexAttribArray(floorNormalParam);
    GLES30.glEnableVertexAttribArray(floorColorParam);

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

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


}
 
开发者ID:JimSeker,项目名称:CardBoardVR,代码行数:36,代码来源:Floor.java

示例2: draw

import android.opengl.GLES30; //导入方法依赖的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
    GLES30.glUseProgram(mProgram);

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

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

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

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

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

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

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

    // Draw the square
    GLES30.glDrawElements(
            GLES30.GL_TRIANGLES, drawOrder.length,
            GLES30.GL_UNSIGNED_SHORT, drawListBuffer);

    // Disable vertex array
    GLES30.glDisableVertexAttribArray(mPositionHandle);
}
 
开发者ID:JimSeker,项目名称:opengl,代码行数:45,代码来源:Square.java

示例3: draw

import android.opengl.GLES30; //导入方法依赖的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
    GLES30.glUseProgram(mProgram);

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

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

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

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

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

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

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

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

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

示例4: glGetUniformLocation

import android.opengl.GLES30; //导入方法依赖的package包/类
@Override
public int glGetUniformLocation(int program, String name)
{
    return GLES30.glGetUniformLocation(program, name);
}
 
开发者ID:sriharshachilakapati,项目名称:SilenceEngine,代码行数:6,代码来源:AndroidGraphicsDevice.java

示例5: draw

import android.opengl.GLES30; //导入方法依赖的package包/类
public void draw(float[] mvpMatrix) {

        // Use the program object
        GLES30.glUseProgram(mProgramObject);

        // get handle to shape's transformation matrix
        mMVPMatrixHandle = GLES30.glGetUniformLocation(mProgramObject, "uMVPMatrix");
        myStereoRenderer.checkGlError("glGetUniformLocation");

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


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

        int VERTEX_POS_INDX = 0;
        mVertices.position(VERTEX_POS_INDX);  //just in case.  We did it already though.

        //add all the points to the space, so they can be correct by the transformations.
        //would need to do this even if there were no transformations actually.
        GLES30.glVertexAttribPointer(VERTEX_POS_INDX, 3, GLES30.GL_FLOAT,
                false, 0, mVertices);
        GLES30.glEnableVertexAttribArray(VERTEX_POS_INDX);


        //Now we are ready to draw the cube finally.
        int startPos = 0;
        int verticesPerface = 3;

        //draw front face
        GLES30.glUniform4fv(mColorHandle, 1, colorblue, 0);
        GLES30.glDrawArrays(GLES30.GL_TRIANGLES, startPos, verticesPerface);
        startPos += verticesPerface;

        //draw right face
        GLES30.glUniform4fv(mColorHandle, 1, colorcyan, 0);
        GLES30.glDrawArrays(GLES30.GL_TRIANGLES, startPos, verticesPerface);
        startPos += verticesPerface;

        //draw back face
        GLES30.glUniform4fv(mColorHandle, 1, colorred, 0);
        GLES30.glDrawArrays(GLES30.GL_TRIANGLES, startPos, verticesPerface);
        startPos += verticesPerface;

        //draw left face
        GLES30.glUniform4fv(mColorHandle, 1, colorgray, 0);
        GLES30.glDrawArrays(GLES30.GL_TRIANGLES, startPos, verticesPerface);
        startPos += verticesPerface;


        //draw bottom face 1 tri square, so 6 faces.
        GLES30.glUniform4fv(mColorHandle, 1, coloryellow, 0);
        GLES30.glDrawArrays(GLES30.GL_TRIANGLES, startPos, verticesPerface);
        startPos += verticesPerface;

        //draw bottom face 2 tri square, so 6 faces.
        GLES30.glUniform4fv(mColorHandle, 1, coloryellow, 0);
        GLES30.glDrawArrays(GLES30.GL_TRIANGLES, startPos, verticesPerface);
        startPos += verticesPerface;
        //last face, so no need to increment.

    }
 
开发者ID:JimSeker,项目名称:CardBoardVR,代码行数:65,代码来源:Pyramid.java

示例6: draw

import android.opengl.GLES30; //导入方法依赖的package包/类
public void draw(float[] mvpMatrix) {

        // Use the program object
        GLES30.glUseProgram(mProgramObject);

        // get handle to shape's transformation matrix
        mMVPMatrixHandle = GLES30.glGetUniformLocation(mProgramObject, "uMVPMatrix");
        myStereoRenderer.checkGlError("glGetUniformLocation");

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


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

        int VERTEX_POS_INDX = 0;
        mVertices.position(VERTEX_POS_INDX);  //just in case.  We did it already though.

        //add all the points to the space, so they can be correct by the transformations.
        //would need to do this even if there were no transformations actually.
        GLES30.glVertexAttribPointer(VERTEX_POS_INDX, 3, GLES30.GL_FLOAT,
                false, 0, mVertices);
        GLES30.glEnableVertexAttribArray(VERTEX_POS_INDX);

        //Now we are ready to draw the cube finally.
        int startPos =0;
        int verticesPerface = 6;

        //draw front face
        GLES30.glUniform4fv(mColorHandle, 1, colorblue, 0);
        GLES30.glDrawArrays(GLES30.GL_TRIANGLES,startPos,verticesPerface);
        startPos += verticesPerface;

        //draw back face
        GLES30.glUniform4fv(mColorHandle, 1, colorcyan, 0);
        GLES30.glDrawArrays(GLES30.GL_TRIANGLES, startPos, verticesPerface);
        startPos += verticesPerface;

        //draw left face
        GLES30.glUniform4fv(mColorHandle, 1, colorred, 0);
        GLES30.glDrawArrays(GLES30.GL_TRIANGLES,startPos,verticesPerface);
        startPos += verticesPerface;

        //draw right face
        GLES30.glUniform4fv(mColorHandle, 1, colorgray, 0);
        GLES30.glDrawArrays(GLES30.GL_TRIANGLES,startPos,verticesPerface);
        startPos += verticesPerface;

        //draw top face
        GLES30.glUniform4fv(mColorHandle, 1, colorgreen, 0);
        GLES30.glDrawArrays(GLES30.GL_TRIANGLES,startPos,verticesPerface);
        startPos += verticesPerface;

        //draw bottom face
        GLES30.glUniform4fv(mColorHandle, 1, coloryellow, 0);
        GLES30.glDrawArrays(GLES30.GL_TRIANGLES,startPos,verticesPerface);
        //last face, so no need to increment.

    }
 
开发者ID:JimSeker,项目名称:CardBoardVR,代码行数:62,代码来源:Cube.java

示例7: draw

import android.opengl.GLES30; //导入方法依赖的package包/类
public void draw(float[] mvpMatrix) {

        // Use the program object
        GLES30.glUseProgram(mProgramObject);

        // get handle to shape's transformation matrix
        mMVPMatrixHandle = GLES30.glGetUniformLocation(mProgramObject, "uMVPMatrix");
        myRenderer.checkGlError("glGetUniformLocation");

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


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

        int VERTEX_POS_INDX = 0;
        mVertices.position(VERTEX_POS_INDX);  //just in case.  We did it already though.

        //add all the points to the space, so they can be correct by the transformations.
        //would need to do this even if there were no transformations actually.
        GLES30.glVertexAttribPointer(VERTEX_POS_INDX, 3, GLES30.GL_FLOAT,
                false, 0, mVertices);
        GLES30.glEnableVertexAttribArray(VERTEX_POS_INDX);


        //Now we are ready to draw the cube finally.
        int startPos = 0;
        int verticesPerface = 3;

        //draw front face
        GLES30.glUniform4fv(mColorHandle, 1, colorblue, 0);
        GLES30.glDrawArrays(GLES30.GL_TRIANGLES, startPos, verticesPerface);
        startPos += verticesPerface;

        //draw right face
        GLES30.glUniform4fv(mColorHandle, 1, colorcyan, 0);
        GLES30.glDrawArrays(GLES30.GL_TRIANGLES, startPos, verticesPerface);
        startPos += verticesPerface;

        //draw back face
        GLES30.glUniform4fv(mColorHandle, 1, colorred, 0);
        GLES30.glDrawArrays(GLES30.GL_TRIANGLES, startPos, verticesPerface);
        startPos += verticesPerface;

        //draw left face
        GLES30.glUniform4fv(mColorHandle, 1, colorgray, 0);
        GLES30.glDrawArrays(GLES30.GL_TRIANGLES, startPos, verticesPerface);
        startPos += verticesPerface;


        //draw bottom face 1 tri square, so 6 faces.
        GLES30.glUniform4fv(mColorHandle, 1, coloryellow, 0);
        GLES30.glDrawArrays(GLES30.GL_TRIANGLES, startPos, verticesPerface);
        startPos += verticesPerface;

        //draw bottom face 2 tri square, so 6 faces.
        GLES30.glUniform4fv(mColorHandle, 1, coloryellow, 0);
        GLES30.glDrawArrays(GLES30.GL_TRIANGLES, startPos, verticesPerface);
        startPos += verticesPerface;
        //last face, so no need to increment.

    }
 
开发者ID:JimSeker,项目名称:opengl,代码行数:65,代码来源:Pyramid.java

示例8: draw

import android.opengl.GLES30; //导入方法依赖的package包/类
public void draw(float[] mvpMatrix) {

        // Use the program object
        GLES30.glUseProgram(mProgramObject);

        // get handle to shape's transformation matrix
        mMVPMatrixHandle = GLES30.glGetUniformLocation(mProgramObject, "uMVPMatrix");
        myRenderer.checkGlError("glGetUniformLocation");

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


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

        int VERTEX_POS_INDX = 0;
        mVertices.position(VERTEX_POS_INDX);  //just in case.  We did it already though.

        //add all the points to the space, so they can be correct by the transformations.
        //would need to do this even if there were no transformations actually.
        GLES30.glVertexAttribPointer(VERTEX_POS_INDX, 3, GLES30.GL_FLOAT,
                false, 0, mVertices);
        GLES30.glEnableVertexAttribArray(VERTEX_POS_INDX);

        //Now we are ready to draw the cube finally.
        int startPos =0;
        int verticesPerface = 6;

        //draw front face
        GLES30.glUniform4fv(mColorHandle, 1, colorblue, 0);
        GLES30.glDrawArrays(GLES30.GL_TRIANGLES,startPos,verticesPerface);
        startPos += verticesPerface;

        //draw back face
        GLES30.glUniform4fv(mColorHandle, 1, colorcyan, 0);
        GLES30.glDrawArrays(GLES30.GL_TRIANGLES, startPos, verticesPerface);
        startPos += verticesPerface;

        //draw left face
        GLES30.glUniform4fv(mColorHandle, 1, colorred, 0);
        GLES30.glDrawArrays(GLES30.GL_TRIANGLES,startPos,verticesPerface);
        startPos += verticesPerface;

        //draw right face
        GLES30.glUniform4fv(mColorHandle, 1, colorgray, 0);
        GLES30.glDrawArrays(GLES30.GL_TRIANGLES,startPos,verticesPerface);
        startPos += verticesPerface;

        //draw top face
        GLES30.glUniform4fv(mColorHandle, 1, colorgreen, 0);
        GLES30.glDrawArrays(GLES30.GL_TRIANGLES,startPos,verticesPerface);
        startPos += verticesPerface;

        //draw bottom face
        GLES30.glUniform4fv(mColorHandle, 1, coloryellow, 0);
        GLES30.glDrawArrays(GLES30.GL_TRIANGLES,startPos,verticesPerface);
        //last face, so no need to increment.

    }
 
开发者ID:JimSeker,项目名称:opengl,代码行数:62,代码来源:Cube.java


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