當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。