當前位置: 首頁>>代碼示例>>Java>>正文


Java GLES20.glVertexAttribPointer方法代碼示例

本文整理匯總了Java中android.opengl.GLES20.glVertexAttribPointer方法的典型用法代碼示例。如果您正苦於以下問題:Java GLES20.glVertexAttribPointer方法的具體用法?Java GLES20.glVertexAttribPointer怎麽用?Java GLES20.glVertexAttribPointer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.opengl.GLES20的用法示例。


在下文中一共展示了GLES20.glVertexAttribPointer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: render

import android.opengl.GLES20; //導入方法依賴的package包/類
void render() {
    if (vbo[0] > 0 && ibo[0] > 0) {
        GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vbo[0]);

        // Bind Attributes
        GLES20.glVertexAttribPointer(positionAttribute, POSITION_DATA_SIZE_IN_ELEMENTS, GLES20.GL_FLOAT, false,
                STRIDE, 0);
        GLES20.glEnableVertexAttribArray(positionAttribute);

        GLES20.glVertexAttribPointer(normalAttribute, NORMAL_DATA_SIZE_IN_ELEMENTS, GLES20.GL_FLOAT, false,
                STRIDE, POSITION_DATA_SIZE_IN_ELEMENTS * BYTES_PER_FLOAT);
        GLES20.glEnableVertexAttribArray(normalAttribute);

        GLES20.glVertexAttribPointer(colorAttribute, COLOR_DATA_SIZE_IN_ELEMENTS, GLES20.GL_FLOAT, false,
                STRIDE, (POSITION_DATA_SIZE_IN_ELEMENTS + NORMAL_DATA_SIZE_IN_ELEMENTS) * BYTES_PER_FLOAT);
        GLES20.glEnableVertexAttribArray(colorAttribute);

        // Draw
        GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, ibo[0]);
        GLES20.glDrawElements(GLES20.GL_TRIANGLE_STRIP, indexCount, GLES20.GL_UNSIGNED_SHORT, 0);

        GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
        GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0);
    }
}
 
開發者ID:biezhihua,項目名稱:Android_OpenGL_Demo,代碼行數:26,代碼來源:LessonEightRenderer.java

示例2: 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 cubes.
	GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, mActualCubeFactor * mActualCubeFactor * mActualCubeFactor * 36);
}
 
開發者ID:biezhihua,項目名稱:Android_OpenGL_Demo,代碼行數:19,代碼來源:LessonSevenRenderer.java

示例3: setupRightEye

import android.opengl.GLES20; //導入方法依賴的package包/類
private void setupRightEye() {
    Matrix.setLookAtM(mCamera, 0, mRightEyePos[0], mRightEyePos[1], mRightEyePos[2], 0.0f, 0.0f, -SCREEN_FAR, 0.0f, 1.0f, 0.0f);
    if (HEAD_TRACKING) Matrix.rotateM(mCamera, 0, (float)mOrientation*90.0f, 0.0f, 0.0f, -1.0f);
    Matrix.multiplyMM(mMVP, 0, mCamera, 0, mHeadTransform, 0);
    Matrix.multiplyMM(mMVP, 0, mPersp, 0, mMVP, 0);
    
    GLES20.glDisable(GLES20.GL_BLEND);
    
    if (getEffectMode() == VideoEffect.ANAGLYPH_MODE) {
        mColorFilter = RED_COLOR_FILTER;
    }

    GLES20.glScissor(mViewWidth/2, 0, mViewWidth/2, mViewHeight);
    GLES20.glViewport(mViewWidth / 2, 0, mViewWidth / 2, mViewHeight);
    if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glViewport");

    GLES20.glVertexAttribPointer(mTexCoordHandle, 2, GLES20.GL_FLOAT,
            false, 0, mVideoTextureCoordRight);
    if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glVertexAttribPointer");
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:21,代碼來源:StereoDiveEffect.java

示例4: bindShaderValues

import android.opengl.GLES20; //導入方法依賴的package包/類
@Override
protected void bindShaderValues() {
    mRenderVertices.position(0);
    GLES20.glVertexAttribPointer(mPositionHandle, 2, GLES20.GL_FLOAT, false,
            8, mRenderVertices);
    GLES20.glEnableVertexAttribArray(mPositionHandle);
    mTextureVertices[mCurrentRotation].position(0);
    GLES20.glVertexAttribPointer(mTextureCoordHandle, 2, GLES20.GL_FLOAT, false,
            8, mTextureVertices[mCurrentRotation]);
    GLES20.glEnableVertexAttribArray(mTextureCoordHandle);

    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTextureIn);
    GLES20.glUniform1i(mTextureHandle, 0);

    mSurfaceTexture.getTransformMatrix(mMatrix);
    GLES20.glUniformMatrix4fv(mMatrixHandle, 1, false, mMatrix, 0);
}
 
