本文整理汇总了Java中android.opengl.GLES20.glDrawElements方法的典型用法代码示例。如果您正苦于以下问题:Java GLES20.glDrawElements方法的具体用法?Java GLES20.glDrawElements怎么用?Java GLES20.glDrawElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.opengl.GLES20
的用法示例。
在下文中一共展示了GLES20.glDrawElements方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawCircle
import android.opengl.GLES20; //导入方法依赖的package包/类
private void drawCircle( float r, float g, float b, float a ) {
for( int i = 0; i < circleBuffersesList.size(); ++i ) {
//頂点バッファの指定
GLES20.glVertexAttribPointer( GLES.positionHandle, 3,
GLES20.GL_FLOAT, false, 0, circleBuffersesList.get(i).vertexBuffer );
//法線バッファの指定
GLES20.glVertexAttribPointer( GLES.normalHandle, 3,
GLES20.GL_FLOAT, false, 0, circleBuffersesList.get(i).normalBuffer );
//描画
setMaterial( r, g, b, a );
circleBuffersesList.get(i).indexBuffer.position(0);
GLES20.glLineWidth( 100f );
GLES20.glDrawElements( GLES20.GL_LINE_LOOP,
circleBuffersesList.get(i).indexBuffer.capacity(), GLES20.GL_UNSIGNED_BYTE, circleBuffersesList.get(i).indexBuffer );
}
}
示例2: drawBar
import android.opengl.GLES20; //导入方法依赖的package包/类
private void drawBar( float r, float g, float b, float a ) {
//頂点バッファの指定
GLES20.glVertexAttribPointer( GLES.positionHandle, 3,
GLES20.GL_FLOAT, false, 0, bar_vertexBuffer );
//法線バッファの指定
GLES20.glVertexAttribPointer( GLES.normalHandle, 3,
GLES20.GL_FLOAT, false, 0, bar_normalBuffer );
//描画
setMaterial( r, g, b, a );
GLES20.glLineWidth( 1f );
bar_indexBuffer.position( 0 );
GLES20.glDrawElements(GLES20.GL_LINE_STRIP,
2, GLES20.GL_UNSIGNED_BYTE, bar_indexBuffer);
float alpha = 0.05f;
for( int i = 0; i < bar_indexBuffer.capacity(); i += 3 ) {
setMaterial( r, g, b, alpha );
alpha -= 0.001f;
bar_indexBuffer.position( i );
GLES20.glDrawElements(GLES20.GL_TRIANGLE_STRIP,
3, GLES20.GL_UNSIGNED_BYTE, bar_indexBuffer);
if( alpha < 0 ) break;
}
}
示例3: drawQuadSet
import android.opengl.GLES20; //导入方法依赖的package包/类
public void drawQuadSet( FloatBuffer vertices, int size ) {
if (size == 0) {
return;
}
vertices.position( 0 );
aXY.vertexPointer( 2, 4, vertices );
vertices.position( 2 );
aUV.vertexPointer( 2, 4, vertices );
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
GLES20.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE * size, GLES20.GL_UNSIGNED_SHORT, 0 );
} else {
FroyoGLES20Fix.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE * size, GLES20.GL_UNSIGNED_SHORT, 0 );
}
}
示例4: drawArcLine
import android.opengl.GLES20; //导入方法依赖的package包/类
private void drawArcLine( float r, float g, float b, float a ) {
//頂点バッファの指定
GLES20.glVertexAttribPointer( GLES.positionHandle, 3,
GLES20.GL_FLOAT, false, 0, arcLine_vertexBuffer );
//法線バッファの指定
GLES20.glVertexAttribPointer( GLES.normalHandle, 3,
GLES20.GL_FLOAT, false, 0, arcLine_normalBuffer );
//描画
setMaterial( r, g, b, a );
arcLine_indexBuffer.position(0);
GLES20.glLineWidth( 7f );
GLES20.glDrawElements( GLES20.GL_LINES,
arcLine_indexBuffer.capacity(), GLES20.GL_UNSIGNED_BYTE, arcLine_indexBuffer );
}
示例5: draw
import android.opengl.GLES20; //导入方法依赖的package包/类
private void draw(float[] cameraView, float[] cameraPerspective) {
// Build the ModelView and ModelViewProjection matrices
// for calculating cube position and light.
Matrix.multiplyMM(mModelViewMatrix, 0, cameraView, 0, mModelMatrix, 0);
Matrix.multiplyMM(mModelViewProjectionMatrix, 0, cameraPerspective, 0, mModelViewMatrix, 0);
// Set the position of the plane
mVertexBuffer.rewind();
GLES20.glVertexAttribPointer(
mPlaneXZPositionAlphaAttribute, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false,
BYTES_PER_FLOAT * COORDS_PER_VERTEX, mVertexBuffer);
// Set the Model and ModelViewProjection matrices in the shader.
GLES20.glUniformMatrix4fv(mPlaneModelUniform, 1, false, mModelMatrix, 0);
GLES20.glUniformMatrix4fv(
mPlaneModelViewProjectionUniform, 1, false, mModelViewProjectionMatrix, 0);
mIndexBuffer.rewind();
GLES20.glDrawElements(GLES20.GL_TRIANGLE_STRIP, mIndexBuffer.limit(),
GLES20.GL_UNSIGNED_SHORT, mIndexBuffer);
ShaderUtil.checkGLError(TAG, "Drawing plane");
}
示例6: drawElements
import android.opengl.GLES20; //导入方法依赖的package包/类
public void drawElements( FloatBuffer vertices, ShortBuffer indices, int size ) {
vertices.position( 0 );
aXY.vertexPointer( 2, 4, vertices );
vertices.position( 2 );
aUV.vertexPointer( 2, 4, vertices );
Quad.releaseIndices();
GLES20.glDrawElements( GLES20.GL_TRIANGLES, size, GLES20.GL_UNSIGNED_SHORT, indices );
Quad.bindIndices();
}
示例7: 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 );
}
示例8: drawTarget
import android.opengl.GLES20; //导入方法依赖的package包/类
private void drawTarget( float r, float g, float b, float a ) {
//頂点バッファの指定
GLES20.glVertexAttribPointer( GLES.positionHandle, 3,
GLES20.GL_FLOAT, false, 0, target_vertexBuffer );
//法線バッファの指定
GLES20.glVertexAttribPointer( GLES.normalHandle, 3,
GLES20.GL_FLOAT, false, 0, target_normalBuffer );
//描画
setMaterial( r, g, b, a );
target_indexBuffer.position(0);
GLES20.glDrawElements( GLES20.GL_TRIANGLE_FAN,
target_indexBuffer.capacity(), GLES20.GL_UNSIGNED_BYTE, target_indexBuffer );
}
示例9: draw
import android.opengl.GLES20; //导入方法依赖的package包/类
public void draw(int texture) {
GLES20.glUseProgram(mProgram);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
if (mOesTexture)
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, texture);
else
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texture);
int positionHandle = GLES20.glGetAttribLocation(mProgram, "position");
GLES20.glEnableVertexAttribArray(positionHandle);
GLES20.glVertexAttribPointer(positionHandle, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, vertexStride, vertexBuffer);
int textureCoordHandle = GLES20.glGetAttribLocation(mProgram, "inputTextureCoordinate");
GLES20.glEnableVertexAttribArray(textureCoordHandle);
GLES20.glVertexAttribPointer(textureCoordHandle, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, vertexStride, textureVerticesBuffer);
GLES20.glUniformMatrix4fv(muMVPMatrixHandle, 1, false, mMVPMatrix, 0);
GLES20.glUniformMatrix4fv(muSTMatrixHandle, 1, false, mSTMatrix, 0);
GLES20.glDrawElements(GLES20.GL_TRIANGLES, drawOrder.length, GLES20.GL_UNSIGNED_SHORT, drawListBuffer);
// Disable vertex array
GLES20.glDisableVertexAttribArray(positionHandle);
GLES20.glDisableVertexAttribArray(textureCoordHandle);
GLES20.glUseProgram(0);
}
示例10: 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);
}
示例11: 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);
}
示例12: drawModel
import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
protected void drawModel() {
if (mDrawGrid) {
GLES20.glDrawElements(GLES20.GL_LINE_STRIP, mIndices.length, GLES20.GL_UNSIGNED_SHORT, mIndicesBuffer);
} else {
super.drawModel();
}
}
示例13: drawModel
import android.opengl.GLES20; //导入方法依赖的package包/类
protected void drawModel() {
GLES20.glDrawElements(GLES20.GL_TRIANGLE_STRIP, mIndices.length, GLES20.GL_UNSIGNED_SHORT, mIndicesBuffer);
}
示例14: render
import android.opengl.GLES20; //导入方法依赖的package包/类
public void render(float[] aMVPMatrix) {
// Use culling to remove back faces.
GLES20.glDisable(GLES20.GL_CULL_FACE);
// Set our per-vertex lighting program.
GLES20.glUseProgram(aProgramHandle);
// Set program handles for cube drawing.
aMVPMatrixHandle = GLES20.glGetUniformLocation(aProgramHandle, "u_MVPMatrix");
aMVMatrixHandle = GLES20.glGetUniformLocation(aProgramHandle, "u_MVMatrix");
aLightPosUniform = GLES20.glGetUniformLocation(aProgramHandle, "u_LightPos");
aPositionHandle = GLES20.glGetAttribLocation(aProgramHandle, "a_Position");
aNormalHandle = GLES20.glGetAttribLocation(aProgramHandle, "a_Normal");
aColorHandle = GLES20.glGetAttribLocation(aProgramHandle, "a_Color");
// Pass in the combined matrix.
GLES20.glUniformMatrix4fv(aMVPMatrixHandle, 1, false, aMVPMatrix, 0);
if (vbo[0] > 0 && ibo[0] > 0) {
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vbo[0]);
// Bind Attributes
GLES20.glVertexAttribPointer(aPositionHandle, POSITION_DATA_SIZE, GLES20.GL_FLOAT, false,
STRIDE, 0);
GLES20.glEnableVertexAttribArray(aPositionHandle);
GLES20.glVertexAttribPointer(aNormalHandle, NORMAL_DATA_SIZE, GLES20.GL_FLOAT, false,
STRIDE, POSITION_DATA_SIZE * BYTES_PER_FLOAT);
GLES20.glEnableVertexAttribArray(aNormalHandle);
GLES20.glVertexAttribPointer(aColorHandle, COLOR_DATA_SIZE, GLES20.GL_FLOAT, false,
STRIDE, (POSITION_DATA_SIZE + NORMAL_DATA_SIZE) * BYTES_PER_FLOAT);
GLES20.glEnableVertexAttribArray(aColorHandle);
// 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);
}
// Use culling to remove back faces.
GLES20.glEnable(GLES20.GL_CULL_FACE);
}
示例15: draw
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* 绘制:
*
* 我们在 onDrawFrame 回调中执行绘制操作,绘制的过程其实就是为 shader 代码变量赋值,并调用绘制命令的过程:
*/
public void draw(float[] mtx) {
// to program
GLES20.glUseProgram(mProgram);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTextureID);
// get handle to vertex shader's vPosition member
// (顶点着色器的vPosition成员得到处理)
int mPositionHandle = GLES20.glGetAttribLocation(mProgram, "vPosition");
// Enable a handle to the triangle vertices(使一个句柄三角形顶点)
GLES20.glEnableVertexAttribArray(mPositionHandle);
// Prepare the <insert shape here> coordinate data (准备<插入形状这里>坐标数据)
GLES20.glVertexAttribPointer(mPositionHandle, COORDS_PER_VERTEX,
GLES20.GL_FLOAT, false, vertexStride, vertexBuffer);
int mTextureCoordHandle = GLES20.glGetAttribLocation(mProgram,
"inputTextureCoordinate");
GLES20.glEnableVertexAttribArray(mTextureCoordHandle);
//照相机镜像
textureVerticesBuffer.clear();
textureVerticesBuffer.put(transformTextureCoordinates(textureVertices,
mtx));
textureVerticesBuffer.position(0);
GLES20.glVertexAttribPointer(mTextureCoordHandle, COORDS_PER_VERTEX,
GLES20.GL_FLOAT, false, vertexStride, textureVerticesBuffer);
GLES20.glDrawElements(GLES20.GL_TRIANGLES, drawOrder.length,
GLES20.GL_UNSIGNED_SHORT, drawListBuffer);
// for (int i = 0; i < points.size(); i++) {
// ArrayList<FloatBuffer> triangleVBList = points.get(i);
// for (int j = 0; j < triangleVBList.size(); j++) {
// FloatBuffer fb = triangleVBList.get(j);
// GLES20.glVertexAttribPointer(mPositionHandle, 3,
// GLES20.GL_FLOAT, false, 0, fb);
// GLES20.glEnableVertexAttribArray(mPositionHandle);
// // Draw the point
// GLES20.glDrawArrays(GLES20.GL_POINTS, 0, 1);
// }
// }
// Disable vertex array
GLES20.glDisableVertexAttribArray(mPositionHandle);
GLES20.glDisableVertexAttribArray(mTextureCoordHandle);
}