当前位置: 首页>>代码示例>>Java>>正文


Java GLES20.glBufferData方法代码示例

本文整理汇总了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;
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:18,代码来源:LessonSevenRenderer.java

示例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");
}
 
开发者ID:googlevr,项目名称:poly-sample-android,代码行数:30,代码来源:PointCloudRenderer.java

示例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");
}
 
开发者ID:nimbl3,项目名称:nimbl3-arcore,代码行数:30,代码来源:PointCloudRenderer.java

示例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");
    }
}
 
开发者ID:regar007,项目名称:ShapesInOpenGLES2.0,代码行数:28,代码来源:HeightMap.java

示例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];
}
 
开发者ID:googlevr,项目名称:poly-sample-android,代码行数:11,代码来源:MyGLUtils.java

示例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;
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:12,代码来源:GLES20Canvas.java

示例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);
}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:12,代码来源:Quad.java

示例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;
}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:16,代码来源:Vertexbuffer.java

示例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;
}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:12,代码来源:Vertexbuffer.java

示例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
    
    
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:11,代码来源:GL.java

示例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);
}
 
开发者ID:mango-tree,项目名称:UNIST-pixel-dungeon,代码行数:12,代码来源:Quad.java

示例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;
}
 
开发者ID:mango-tree,项目名称:UNIST-pixel-dungeon,代码行数:16,代码来源:Vertexbuffer.java

示例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;
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:35,代码来源:LessonSevenRenderer.java

示例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;
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:35,代码来源:LessonSevenRenderer.java

示例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;
}
 
开发者ID:regar007,项目名称:ShapesInOpenGLES2.0,代码行数:38,代码来源:Triangles.java


注:本文中的android.opengl.GLES20.glBufferData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。