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


Java GL11.glDrawElements方法代码示例

本文整理汇总了Java中javax.microedition.khronos.opengles.GL11.glDrawElements方法的典型用法代码示例。如果您正苦于以下问题:Java GL11.glDrawElements方法的具体用法?Java GL11.glDrawElements怎么用?Java GL11.glDrawElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.microedition.khronos.opengles.GL11的用法示例。


在下文中一共展示了GL11.glDrawElements方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: draw

import javax.microedition.khronos.opengles.GL11; //导入方法依赖的package包/类
public void draw(GL10 gl, boolean useTexture, boolean useColor) {
    if (!mUseHardwareBuffers) {
        gl.glVertexPointer(3, mCoordinateType, 0, mVertexBuffer);

        if (useTexture) {
            gl.glTexCoordPointer(2, mCoordinateType, 0, mTexCoordBuffer);
        }
        
        if (useColor) {
            gl.glColorPointer(4, mCoordinateType, 0, mColorBuffer);
        }

        gl.glDrawElements(GL10.GL_TRIANGLES, mIndexCount,
                GL10.GL_UNSIGNED_SHORT, mIndexBuffer);
    } else {
        GL11 gl11 = (GL11)gl;
        // draw using hardware buffers
        gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, mVertBufferIndex);
        gl11.glVertexPointer(3, mCoordinateType, 0, 0);
        
        if (useTexture) {
         gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, mTextureCoordBufferIndex);
         gl11.glTexCoordPointer(2, mCoordinateType, 0, 0);
        }
        
        if (useColor) {
         gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, mColorBufferIndex);
         gl11.glColorPointer(4, mCoordinateType, 0, 0);
        }
        
        gl11.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, mIndexBufferIndex);
        gl11.glDrawElements(GL11.GL_TRIANGLES, mIndexCount,
                GL11.GL_UNSIGNED_SHORT, 0);
        
        gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, 0);
        gl11.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, 0);


    }
}
 
开发者ID:tgmarinho,项目名称:apps-for-android,代码行数:41,代码来源:Grid.java

示例2: drawStrip

import javax.microedition.khronos.opengles.GL11; //导入方法依赖的package包/类
public void drawStrip(GL10 gl, boolean useTexture, int startIndex, int indexCount) {
	int count = indexCount;
	if (startIndex + indexCount >= mIndexCount) {
		count = mIndexCount - startIndex;
	}
	if (!mUseHardwareBuffers) {
        gl.glDrawElements(GL10.GL_TRIANGLES, count,
                GL10.GL_UNSIGNED_SHORT, mIndexBuffer.position(startIndex));
    } else {
    	GL11 gl11 = (GL11)gl;
        gl11.glDrawElements(GL11.GL_TRIANGLES, count,
                GL11.GL_UNSIGNED_SHORT, startIndex * CHAR_SIZE);
 
    }
}
 
开发者ID:gogas,项目名称:replicaisland,代码行数:16,代码来源:Grid.java

示例3: draw

import javax.microedition.khronos.opengles.GL11; //导入方法依赖的package包/类
public void draw(GL10 gl, boolean useTexture) {
    if (!mUseHardwareBuffers) {
        gl.glVertexPointer(3, mCoordinateType, 0, mVertexBuffer);

        if (useTexture) {
            gl.glTexCoordPointer(2, mCoordinateType, 0, mTexCoordBuffer);
        } 

        gl.glDrawElements(GL10.GL_TRIANGLES, mIndexCount,
                GL10.GL_UNSIGNED_SHORT, mIndexBuffer);
    } else {
        GL11 gl11 = (GL11)gl;
        // draw using hardware buffers
        gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, mVertBufferIndex);
        gl11.glVertexPointer(3, mCoordinateType, 0, 0);
        
        gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, mTextureCoordBufferIndex);
        gl11.glTexCoordPointer(2, mCoordinateType, 0, 0);
        
        gl11.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, mIndexBufferIndex);
        gl11.glDrawElements(GL11.GL_TRIANGLES, mIndexCount,
                GL11.GL_UNSIGNED_SHORT, 0);
        
        gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, 0);
        gl11.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, 0);


    }
}
 
开发者ID:gogas,项目名称:replicaisland,代码行数:30,代码来源:Grid.java


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