@Override public void glDrawElementsInstanced (int mode, int count, int type, int indicesOffset, int instanceCount) { GL31.glDrawElementsInstanced(mode, count, type, indicesOffset, instanceCount); }
@Override public void glDrawElementsInstanced (int mode, int count, int type, int indicesOffset, int instanceCount) { GL31.glDrawElementsInstanced(mode, count, type, indicesOffset, instanceCount); }
@Override public void glDrawElementsInstanced (int mode, int count, int type, int indicesOffset, int instanceCount) { GL31.glDrawElementsInstanced(mode, count, type, indicesOffset, instanceCount); }
@Override public void glDrawElementsInstanced (int mode, int count, int type, int indicesOffset, int instanceCount) { GL31.glDrawElementsInstanced(mode, count, type, indicesOffset, instanceCount); }
public void drawElementsInstanced(int mode, int size, int count){ glDrawElementsInstanced(mode, size, GL_UNSIGNED_INT, 0, count); }
@Override public void glDrawElementsInstanced (int mode, int count, int type, int indicesOffset, int instanceCount) { GL31.glDrawElementsInstanced(mode, count, type, indicesOffset, instanceCount); }
@Override public void glDrawElementsInstanced (int mode, int count, int type, int indicesOffset, int instanceCount) { GL31.glDrawElementsInstanced(mode, count, type, indicesOffset, instanceCount); }
glBufferData(GL_ARRAY_BUFFER, instanceDataBuffer, GL_DYNAMIC_READ); glDrawElementsInstanced( GL_TRIANGLES, getVertexCount(), GL_UNSIGNED_INT, 0, gameItems.size());
glBufferData(GL_ARRAY_BUFFER, instanceDataBuffer, GL_DYNAMIC_READ); glDrawElementsInstanced( GL_TRIANGLES, getVertexCount(), GL_UNSIGNED_INT, 0, gameItems.size());
glBufferData(GL_ARRAY_BUFFER, instanceDataBuffer, GL_DYNAMIC_READ); glDrawElementsInstanced( GL_TRIANGLES, getVertexCount(), GL_UNSIGNED_INT, 0, gameItems.size());
glBufferData(GL_ARRAY_BUFFER, instanceDataBuffer, GL_DYNAMIC_READ); glDrawElementsInstanced( GL_TRIANGLES, getVertexCount(), GL_UNSIGNED_INT, 0, gameItems.size());
@Override public void drawElementsInstanced( final JCGLPrimitives p, final int instances) throws JCGLException, JCGLExceptionBufferNotBound { NullCheck.notNull(p, "Primitives"); RangeCheck.checkIncludedInInteger( instances, "Instances", Ranges.NATURAL_INTEGER, "Valid instances"); if (this.index_buffers.indexBufferIsBound()) { final LWJGL3IndexBuffer ib = this.array_objects.getCurrentIndexBuffer(); final int pgl = LWJGL3TypeConversions.primitiveToGL(p); final int type = LWJGL3TypeConversions.unsignedTypeToGL(ib.type()); GL31.glDrawElementsInstanced( pgl, (int) ib.indices(), type, 0L, instances); } else { throw new JCGLExceptionBufferNotBound( "No index buffer is currently bound"); } } }
@Override public void drawElementsInstanced( final JCGLPrimitives p, final int instances) throws JCGLException, JCGLExceptionBufferNotBound { NullCheck.notNull(p); RangeCheck.checkIncludedInInteger( instances, "Instances", Ranges.NATURAL_INTEGER, "Valid instances"); if (this.index_buffers.indexBufferIsBound()) { final LWJGL3IndexBuffer ib = this.array_objects.getCurrentIndexBuffer(); final int pgl = LWJGL3TypeConversions.primitiveToGL(p); final int type = LWJGL3TypeConversions.unsignedTypeToGL(ib.getType()); GL31.glDrawElementsInstanced( pgl, (int) ib.getIndices(), type, 0L, instances); } else { throw new JCGLExceptionBufferNotBound( "No index buffer is currently bound"); } } }
private void renderChunkInstanced(List<GameItem> gameItems, boolean depthMap, Transformation transformation, Matrix4f viewMatrix, Matrix4f lightViewMatrix) { this.modelViewBuffer.clear(); this.modelLightViewBuffer.clear(); int i = 0; for (GameItem gameItem : gameItems) { Matrix4f modelMatrix = transformation.buildModelMatrix(gameItem); if (!depthMap) { Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(modelMatrix, viewMatrix); modelViewMatrix.get(MATRIX_SIZE_FLOATS * i, modelViewBuffer); } Matrix4f modelLightViewMatrix = transformation.buildModelLightViewMatrix(modelMatrix, lightViewMatrix); modelLightViewMatrix.get(MATRIX_SIZE_FLOATS * i, this.modelLightViewBuffer); i++; } glBindBuffer(GL_ARRAY_BUFFER, modelViewVBO); glBufferData(GL_ARRAY_BUFFER, modelViewBuffer, GL_DYNAMIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, modelLightViewVBO); glBufferData(GL_ARRAY_BUFFER, modelLightViewBuffer, GL_DYNAMIC_DRAW); glDrawElementsInstanced( GL_TRIANGLES, getVertexCount(), GL_UNSIGNED_INT, 0, gameItems.size()); glBindBuffer(GL_ARRAY_BUFFER, 0); } }
glBufferData(GL_ARRAY_BUFFER, instanceDataBuffer, GL_DYNAMIC_DRAW); glDrawElementsInstanced( GL_TRIANGLES, getVertexCount(), GL_UNSIGNED_INT, 0, gameItems.size());
glBufferData(GL_ARRAY_BUFFER, instanceDataBuffer, GL_DYNAMIC_DRAW); glDrawElementsInstanced( GL_TRIANGLES, getVertexCount(), GL_UNSIGNED_INT, 0, gameItems.size());
glBufferData(GL_ARRAY_BUFFER, instanceDataBuffer, GL_DYNAMIC_DRAW); glDrawElementsInstanced( GL_TRIANGLES, getVertexCount(), GL_UNSIGNED_INT, 0, gameItems.size());
glBufferData(GL_ARRAY_BUFFER, instanceDataBuffer, GL_DYNAMIC_DRAW); glDrawElementsInstanced( GL_TRIANGLES, getVertexCount(), GL_UNSIGNED_INT, 0, gameItems.size());
glBufferData(GL_ARRAY_BUFFER, instanceDataBuffer, GL_DYNAMIC_DRAW); glDrawElementsInstanced( GL_TRIANGLES, getVertexCount(), GL_UNSIGNED_INT, 0, gameItems.size());
public void draw() { glBindVertexArray(vaoId); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glEnableVertexAttribArray(2); if (hasTangentsBitangents){ glEnableVertexAttribArray(3); glEnableVertexAttribArray(4); } if (isInstanced) glDrawElementsInstanced(GL_TRIANGLES, size, GL_UNSIGNED_INT, 0, instances.getValue()); else glDrawElements(GL_TRIANGLES, size, GL_UNSIGNED_INT, 0); glDisableVertexAttribArray(0); glDisableVertexAttribArray(1); glDisableVertexAttribArray(2); if (hasTangentsBitangents){ glDisableVertexAttribArray(3); glDisableVertexAttribArray(4); } glBindVertexArray(0); }