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