Example usage for org.lwjgl.opengl GL11 glDrawElements

List of usage examples for org.lwjgl.opengl GL11 glDrawElements

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glDrawElements.

Prototype

public static void glDrawElements(@NativeType("GLenum") int mode, @NativeType("GLsizei") int count,
        @NativeType("GLenum") int type, @NativeType("void const *") long indices) 

Source Link

Document

Constructs a sequence of geometric primitives by successively transferring elements for count vertices to the GL.

Usage

From source file:game.entity.lwjgl.EntityRenderer.java

/**
 * Renders a single entity to the screen.
 * <b>Deprecated</b>/*from   www  .  jav  a 2  s.c  om*/
 *
 * @param entity The entity to be rendered.
 */
@Override
public void render(Entity entity) {
    if (entity.getModel().getRawModel().doesContainInvertedNormals()) {
        GL11.glDisable(GL11.GL_CULL_FACE);
    }
    this.prepareTexturedModel(entity.getModel());
    this.loadModelMatrix(entity);

    GL11.glDrawElements(GL11.GL_TRIANGLES, entity.getModel().getRawModel().getVertexCount(),
            GL11.GL_UNSIGNED_INT, 0);

    unbindTexturedModel(entity.getModel());

    if (entity.getModel().getRawModel().doesContainInvertedNormals()) {
        GL11.glEnable(GL11.GL_CULL_FACE);
    }
}

From source file:game.terrain.lwjgl.TerrainRenderer.java

/**
 *
 * @param terrain//from w  w  w .j a v  a  2s.co  m
 */
@Override
public void render(Terrain terrain) {
    prepareTerrain(terrain);
    loadModelMatrix(terrain);

    GL11.glDrawElements(GL11.GL_TRIANGLES, terrain.getModel().getVertexCount(), GL11.GL_UNSIGNED_INT, 0);

    unbindTexturedModel();

}

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

License:Apache License

public static void glDrawElements(int mode, int count, int type, int indices) {
    GL11.glDrawElements(mode, count, type, indices);
}

From source file:jpcsp.graphics.RE.RenderingEngineLwjgl.java

License:Open Source License

@Override
public void drawElements(int primitive, int count, int indexType, long indicesOffset) {
    GL11.glDrawElements(primitiveToGL[primitive], count, pointerTypeToGL[indexType], indicesOffset);
}

From source file:main.EntityRenderer.java

public void render(Map<TextureModel, List<Entity>> entities) {
    for (TextureModel model : entities.keySet()) {
        prepareTextureModel(model);//from w ww  . ja  v  a 2  s  .c om
        List<Entity> batch = entities.get(model);
        for (Entity entity : batch) {
            prepareInstance(entity);
            GL11.glDrawElements(GL11.GL_TRIANGLES, model.getRawModel().getVertexCount(), GL11.GL_UNSIGNED_INT,
                    0);
        }
        unbindTextureModel();
    }
}

From source file:main.java.com.YeAJG.game.entity.Entity.java

License:Open Source License

@Override
public void Render(float interpolation) {

    GL20.glUseProgram(pId);/* w w w .  ja  v  a  2 s .c  o m*/

    // Bind the texture
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId);

    // Bind to the VAO that has all the information about the vertices
    GL30.glBindVertexArray(vaoId);
    GL20.glEnableVertexAttribArray(0);
    GL20.glEnableVertexAttribArray(1);
    GL20.glEnableVertexAttribArray(2);

    // Bind to the index VBO that has all the information about the order of the vertices
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboiId);

    // Draw the vertices
    GL11.glDrawElements(GL11.GL_TRIANGLES, indicesCount, GL11.GL_UNSIGNED_BYTE, 0);

    // Put everything back to default (deselect)
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    GL20.glDisableVertexAttribArray(0);
    GL20.glDisableVertexAttribArray(1);
    GL20.glDisableVertexAttribArray(2);
    GL30.glBindVertexArray(0);

    GL20.glUseProgram(0);

    Game.exitOnGLError("renderCycle");
}

From source file:main.TerrainRenderer.java

public void render(List<Terrain> terrains) {
    for (Terrain terrain : terrains) {
        prepareTerrain(terrain);//w  w  w  .j  av a2s  .co m
        loadModelMatrix(terrain);
        GL11.glDrawElements(GL11.GL_TRIANGLES, terrain.getModel().getVertexCount(), GL11.GL_UNSIGNED_INT, 0);
        unbindTextureModel();
    }
}

From source file:me.thehutch.fusion.engine.render.opengl.gl30.OpenGL30VertexArray.java

License:Open Source License

@Override
public void draw() {
    ensureCreated("VertexArray must be created to draw.");

    //Bind the vertex array object
    GL30.glBindVertexArray(vao);//  www  .j a  v a2s .co  m

    // Enable the vertex attributes
    for (int i = 0; i < attributes.size(); ++i) {
        GL20.glEnableVertexAttribArray(i);
    }

    // Bind the index buffer
    GL15.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo);
    // Draw the vertex elements
    GL11.glDrawElements(GL_TRIANGLES, drawCount, DataType.UNSIGNED_INT.getGLConstant(), 0L);
    // Unbind the index buffer
    GL15.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

    // Disable the vertex attributes
    for (int i = 0; i < attributes.size(); ++i) {
        GL20.glDisableVertexAttribArray(i);
    }

    // Unbind the vertex array object
    GL30.glBindVertexArray(0);
}

From source file:net.neilcsmith.praxis.video.opengl.internal.Mesh.java

License:Apache License

/** <p>
 * Renders the mesh using the given primitive type. offset specifies the offset into either the vertex buffer or the index
 * buffer depending on whether indices are defined. count specifies the number of vertices or indices to use thus count /
 * #vertices per primitive primitives are rendered.
 * </p>/*from   w ww .j  av  a2 s  .  c  o  m*/
 * 
 * <p>
 * This method will automatically bind each vertex attribute as specified at construction time via {@link VertexAttributes} to
 * the respective shader attributes. The binding is based on the alias defined for each VertexAttribute.
 * </p>
 * 
 * <p>
 * This method must only be called after the {@link ShaderProgram#begin()} method has been called!
 * </p>
 * 
 * <p>
 * This method is intended for use with OpenGL ES 2.0 and will throw an IllegalStateException when OpenGL ES 1.x is used.
 * </p>
 * 
 * @param shader the shader to be used
 * @param primitiveType the primitive type
 * @param offset the offset into the vertex or index buffer
 * @param count number of vertices or indices to use */
public void render(ShaderProgram shader, int primitiveType, int offset, int count) {
    if (autoBind) {
        bind(shader);
    }
    if (indices.getNumIndices() > 0) {
        GL11.glDrawElements(primitiveType, count, GL11.GL_UNSIGNED_SHORT, offset * 2);
    } else {
        GL11.glDrawArrays(primitiveType, offset, count);
    }

    if (autoBind) {
        unbind(shader);
    }
}

From source file:net.smert.frameworkgl.opengl.helpers.VertexArrayHelper.java

License:Apache License

public void drawElements(int mode, int count, int type, ByteBuffer byteBuffer) {
    GL11.glDrawElements(mode, count, type, byteBuffer);
}