Example usage for org.lwjgl.opengl GL11 glBegin

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

Introduction

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

Prototype

public static native void glBegin(@NativeType("GLenum") int mode);

Source Link

Document

Begins the definition of vertex attributes of a sequence of primitives to be transferred to the GL.

Usage

From source file:myfirstgame.Tree.java

public void outline() {
    GL11.glLineWidth((float) 2.5);
    GL11.glColor3f(255, 0, 0);//from   w  ww .  j av a 2  s. c  om
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex2f(treex, treey);
    GL11.glVertex2f(treex, treey + sizeY);
    GL11.glEnd();

    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex2f(treex, treey + sizeY);
    GL11.glVertex2f(treex + sizeX, treey + sizeY);
    GL11.glEnd();

    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex2f(treex + sizeX, treey + sizeY);
    GL11.glVertex2f(treex + sizeX, treey);
    GL11.glEnd();

    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex2f(treex + sizeX, treey);
    GL11.glVertex2f(treex, treey);
    GL11.glEnd();

    GL11.glColor3f(255, 255, 255);

}

From source file:myfirstgame.Tree.java

public void drawTree(Texture tex) {
    outline();/* w w  w .  ja va2s .  co  m*/
    tex.bind();
    GL11.glBegin(GL_QUADS);
    glTexCoord2f(0, 1);
    glVertex2i(treex, treey);
    glTexCoord2f(1, 1);
    glVertex2i(treex + sizeX, treey);
    glTexCoord2f(1, 0);
    glVertex2i(treex + sizeX, treey + sizeY);
    glTexCoord2f(0, 0);
    glVertex2i(treex, treey + sizeY);
    GL11.glEnd();
}

From source file:myfirstgame.Tree.java

public static void drawTree() {

    GL11.glBegin(GL_QUADS);
    glVertex2i(treex, treey);//from  ww w .j  ava 2s  .  c  om
    glVertex2i(treex + sizeX, treey);
    glVertex2i(treex + sizeX, treey + sizeY);
    glVertex2i(treex, treey + sizeY);
    GL11.glEnd();
}

From source file:naftoreiclag.splendidanimator.Application.java

License:MIT License

public void renderGL() {
    GL11.glColor3f(0.5f, 0.5f, 1.0f);/*w  w  w  .j  a v a2s  .c  o  m*/

    GL11.glPushMatrix();

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2f(100 - 50, 100 - 50);
    GL11.glVertex2f(100 + 50, 100 - 50);
    GL11.glVertex2f(100 + 50, 100 + 50);
    GL11.glVertex2f(100 - 50, 100 + 50);
    GL11.glEnd();

}

From source file:name.martingeisse.minimal.simulation.subject.FullySimulatedSubject.java

License:Open Source License

@Override
public void drawCell(final int x, final int y, int pattern) {
    if (pattern < 0 || pattern > 15) {
        pattern = 0;//from w w  w.  ja  v  a2  s .  com
    }
    switch (pattern) {

    case 0:
        GL11.glColor3f(0.0f, 0.0f, 0.0f);
        break;

    case 1:
        GL11.glColor3f(0.0f, 0.0f, 0.5f);
        break;

    case 2:
        GL11.glColor3f(0.0f, 0.5f, 0.0f);
        break;

    case 3:
        GL11.glColor3f(0.0f, 0.5f, 0.5f);
        break;

    case 4:
        GL11.glColor3f(0.5f, 0.0f, 0.0f);
        break;

    case 5:
        GL11.glColor3f(0.5f, 0.0f, 0.5f);
        break;

    case 6:
        GL11.glColor3f(0.5f, 0.5f, 0.0f);
        break;

    case 7:
        GL11.glColor3f(0.75f, 0.75f, 0.75f);
        break;

    case 8:
        GL11.glColor3f(0.5f, 0.5f, 0.5f);
        break;

    case 9:
        GL11.glColor3f(0.0f, 0.0f, 1.0f);
        break;

    case 10:
        GL11.glColor3f(0.0f, 1.0f, 0.0f);
        break;

    case 11:
        GL11.glColor3f(0.0f, 1.0f, 1.0f);
        break;

    case 12:
        GL11.glColor3f(1.0f, 0.0f, 0.0f);
        break;

    case 13:
        GL11.glColor3f(1.0f, 0.0f, 1.0f);
        break;

    case 14:
        GL11.glColor3f(1.0f, 1.0f, 0.0f);
        break;

    case 15:
        GL11.glColor3f(1.0f, 1.0f, 1.0f);
        break;

    }
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2i(x * 20, y * 20);
    GL11.glVertex2i(x * 20 + 20, y * 20);
    GL11.glVertex2i(x * 20 + 20, y * 20 + 20);
    GL11.glVertex2i(x * 20, y * 20 + 20);
    GL11.glEnd();
}

