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