List of usage examples for org.lwjgl.opengl GL11 glDrawElements
public static void glDrawElements(@NativeType("GLenum") int mode, @NativeType("void const *") IntBuffer indices)
From source file:com.ardor3d.renderer.lwjgl.LwjglRenderer.java
License:Open Source License
@Override public void drawElements(final IndexBufferData<?> indices, final int[] indexLengths, final IndexMode[] indexModes, final int primcount) { if (indices == null || indices.getBuffer() == null) { logger.severe("Missing indices for drawElements call without VBO"); return;/* ww w.java2 s . c o m*/ } if (indexLengths == null) { final int glIndexMode = getGLIndexMode(indexModes[0]); indices.position(0); if (indices.getBuffer() instanceof IntBuffer) { if (primcount < 0) { GL11.glDrawElements(glIndexMode, (IntBuffer) indices.getBuffer()); } else { GL31.glDrawElementsInstanced(glIndexMode, (IntBuffer) indices.getBuffer(), primcount); } } else if (indices.getBuffer() instanceof ShortBuffer) { if (primcount < 0) { GL11.glDrawElements(glIndexMode, (ShortBuffer) indices.getBuffer()); } else { GL31.glDrawElementsInstanced(glIndexMode, (ShortBuffer) indices.getBuffer(), primcount); } } else if (indices.getBuffer() instanceof ByteBuffer) { if (primcount < 0) { GL11.glDrawElements(glIndexMode, (ByteBuffer) indices.getBuffer()); } else { GL31.glDrawElementsInstanced(glIndexMode, (ByteBuffer) indices.getBuffer(), primcount); } } if (Constants.stats) { addStats(indexModes[0], indices.getBufferLimit()); } } else { int offset = 0; int indexModeCounter = 0; for (int i = 0; i < indexLengths.length; i++) { final int count = indexLengths[i]; final int glIndexMode = getGLIndexMode(indexModes[indexModeCounter]); indices.getBuffer().position(offset); indices.getBuffer().limit(offset + count); if (indices.getBuffer() instanceof IntBuffer) { if (primcount < 0) { GL11.glDrawElements(glIndexMode, (IntBuffer) indices.getBuffer()); } else { GL31.glDrawElementsInstanced(glIndexMode, (IntBuffer) indices.getBuffer(), primcount); } } else if (indices.getBuffer() instanceof ShortBuffer) { if (primcount < 0) { GL11.glDrawElements(glIndexMode, (ShortBuffer) indices.getBuffer()); } else { GL31.glDrawElementsInstanced(glIndexMode, (ShortBuffer) indices.getBuffer(), primcount); } } else if (indices.getBuffer() instanceof ByteBuffer) { if (primcount < 0) { GL11.glDrawElements(glIndexMode, (ByteBuffer) indices.getBuffer()); } else { GL31.glDrawElementsInstanced(glIndexMode, (ByteBuffer) indices.getBuffer(), primcount); } } if (Constants.stats) { addStats(indexModes[indexModeCounter], count); } offset += count; if (indexModeCounter < indexModes.length - 1) { indexModeCounter++; } } } }
From source file:com.badlogic.gdx.backends.jglfw.JglfwGL20.java
License:Apache License
public void glDrawElements(int mode, int count, int type, Buffer indices) { if (indices instanceof ShortBuffer && type == com.badlogic.gdx.graphics.GL20.GL_UNSIGNED_SHORT) GL11.glDrawElements(mode, (ShortBuffer) indices); else if (indices instanceof ByteBuffer && type == com.badlogic.gdx.graphics.GL20.GL_UNSIGNED_SHORT) GL11.glDrawElements(mode, ((ByteBuffer) indices).asShortBuffer()); // FIXME yay... else if (indices instanceof ByteBuffer && type == com.badlogic.gdx.graphics.GL20.GL_UNSIGNED_BYTE) GL11.glDrawElements(mode, (ByteBuffer) indices); else if (indices instanceof IntBuffer && type == com.badlogic.gdx.graphics.GL20.GL_INT) GL11.glDrawElements(mode, (IntBuffer) indices); else/* w ww . j a v a2s . co m*/ throw new GdxRuntimeException("Can't use " + indices.getClass().getName() + " with this method. Use IntBuffer, ShortBuffer or ByteBuffer instead. Blame LWJGL"); }
From source file:com.badlogic.gdx.backends.lwjgl.LwjglGL10.java
License:Apache License
public final void glDrawElements(int mode, int count, int type, Buffer indices) { if (indices instanceof ShortBuffer && type == GL10.GL_UNSIGNED_SHORT) GL11.glDrawElements(mode, (ShortBuffer) indices); else if (indices instanceof ByteBuffer && type == GL10.GL_UNSIGNED_SHORT) GL11.glDrawElements(mode, ((ByteBuffer) indices).asShortBuffer()); // FIXME yay... else if (indices instanceof ByteBuffer && type == GL10.GL_UNSIGNED_BYTE) GL11.glDrawElements(mode, (ByteBuffer) indices); else// www . j av a 2s . co m throw new GdxRuntimeException("Can't use " + indices.getClass().getName() + " with this method. Use ShortBuffer or ByteBuffer instead. Blame LWJGL"); }
From source file:com.badlogic.gdx.backends.lwjgl.LwjglGL20.java
License:Apache License
public void glDrawElements(int mode, int count, int type, Buffer indices) { if (indices instanceof ShortBuffer && type == com.badlogic.gdx.graphics.GL20.GL_UNSIGNED_SHORT) GL11.glDrawElements(mode, (ShortBuffer) indices); else if (indices instanceof ByteBuffer && type == com.badlogic.gdx.graphics.GL20.GL_UNSIGNED_SHORT) GL11.glDrawElements(mode, ((ByteBuffer) indices).asShortBuffer()); // FIXME yay... else if (indices instanceof ByteBuffer && type == com.badlogic.gdx.graphics.GL20.GL_UNSIGNED_BYTE) GL11.glDrawElements(mode, (ByteBuffer) indices); else//from w w w .ja v a 2 s. c o m throw new GdxRuntimeException("Can't use " + indices.getClass().getName() + " with this method. Use ShortBuffer or ByteBuffer instead. Blame LWJGL"); }
From source file:com.badlogic.gdx.backends.lwjgl.swt.LwjglGL20.java
License:Apache License
public void glDrawElements(int mode, int count, int type, Buffer indices) { if (indices instanceof ShortBuffer && type == GL10.GL_UNSIGNED_SHORT) GL11.glDrawElements(mode, (ShortBuffer) indices); else if (indices instanceof ByteBuffer && type == GL10.GL_UNSIGNED_SHORT) GL11.glDrawElements(mode, ((ByteBuffer) indices).asShortBuffer()); // FIXME yay... else if (indices instanceof ByteBuffer && type == GL10.GL_UNSIGNED_BYTE) GL11.glDrawElements(mode, (ByteBuffer) indices); else//from ww w . ja va2 s .c o m throw new GdxRuntimeException("Can't use " + indices.getClass().getName() + " with this method. Use ShortBuffer or ByteBuffer instead. Blame LWJGL"); }
From source file:com.badlogic.gdx.backends.lwjgl3.Lwjgl3GL20.java
License:Apache License
public void glDrawElements(int mode, int count, int type, Buffer indices) { if (indices instanceof ShortBuffer && type == com.badlogic.gdx.graphics.GL20.GL_UNSIGNED_SHORT) GL11.glDrawElements(mode, (ShortBuffer) indices); else if (indices instanceof ByteBuffer && type == com.badlogic.gdx.graphics.GL20.GL_UNSIGNED_SHORT) GL11.glDrawElements(mode, ((ByteBuffer) indices).asShortBuffer()); else if (indices instanceof ByteBuffer && type == com.badlogic.gdx.graphics.GL20.GL_UNSIGNED_BYTE) GL11.glDrawElements(mode, (ByteBuffer) indices); else/*from w w w. j av a 2s. c o m*/ throw new GdxRuntimeException("Can't use " + indices.getClass().getName() + " with this method. Use ShortBuffer or ByteBuffer instead. Blame LWJGL"); }
From source file:com.gundogstudios.modules.DesktopGL11.java
License:Open Source License
public final void glDrawElements(int mode, int count, int type, ByteBuffer indices) { GL11.glDrawElements(mode, indices); }
From source file:io.root.gfx.glutils.GL.java
License:Apache License
public static void glDrawElements(int mode, int count, int type, Buffer indices) { if (indices instanceof ShortBuffer && type == GL_UNSIGNED_SHORT) GL11.glDrawElements(mode, (ShortBuffer) indices); else if (indices instanceof ByteBuffer && type == GL_UNSIGNED_SHORT) GL11.glDrawElements(mode, ((ByteBuffer) indices).asShortBuffer()); else if (indices instanceof ByteBuffer && type == GL_UNSIGNED_BYTE) GL11.glDrawElements(mode, (ByteBuffer) indices); else// ww w. j a v a 2s . c om throw new RootException("Can't use " + indices.getClass().getName() + " with this method. Use ShortBuffer or ByteBuffer instead."); }
From source file:ion2d.INGrid3D.java
License:Open Source License
/** * Draw the Grid3D to the output/*from www. j a v a2 s .com*/ */ public void blit() { // Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY // Needed states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_TEXTURE_COORD_ARRAY // Unneeded states: GL_COLOR_ARRAY GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); GL11.glVertexPointer(3, 0, this.vertices); GL11.glTexCoordPointer(2, 0, this.textureCoordinates); GL11.glDrawElements(GL11.GL_TRIANGLES, this.indices); //Restore GL Default State GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); }
From source file:ion2d.INTiledGrid3D.java
License:Open Source License
/** * Draws the Grid3D to the output/*from ww w . ja v a 2s . c o m*/ */ public void blit() { // Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY // Needed states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_TEXTURE_COORD_ARRAY // Unneeded states: GL_COLOR_ARRAY GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); GL11.glVertexPointer(3, 0, this.vertices); GL11.glTexCoordPointer(2, 0, this.textureCoordinates); GL11.glDrawElements(GL11.GL_QUADS, this.indices); //Restore GL Default State GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); }