GL10 glDrawElements - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for GL10 glDrawElements method.

This code example shows how to use the following methods:glDrawArrays, glBindBuffer, glColorPointer, glDrawElements, glVertexPointer
		} 
	} 
 
	public void draw(GL11 gl) {
		if (useVBO) {
			gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, vertexVbo);
			gl.glVertexPointer(3, GL10.GL_FLOAT, 0, 0);
 
			gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, colorVbo);
			gl.glColorPointer(4, GL10.GL_UNSIGNED_BYTE, 0, 0);
 
			gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, 0);
			// gl.glDrawArrays(GL10.GL_LINE_STRIP, 0, N*N); 
 
			gl.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, vertexElementVbo);
			gl.glDrawElements(GL10.GL_LINE_STRIP, n * n, GL10.GL_UNSIGNED_SHORT, 0);
			gl.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, 0);
		} else { 
			gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuf);
			gl.glColorPointer(4, GL10.GL_UNSIGNED_BYTE, 0, colorBuf);

7
CodeRank
This code example shows how to use the following methods:capacity
This code example shows how to use the following methods:glDrawElements, glEnable, glFrontFace, glTexCoordPointer, glVertexPointer
This code example shows how to use the following methods:position
	//    offset - the offset in the vertex/index buffer to start at 
	//    numVertices - the number of vertices (indices) to draw 
	// R: [none] 
	public void draw(int primitiveType, int offset, int numVertices) {
		if (indices != null) {                    // IF Indices Exist
			indices.position(offset);                // Set Index Buffer to Specified Offset
			gl.glDrawElements(primitiveType, numVertices, GL10.GL_UNSIGNED_SHORT, indices);  // Draw Indexed
		} else {                                        // ELSE No Indices Exist 
			gl.glDrawArrays(primitiveType, offset, numVertices);  // Draw Direct (Array)
		} 
	} 
 
	//--Unbind--// 
	// D: clear binding states when done rendering batches. 
	//    USAGE: call once before calling draw() multiple times for this buffer. 
	// A: [none] 
	// R: [none] 
	public void unbind() { 
		if (hasColor)                                // IF Vertices Have Color
			gl.glDisableClientState(GL10.GL_COLOR_ARRAY);  // Clear Color State
6
CodeRank
This code example shows how to use the following methods:glDrawElements, glEnable, glFrontFace, glTexCoordPointer, glVertexPointer
        mTexBuffer.position(0);
        mIndexBuffer.position(0);
    } 
 
    public void draw(GL10 gl) {
        gl.glFrontFace(GL10.GL_CCW);
        gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mFVertexBuffer);
        gl.glEnable(GL10.GL_TEXTURE_2D);
        gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTexBuffer);
        gl.glDrawElements(GL10.GL_TRIANGLE_STRIP, VERTS,
                GL10.GL_UNSIGNED_SHORT, mIndexBuffer);
    } 
 
    public float getX(int vertex) {
        return sCoords[3*vertex];
    } 
 
    public float getY(int vertex) {
        return sCoords[3*vertex+1];
    } 
8
CodeRank
This code example shows how to use the following methods:glColorPointer, glDrawElements, glEnable, glFrontFace, glShadeModel
This code example shows how to use the following methods:glDisableClientState, glDrawElements, glEnable, glEnableClientState, glTexCoordPointer
8
CodeRank
This code example shows how to use the following methods:glColorPointer, glDrawElements, glFrontFace, glVertexPointer
This code example shows how to use the following methods:glDrawElements, glEnable, glFrontFace, glTexCoordPointer, glVertexPointer
            mTexBuffer.position(0);
            mIndexBuffer.position(0);
        } 
 
        public void draw(GL10 gl) {
            gl.glFrontFace(GL10.GL_CCW);
            gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mFVertexBuffer);
            gl.glEnable(GL10.GL_TEXTURE_2D);
            gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTexBuffer);
            gl.glDrawElements(GL10.GL_TRIANGLE_STRIP, 24, GL10.GL_UNSIGNED_SHORT, mIndexBuffer);
        } 
    } 
 
    /** 
     * A representation of the Z-axis in vector form. 
     */ 
    protected static final float[] Z_AXIS = new float[] {
            0, 0, 1 
    }; 
 
8
CodeRank
This code example shows how to use the following methods:glDrawElements, glTexCoordPointer, glVertexPointer

Related GL10 glDrawElements Questions & Answers: