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:playn.java.JavaGL20.java

License:Apache License

@Override
public void glDrawArrays(int mode, int first, int count) {
    GL11.glDrawArrays(mode, first, count);
}

From source file:processing.opengl.PLWJGL.java

License:Open Source License

@Override
public void drawArrays(int mode, int first, int count) {
    GL11.glDrawArrays(mode, first, count);
}

From source file:src.graphics.common.MeshBuffer.java

License:Open Source License

public static void render(float scale, float rotation, Vec3D offset, FloatBuffer vertBuffer,
        FloatBuffer normBuffer, FloatBuffer textBuffer, int numFacets) {
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();//w ww .ja va 2s.  c  om
    if (numFacets < 1)
        numFacets = vertBuffer.capacity() / VFP;
    if (offset != null)
        GL11.glTranslatef(offset.x, offset.y, offset.z);
    else
        GL11.glTranslatef(0, 0, 0);
    GL11.glRotatef(rotation, 0, 0, 1);
    GL11.glScalef(scale, scale, scale);
    //
    //  Only set the texture buffer if one has been provided:
    if (textBuffer == null) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
    } else {
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
        GL11.glTexCoordPointer(2, 0, textBuffer);
    }
    //
    //  And only set the normal buffer if one has been provided:
    if (normBuffer == null)
        GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY);
    else {
        GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);
        GL11.glNormalPointer(0, normBuffer);
    }
    //
    //  Bind the vertex buffer and render-
    GL11.glVertexPointer(3, 0, vertBuffer);
    GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, numFacets * 3);
}

From source file:taiga.gpvm.render.ColorTileRenderer.java

License:Open Source License

@Override
public void render(int pass, ReadableMatrix4 proj, ReadableMatrix4 modelview) {
    if (verts == null || color == null || pass != HardcodedValues.OPAQUE_WORLD_LAYER)
        return;/*from   w ww  . j av  a2 s  .c  o m*/

    simplecolor.bind();

    simplecolor.setUniformMatrix(projloc, proj);
    simplecolor.setUniformMatrix(mvloc, modelview);

    GL11.glPushClientAttrib(GL11.GL_VERTEX_ARRAY | GL11.GL_COLOR_ARRAY);

    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);

    GL11.glEnable(GL11.GL_DEPTH_TEST);

    //There are 3 elements to each vertex
    //stride is zero the vertices are tightly packed.
    GL11.glVertexPointer(3, 0, verts);

    //4 elements in each color: alpha, red, green, and blue
    GL11.glColorPointer(4, true, 0, color);

    GL11.glDrawArrays(GL11.GL_QUADS, 0, verts.limit() / 3);

    GL11.glPopClientAttrib();
}

From source file:tectonicus.rasteriser.lwjgl.LwjglMesh.java

License:BSD License

@Override
public void draw(final float xOffset, final float yOffset, final float zOffset) {
    if (vertices == null)
        return;/*  w w  w . ja va2 s. c o m*/

    assert (numVertices > 0);

    //   if (hasDisplayList)
    {
        //      GL11.glCallList(displayList);
    }
    //   else
    {
        //      org.lwjgl.opengl.Util.checkGLError();

        //   displayList = GL11.glGenLists(1);

        //   GL11.glNewList(displayList, GL11.GL_COMPILE);
        {
            GL11.glPushMatrix();
            GL11.glTranslatef(xOffset, yOffset, zOffset);

            GL11.glDrawArrays(GL11.GL_QUADS, 0, numVertices);

            GL11.glPopMatrix();
        }
        //   GL11.glEndList();

        //   GL11.glCallList(displayList);

        //   hasDisplayList = true;

        //   org.lwjgl.opengl.Util.checkGLError();
    }
}

From source file:thebounzer.org.lwgldemo.Chapter3.java

License:Open Source License

@Override
public void loopCycle() {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

    GL20.glUseProgram(program.getId());/*from   w  w w . j  a va 2 s .c o m*/

    vaoId = GL30.glGenVertexArrays();
    GL30.glBindVertexArray(vaoId);
    attributesBind(time += 0.01f);
    GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, 3);
    GL20.glUseProgram(0);
}

From source file:thebounzer.org.lwgldemo.Chapter5.java

License:Open Source License

