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


Java GLES20.glEnableVertexAttribArray方法代码示例

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


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

示例1: render

import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public void render() {	      
	// Pass in the position information
	GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mCubePositionsBufferIdx);
	GLES20.glEnableVertexAttribArray(mPositionHandle);
	GLES20.glVertexAttribPointer(mPositionHandle, POSITION_DATA_SIZE, GLES20.GL_FLOAT, false, 0, 0);

	// Pass in the normal information
	GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mCubeNormalsBufferIdx);
	GLES20.glEnableVertexAttribArray(mNormalHandle);
	GLES20.glVertexAttribPointer(mNormalHandle, NORMAL_DATA_SIZE, GLES20.GL_FLOAT, false, 0, 0);
	
	// Pass in the texture information
	GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mCubeTexCoordsBufferIdx);
	GLES20.glEnableVertexAttribArray(mTextureCoordinateHandle);
	GLES20.glVertexAttribPointer(mTextureCoordinateHandle, TEXTURE_COORDINATE_DATA_SIZE, 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 cubes.
	GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, mActualCubeFactor * mActualCubeFactor * mActualCubeFactor * 36);
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:25,代码来源:LessonSevenRenderer.java

示例2: bindData

import android.opengl.GLES20; //导入方法依赖的package包/类
@Override public void bindData(ShaderProgram shaderProgram, float[] projectionMatrix, float[] modelViewMatrix) {
    GraphShaderProgram graphShaderProgram = (GraphShaderProgram) shaderProgram;
    // Calculate the projection and view transformation
    Matrix.multiplyMM(modelMatrix, 0, projectionMatrix, 0, modelViewMatrix, 0);
    Matrix.translateM(modelMatrix, 0, 0f, graphInfo.getyPositionToDraw(), 0f);

    graphShaderProgram.setUniforms(modelMatrix);

    GLES20.glEnableVertexAttribArray(graphShaderProgram.getPositionAttributeLocation());
    GLES20.glVertexAttribPointer(graphShaderProgram.getPositionAttributeLocation(), 1, GLES20.GL_FLOAT, false, 0, vertexData);

    GLES20.glEnableVertexAttribArray(graphShaderProgram.getSensorValue());
    GLES20.glVertexAttribPointer(graphShaderProgram.getSensorValue(), 1, GLES20.GL_FLOAT, false, 0, vertexSensor);
}
 
开发者ID:khoatd92,项目名称:sensor-graph-opengl-es-android,代码行数:15,代码来源:SensorGraph.java

示例3: onDrawFrame

import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public int onDrawFrame(int textureId, FloatBuffer vertexBuffer, FloatBuffer textureBuffer) {
       GLES20.glUseProgram(mGLProgId);
       if(!isInitialized()) {
           return OpenGLUtils.NOT_INIT;
       }
       vertexBuffer.position(0);
       GLES20.glVertexAttribPointer(mGLAttribPosition, 2, GLES20.GL_FLOAT, false, 0, vertexBuffer);
       GLES20.glEnableVertexAttribArray(mGLAttribPosition);
       textureBuffer.position(0);
       GLES20.glVertexAttribPointer(mGLAttribTextureCoordinate, 2, GLES20.GL_FLOAT, false, 0, textureBuffer);
       GLES20.glEnableVertexAttribArray(mGLAttribTextureCoordinate);
       GLES20.glUniformMatrix4fv(mTextureTransformMatrixLocation, 1, false, mTextureTransformMatrix, 0);
       
       if(textureId != OpenGLUtils.NO_TEXTURE){
        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, textureId);
        GLES20.glUniform1i(mGLUniformTexture, 0);
       }
       
       GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
       GLES20.glDisableVertexAttribArray(mGLAttribPosition);
       GLES20.glDisableVertexAttribArray(mGLAttribTextureCoordinate);
       GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 0);
       return OpenGLUtils.ON_DRAWN;
   }
 
开发者ID:smartbeng,项目名称:PaoMovie,代码行数:27,代码来源:MagicCameraInputFilter.java

示例4: initShaders

import android.opengl.GLES20; //导入方法依赖的package包/类
private void initShaders() {
    String strGLVersion = GLES20.glGetString(GLES20.GL_VERSION);
    if (strGLVersion != null)
        Log.i(LOGTAG, "OpenGL ES version: " + strGLVersion);

    GLES20.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);

    progOES = loadShader(vss, fssOES);
    vPosOES = GLES20.glGetAttribLocation(progOES, "vPosition");
    vTCOES  = GLES20.glGetAttribLocation(progOES, "vTexCoord");
    GLES20.glEnableVertexAttribArray(vPosOES);
    GLES20.glEnableVertexAttribArray(vTCOES);

    prog2D  = loadShader(vss, fss2D);
    vPos2D = GLES20.glGetAttribLocation(prog2D, "vPosition");
    vTC2D  = GLES20.glGetAttribLocation(prog2D, "vTexCoord");
    GLES20.glEnableVertexAttribArray(vPos2D);
    GLES20.glEnableVertexAttribArray(vTC2D);
}
 
