Example usage for org.lwjgl.opengl GL11 GL_VERTEX_ARRAY

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

Introduction

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

Prototype

int GL_VERTEX_ARRAY

To view the source code for org.lwjgl.opengl GL11 GL_VERTEX_ARRAY.

Click Source Link

Document

vertex_array

Usage

From source file:taiga.code.opengl.NinePatch.java

License:Open Source License

/**
 * Draws this {@link NinePatch} in the given rectangle.  The {@link NinePatch}
 * will expand to fill the entire area, but the behavior for a rectangle smaller
 * than the {@link NinePatch} is undefined.
 * /*from ww w  . jav a  2 s .com*/
 * @param x The x coordinate to begin drawing at.
 * @param y The y coordinate to begin drawing at.
 * @param w The width of the drawing area.
 * @param h The height of the drawing area.
 */
public void draw(int x, int y, int w, int h) {
    if (texture == null)
        return;

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

    texture.bind();

    setCoords(x, y, w, h);

    GL11.glVertexPointer(2, 0, coordinates);
    GL11.glTexCoordPointer(2, 0, texcoords);

    GL11.glDrawElements(GL11.GL_QUADS, indices);
}

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   ww w . ja v  a2 s.  c om*/

    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 bind() {
    if (vertices == null)
        return;/*from   www .  j av a 2 s.  co m*/

    assert (isFinalised);
    assert (numVertices > 0);

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

    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glVertexPointer(3, 0, vertices);

    GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
    GL11.glColorPointer(4, true, 0, colours);

    GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
    GL11.glTexCoordPointer(2, 0, texCoords);

    if (texture != null) {
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getId());
    } else {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
    }

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

From source file:vazkii.botania.client.render.world.SkyblockSkyRenderer.java

License:Open Source License

private void drawVboOrList(net.minecraft.client.renderer.vertex.VertexBuffer vbo, int displayList) {
    if (OpenGlHelper.useVbo()) {
        vbo.bindBuffer();/*from   w  w  w  . ja  v  a  2s.  co  m*/
        GlStateManager.glEnableClientState(GL11.GL_VERTEX_ARRAY);
        GlStateManager.glVertexPointer(3, GL11.GL_FLOAT, 12, 0);
        vbo.drawArrays(GL11.GL_QUADS);
        vbo.unbindBuffer();
        GlStateManager.glDisableClientState(GL11.GL_VERTEX_ARRAY);
    } else {
        GlStateManager.callList(displayList);
    }
}

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);// w w  w.j a va  2 s.  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:vertigo.graphics.lwjgl.LWJGL_Renderer.java

License:Open Source License

/**
 * Enable the good type of VBO//from w w  w . j  a v a2  s .c  o  m
 *
 * @param vbo
 */
private void enable(VBO vbo) {
    if (vbo.getType().contains("V")) {
        vbo3f = vbo;
        capacity = vbo.capacity();
        GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    }
    if (vbo.getType().contains("C")) {
        GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
    }
}

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);
}

From source file:voxicity.Voxicity.java

License:Open Source License

static void init(Arguments args) {
    // Load the specified config file
    Config config = new Config(args.get_value("config", "voxicity.properties"));

    String mode = args.get_value("mode", "client");

    if (mode.equals("server")) {
        // Start the server, it spawns its own thread
        // and takes over from here
        new Server(config).run();
    } else if (mode.equals("client")) {
        try {//from  w w  w.  j av a  2  s .c om
            System.out.println("Intializing display");
            Display.setDisplayMode(new DisplayMode(1200, 720));
            Display.create();
            Display.setTitle("Voxicity");
            System.out.println("Display created");
        } catch (LWJGLException e) {
            System.out.println("Unable to open Display");
            e.printStackTrace();
            System.exit(1);
        }

        System.out.println("Setting up OpenGL states");
        GL11.glShadeModel(GL11.GL_SMOOTH);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glClearColor(126.0f / 255.0f, 169.0f / 255.0f, 254.0f / 255.0f, 1.0f);
        GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
        GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

        System.out.println("Number of texture units: " + GL11.glGetInteger(GL13.GL_MAX_TEXTURE_UNITS));
        System.out.println(
                "Number of image texture units: " + GL11.glGetInteger(GL20.GL_MAX_TEXTURE_IMAGE_UNITS));
        System.out.println(
                "Number of vertex texture units: " + GL11.glGetInteger(GL20.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS));
        System.out.println("Number of combined vertex/image texture units: "
                + GL11.glGetInteger(GL20.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS));

        try {
            LWJGLRenderer gui_renderer = new LWJGLRenderer();
            LoginGUI login_gui = new LoginGUI();
            ThemeManager theme = ThemeManager.createThemeManager(Voxicity.class.getResource("/login.xml"),
                    gui_renderer);
            GUI gui = new GUI(login_gui, gui_renderer);
            gui.applyTheme(theme);

            while (!login_gui.is_login_pressed()) {
                GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
                gui.update();
                Display.update();

                if (Display.isCloseRequested()) {
                    Display.destroy();
                    System.exit(0);
                }
            }

            Socket client_s = new Socket(login_gui.get_server_name(), 11000);
            Client client = new Client(config, new NetworkConnection(client_s));
            client.run();

            System.out.println("Destroying display");
            Display.destroy();
        }

        // Catch exceptions from the game init and main game-loop

        catch (LWJGLException e) {
            System.out.println(e);
            e.printStackTrace();
            System.exit(1);
        } catch (IOException e) {
            System.out.println(e);
            e.printStackTrace();
            System.exit(1);
        } catch (Exception e) {
            System.out.println(e);
            e.printStackTrace();
        }
    } else {
        System.out.println("Invalid mode: " + mode);
    }
}

From source file:zildo.fwk.gfx.TilePrimitive.java

License:Open Source License

public void render() {

    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);
    GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

    vbo.draw(bufs);//from w  w w . j a va 2s  .  c  o m

    // Le buffer d'indices contient les indices pour 4096 tiles. On doit le limiter au nombre de tiles
    // rellement utilis.
    bufs.indices.limit(nIndices);
    GL11.glDrawElements(GL11.GL_TRIANGLES, bufs.indices);

}

From source file:zildo.platform.opengl.compatibility.VBOSoftware.java

License:Open Source License

protected void preDraw() {
    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
}