本文整理匯總了Java中android.opengl.GLES20.glGenBuffers方法的典型用法代碼示例。如果您正苦於以下問題:Java GLES20.glGenBuffers方法的具體用法?Java GLES20.glGenBuffers怎麽用?Java GLES20.glGenBuffers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.opengl.GLES20
的用法示例。
在下文中一共展示了GLES20.glGenBuffers方法的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: 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;
}
示例3: Lines
import android.opengl.GLES20; //導入方法依賴的package包/類
/**
* instantiate the Lines shape object
* @param activity
* @param positions
* @param colors
*/
public Lines(Context activity, float[] positions, float[] colors) {
/** initialize the line program */
final String lineVS = RawResourceReader.readTextFileFromRawResource(activity, R.raw.line_vertex_shader);
final String lineFS = RawResourceReader.readTextFileFromRawResource(activity, R.raw.line_fragment_shader);
final int lineVSHandle = ShaderHelper.compileShader(GLES20.GL_VERTEX_SHADER, lineVS);
final int lineFSHandle = ShaderHelper.compileShader(GLES20.GL_FRAGMENT_SHADER, lineFS);
aLineProgramHandle = ShaderHelper.createAndLinkProgram(lineVSHandle, lineFSHandle,
new String[]{"a_Position", "a_Color"});
// Second, copy these buffers into OpenGL's memory. After, we don't need to keep the client-side buffers around.
GLES20.glGenBuffers(glLineBuffer.length, glLineBuffer, 0);
createBuffers(positions, colors);
}
示例4: Quad
import android.opengl.GLES20; //導入方法依賴的package包/類
/**
* instantiate the Quad shape object
* @param activity
* @param positions
* @param widths
*/
public Quad(Context activity, float[] positions, float[] widths) {
final String vertexShader = RawResourceReader.readTextFileFromRawResource(activity,
R.raw.quad_vertex_shader);
final String fragmentShader = RawResourceReader.readTextFileFromRawResource(activity,
R.raw.quad_fragment_shader);
final int vertexShaderHandle = ShaderHelper.compileShader(GLES20.GL_VERTEX_SHADER, vertexShader);
final int fragmentShaderHandle = ShaderHelper.compileShader(GLES20.GL_FRAGMENT_SHADER, fragmentShader);
aQuadProgramHandle = ShaderHelper.createAndLinkProgram(vertexShaderHandle, fragmentShaderHandle, new String[] {
"a_Position", "a_Color", "a_TexCoordinate" });
GLES20.glGenBuffers(1, qvbo, 0);
GLES20.glGenBuffers(1, qibo, 0);
createBuffers(positions, widths);
}
示例5: Spheres
import android.opengl.GLES20; //導入方法依賴的package包/類
/**
* Instantiate Sphere objects
* @param activity
* @param glTrue
* @param steps
* @param positions
* @param colors
* @param radii
*/
public Spheres(Context activity, int glTrue, int steps, float[] positions, float[] colors, float[] radii){
/** initialize the sphere program */
final String sphereVS = RawResourceReader.readTextFileFromRawResource(activity, R.raw.sphere_vertex_shader);
final String sphereFS = RawResourceReader.readTextFileFromRawResource(activity, R.raw.sphere_fragment_shader);
final int sphereVSHandle = ShaderHelper.compileShader(GLES20.GL_VERTEX_SHADER, sphereVS);
final int sphereFSHandle = ShaderHelper.compileShader(GLES20.GL_FRAGMENT_SHADER, sphereFS);
aSphereProgramHandle = ShaderHelper.createAndLinkProgram(sphereVSHandle, sphereFSHandle,
new String[]{"a_Position", "a_Color"});
// Second, copy these buffers into OpenGL's memory. After, we don't need to keep the client-side buffers around.
glSphereBuffer = new int[4];
GLES20.glGenBuffers(glSphereBuffer.length, glSphereBuffer, 0);
BLENDING = (glTrue == GLES20.GL_TRUE) ? true : false;
createBuffers(positions, colors, radii, steps);
}
示例6: Points
import android.opengl.GLES20; //導入方法依賴的package包/類
/**
* instantiate the Points shape object
* @param aActivity
* @param positions
* @param colors
*/
public Points(Context aActivity, float[] positions, float[] colors){
/** initialize the point program */
final String pointVS = RawResourceReader.readTextFileFromRawResource(aActivity, R.raw.point_vertex_shader);
final String pointFS = RawResourceReader.readTextFileFromRawResource(aActivity, R.raw.point_fragment_shader);
final int pointVSHandle = ShaderHelper.compileShader(GLES20.GL_VERTEX_SHADER, pointVS);
final int pointFSHandle = ShaderHelper.compileShader(GLES20.GL_FRAGMENT_SHADER, pointFS);
aPointProgramHandle = ShaderHelper.createAndLinkProgram(pointVSHandle, pointFSHandle,
new String[]{"a_Position", "a_Color"});
// Second, copy these buffers into OpenGL's memory. After, we don't need to keep the client-side buffers around.
GLES20.glGenBuffers(glPointBuffer.length, glPointBuffer, 0);
createBuffers(positions, colors);
}
示例7: 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");
}
示例8: createIbo
import android.opengl.GLES20; //導入方法依賴的package包/類
public static int createIbo(ShortBuffer data) {
int[] ibos = new int[1];
data.position(0);
GLES20.glGenBuffers(1, ibos, 0);
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, ibos[0]);
GLES20.glBufferData(GLES20.GL_ELEMENT_ARRAY_BUFFER, data.capacity() * MyGLUtils.SHORT_SIZE,
data, GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0);
return ibos[0];
}
示例9: 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);
}
示例10: Vertexbuffer
import android.opengl.GLES20; //導入方法依賴的package包/類
public Vertexbuffer(FloatBuffer vertices) {
synchronized (buffers) {
int[] ptr = new int[1];
GLES20.glGenBuffers(1, ptr, 0);
id = ptr[0];
this.vertices = vertices;
buffers.add(this);
updateStart = 0;
updateEnd = vertices.limit();
}
}
示例11: glGenBuffers
import android.opengl.GLES20; //導入方法依賴的package包/類
public static void glGenBuffers(final int aNumber, final IntBuffer aBufferHandle)
{
//.if DESKTOP
//|gl.glGenBuffers(aNumber,aBufferHandle);
//.elseif ANDROID
GLES20.glGenBuffers(aNumber,aBufferHandle);
//.endif
}
示例12: 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);
}
示例13: Vertexbuffer
import android.opengl.GLES20; //導入方法依賴的package包/類
public Vertexbuffer( FloatBuffer vertices ) {
synchronized (buffers) {
int[] ptr = new int[1];
GLES20.glGenBuffers(1, ptr, 0);
id = ptr[0];
this.vertices = vertices;
buffers.add(this);
updateStart = 0;
updateEnd = vertices.limit();
}
}
示例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: 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;
}