开发者ID:csarron,项目名称:renderscript_examples,代码行数:20,代码来源:CameraGLRendererBase.java

示例5: render

import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public void render() {
    // Pass in the position information
    GLES20.glEnableVertexAttribArray(mPositionHandle);
    GLES20.glVertexAttribPointer(mPositionHandle, POSITION_DATA_SIZE, GLES20.GL_FLOAT, false, 0, mCubePositions);

    // Pass in the normal information
    GLES20.glEnableVertexAttribArray(mNormalHandle);
    GLES20.glVertexAttribPointer(mNormalHandle, NORMAL_DATA_SIZE, GLES20.GL_FLOAT, false, 0, mCubeNormals);

    // Pass in the texture information
    GLES20.glEnableVertexAttribArray(mTextureCoordinateHandle);
    GLES20.glVertexAttribPointer(mTextureCoordinateHandle, TEXTURE_COORDINATE_DATA_SIZE, GLES20.GL_FLOAT, false,
            0, mCubeTextureCoordinates);

    // Draw the mCubes.
    GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, mActualCubeFactor * mActualCubeFactor * mActualCubeFactor * 36);
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:19,代码来源:LessonSevenRenderer.java

示例6: 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 square
    GLES20.glDrawElements(
            GLES20.GL_TRIANGLES, drawOrder.length,
            GLES20.GL_UNSIGNED_SHORT, drawListBuffer);

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

示例7: drawSelf

import android.opengl.GLES20; //导入方法依赖的package包/类
public void drawSelf(int texId){
    GLES20.glUseProgram(mProgram);
    MatrixState.setInitStack();
    //Z轴移动1
    MatrixState.translate(0,0,1);

    MatrixState.rotate(yAngle , 0 , 1 , 0);
    MatrixState.rotate(zAngle , 0 , 0 , 1);
    MatrixState.rotate(xAngle , 1 , 0 , 1);

    //最终变换矩阵传给渲染管线
    GLES20.glUniformMatrix4fv(muMVPMatrixHandle , 1 , false , MatrixState.getFinalMatrix() , 0);

    GLES20.glVertexAttribPointer(maPositionHandle , 3 , GLES20.GL_FLOAT , false , 3 *4 , mVertexBuffer);
    GLES20.glVertexAttribPointer(maTexCoorHandle , 2 , GLES20.GL_FLOAT , false , 2 *4 , mTexCoorBuffer);

    GLES20.glEnableVertexAttribArray(maPositionHandle);
    GLES20.glEnableVertexAttribArray(maTexCoorHandle);

    //设置使用纹理编号
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    //绑定指定纹理id
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D , texId);

    GLES20.glDrawArrays(GLES20.GL_TRIANGLES , 0 , vCount);

}
 
开发者ID:ynztlxdeai,项目名称:GLproject,代码行数:28,代码来源:Triangle.java

示例8: onDrawFrame

import android.opengl.GLES20; //导入方法依赖的package包/类
public int onDrawFrame(final int textureId, final FloatBuffer cubeBuffer,
                   final FloatBuffer textureBuffer) {
    GLES20.glUseProgram(mGLProgId);
    runPendingOnDrawTasks();
    if (!mIsInitialized) {
        return OpenGLUtils.NOT_INIT;
    }

    cubeBuffer.position(0);
    GLES20.glVertexAttribPointer(mGLAttribPosition, 2, GLES20.GL_FLOAT, false, 0, cubeBuffer);
    GLES20.glEnableVertexAttribArray(mGLAttribPosition);
    textureBuffer.position(0);
    GLES20.glVertexAttribPointer(mGLAttribTextureCoordinate, 2, GLES20.GL_FLOAT, false, 0,
            textureBuffer);
    GLES20.glEnableVertexAttribArray(mGLAttribTextureCoordinate);
    if (textureId != OpenGLUtils.NO_TEXTURE) {
        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId);
        GLES20.glUniform1i(mGLUniformTexture, 0);
    }
    onDrawArraysPre();
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
    GLES20.glDisableVertexAttribArray(mGLAttribPosition);
    GLES20.glDisableVertexAttribArray(mGLAttribTextureCoordinate);
    onDrawArraysAfter();
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
    return OpenGLUtils.ON_DRAWN;
}
 
开发者ID:smartbeng,项目名称:PaoMovie,代码行数:29,代码来源:GPUImageFilter.java

示例9: drawFromCameraPreview

