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:net.smert.frameworkgl.opengl.helpers.VertexBufferObjectHelper.java

License:Apache License

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

From source file:opengl.test.object.CaroTable.java

@Override
public void render() {

    this.bind();// use porgrma --> ket thuc disable program

    GL30.glBindVertexArray(this.vao);// bind vao -- > unbind vao
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo);
    this.VertexAttribPointer();
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ebo);

    GL20.glEnableVertexAttribArray(0);// set index ve 0 

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);

    GL11.glDrawElements(GL11.GL_TRIANGLES, 6, GL11.GL_UNSIGNED_INT, 0);

    GL20.glDisableVertexAttribArray(0);// disable 

    GL30.glBindVertexArray(0);// unbind vao

    this.unbind();// dsiable program
}

From source file:opengl.test.object.cube.wall.java

@Override
public void render() {
    this.bind();// use porgrma --> ket thuc disable program

    GL30.glBindVertexArray(this.vao);// bind vao -- > unbind vao
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo);
    this.VertexAttribPointer();
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ebo);

    GL20.glEnableVertexAttribArray(0);// set index ve 0 

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);

    GL11.glDrawElements(GL11.GL_TRIANGLE_STRIP, 6, GL11.GL_UNSIGNED_INT, 0);

    GL20.glDisableVertexAttribArray(0);// disable 

    GL30.glBindVertexArray(0);// unbind vao

    this.unbind();// dsiable program
}

From source file:opengl.test.object.image.java

@Override
public void render() {

    this.bind();// use porgrma --> ket thuc disable program

    GL30.glBindVertexArray(this.vao);// bind vao -- > unbind vao
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo);
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ebo);
    this.VertexAttribPointer();

    GL20.glEnableVertexAttribArray(0);// set index ve 0 

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);

    GL11.glDrawElements(GL11.GL_TRIANGLES, 6, GL11.GL_UNSIGNED_INT, 0);

    GL20.glDisableVertexAttribArray(0);// disable 

    GL30.glBindVertexArray(0);// unbind vao

    this.unbind();// dsiable program
}

From source file:opengl.test.object.lineCube.java

@Override
public void render() {
    this.bind();// use porgrma --> ket thuc disable program

    GL30.glBindVertexArray(this.vao);// bind vao -- > unbind vao
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo);
    this.VertexAttribPointer();
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ebo);

    GL20.glEnableVertexAttribArray(0);// set index ve 0 

    GL11.glDrawElements(GL11.GL_LINE_STRIP, 16, GL11.GL_UNSIGNED_INT, 0);

    GL20.glDisableVertexAttribArray(0);// disable 

    GL30.glBindVertexArray(0);// unbind vao

    this.unbind();// dsiable program
}

From source file:opengl.test.object.tree.testobject.leaf.java

public void render() {

    this.bind();// use porgrma --> ket thuc disable program

    GL30.glBindVertexArray(this.vao);// bind vao -- > unbind vao
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo);
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ebo);
    this.VertexAttribPointer();

    GL20.glEnableVertexAttribArray(0);// set index ve 0 

    GL11.glDrawElements(GL11.GL_TRIANGLES, this.indices.capacity(), GL11.GL_UNSIGNED_INT, 0);// capacity --> luon luon chua max
    //GL11.//from  ww  w.ja  v a 2 s. co m
    GL20.glDisableVertexAttribArray(0);// disable 

    GL30.glBindVertexArray(0);// unbind vao

    this.unbind();// dsiable program
}

From source file:opengl.test.object.XO.java

@Override
public void render() {

    this.bind();// use porgrma --> ket thuc disable program

    GL30.glBindVertexArray(this.vao);// bind vao -- > unbind vao
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo);
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ebo);
    this.VertexAttribPointer();

    GL20.glEnableVertexAttribArray(0);// set index ve 0 

    GL11.glDrawElements(GL11.GL_TRIANGLES, this.indices.capacity(), GL11.GL_UNSIGNED_INT, 0);// capacity --> luon luon chua max
    //GL11./*from   ww  w  . j  a  va2  s. co  m*/
    GL20.glDisableVertexAttribArray(0);// disable 

    GL30.glBindVertexArray(0);// unbind vao

    this.unbind();// dsiable program
}

From source file:org.ajgl.graphics.VertexArrays.java

License:Open Source License

/**
 * Draws the vertex array; Does not use redundant vertices. You need to enable 
 * {@link org.lwjgl.opengl.GL11#GL_VERTEX_ARRAY GL_VERTEX_ARRAY} before 
 * you can use this method./*from   ww w  .j a v  a  2  s.c o  m*/
 * @param beginMode - The OpenGL begin mode
 * @param dataType - The OpenGL dataType
 * @param vertexPointData - The number of points per vertex data (i.e. 1-1D, 2-2D, 3-3D)
 * @param vertexNumber - The number of vertices
 * @param first - The start point of the array
 * @param stride - The stride offset; used for interleaving data
 * @param vertices - The vertex vertices
 * @param indices - The index vertices
 */
@OpenGLInfo(fwdCompatible = false, openGLVersion = "1.1", status = "Release")
public static void drawElements(@BeginMode int beginMode, @GLDataType int dataType, int vertexPointData,
        int vertexNumber, int first, int stride, FloatBuffer vertices, ByteBuffer indices) {
    // point to and draw vertex array
    GL11.glVertexPointer(vertexPointData, stride, vertices);
    GL11.glDrawElements(beginMode, vertexNumber, dataType, indices);
}

From source file:org.ajgl.graphics.VertexBufferedObject.java

License:Open Source License

/**
 * Draws a vertex buffered object; Uses redundant vertices. You need to enable 
 * {@link org.lwjgl.opengl.GL11#GL_VERTEX_ARRAY GL_VERTEX_ARRAY} before 
 * you can use this method.//from w  w w. ja  v a2s .  co  m
 * @param vertexHandler - The vertex buffered object vertex handler
 * @param vertexPointData - The number of points per vertex data (i.e. 1-1D, 2-2D, 3-3D)
 * @param vertexNumber - The number of vertices
 * @param stride - The stride offset; used for interleaving data
 * @param offSet - initial offset for the data
 * @param dataType - The OpenGL dataType
 * @param beginMode - The OpenGL begin mode
 */
public static void drawVboElements(int vertexHandler, int vertexPointData, int vertexNumber, int stride,
        int offSet, @GLDataType int dataType, @BeginMode int beginMode) {
    // bind vertex data
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertexHandler);
    GL11.glVertexPointer(vertexPointData, dataType, stride, offSet);
    // Draw vertex buffer object
    GL11.glDrawElements(beginMode, vertexNumber, dataType, offSet);
}

From source file:org.jtrfp.mtmx.draw.TerrainDrawer.java

License:Open Source License

private void drawTextured() {
    int[] sizes = vboUtil.getSizes();
    int len = sizes.length;
    long offset = 0;

    String[] textureNames = world.getTexData().getTextureNames();
    ITextureManager textureManager = engine.getResourceManager().getTextureManager();

    for (int i = 0; i < len; i++) {
        int size = sizes[i];
        if (size > 0) {

            String name = textureNames[i];
            ITexture texture = textureManager.get(name);
            texture.bind();/*from ww  w  .java  2s  .  com*/

            GL11.glDrawElements(renderMode, size, GL11.GL_UNSIGNED_INT, offset * (Integer.SIZE / 8));

            offset += size;
        }
    }
}