List of usage examples for org.lwjgl.opengl GL31 glDrawElementsInstanced
public static void glDrawElementsInstanced(@NativeType("GLenum") int mode, @NativeType("GLsizei") int count, @NativeType("GLenum") int type, @NativeType("void const *") long indices, @NativeType("GLsizei") int primcount)
From source file:com.ardor3d.renderer.lwjgl.LwjglRenderer.java
License:Open Source License
@Override public void drawElementsVBO(final IndexBufferData<?> indices, final int[] indexLengths, final IndexMode[] indexModes, final int primcount) { final RenderContext context = ContextManager.getCurrentContext(); final RendererRecord rendRecord = context.getRendererRecord(); final int vboID = setupIndicesVBO(indices, context, rendRecord); LwjglRendererUtil.setBoundElementVBO(rendRecord, vboID); if (indexLengths == null) { final int glIndexMode = getGLIndexMode(indexModes[0]); final int type = getGLDataType(indices); if (primcount < 0) { GL11.glDrawElements(glIndexMode, indices.getBufferLimit(), type, 0); } else {//from w w w .j av a 2 s.c o m GL31.glDrawElementsInstanced(glIndexMode, indices.getBufferLimit(), type, 0, 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]); final int type = getGLDataType(indices); final int byteSize = indices.getByteCount(); // offset in this call is done in bytes. if (primcount < 0) { GL11.glDrawElements(glIndexMode, count, type, offset * byteSize); } else { GL31.glDrawElementsInstanced(glIndexMode, count, type, offset * byteSize, primcount); } if (Constants.stats) { addStats(indexModes[indexModeCounter], count); } offset += count; if (indexModeCounter < indexModes.length - 1) { indexModeCounter++; } } } }
From source file:com.badlogic.gdx.backends.jglfw.JglfwGL30.java
License:Apache License
@Override public void glDrawElementsInstanced(int mode, int count, int type, int indicesOffset, int instanceCount) { GL31.glDrawElementsInstanced(mode, count, type, indicesOffset, instanceCount); }
From source file:com.samrj.devil.gl.DGL.java
License:Open Source License
/** * Performs instanced rendering on the given vertex data, using the given * primitive mode. The instance ID may be read as by a vertex shader as * {@code gl_InstanceID}./*from w w w . j a v a2 s . co m*/ * * @param <T> A type of vertex data. * @param data The vertex data to render. * @param mode An OpenGL primitive draw mode. * @param primcount The number of instances to render. * @return The given vertex data. */ public static <T extends VertexData> T drawInstanced(T data, int mode, int primcount) { if (boundProgram == null) throw new IllegalStateException("No shader program is in use."); int verts = data.numVertices(); int inds = data.numIndices(); VAO.bindFor(data, boundProgram, () -> { if (inds < 0) GL31.glDrawArraysInstanced(mode, 0, verts, primcount); else GL31.glDrawElementsInstanced(mode, inds, GL11.GL_UNSIGNED_INT, 0, primcount); }); return data; }
From source file:com.xrbpowered.gl.res.StaticMesh.java
License:Open Source License
public void drawCallInstanced(int count) { if (vboiId != GL11.GL_INVALID_VALUE) { GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboiId); GL31.glDrawElementsInstanced(drawMode, countElements, GL11.GL_UNSIGNED_SHORT, 0, count); } else {/*from w w w.j ava2 s . com*/ GL31.glDrawArraysInstanced(drawMode, 0, countElements, count); } }
From source file:io.root.gfx.glutils.GL.java
License:Apache License
public static void glDrawElementsInstanced(int mode, int count, int type, int indicesOffset, int instanceCount) { GL31.glDrawElementsInstanced(mode, count, type, indicesOffset, instanceCount); }
From source file:tk.ivybits.engine.gl.GL.java
License:Open Source License
public static void glDrawElementsInstanced(int a, int b, int c, long d, int e) { GL31.glDrawElementsInstanced(a, b, c, d, e); }