From source file:name.martingeisse.stackd.client.gui.element.FillColor.java

License:Open Source License

@Override
protected void draw() {
    GL11.glDisable(GL11.GL_TEXTURE_2D);/*from   w w w  .  j a  va2s .  co  m*/
    GL11.glEnable(GL11.GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    color.glColor();
    int x = getAbsoluteX(), y = getAbsoluteY(), w = getWidth(), h = getHeight();
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    GL11.glVertex2i(x, y);
    GL11.glVertex2i(x + w, y);
    GL11.glVertex2i(x + w, y + h);
    GL11.glVertex2i(x, y + h);
    GL11.glEnd();
}

From source file:name.martingeisse.stackd.client.gui.element.FillTexture.java

License:Open Source License

@Override
protected void draw() {
    GL11.glEnable(GL11.GL_TEXTURE_2D);// w w  w .j av  a2s . co  m
    GL11.glDisable(GL11.GL_BLEND);
    texture.glBindTexture();
    final int x = getAbsoluteX(), y = getAbsoluteY(), w = getWidth(), h = getHeight();
    final Gui gui = getGui();
    final float effectiveRepetitionLengthX = (repetitionLengthX < 1 ? gui.pixelsToUnitsInt(texture.getWidth())
            : repetitionLengthX);
    final float effectiveRepetitionLengthY = (repetitionLengthY < 1 ? gui.pixelsToUnitsInt(texture.getHeight())
            : repetitionLengthY);
    final float s = (w / effectiveRepetitionLengthX);
    final float t = (h / effectiveRepetitionLengthY);

    GL11.glColor3ub((byte) 255, (byte) 255, (byte) 255);
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex2i(x, y);
    GL11.glTexCoord2f(s, 0.0f);
    GL11.glVertex2i(x + w, y);
    GL11.glTexCoord2f(s, t);
    GL11.glVertex2i(x + w, y + h);
    GL11.glTexCoord2f(0.0f, t);
    GL11.glVertex2i(x, y + h);
    GL11.glEnd();
}

From source file:name.martingeisse.stackd.client.gui.element.PulseFillColor.java

License:Open Source License

@Override
protected void draw() {
    GL11.glDisable(GL11.GL_TEXTURE_2D);//from w  ww  .j  av a2 s.c om
    GL11.glEnable(GL11.GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    color.glColorWithCombinedAlpha(pulseFunction.evaluate(getGui().getTime(), period));
    final int x = getAbsoluteX(), y = getAbsoluteY(), w = getWidth(), h = getHeight();
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    GL11.glVertex2i(x, y);
    GL11.glVertex2i(x + w, y);
    GL11.glVertex2i(x + w, y + h);
    GL11.glVertex2i(x, y + h);
    GL11.glEnd();
}

From source file:name.martingeisse.stackd.client.gui.element.ThickBorder.java

License:Open Source License

@Override
public void handleEvent(GuiEvent event) {
    requireWrappedElement();/*from   w  ww  . j  av a  2s  .c o  m*/
    getWrappedElement().handleEvent(event);
    if (event == GuiEvent.DRAW) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_BLEND);
        color.glColor();
        int sizeDelta = getGui().pixelsToUnitsInt(thickness);
        int borderOffset = sizeDelta / 2;
        int x = getAbsoluteX() + borderOffset;
        int y = getAbsoluteY() + borderOffset;
        int w = getWidth() - sizeDelta;
        int h = getHeight() - sizeDelta;
        GL11.glLineWidth(thickness);
        GL11.glBegin(GL11.GL_LINE_STRIP);
        GL11.glVertex2i(x, y);
        GL11.glVertex2i(x + w, y);
        GL11.glVertex2i(x + w, y + h);
        GL11.glVertex2i(x, y + h);
        GL11.glVertex2i(x, y);
        GL11.glEnd();
    }
}

From source file:name.martingeisse.stackd.client.gui.element.ThinBorder.java

License:Open Source License

@Override
public void handleEvent(GuiEvent event) {
    requireWrappedElement();//from  ww  w. j  a  va2  s  . c  o  m
    getWrappedElement().handleEvent(event);
    if (event == GuiEvent.DRAW) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_BLEND);
        color.glColor();
        int x = getAbsoluteX(), y = getAbsoluteY(), w = getWidth(), h = getHeight();
        GL11.glLineWidth(thickness);
        GL11.glBegin(GL11.GL_LINE_STRIP);
        GL11.glVertex2i(x, y);
        GL11.glVertex2i(x + w, y);
        GL11.glVertex2i(x + w, y + h);
        GL11.glVertex2i(x, y + h);
        GL11.glVertex2i(x, y);
        GL11.glEnd();
    }
}