Example usage for org.lwjgl.opengl GL11 glDrawArrays

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

Introduction

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

Prototype

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

Source Link

Document

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

Usage

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

public static void glhDrawArrays(int dst, int begin, int vertex_count) {
    GL11.glDrawArrays(dst, begin, vertex_count);
    theContext.incrementDrawCalls();//  w  w w  . j  ava 2  s .c om
    theContext.increaseVerticesDrawn(vertex_count);
}

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

public static void glhDrawArrays(int dst, int begin, int vertex_count) {
    GL11.glDrawArrays(dst, begin, vertex_count);
    _context.incrementDrawCalls();/*from  w ww.  j  a  v a2s.co  m*/
    _context.increaseVerticesDrawn(vertex_count);
}

From source file:com.kauridev.lunarfever.graphics.SpriteBatch.java

License:Open Source License

private void render() {
    if (lastTexture != null) {
        lastTexture.bind();
    }

    data.bind();
    GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, index / 8);
    data.unbind();
}

From source file:com.opengrave.og.base.Renderable2D.java

License:Open Source License

@Override
public void renderForPicking(Matrix4f matrix, Pickable object) {
    dealWithChange();/*from w  ww. j a  va 2  s.c om*/
    if (vertexList.size() == 0) {
        return;
    }
    int pID = Resources.loadShader("pickinggui.vs", "pickinggui.fs").getProgram();
    GL20.glUseProgram(pID);
    GL30.glBindVertexArray(vaoID);
    GL20.glEnableVertexAttribArray(0);
    Util.setMatrices(pID, location2d);
    Picking.registerObject(pID, getContext(), object);
    GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, vertexList.size());
    GL20.glDisableVertexAttribArray(0);
    GL30.glBindVertexArray(0);
    GL20.glUseProgram(0);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    GL30.glBindVertexArray(0);
}

From source file:com.opengrave.og.base.Renderable2D.java

License:Open Source License

@Override
public void render(Matrix4f matrix, RenderStyle style) {
    Util.checkErr();//from w w  w.j  ava 2  s.c  o m
    dealWithChange();
    Util.checkErr();
    if (vertexList.size() == 0) {
        return;
    }
    int pID = Resources.loadShader("gui.vs", "gui.fs").getProgram();
    GL20.glUseProgram(pID);
    GL30.glBindVertexArray(vaoID);
    GL20.glEnableVertexAttribArray(0);
    GL20.glEnableVertexAttribArray(1);
    GL20.glEnableVertexAttribArray(2);
    Util.checkErr();
    if (texture != null) {
        texture.bind(GL13.GL_TEXTURE0);
    }
    Util.setMatrices(pID, location2d);
    Util.checkErr();

    GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, vertexList.size());
    Util.checkErr();
    if (texture != null) {
        texture.unbind();
    }
    GL20.glDisableVertexAttribArray(0);
    GL20.glDisableVertexAttribArray(1);
    GL20.glDisableVertexAttribArray(2);
    Util.checkErr();

    GL30.glBindVertexArray(0);
    GL20.glUseProgram(0);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    GL30.glBindVertexArray(0);
    Util.checkErr();
}

From source file:com.opengrave.og.base.RenderableLines.java

License:Open Source License

@Override
public void render(Matrix4f matrix, RenderStyle style) {
    dealWithChange();//  w w w.j  a v a  2  s .c  o m
    if (!visible) {
        return;
    }
    if (vertCount == 0) {
        return;
    }
    GL11.glPointSize(3f);

    int pID = Resources.loadShader("lines.vs", "lines.fs").getProgram();
    GL20.glUseProgram(pID);
    if (pID == 0) {
        return;
    }
    GL30.glBindVertexArray(vaoID);
    GL20.glEnableVertexAttribArray(0);
    GL20.glEnableVertexAttribArray(1);

    Util.checkErr();

    getContext().setMatrices(pID, matrix);
    Util.checkErr();
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDrawArrays(GL11.GL_LINES, 0, vertCount);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    Util.checkErr();
    GL20.glDisableVertexAttribArray(1);
    GL20.glDisableVertexAttribArray(0);
    Util.checkErr();

    GL30.glBindVertexArray(0);
    GL20.glUseProgram(0);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    GL30.glBindVertexArray(0);
    Util.checkErr();

}

From source file:com.opengrave.og.base.RenderableLiquid.java

License:Open Source License

@Override
public void render(Matrix4f matrix, RenderStyle style) {
    dealWithChange();/*w ww . j  a v a2s  .c o m*/
    if (vertexList.size() == 0) {
        return;
    }
    int pID = Resources.loadShader("liquid.vs", "liquid.fs").getProgram();
    GL20.glUseProgram(pID);
    int atlas = GL20.glGetUniformLocation(pID, "arraytexture");
    int normals = GL20.glGetUniformLocation(pID, "arraytexturedata");
    int colours = GL20.glGetUniformLocation(pID, "colours");
    int flows = GL20.glGetUniformLocation(pID, "flows");
    int shadow = GL20.glGetUniformLocation(pID, "shadowMap");

    GL20.glUniform1i(atlas, 0);
    GL20.glUniform1i(normals, 1);
    GL20.glUniform1i(colours, 2);
    GL20.glUniform1i(flows, 3);
    GL20.glUniform1i(shadow, 4);
    GL30.glBindVertexArray(vaoID);

    GL20.glEnableVertexAttribArray(0);
    GL20.glEnableVertexAttribArray(1);
    GL20.glEnableVertexAttribArray(2);

    getContext().setMatrices(pID, matrix);
    textureAtlas.bind(GL13.GL_TEXTURE0);
    normalAtlas.bind(GL13.GL_TEXTURE1);
    getColourTexture().bind(GL13.GL_TEXTURE2);
    getFlowTexture().bind(GL13.GL_TEXTURE3);

    getContext().bindShadowData(GL13.GL_TEXTURE4);
    getContext().bindLights(pID, GL13.GL_TEXTURE5);
    Util.setRenderStyle(pID, style);
    GL11.glDepthMask(false);
    GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, vertexList.size());
    GL11.glDepthMask(true);
    getContext().unbindLights();
    getContext().unbindShadowData();

    textureAtlas.unbind();
    getFlowTexture().unbind();
    getColourTexture().unbind();
    GL20.glDisableVertexAttribArray(0);
    GL20.glDisableVertexAttribArray(1);
    GL20.glDisableVertexAttribArray(2);

    GL30.glBindVertexArray(0);

    GL20.glUseProgram(0);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    GL30.glBindVertexArray(0);
}