開發者ID:uestccokey,項目名稱:EZFilter,代碼行數:19,代碼來源:VideoInput.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: drawTex

import android.opengl.GLES20; //導入方法依賴的package包/類
private void drawTex(int tex, boolean isOES, int fbo)
{
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, fbo);

    if(fbo == 0)
        GLES20.glViewport(0, 0, mView.getWidth(), mView.getHeight());
    else
        GLES20.glViewport(0, 0, mFBOWidth, mFBOHeight);

    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);

    if(isOES) {
        GLES20.glUseProgram(progOES);
        GLES20.glVertexAttribPointer(vPosOES, 2, GLES20.GL_FLOAT, false, 4*2, vert);
        GLES20.glVertexAttribPointer(vTCOES,  2, GLES20.GL_FLOAT, false, 4*2, texOES);
    } else {
        GLES20.glUseProgram(prog2D);
        GLES20.glVertexAttribPointer(vPos2D, 2, GLES20.GL_FLOAT, false, 4*2, vert);
        GLES20.glVertexAttribPointer(vTC2D,  2, GLES20.GL_FLOAT, false, 4*2, tex2D);
    }

    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);

    if(isOES) {
        GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, tex);
        GLES20.glUniform1i(GLES20.glGetUniformLocation(progOES, "sTexture"), 0);
    } else {
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tex);
        GLES20.glUniform1i(GLES20.glGetUniformLocation(prog2D, "sTexture"), 0);
    }

    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
    GLES20.glFlush();
}
 
開發者ID:vulovicv23,項目名稱:opencv-documentscanner-android,代碼行數:35,代碼來源:CameraGLRendererBase.java

示例7: bindShaderValues

import android.opengl.GLES20; //導入方法依賴的package包/類
/**
 * 綁定Uniform參數
 */
protected void bindShaderValues() {
    mRenderVertices.position(0);
    GLES20.glVertexAttribPointer(mPositionHandle, 2, GLES20.GL_FLOAT, false,
            8, mRenderVertices);
    GLES20.glEnableVertexAttribArray(mPositionHandle);
    mTextureVertices[mCurrentRotation].position(0);
    GLES20.glVertexAttribPointer(mTextureCoordHandle, 2, GLES20.GL_FLOAT, false,
            8, mTextureVertices[mCurrentRotation]);
    GLES20.glEnableVertexAttribArray(mTextureCoordHandle);

    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureIn);
    GLES20.glUniform1i(mTextureHandle, 0);
}
 
開發者ID:uestccokey,項目名稱:EZFilter,代碼行數:18,代碼來源:AbstractRender.java

示例8: drawUIOverlay

