本文整理汇总了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);
}
}
示例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);
}
示例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");
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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 );
}
示例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");
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}