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


Java GLES30.glEnableVertexAttribArray方法代码示例

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


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

示例1: onDrawFrame

import android.opengl.GLES30; //导入方法依赖的package包/类
public void onDrawFrame ( GL10 glUnused )
{
   // Set the viewport
   GLES30.glViewport ( 0, 0, mWidth, mHeight );

   // Clear the color buffer
   GLES30.glClear ( GLES30.GL_COLOR_BUFFER_BIT );

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

   // Set the vertex color to red
   GLES30.glVertexAttrib4f ( 0, 1.0f, 0.0f, 0.0f, 1.0f );

   // Load the vertex position
   mVertices.position ( 0 );
   GLES30.glVertexAttribPointer ( 1, 3, GLES30.GL_FLOAT,
                                  false,
                                  0, mVertices );

   GLES30.glEnableVertexAttribArray ( 1 );

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

   GLES30.glDisableVertexAttribArray ( 1 );
}
 
开发者ID:zhuangzaiku,项目名称:AndroidCollection,代码行数:27,代码来源:Example6_3Renderer.java

示例2: onDrawFrame

import android.opengl.GLES30; //导入方法依赖的package包/类
public void onDrawFrame(GL10 glUnused) {
    // Set the viewport
    GLES30.glViewport(0, 0, mWidth, mHeight);

    // Clear the color buffer, which was set above in glClearColor
    GLES30.glClear(GLES30.GL_COLOR_BUFFER_BIT);

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

    // Load the vertex data
    GLES30.glVertexAttribPointer(0, 3, GLES30.GL_FLOAT, false, 0, mVertices);
    //set the starting vertex at 0.
    GLES30.glEnableVertexAttribArray(0);

    //actually draw the traingle here
    GLES30.glDrawArrays(GLES30.GL_TRIANGLES, 0, 3);
}
 
开发者ID:JimSeker,项目名称:opengl,代码行数:19,代码来源:HelloTriangleRenderer.java

示例3: 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

示例4: drawTriangle

import android.opengl.GLES30; //导入方法依赖的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);
       GLES30.glVertexAttribPointer(mPositionHandle, mPositionDataSize, GLES30.GL_FLOAT, false,
       		mStrideBytes, aTriangleBuffer);        
               
       GLES30.glEnableVertexAttribArray(mPositionHandle);        
       
       // Pass in the color information
       aTriangleBuffer.position(mColorOffset);
       GLES30.glVertexAttribPointer(mColorHandle, mColorDataSize, GLES30.GL_FLOAT, false,
       		mStrideBytes, aTriangleBuffer);        
       
       GLES30.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);

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

示例5: 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

示例6: 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

示例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");
        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

示例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");
        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

示例9: 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

示例10: 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

示例11: glEnableVertexAttribArray

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


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