@Override
public void loopCycle() {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
    float f = (float) (time * Math.PI * 0.1f);
    Matrix4f modelViewM = new Matrix4f();
    Matrix4f mat = new Matrix4f();
    Matrix4f transOne = new Matrix4f();
    Matrix4f transTwo = new Matrix4f();
    Matrix4f rotaOne = new Matrix4f();
    Matrix4f rotaTwo = new Matrix4f();
    Matrix4f.translate(new Vector3f(0.0f, 0.0f, -0.4f), mat, transOne);
    Matrix4f.translate(new Vector3f((float) Math.sin(2.1f * f) * 0.5f, (float) Math.cos(1.7f * f) * 0.5f,
            (float) Math.sin(1.3f * f) * (float) Math.cos(1.5 * f) * 2.0f), mat, transTwo);
    Matrix4f.rotate(time * 45.0f, new Vector3f(0.0f, 1.0f, 0.0f), mat, rotaOne);
    Matrix4f.rotate(time * 81.0f, new Vector3f(1.0f, 0.0f, 0.0f), mat, rotaTwo);
    Matrix4f.mul(modelViewM, transOne, modelViewM);
    Matrix4f.mul(modelViewM, transTwo, modelViewM);
    Matrix4f.mul(modelViewM, rotaOne, modelViewM);
    Matrix4f.mul(modelViewM, rotaTwo, modelViewM);

    GL20.glUseProgram(program.getId());/*from  ww w.j av  a 2  s .  c  o  m*/
    FloatBuffer matrixBuf = BufferUtils.createFloatBuffer(16);
    modelViewM.store(matrixBuf);
    matrixBuf.flip();
    int uniLoc = GL20.glGetUniformLocation(program.getId(), "mv_matrix");
    GL20.glUniformMatrix4(uniLoc, false, matrixBuf);
    int uniProjMatLoc = GL20.glGetUniformLocation(program.getId(), "proj_matrix");
    GL20.glUniformMatrix4(uniProjMatLoc, false, matrixBuf);
    vaoId = GL30.glGenVertexArrays();
    GL30.glBindVertexArray(vaoId);
    GL11.glDrawArrays(GL11.GL_POINTS, 0, 36);
    GL20.glUseProgram(0);
    time += 0.001f;
}

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

License:Open Source License

public static void glDrawArrays(int a, int b, int c) {
    GL11.glDrawArrays(a, b, c);
}

From source file:vertigo.graphics.lwjgl.LWJGL_Renderer.java

License:Open Source License

private void drawShape(Shape obj) {
    // Geometry: VBO and IBO
    if (obj.isDirty(Node.VBO)) {
        processBO(obj);/*from  w  ww. j  a v  a2s . c  o m*/
        obj.setDirty(Node.VBO, false);
    }

    ShaderProg glshader = obj.getMaterial().getShaderMaterial();
    GL20.glUseProgram(glshader.getHandle());

    updateUniform();
    VBO vbo = null;

    for (Attribute attrib : attribute) {
        if (vbo.getType().equals(attrib.getType())) {
            int alocation = GL20.glGetAttribLocation(glshader.getHandle(), attrib.getName());
            GL20.glEnableVertexAttribArray(alocation);
            GL20.glVertexAttribPointer(alocation, attrib.getSize(), GL11.GL_FLOAT, false, vbo.getStride() << 2,
                    0L);
        }
    }

    if (isIndexed) {
        // draw with index
        GL11.glDrawElements(getOpenGLStyle(obj.getDrawingStyle()), /* elements */ ibo.getSize(),
                GL_UNSIGNED_INT, 0L);
        GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
        GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
        GL20.glDisableVertexAttribArray(0);
    } else {
        // draw without index
        GL11.glDrawArrays(getOpenGLStyle(obj.getDrawingStyle()), 0, capacity / vbo3f.getStride());
        GL20.glDisableVertexAttribArray(0);
        GL30.glBindVertexArray(0);
    }

    GL20.glUseProgram(0);
}

From source file:view.renderer.GridRenderer.java

public void draw() {

    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);

    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vID);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vB, GL15.GL_STATIC_DRAW);
    GL11.glVertexPointer(2, GL11.GL_INT, 2 * 4, 0L);

    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, cID);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, cB, GL15.GL_STATIC_DRAW);
    GL11.glColorPointer(3, GL11.GL_FLOAT, 3 * 4, 0L);

    GL11.glDrawArrays(GL11.GL_QUADS, 0, (linesX + linesY) * 4);

    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

    GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);
    GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
}