import android.opengl.GLES20; //導入方法依賴的package包/類
private void drawUIOverlay() {
    mColorFilter = CLEAR_COLOR_FILTER;
    GLES20.glEnable(GLES20.GL_BLEND);
    GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
    
    GLES20.glUniform1i(mTexHandle, 1);
    if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glUniform1i");
    
    GLES20.glVertexAttribPointer(mTexCoordHandle, 2, GLES20.GL_FLOAT,
            false, 0, mUITextureCoord);
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:12,代碼來源:StereoDiveEffect.java

示例9: drawFillCircle

import android.opengl.GLES20; //導入方法依賴的package包/類
private void drawFillCircle( float r, float g, float b, float a ) {
    //頂點バッファの指定
    GLES20.glVertexAttribPointer( GLES.positionHandle, 3,
            GLES20.GL_FLOAT, false, 0, fillCircle_vertexBuffer );

    //法線バッファの指定
    GLES20.glVertexAttribPointer( GLES.normalHandle, 3,
            GLES20.GL_FLOAT, false, 0, fillCircle_normalBuffer );

    //描畫
    setMaterial( r, g, b, a );
    fillCircle_indexBuffer.position(0);
    GLES20.glDrawElements( GLES20.GL_TRIANGLE_FAN,
            fillCircle_indexBuffer.capacity(), GLES20.GL_UNSIGNED_BYTE, fillCircle_indexBuffer );
}
 
開發者ID:jphacks,項目名稱:TK_1701,代碼行數:16,代碼來源:RaderObject_UI.java

示例10: uploadVerticesBuffer

import android.opengl.GLES20; //導入方法依賴的package包/類
public void uploadVerticesBuffer(int positionHandle){
    FloatBuffer vertexBuffer = getVerticesBuffer();
    if (vertexBuffer == null) return;
    vertexBuffer.position(0);

    GLES20.glVertexAttribPointer(positionHandle, sPositionDataSize, GLES20.GL_FLOAT, false, 0, vertexBuffer);
    ShaderUtils.checkGlError("glVertexAttribPointer maPosition");
    GLES20.glEnableVertexAttribArray(positionHandle);
    ShaderUtils.checkGlError("glEnableVertexAttribArray maPositionHandle");
}
 
開發者ID:zhangyaqiang,項目名稱:Fatigue-Detection,代碼行數:11,代碼來源:Sphere.java

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

示例12: draw

import android.opengl.GLES20; //導入方法依賴的package包/類
public void draw(float[] mVPMatrix) {

        GLES20.glUseProgram(program);

        positionHandle = GLES20.glGetAttribLocation(program, "vPosition");


        GLES20.glEnableVertexAttribArray(positionHandle);

        GLES20.glVertexAttribPointer(positionHandle, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, vertexStride,
                vertexBuffer);

        colorHandle = GLES20.glGetUniformLocation(program, "vColor");

        GLES20.glUniform4fv(colorHandle, 1, color, 0);

        mVPHandle = GLES20.glGetUniformLocation(program, "uMVPMatrix");

        GLES20.glUniformMatrix4fv(mVPHandle, 1, false, mVPMatrix, 0);

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

        GLES20.glDisableVertexAttribArray(positionHandle);


    }
 
開發者ID:FreeSunny,項目名稱:Amazing,代碼行數:27,代碼來源:Triangle.java

示例13: 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 color information
    mCubeColors.position(0);
    GLES20.glVertexAttribPointer(
            mColorHandle,
            mColorDataSize,
            GLES20.GL_FLOAT,
            false,
            0, mCubeColors
    );
    GLES20.glEnableVertexAttribArray(mColorHandle);

    // 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 the MVP matrix.
    // which currently contains model * view.
    Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mModelMatrix, 0);

    // Pass in the model view matrix
    GLES20.glUniformMatrix4fv(mMVMatrixHandle, 1, false, mMVPMatrix, 0);

    // This multiplies the model view 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);

    // 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,代碼行數:64,代碼來源:Cube.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 color information
       mCubeColors.position(0);
       GLES20.glVertexAttribPointer(mColorHandle, mColorDataSize, GLES20.GL_FLOAT, false,
       		0, mCubeColors);        
       
       GLES20.glEnableVertexAttribArray(mColorHandle);
       
       // Pass in the normal information
       mCubeNormals.position(0);
       GLES20.glVertexAttribPointer(mNormalHandle, mNormalDataSize, GLES20.GL_FLOAT, false, 
       		0, mCubeNormals);
       
       GLES20.glEnableVertexAttribArray(mNormalHandle);
       
       // Pass in the texture coordinate information
       mCubeTextureCoordinates.position(0);
       GLES20.glVertexAttribPointer(mTextureCoordinateHandle, mTextureCoordinateDataSize, GLES20.GL_FLOAT, false, 
       		0, mCubeTextureCoordinates);
       
       GLES20.glEnableVertexAttribArray(mTextureCoordinateHandle);
       
	// 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(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);

       // 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,代碼行數:54,代碼來源:LessonFourRenderer.java

示例15: draw

import android.opengl.GLES20; //導入方法依賴的package包/類
public void draw() {

        if (mTexture == 0) {
            mTexture = OpenGLUtils.loadTexture(mResource);
        }

        if (mProgram == null) {
            mProgram = new ImageProgram();
        }

        setCube();

        float translateX = (mPosition.x + mTranslationX) * 2.0f / mViewportSize.x;
        float translateY = (-mPosition.y - mTranslationY) * 2.0f / mViewportSize.y;
        float[] mvp = new float[16];
        Matrix.setIdentityM(mvp, 0);
        Matrix.translateM(mMVPMatrix, 0, mvp, 0, translateX, translateY, 0);
        mMVPBuffer.position(0);
        mMVPBuffer.put(mMVPMatrix).position(0);

        GLES20.glUseProgram(mProgram.mProgram);

        mCubeBuffer.position(0);
        GLES20.glVertexAttribPointer(mProgram.mAPositionHandle, 2, GLES20.GL_FLOAT, false, 0, mCubeBuffer);
        GLES20.glEnableVertexAttribArray(mProgram.mAPositionHandle);

        mTextureBuffer.position(0);
        GLES20.glVertexAttribPointer(mProgram.mATextureCoordinateHandle, 2, GLES20.GL_FLOAT, false, 0, mTextureBuffer);
        GLES20.glEnableVertexAttribArray(mProgram.mATextureCoordinateHandle);

        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexture);
        GLES20.glUniform1i(mProgram.mUTextureHandle, 0);

        mMVPBuffer.position(0);
        GLES20.glUniformMatrix4fv(mProgram.mUMVPMatrixHandle, 1, false, mMVPBuffer);

        GLES20.glUniform1f(mProgram.mUOpacityHandle, mOpacity);

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

        GLES20.glDisableVertexAttribArray(mProgram.mAPositionHandle);
        GLES20.glDisableVertexAttribArray(mProgram.mATextureCoordinateHandle);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
    }
 
開發者ID:vipycm,項目名稱:mao-android,代碼行數:46,代碼來源:GLImageView.java


注:本文中的android.opengl.GLES20.glVertexAttribPointer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。