本文整理汇总了Java中android.opengl.GLES20.glBindBuffer方法的典型用法代码示例。如果您正苦于以下问题:Java GLES20.glBindBuffer方法的具体用法?Java GLES20.glBindBuffer怎么用?Java GLES20.glBindBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.opengl.GLES20
的用法示例。
在下文中一共展示了GLES20.glBindBuffer方法的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() {
final int stride = (POSITION_DATA_SIZE + NORMAL_DATA_SIZE + TEXTURE_COORDINATE_DATA_SIZE) * BYTES_PER_FLOAT;
// Pass in the position information
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mCubeBufferIdx);
GLES20.glEnableVertexAttribArray(mPositionHandle);
GLES20.glVertexAttribPointer(mPositionHandle, POSITION_DATA_SIZE, GLES20.GL_FLOAT, false, stride, 0);
// Pass in the normal information
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mCubeBufferIdx);
GLES20.glEnableVertexAttribArray(mNormalHandle);
GLES20.glVertexAttribPointer(mNormalHandle, NORMAL_DATA_SIZE, GLES20.GL_FLOAT, false, stride, POSITION_DATA_SIZE * BYTES_PER_FLOAT);
// Pass in the texture information
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mCubeBufferIdx);
GLES20.glEnableVertexAttribArray(mTextureCoordinateHandle);
GLES20.glVertexAttribPointer(mTextureCoordinateHandle, TEXTURE_COORDINATE_DATA_SIZE, GLES20.GL_FLOAT, false,
stride, (POSITION_DATA_SIZE + NORMAL_DATA_SIZE) * BYTES_PER_FLOAT);
// Clear the currently bound buffer (so future OpenGL calls do not use this buffer).
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
// Draw the mCubes.
GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, mActualCubeFactor * mActualCubeFactor * mActualCubeFactor * 36);
}
示例3: 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);
}
示例4: update
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* Updates the OpenGL buffer contents to the provided point. Repeated calls with the same
* point cloud will be ignored.
*/
public void update(PointCloud cloud) {
if (mLastPointCloud == cloud) {
// Redundant call.
return;
}
ShaderUtil.checkGLError(TAG, "before update");
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mVbo);
mLastPointCloud = cloud;
// If the VBO is not large enough to fit the new point cloud, resize it.
mNumPoints = mLastPointCloud.getPoints().remaining() / FLOATS_PER_POINT;
if (mNumPoints * BYTES_PER_POINT > mVboSize) {
while (mNumPoints * BYTES_PER_POINT > mVboSize) {
mVboSize *= 2;
}
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, mVboSize, null, GLES20.GL_DYNAMIC_DRAW);
}
GLES20.glBufferSubData(GLES20.GL_ARRAY_BUFFER, 0, mNumPoints * BYTES_PER_POINT,
mLastPointCloud.getPoints());
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
ShaderUtil.checkGLError(TAG, "after update");
}
示例5: createOnGlThread
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* Allocates and initializes OpenGL resources needed by the plane renderer. Must be
* called on the OpenGL thread, typically in
* {@link GLSurfaceView.Renderer#onSurfaceCreated(GL10, EGLConfig)}.
*
* @param context Needed to access shader source.
*/
public void createOnGlThread(Context context) {
ShaderUtil.checkGLError(TAG, "before create");
int buffers[] = new int[1];
GLES20.glGenBuffers(1, buffers, 0);
mVbo = buffers[0];
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mVbo);
mVboSize = INITIAL_BUFFER_POINTS * BYTES_PER_POINT;
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, mVboSize, null, GLES20.GL_DYNAMIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
ShaderUtil.checkGLError(TAG, "buffer alloc");
int vertexShader = ShaderUtil.loadGLShader(TAG, context,
GLES20.GL_VERTEX_SHADER, R.raw.point_cloud_vertex);
int passthroughShader = ShaderUtil.loadGLShader(TAG, context,
GLES20.GL_FRAGMENT_SHADER, R.raw.passthrough_fragment);
mProgramName = GLES20.glCreateProgram();
GLES20.glAttachShader(mProgramName, vertexShader);
GLES20.glAttachShader(mProgramName, passthroughShader);
GLES20.glLinkProgram(mProgramName);
GLES20.glUseProgram(mProgramName);
ShaderUtil.checkGLError(TAG, "program");
mPositionAttribute = GLES20.glGetAttribLocation(mProgramName, "a_Position");
mColorUniform = GLES20.glGetUniformLocation(mProgramName, "u_Color");
mModelViewProjectionUniform = GLES20.glGetUniformLocation(
mProgramName, "u_ModelViewProjection");
mPointSizeUniform = GLES20.glGetUniformLocation(mProgramName, "u_PointSize");
ShaderUtil.checkGLError(TAG, "program params");
}
示例6: draw
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* Renders the point cloud.
*
* @param pose the current point cloud pose, from {@link Frame#getPointCloudPose()}.
* @param cameraView the camera view matrix for this frame, typically from
* {@link Frame#getViewMatrix(float[], int)}.
* @param cameraPerspective the camera projection matrix for this frame, typically from
* {@link Session#getProjectionMatrix(float[], int, float, float)}.
*/
public void draw(Pose pose, float[] cameraView, float[] cameraPerspective) {
float[] modelMatrix = new float[16];
pose.toMatrix(modelMatrix, 0);
float[] modelView = new float[16];
float[] modelViewProjection = new float[16];
Matrix.multiplyMM(modelView, 0, cameraView, 0, modelMatrix, 0);
Matrix.multiplyMM(modelViewProjection, 0, cameraPerspective, 0, modelView, 0);
ShaderUtil.checkGLError(TAG, "Before draw");
GLES20.glUseProgram(mProgramName);
GLES20.glEnableVertexAttribArray(mPositionAttribute);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mVbo);
GLES20.glVertexAttribPointer(
mPositionAttribute, 4, GLES20.GL_FLOAT, false, BYTES_PER_POINT, 0);
GLES20.glUniform4f(mColorUniform, 31.0f / 255.0f, 188.0f / 255.0f, 210.0f / 255.0f, 1.0f);
GLES20.glUniformMatrix4fv(mModelViewProjectionUniform, 1, false, modelViewProjection, 0);
GLES20.glUniform1f(mPointSizeUniform, 5.0f);
GLES20.glDrawArrays(GLES20.GL_POINTS, 0, mNumPoints);
GLES20.glDisableVertexAttribArray(mPositionAttribute);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
ShaderUtil.checkGLError(TAG, "Draw");
}
示例7: createVbo
import android.opengl.GLES20; //导入方法依赖的package包/类
public static int createVbo(FloatBuffer data) {
int[] vbos = new int[1];
data.position(0);
GLES20.glGenBuffers(1, vbos, 0);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vbos[0]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, data.capacity() * MyGLUtils.FLOAT_SIZE, data,
GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
return vbos[0];
}
示例8: createBuffers
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* create buffers for the Lines shape object
* @param linePositions
* @param lineColors
*/
public void createBuffers(float[] linePositions, float[] lineColors) {
final int lineDataLength = linePositions.length;
vertexCount = linePositions.length / POSITION_DATA_SIZE;
final FloatBuffer lineBuffer = ByteBuffer.allocateDirect(lineDataLength * BYTES_PER_FLOAT)
.order(ByteOrder.nativeOrder()).asFloatBuffer();
lineBuffer.put(linePositions);
final FloatBuffer colorBuffer = ByteBuffer.allocateDirect(lineColors.length * BYTES_PER_FLOAT)
.order(ByteOrder.nativeOrder()).asFloatBuffer();
colorBuffer.put(lineColors);
lineBuffer.position(0);
colorBuffer.position(0);
FloatBuffer linePositionsBuffer = lineBuffer;
FloatBuffer lineColorsBuffers = colorBuffer;
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, glLineBuffer[0]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, linePositionsBuffer.capacity() * BYTES_PER_FLOAT, linePositionsBuffer, GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, glLineBuffer[1]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, lineColorsBuffers.capacity() * BYTES_PER_FLOAT, lineColorsBuffers, GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
aLinePositionsBufferIdx = glLineBuffer[0];
aLineColorsBufferIdx = glLineBuffer[1];
linePositionsBuffer.limit(0);
linePositionsBuffer = null;
lineColorsBuffers.limit(0);
lineColorsBuffers = null;
}
示例9: render
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* draws the Lines shape object
* @param aMVPMatrix
*/
public void render(float[] aMVPMatrix) {
// Set our per-vertex lighting program.
GLES20.glUseProgram(aLineProgramHandle);
int aLineMVPMatrixHandle = GLES20.glGetUniformLocation(aLineProgramHandle, "u_MVPMatrix");
int aLinePositionHandle = GLES20.glGetAttribLocation(aLineProgramHandle, "a_Position");
int aLineColorHandle = GLES20.glGetAttribLocation(aLineProgramHandle, "a_Color");
// Pass in the combined matrix.
GLES20.glUniformMatrix4fv(aLineMVPMatrixHandle, 1, false, aMVPMatrix, 0);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, aLinePositionsBufferIdx);
GLES20.glEnableVertexAttribArray(aLinePositionHandle);
GLES20.glVertexAttribPointer(aLinePositionHandle, POSITION_DATA_SIZE, GLES20.GL_FLOAT, false, 0, 0);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, aLineColorsBufferIdx);
GLES20.glEnableVertexAttribArray(aLineColorHandle);
GLES20.glVertexAttribPointer(aLineColorHandle, 4, 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 line.
GLES20.glDrawArrays(GLES20.GL_LINES, 0, vertexCount);
}
示例10: setPosition
import android.opengl.GLES20; //导入方法依赖的package包/类
private void setPosition(ShaderParameter[] params, int offset) {
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mBoxCoordinates);
checkError();
GLES20.glVertexAttribPointer(params[INDEX_POSITION].handle, COORDS_PER_VERTEX,
GLES20.GL_FLOAT, false, VERTEX_STRIDE, offset * VERTEX_STRIDE);
checkError();
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
checkError();
}
示例11: render
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* draws the Points shape object
* @param aMVPMatrix
*/
public void render(float[] aMVPMatrix) {
// Set our per-vertex lighting program.
GLES20.glUseProgram(aPointProgramHandle);
aMVPMatrixHandle = GLES20.glGetUniformLocation(aPointProgramHandle, "u_MVPMatrix");
aPositionHandle = GLES20.glGetAttribLocation(aPointProgramHandle, "a_Position");
aColorHandle = GLES20.glGetAttribLocation(aPointProgramHandle, "a_Color");
// Pass in the combined matrix.
GLES20.glUniformMatrix4fv(aMVPMatrixHandle, 1, false, aMVPMatrix, 0);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, aPointPositionsBufferIdx);
GLES20.glEnableVertexAttribArray(aPositionHandle);
GLES20.glVertexAttribPointer(aPositionHandle, POSITION_DATA_SIZE, GLES20.GL_FLOAT, false, 0, 0);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, aPointColorsBufferIdx);
GLES20.glEnableVertexAttribArray(aColorHandle);
GLES20.glVertexAttribPointer(aColorHandle, COLOR_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 point.
GLES20.glDrawArrays(GLES20.GL_POINTS, 0, vertexCount);
}
示例12: draw
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* Renders the point cloud.
*
* @param pose the current point cloud pose, from {@link Frame#getPointCloudPose()}.
* @param cameraView the camera view matrix for this frame, typically from
* {@link Frame#getViewMatrix(float[], int)}.
* @param cameraPerspective the camera projection matrix for this frame, typically from
* {@link Session#getProjectionMatrix(float[], int, float, float)}.
*/
public void draw(Pose pose, float[] cameraView, float[] cameraPerspective) {
float[] modelMatrix = new float[16];
pose.toMatrix(modelMatrix, 0);
float[] modelView = new float[16];
float[] modelViewProjection = new float[16];
Matrix.multiplyMM(modelView, 0, cameraView, 0, modelMatrix, 0);
Matrix.multiplyMM(modelViewProjection, 0, cameraPerspective, 0, modelView, 0);
ShaderUtil.checkGLError(TAG, "Before draw");
GLES20.glUseProgram(mProgramName);
GLES20.glEnableVertexAttribArray(mPositionAttribute);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mVbo);
GLES20.glVertexAttribPointer(
mPositionAttribute, 4, GLES20.GL_FLOAT, false, BYTES_PER_POINT, 0);
GLES20.glUniform4f(mColorUniform, 31.0f / 255.0f, 188.0f / 255.0f, 210.0f / 255.0f, 1.0f);
GLES20.glUniformMatrix4fv(mModelViewProjectionUniform, 1, false, modelViewProjection, 0);
GLES20.glUniform1f(mPointSizeUniform, 5.0f);
GLES20.glDrawArrays(GLES20.GL_POINTS, 0, mNumPoints);
GLES20.glDisableVertexAttribArray(mPositionAttribute);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
ShaderUtil.checkGLError(TAG, "Draw");
}
示例13: CubesWithVbo
import android.opengl.GLES20; //导入方法依赖的package包/类
CubesWithVbo(float[] cubePositions, float[] cubeNormals, float[] cubeTextureCoordinates, int generatedCubeFactor) {
FloatBuffer[] floatBuffers = getBuffers(cubePositions, cubeNormals, cubeTextureCoordinates, generatedCubeFactor);
FloatBuffer cubePositionsBuffer = floatBuffers[0];
FloatBuffer cubeNormalsBuffer = floatBuffers[1];
FloatBuffer cubeTextureCoordinatesBuffer = floatBuffers[2];
// Second, copy these buffers into OpenGL's memory. After, we don't need to keep the client-side buffers around.
final int buffers[] = new int[3];
GLES20.glGenBuffers(3, buffers, 0);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, buffers[0]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, cubePositionsBuffer.capacity() * BYTES_PER_FLOAT, cubePositionsBuffer, GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, buffers[1]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, cubeNormalsBuffer.capacity() * BYTES_PER_FLOAT, cubeNormalsBuffer, GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, buffers[2]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, cubeTextureCoordinatesBuffer.capacity() * BYTES_PER_FLOAT, cubeTextureCoordinatesBuffer,
GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
mCubePositionsBufferIdx = buffers[0];
mCubeNormalsBufferIdx = buffers[1];
mCubeTexCoordsBufferIdx = buffers[2];
cubePositionsBuffer.limit(0);
cubePositionsBuffer = null;
cubeNormalsBuffer.limit(0);
cubeNormalsBuffer = null;
cubeTextureCoordinatesBuffer.limit(0);
cubeTextureCoordinatesBuffer = null;
}
示例14: createBuffers
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* create buffers for the Points shape object
* @param pointPositions
* @param pointColors
*/
public void createBuffers(float[] pointPositions, float[] pointColors) {
// First, copy cube information into client-side floating point buffers.
FloatBuffer pointPositionsBuffer;
FloatBuffer pointColorsBuffer;
try{
vertexCount = pointPositions.length / POSITION_DATA_SIZE;
pointPositionsBuffer = ByteBuffer.allocateDirect(pointPositions.length * BYTES_PER_FLOAT)
.order(ByteOrder.nativeOrder()).asFloatBuffer();
pointPositionsBuffer.put(pointPositions).position(0);
pointColorsBuffer = ByteBuffer.allocateDirect(pointColors.length * BYTES_PER_FLOAT)
.order(ByteOrder.nativeOrder()).asFloatBuffer();
pointColorsBuffer.put(pointColors).position(0);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, glPointBuffer[0]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, pointPositionsBuffer.capacity() * BYTES_PER_FLOAT, pointPositionsBuffer, GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, glPointBuffer[1]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, pointColorsBuffer.capacity() * BYTES_PER_FLOAT, pointColorsBuffer, GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
aPointPositionsBufferIdx = glPointBuffer[0];
aPointColorsBufferIdx = glPointBuffer[1];
pointPositionsBuffer.limit(0);
pointPositionsBuffer = null;
pointColorsBuffer.limit(0);
pointColorsBuffer = null;
}catch (Exception e){
Log.d(Tag,"point buffer creation failed:", e);
}
}
示例15: createBuffers
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* creates buffers for Triangle shape object
* @param positions
* @param colors
*/
public void createBuffers(float[] positions, float[] colors) {
FloatBuffer aTriangleVerticesBuffer;
FloatBuffer aTriangleColorBuffer;
vertexCount = positions.length/POSITION_DATA_SIZE;
// Initialize the buffers.
aTriangleVerticesBuffer = ByteBuffer.allocateDirect(positions.length * BYTES_PER_FLOAT)
.order(ByteOrder.nativeOrder()).asFloatBuffer();
aTriangleColorBuffer = ByteBuffer.allocateDirect(colors.length * BYTES_PER_FLOAT)
.order(ByteOrder.nativeOrder()).asFloatBuffer();
aTriangleVerticesBuffer.put(positions).position(0);
aTriangleColorBuffer.put(colors).position(0);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, glTriangleBuffer[0]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, aTriangleVerticesBuffer.capacity() * BYTES_PER_FLOAT, aTriangleVerticesBuffer, GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, glTriangleBuffer[1]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, aTriangleColorBuffer.capacity() * BYTES_PER_FLOAT, aTriangleColorBuffer, GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
aTrianglePositionsBufferIdx = glTriangleBuffer[0];
aTriangleColorsBufferIdx = glTriangleBuffer[1];
aTriangleVerticesBuffer.limit(0);
aTriangleVerticesBuffer = null;
aTriangleColorBuffer.limit(0);
aTriangleColorBuffer = null;
}