From source file:com.opengrave.og.base.RenderableMultitex.java

License:Open Source License

@Override
public void renderShadows(Matrix4f matrix, Shadow shadow) {
    dealWithChange();//from w  w w .  j av  a  2 s .com
    if (vertexList.size() == 0) {
        return;
    }
    int pID = Resources.loadShader("terrainshadow.vs", "castshadow.fs").getProgram();
    GL20.glUseProgram(pID);
    GL30.glBindVertexArray(vaoID);

    GL20.glEnableVertexAttribArray(0);
    getContext().setShadowMatrices(pID, matrix, shadow);
    GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, vertexList.size());
    // System.out.println(getClass().getName()+" : "+vertexList.size()+" rendered");
    GL20.glDisableVertexAttribArray(0);
    GL30.glBindVertexArray(0);
    GL20.glUseProgram(0);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    GL30.glBindVertexArray(0);
}

From source file:com.opengrave.og.base.RenderableMultitex.java

License:Open Source License

@Override
public void render(Matrix4f matrix, RenderStyle style) {
    dealWithChange();// ww  w  . j  a  v a2s. c  om
    if (vertexList.size() == 0) {
        return;
    }
    // GL11.glBindTexture(GL11.GL_TEXTURE_2D,
    // Resources.loadTexture("tex/blank.png").id);
    int pID = Resources.loadShader("terrain.vs", "terrain.fs").getProgram();
    GL20.glUseProgram(pID);
    int atlas = GL20.glGetUniformLocation(pID, "arraytexture");
    int colours = GL20.glGetUniformLocation(pID, "colours");
    int shadow = GL20.glGetUniformLocation(pID, "shadowMap");
    int normals = GL20.glGetUniformLocation(pID, "arraytexturedata");
    GL20.glUniform1i(atlas, 0);
    GL20.glUniform1i(colours, 1);
    GL20.glUniform1i(normals, 2);
    GL20.glUniform1i(shadow, 3);
    GL30.glBindVertexArray(vaoID);

    GL20.glEnableVertexAttribArray(0);
    GL20.glEnableVertexAttribArray(1);
    GL20.glEnableVertexAttribArray(2);
    GL20.glEnableVertexAttribArray(3);
    GL20.glBindAttribLocation(pID, 0, "in_Position");
    GL20.glBindAttribLocation(pID, 1, "in_TextureCoord");
    GL20.glBindAttribLocation(pID, 2, "in_TexIndex");
    GL20.glBindAttribLocation(pID, 3, "in_Normal");

    getContext().setMatrices(pID, matrix);
    GL20.glUniform1i(GL20.glGetUniformLocation(pID, "hidden"), hidden);
    textureAtlas.bind(GL13.GL_TEXTURE0);
    getColourTexture().bind(GL13.GL_TEXTURE1);
    normalAtlas.bind(GL13.GL_TEXTURE2);
    getContext().bindShadowData(GL13.GL_TEXTURE3);
    getContext().bindLights(pID, GL13.GL_TEXTURE4);
    Util.setRenderStyle(pID, style);
    GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, vertexList.size());
    getContext().unbindLights();
    getContext().unbindShadowData();

    textureAtlas.unbind();
    // HGMainThread.shadowMap.unbind();

    getColourTexture().unbind();
    // System.out.println(getClass().getName()+" : "+vertexList.size()+" rendered");
    GL20.glDisableVertexAttribArray(0);
    GL20.glDisableVertexAttribArray(1);
    GL20.glDisableVertexAttribArray(2);
    GL20.glDisableVertexAttribArray(3);
    GL30.glBindVertexArray(0);
    GL20.glUseProgram(0);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    GL30.glBindVertexArray(0);
}

From source file:com.opengrave.og.base.RenderableMultitex.java

License:Open Source License

@Override
public void renderForPicking(Matrix4f matrix, Pickable object) {
    dealWithChange();/*from   w ww  . j  a  va2s  . com*/
    if (vertexList.size() == 0) {
        return;
    }
    int pID = Resources.loadShader("terrainshadow.vs", "pickingmodel.fs").getProgram();
    GL20.glUseProgram(pID);
    GL30.glBindVertexArray(vaoID);
    GL20.glEnableVertexAttribArray(0);
    getContext().setMatrices(pID, matrix);
    Picking.registerObject(pID, getContext(), object);
    GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, vertexList.size());
    GL20.glDisableVertexAttribArray(0);
    GL30.glBindVertexArray(0);
    GL20.glUseProgram(0);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    GL30.glBindVertexArray(0);
}