Example usage for org.lwjgl.opengl GL31 glDrawArraysInstanced

List of usage examples for org.lwjgl.opengl GL31 glDrawArraysInstanced

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL31 glDrawArraysInstanced.

Prototype

public static void glDrawArraysInstanced(@NativeType("GLenum") int mode, @NativeType("GLint") int first,
        @NativeType("GLsizei") int count, @NativeType("GLsizei") int primcount) 

Source Link

Document

Draw multiple instances of a range of elements.

Usage

From source file:com.ardor3d.renderer.lwjgl.LwjglRenderer.java

License:Open Source License

@Override
public void drawArrays(final FloatBufferData vertices, final int[] indexLengths, final IndexMode[] indexModes,
        final int primcount) {
    if (indexLengths == null) {
        final int glIndexMode = getGLIndexMode(indexModes[0]);

        if (primcount < 0) {
            GL11.glDrawArrays(glIndexMode, 0, vertices.getTupleCount());
        } else {//w w  w  .ja  va  2s .c  o  m
            GL31.glDrawArraysInstanced(glIndexMode, 0, vertices.getTupleCount(), primcount);
        }

        if (Constants.stats) {
            addStats(indexModes[0], vertices.getTupleCount());
        }
    } 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]);

            if (primcount < 0) {
                GL11.glDrawArrays(glIndexMode, offset, count);
            } else {
                GL31.glDrawArraysInstanced(glIndexMode, offset, count, 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 glDrawArraysInstanced(int mode, int first, int count, int instanceCount) {
    GL31.glDrawArraysInstanced(mode, first, count, instanceCount);
}

From source file:com.grillecube.client.opengl.GLH.java

public static void glhDrawArraysInstanced(int mode, int first, int count, int primcount) {
    GL31.glDrawArraysInstanced(mode, first, count, primcount);
    theContext.incrementDrawCalls();/*from   w  w  w  .  j ava  2s.  c o m*/
    theContext.increaseVerticesDrawn(3 * count);
}

From source file:com.grillecube.engine.opengl.GLH.java

public static void glhDrawArraysInstanced(int mode, int first, int count, int primcount) {
    GL31.glDrawArraysInstanced(mode, first, count, primcount);
    _context.incrementDrawCalls();//from  w w  w  . ja  va  2 s  .com
    _context.increaseVerticesDrawn(3 * count);
}

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  ww. java 2  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 ava  2  s .c  o  m*/
        GL31.glDrawArraysInstanced(drawMode, 0, countElements, count);
    }
}

From source file:io.root.gfx.glutils.GL.java

License:Apache License

public static void glDrawArraysInstanced(int mode, int first, int count, int instanceCount) {
    GL31.glDrawArraysInstanced(mode, first, count, instanceCount);
}

From source file:org.spout.engine.renderer.GL40BatchVertexRenderer.java

License:Open Source License

/**
 * Draws this batch/*from w  ww  . j a  va 2s.com*/
 */
@Override
public void doDraw(RenderMaterial material, int elements, int instances) {
    GL30.glBindVertexArray(vao);
    SpoutRenderer.checkGLError();

    material.assign();

    GL31.glDrawArraysInstanced(renderMode, 0, elements, instances);
    SpoutRenderer.checkGLError();
}

From source file:org.spout.engine.renderer.GLBatchInstanceRenderer.java

License:Open Source License

/**
 * Draws this batch//from w  ww  .  j a v  a2 s  .com
 */
@Override
public void doDraw(RenderMaterial material, int elements, int instances) {
    GL30.glBindVertexArray(vao);
    SpoutRenderer.checkGLError();

    material.assign();

    //System.out.println("glDrawArrays");
    // RenderModer, ? , Type of index of instance, ? , ?
    GL31.glDrawArraysInstanced(renderMode, 0, elements, instances);
    SpoutRenderer.checkGLError();

    //GL30.glBindVertexArray(0); //Run without
}

From source file:tk.ivybits.engine.gl.GL.java

License:Open Source License

public static void glDrawArraysInstanced(int a, int b, int c, int d) {
    GL31.glDrawArraysInstanced(a, b, c, d);
}