本文整理匯總了Java中android.opengl.GLES20.glBufferData方法的典型用法代碼示例。如果您正苦於以下問題:Java GLES20.glBufferData方法的具體用法?Java GLES20.glBufferData怎麽用?Java GLES20.glBufferData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.opengl.GLES20
的用法示例。
在下文中一共展示了GLES20.glBufferData方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: CubesWithVboWithStride
import android.opengl.GLES20; //導入方法依賴的package包/類
CubesWithVboWithStride(float[] cubePositions, float[] cubeNormals, float[] cubeTextureCoordinates, int generatedCubeFactor) {
FloatBuffer cubeBuffer = getInterleavedBuffer(cubePositions, cubeNormals, cubeTextureCoordinates, generatedCubeFactor);
// 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[1];
GLES20.glGenBuffers(1, buffers, 0);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, buffers[0]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, cubeBuffer.capacity() * BYTES_PER_FLOAT, cubeBuffer, GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
mCubeBufferIdx = buffers[0];
cubeBuffer.limit(0);
cubeBuffer = null;
}
示例2: 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");
}
示例3: 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");
}
示例4: createBuffers
import android.opengl.GLES20; //導入方法依賴的package包/類
public static void createBuffers() {
final FloatBuffer heightMapVertexDataBuffer = ByteBuffer
.allocateDirect(aHeightMapVertexData.length * BYTES_PER_FLOAT).order(ByteOrder.nativeOrder())
.asFloatBuffer();
heightMapVertexDataBuffer.put(aHeightMapVertexData).position(0);
final ShortBuffer heightMapIndexDataBuffer = ByteBuffer
.allocateDirect(aHeightMapIndexData.length * BYTES_PER_SHORT).order(ByteOrder.nativeOrder())
.asShortBuffer();
heightMapIndexDataBuffer.put(aHeightMapIndexData).position(0);
if (vbo[0] > 0 && ibo[0] > 0) {
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vbo[0]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, heightMapVertexDataBuffer.capacity() * BYTES_PER_FLOAT,
heightMapVertexDataBuffer, GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, ibo[0]);
GLES20.glBufferData(GLES20.GL_ELEMENT_ARRAY_BUFFER, heightMapIndexDataBuffer.capacity()
* BYTES_PER_SHORT, heightMapIndexDataBuffer, GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0);
} else {
GlUtil.checkGlError("glGenBuffers");
}
}
示例5: 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];
}
示例6: uploadBuffer
import android.opengl.GLES20; //導入方法依賴的package包/類
private int uploadBuffer(Buffer buffer, int elementSize) {
mGLId.glGenBuffers(1, mTempIntArray, 0);
checkError();
int bufferId = mTempIntArray[0];
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, bufferId);
checkError();
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, buffer.capacity() * elementSize, buffer,
GLES20.GL_STATIC_DRAW);
checkError();
return bufferId;
}
示例7: setupIndices
import android.opengl.GLES20; //導入方法依賴的package包/類
public static void setupIndices() {
ShortBuffer indices = getIndices(Short.MAX_VALUE);
if (bufferIndex == -1) {
int[] buf = new int[1];
GLES20.glGenBuffers(1, buf, 0);
bufferIndex = buf[0];
}
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, bufferIndex);
GLES20.glBufferData(GLES20.GL_ELEMENT_ARRAY_BUFFER, (indices.capacity() * 2), indices, GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0);
}
示例8: updateGLData
import android.opengl.GLES20; //導入方法依賴的package包/類
public void updateGLData() {
if (updateStart == -1) return;
vertices.position(updateStart);
bind();
if (updateStart == 0 && updateEnd == vertices.limit()) {
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, vertices.limit() * 4, vertices, GLES20.GL_DYNAMIC_DRAW);
} else {
GLES20.glBufferSubData(GLES20.GL_ARRAY_BUFFER, updateStart * 4, (updateEnd - updateStart) * 4, vertices);
}
release();
updateStart = updateEnd = -1;
}
示例9: updateGLData2
import android.opengl.GLES20; //導入方法依賴的package包/類
public void updateGLData2() {
if (updateStart == -1) return;
vertices.position(updateStart);
bind();
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, vertices.limit() * 4, vertices, GLES20.GL_DYNAMIC_DRAW);
release();
updateStart = updateEnd = -1;
}
示例10: glBufferData
import android.opengl.GLES20; //導入方法依賴的package包/類
public static void glBufferData(final int aTarget, final int aSize, final FloatBuffer aVertexData, final int aUsageHint)
{
//.if DESKTOP
//|gl.glBufferData (aTarget, aSize, aVertexData, aUsageHint);
//.elseif ANDROID
GLES20.glBufferData (aTarget, aSize, aVertexData, aUsageHint);
//.endif
}
示例11: setupIndices
import android.opengl.GLES20; //導入方法依賴的package包/類
public static void setupIndices(){
ShortBuffer indices = getIndices( Short.MAX_VALUE );
if (bufferIndex == -1){
int[] buf = new int[1];
GLES20.glGenBuffers(1, buf, 0);
bufferIndex = buf[0];
}
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, bufferIndex);
GLES20.glBufferData(GLES20.GL_ELEMENT_ARRAY_BUFFER, (indices.capacity()*2), indices, GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0);
}
示例12: updateGLData
import android.opengl.GLES20; //導入方法依賴的package包/類
public void updateGLData(){
if (updateStart == -1) return;
vertices.position(updateStart);
bind();
if (updateStart == 0 && updateEnd == vertices.limit()){
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, vertices.limit()*4, vertices, GLES20.GL_DYNAMIC_DRAW);
} else {
GLES20.glBufferSubData(GLES20.GL_ARRAY_BUFFER, updateStart*4, (updateEnd - updateStart)*4, vertices);
}
release();
updateStart = updateEnd = -1;
}
示例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: 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;
}
示例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;
}