import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public void drawFromCameraPreview(final float[] tex_mtx) {
    if (-1 == mProgram || mTextureId == -1 || mWidth == -1) {
        return;
    }

    AndroidUntil.checkGlError("draw_S");
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFboId[0]);

    GLES20.glViewport(0, 0, mWidth, mHeight);
    GLES20.glClearColor(0f, 0f, 0f, 1f);
    GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);

    GLES20.glUseProgram(mProgram);
    runPendingOnDrawTasks();

    mVtxBuf.position(0);
    GLES20.glVertexAttribPointer(mPositionHandle,
            3, GLES20.GL_FLOAT, false, 4 * (3 + 2), mVtxBuf);
    GLES20.glEnableVertexAttribArray(mPositionHandle);

    mVtxBuf.position(3);
    GLES20.glVertexAttribPointer(mTexCoordinatesHandle,
            2, GLES20.GL_FLOAT, false, 4 * (3 + 2), mVtxBuf);
    GLES20.glEnableVertexAttribArray(mTexCoordinatesHandle);

    if (mPosMtxHandle >= 0)
        GLES20.glUniformMatrix4fv(mPosMtxHandle, 1, false, mPosMtx, 0);

    if (mTexMtxHandle >= 0)
        GLES20.glUniformMatrix4fv(mTexMtxHandle, 1, false, tex_mtx, 0);

    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTextureId);

    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);

    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
    AndroidUntil.checkGlError("draw_E");
}
 
开发者ID:wuyisheng,项目名称:libRtmp,代码行数:41,代码来源:Effect.java

示例10: run

import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public void run() {
    if (!initied) {
        return;
    }

    if (!eglContext.equals(egl10.eglGetCurrentContext()) || !eglSurface.equals(egl10.eglGetCurrentSurface(EGL10.EGL_DRAW))) {
        if (!egl10.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)) {
            FileLog.e("tmessages", "eglMakeCurrent failed " + GLUtils.getEGLErrorString(egl10.eglGetError()));
            return;
        }
    }

    GLES20.glViewport(0, 0, renderBufferWidth, renderBufferHeight);
    drawEnhancePass();
    drawSharpenPass();
    drawCustomParamsPass();
    blured = drawBlurPass();

    //onscreen draw
    GLES20.glViewport(0, 0, surfaceWidth, surfaceHeight);
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
    GLES20.glClear(0);

    GLES20.glUseProgram(simpleShaderProgram);
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[blured ? 0 : 1]);
    GLES20.glUniform1i(simpleSourceImageHandle, 0);
    GLES20.glEnableVertexAttribArray(simpleInputTexCoordHandle);
    GLES20.glVertexAttribPointer(simpleInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
    GLES20.glEnableVertexAttribArray(simplePositionHandle);
    GLES20.glVertexAttribPointer(simplePositionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexBuffer);
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
    egl10.eglSwapBuffers(eglDisplay, eglSurface);
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:36,代码来源:PhotoFilterView.java

示例11: draw

import android.opengl.GLES20; //导入方法依赖的package包/类
/**
 * Issues the draw call.  Does the full setup on every call.
 *
 * @param mvpMatrix The 4x4 projection matrix.
 * @param color A 4-element color vector.
 * @param vertexBuffer Buffer with vertex 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 data for each vertex (often vertexCount *
 *        sizeof(float)).
 */
public void draw(float[] mvpMatrix, float[] color, FloatBuffer vertexBuffer,
        int firstVertex, int vertexCount, int coordsPerVertex, int vertexStride) {
    GlUtil.checkGlError("draw start");

    // Select the program.
    GLES20.glUseProgram(mProgramHandle);
    GlUtil.checkGlError("glUseProgram");

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

    // Copy the color vector in.
    GLES20.glUniform4fv(muColorLoc, 1, color, 0);
    GlUtil.checkGlError("glUniform4fv ");

    // 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");

    // Draw the rect.
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, firstVertex, vertexCount);
    GlUtil.checkGlError("glDrawArrays");

    // Done -- disable vertex array and program.
    GLES20.glDisableVertexAttribArray(maPositionLoc);
    GLES20.glUseProgram(0);
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:46,代码来源:FlatShadedProgram.java

示例12: drawFrame

import android.opengl.GLES20; //导入方法依赖的package包/类
public void drawFrame(SurfaceTexture st, boolean invert) {
    checkGlError("onDrawFrame start");
    st.getTransformMatrix(mSTMatrix);

    if (invert) {
        mSTMatrix[5] = -mSTMatrix[5];
        mSTMatrix[13] = 1.0f - mSTMatrix[13];
    }

    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");
    GLES20.glUniformMatrix4fv(muSTMatrixHandle, 1, false, mSTMatrix, 0);
    GLES20.glUniformMatrix4fv(muMVPMatrixHandle, 1, false, mMVPMatrix, 0);
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
    checkGlError("glDrawArrays");
    GLES20.glFinish();
}
 
开发者ID:fishwjy,项目名称:VideoCompressor,代码行数:30,代码来源:TextureRenderer.java

示例13: onDrawArraysPre

import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
protected void onDrawArraysPre() {
    GLES20.glEnableVertexAttribArray(mFilterSecondTextureCoordinateAttribute);
    GLES20.glActiveTexture(GLES20.GL_TEXTURE3);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mFilterSourceTexture2);
    GLES20.glUniform1i(mFilterInputTextureUniform2, 3);

    mTexture2CoordinatesBuffer.position(0);
    GLES20.glVertexAttribPointer(mFilterSecondTextureCoordinateAttribute, 2, GLES20.GL_FLOAT, false, 0, mTexture2CoordinatesBuffer);
}
 
开发者ID:vipycm,项目名称:mao-android,代码行数:11,代码来源:TwoInputFilter.java

示例14: drawCube

import android.opengl.GLES20; //导入方法依赖的package包/类
/**
 * Draws a cube.
 */			
private void drawCube()
{		
	// Pass in the position information
	mCubePositions.position(0);		
       GLES20.glVertexAttribPointer(mPositionHandle, mPositionDataSize, GLES20.GL_FLOAT, false,
       		0, mCubePositions);        
               
       GLES20.glEnableVertexAttribArray(mPositionHandle);                       
       
       // Pass in the normal information
       mCubeNormals.position(0);
       GLES20.glVertexAttribPointer(mNormalHandle, mNormalDataSize, GLES20.GL_FLOAT, false, 
       		0, mCubeNormals);
       
       GLES20.glEnableVertexAttribArray(mNormalHandle);                
       
	// 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);   
       
       // Pass in the modelview matrix.
       GLES20.glUniformMatrix4fv(mMVMatrixHandle, 1, false, mMVPMatrix, 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(mTemporaryMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);
       System.arraycopy(mTemporaryMatrix, 0, mMVPMatrix, 0, 16);

       // Pass in the combined matrix.
       GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);
       
       // Pass in the light position in eye space.        
       GLES20.glUniform3f(mLightPosHandle, mLightPosInEyeSpace[0], mLightPosInEyeSpace[1], mLightPosInEyeSpace[2]);
       
       // Draw the cube.
       GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 36);                               
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:41,代码来源:LessonSixRenderer.java

示例15: draw

import android.opengl.GLES20; //导入方法依赖的package包/类
public void draw(float[] mtrxProjectionAndView) {
    // get handle to vertex shader's vPosition member
    int mPositionHandle = GLES20.glGetAttribLocation(ShaderInfo.sp_Image, "vPosition");

    // Enable generic vertex attribute array
    GLES20.glEnableVertexAttribArray(mPositionHandle);

    // Prepare the triangle coordinate data
    GLES20.glVertexAttribPointer(mPositionHandle, 3, GLES20.GL_FLOAT, false, 0, mVertexBuffer);

    // Get handle to texture coordinates location
    int mTexCoordLoc = GLES20.glGetAttribLocation(ShaderInfo.sp_Image, "a_texCoord" );

    // Enable generic vertex attribute array
    GLES20.glEnableVertexAttribArray (mTexCoordLoc);

    // Prepare the texture coordinates
    GLES20.glVertexAttribPointer (mTexCoordLoc, 2, GLES20.GL_FLOAT, false, 0, mTextureBuffer);

    // Get handle to shape's transformation matrix
    int mtrxhandle = GLES20.glGetUniformLocation(ShaderInfo.sp_Image, "uMVPMatrix");

    // Apply the projection and view transformation
    GLES20.glUniformMatrix4fv(mtrxhandle, 1, false, mtrxProjectionAndView, 0);

    // Get handle to textures locations
    int mSamplerLoc = GLES20.glGetUniformLocation (ShaderInfo.sp_Image, "s_texture" );

    // Set the sampler texture unit to the index of the image we're trying to draw
    GLES20.glUniform1i ( mSamplerLoc, mTextureIndex);
    //Log.d(TAG,"Texture index is " + mTextureIndex);

    // Draw the triangle
    GLES20.glDrawElements(GLES20.GL_TRIANGLES, mIndices.length, GLES20.GL_UNSIGNED_SHORT, mDrawlistBuffer);

    // Disable vertex array
    GLES20.glDisableVertexAttribArray(mPositionHandle);
    GLES20.glDisableVertexAttribArray(mTexCoordLoc);

 //   Log.d(TAG,"Drawing at: " + mLocationRect);
}
 
开发者ID:kaidenho,项目名称:spellcaster,代码行数:42,代码来源:RenderObject.java


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