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:com.jmex.bui.border.LineBorder.java

License:Open Source License

@Override
// from BBorder/*from ww w  .  j  a v a 2s.  c o m*/
public void render(Renderer renderer, int x, int y, int width, int height, float alpha) {
    super.render(renderer, x, y, width, height, alpha);

    BComponent.applyDefaultStates();
    BImage.blendState.apply();

    if (_width > 0) {
        RenderContext ctx = DisplaySystem.getDisplaySystem().getCurrentContext();
        GL11.glColor4f(_color.r, _color.g, _color.b, _color.a * alpha);
        // First draw the bottom line.
        if (_bottom > 0) {
            ((LineRecord) ctx.getLineRecord()).applyLineWidth(_bottom);
            float offset = _bottom / 2f;
            GL11.glBegin(GL11.GL_LINE_STRIP);
            GL11.glVertex2f(x - offset, y);
            GL11.glVertex2f(x + width, y);
            GL11.glEnd();
        }
        // Next draw the right hand side.
        if (_right > 0) {
            ((LineRecord) ctx.getLineRecord()).applyLineWidth(_right);
            float offset = _right / 2f;
            GL11.glBegin(GL11.GL_LINE_STRIP);
            GL11.glVertex2f(x + width - offset, y);
            GL11.glVertex2f(x + width - offset, y + height);
            GL11.glEnd();
        }
        // Next draw the top line.
        if (_top > 0) {
            ((LineRecord) ctx.getLineRecord()).applyLineWidth(_top);
            float offset = _top / 2f;
            GL11.glBegin(GL11.GL_LINE_STRIP);
            GL11.glVertex2f(x + width, y + height - offset);
            GL11.glVertex2f(x - offset, y + height - offset);
            GL11.glEnd();
        }
        // Last draw the left hand side.
        if (_left > 0) {
            ((LineRecord) ctx.getLineRecord()).applyLineWidth(_left);
            GL11.glBegin(GL11.GL_LINE_STRIP);
            GL11.glVertex2f(x, y + height);
            GL11.glVertex2f(x, y);
            GL11.glEnd();
        }
    }
}

From source file:com.jmex.bui.BRootNode.java

License:Open Source License

protected void renderModalShade() {
    BComponent.applyDefaultStates();/* ww  w.j a v a 2 s .  c  o  m*/
    BImage.blendState.apply();

    int width = DisplaySystem.getDisplaySystem().getWidth();
    int height = DisplaySystem.getDisplaySystem().getHeight();

    GL11.glColor4f(_modalShade.r, _modalShade.g, _modalShade.b, _modalShade.a);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2f(0, 0);
    GL11.glVertex2f(width, 0);
    GL11.glVertex2f(width, height);
    GL11.glVertex2f(0, height);
    GL11.glEnd();
}

From source file:com.jmex.bui.BTextField.java

License:Open Source License

@Override
// documentation inherited
protected void renderComponent(Renderer renderer) {
    super.renderComponent(renderer);

    Insets insets = getInsets();/* ww  w. j av  a2s.  c o m*/

    // render our text
    if (_glyphs != null) {
        // clip the text to our visible text region
        boolean scissored = intersectScissorBox(_srect, getAbsoluteX() + insets.left,
                getAbsoluteY() + insets.bottom, _width - insets.getHorizontal(),
                _height - insets.getVertical());
        try {
            _glyphs.render(renderer, insets.left - _txoff, insets.bottom, _alpha);
        } finally {
            restoreScissorState(scissored, _srect);
        }
    }

    // render the cursor if we have focus
    if (_showCursor) {
        int cx = insets.left - _txoff + _cursx;
        BComponent.applyDefaultStates();
        ColorRGBA c = getColor();
        GL11.glColor4f(c.r, c.g, c.b, c.a);
        GL11.glBegin(GL11.GL_LINE_STRIP);
        GL11.glVertex2f(cx, insets.bottom);
        int cheight = getTextFactory().getHeight();
        GL11.glVertex2f(cx, insets.bottom + cheight);
        GL11.glEnd();
    }
}

From source file:com.kodehawa.gui.api.render.ModGuiUtils.java

License:Open Source License

/**
 * Basic quad/* w  ww.  ja v  a 2s  . c o  m*/
 * 
 * @param g
 * @param h
 * @param i
 * @param j
 * @param col1
 */
public static void drawRect(float g, float h, float i, float j, int col1) {
    float f = ((col1 >> 24) & 0xFF) / 255F;
    float f1 = ((col1 >> 16) & 0xFF) / 255F;
    float f2 = ((col1 >> 8) & 0xFF) / 255F;
    float f3 = (col1 & 0xFF) / 255F;

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);

    GL11.glPushMatrix();
    GL11.glColor4f(f1, f2, f3, f);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2d(i, h);
    GL11.glVertex2d(g, h);
    GL11.glVertex2d(g, j);
    GL11.glVertex2d(i, j);
    GL11.glEnd();
    GL11.glPopMatrix();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
}

From source file:com.kodehawa.gui.api.render.ModGuiUtils.java

License:Open Source License

/**
 * Gradient quad//from  w  w w. j av  a2  s  . c om
 * 
 * @param x
 * @param y
 * @param x2
 * @param y2
 * @param col1
 * @param col2
 */
public static void drawGradientRect(int x, int y, int x2, int y2, int col1, int col2) {
    float f = ((col1 >> 24) & 0xFF) / 255F;
    float f1 = ((col1 >> 16) & 0xFF) / 255F;
    float f2 = ((col1 >> 8) & 0xFF) / 255F;
    float f3 = (col1 & 0xFF) / 255F;

    float f4 = ((col2 >> 24) & 0xFF) / 255F;
    float f5 = ((col2 >> 16) & 0xFF) / 255F;
    float f6 = ((col2 >> 8) & 0xFF) / 255F;
    float f7 = (col2 & 0xFF) / 255F;

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glShadeModel(GL11.GL_SMOOTH);

    GL11.glPushMatrix();
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glColor4f(f1, f2, f3, f);
    GL11.glVertex2d(x2, y);
    GL11.glVertex2d(x, y);

    GL11.glColor4f(f5, f6, f7, f4);
    GL11.glVertex2d(x, y2);
    GL11.glVertex2d(x2, y2);
    GL11.glEnd();
    GL11.glPopMatrix();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
    GL11.glShadeModel(GL11.GL_FLAT);
}

From source file:com.kodehawa.gui.api.render.ModGuiUtils.java

License:Open Source License

/**
 * Sideways gradient quad/* w w w.j a  va2 s .c  om*/
 * 
 * @param x
 * @param y
 * @param x2
 * @param y2
 * @param col1
 * @param col2
 */
public static void drawSideGradientRect(float x, float y, float x2, float y2, int col1, int col2) {
    float f = ((col1 >> 24) & 0xFF) / 255F;
    float f1 = ((col1 >> 16) & 0xFF) / 255F;
    float f2 = ((col1 >> 8) & 0xFF) / 255F;
    float f3 = (col1 & 0xFF) / 255F;

    float f4 = ((col2 >> 24) & 0xFF) / 255F;
    float f5 = ((col2 >> 16) & 0xFF) / 255F;
    float f6 = ((col2 >> 8) & 0xFF) / 255F;
    float f7 = (col2 & 0xFF) / 255F;

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glShadeModel(GL11.GL_SMOOTH);

    GL11.glPushMatrix();
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glColor4f(f1, f2, f3, f);
    GL11.glVertex2d(x2, y);

    GL11.glColor4f(f5, f6, f7, f4);
    GL11.glVertex2d(x, y);
    GL11.glVertex2d(x, y2);

    GL11.glColor4f(f1, f2, f3, f);
    GL11.glVertex2d(x2, y2);
    GL11.glEnd();
    GL11.glPopMatrix();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
    GL11.glShadeModel(GL11.GL_FLAT);
}

From source file:com.kodehawa.gui.api.render.ModGuiUtils.java

License:Open Source License

/**
 * Bordered quad/*from w  w w  .  j a  va  2  s. c o m*/
 * 
 * @param x
 * @param y
 * @param x2
 * @param y2
 * @param l1
 * @param col1
 * @param col2
 */
public static void drawBorderedRect(int x, int y, int x2, int y2, float l1, int col1, int col2) {
    drawRect(x, y, x2, y2, col2);

    float f = ((col1 >> 24) & 0xFF) / 255F;
    float f1 = ((col1 >> 16) & 0xFF) / 255F;
    float f2 = ((col1 >> 8) & 0xFF) / 255F;
    float f3 = (col1 & 0xFF) / 255F;

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);

    GL11.glPushMatrix();
    GL11.glColor4f(f1, f2, f3, f);
    GL11.glLineWidth(l1);
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex2d(x, y);
    GL11.glVertex2d(x, y2);
    GL11.glVertex2d(x2, y2);
    GL11.glVertex2d(x2, y);
    GL11.glVertex2d(x, y);
    GL11.glVertex2d(x2, y);
    GL11.glVertex2d(x, y2);
    GL11.glVertex2d(x2, y2);
    GL11.glEnd();
    GL11.glPopMatrix();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
}

From source file:com.kodehawa.gui.api.render.ModGuiUtils.java

License:Open Source License

/**
 * Border of a quad/*from  w ww  .  ja v a  2 s . c o  m*/
 * 
 * @param x
 * @param y
 * @param x2
 * @param y2
 * @param l1
 * @param col1
 */
public static void drawHollowBorderedRect(int x, int y, int x2, int y2, float l1, int col1) {
    float f = ((col1 >> 24) & 0xFF) / 255F;
    float f1 = ((col1 >> 16) & 0xFF) / 255F;
    float f2 = ((col1 >> 8) & 0xFF) / 255F;
    float f3 = (col1 & 0xFF) / 255F;

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);

    GL11.glPushMatrix();
    GL11.glColor4f(f1, f2, f3, f);
    GL11.glLineWidth(l1);
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex2d(x, y);
    GL11.glVertex2d(x, y2);
    GL11.glVertex2d(x2, y2);
    GL11.glVertex2d(x2, y);
    GL11.glVertex2d(x, y);
    GL11.glVertex2d(x2, y);
    GL11.glVertex2d(x, y2);
    GL11.glVertex2d(x2, y2);
    GL11.glEnd();
    GL11.glPopMatrix();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
}

From source file:com.kodehawa.gui.api.render.ModGuiUtils.java

License:Open Source License

/**
 * Gradient rect with a border//w w w. ja v  a 2 s.  co m
 * 
 * @param x
 * @param y
 * @param x2
 * @param y2
 * @param l1
 * @param col1
 * @param col2
 * @param col3
 */
public static void drawGradientBorderedRect(int x, int y, int x2, int y2, float l1, int col1, int col2,
        int col3) {
    drawGradientRect(x, y, x2, y2, col2, col3);

    float f = ((col1 >> 24) & 0xFF) / 255F;
    float f1 = ((col1 >> 16) & 0xFF) / 255F;
    float f2 = ((col1 >> 8) & 0xFF) / 255F;
    float f3 = (col1 & 0xFF) / 255F;

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);

    GL11.glPushMatrix();
    GL11.glColor4f(f1, f2, f3, f);
    GL11.glLineWidth(l1);
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex2d(x, y);
    GL11.glVertex2d(x, y2);
    GL11.glVertex2d(x2, y2);
    GL11.glVertex2d(x2, y);
    GL11.glVertex2d(x, y);
    GL11.glVertex2d(x2, y);
    GL11.glVertex2d(x, y2);
    GL11.glVertex2d(x2, y2);
    GL11.glEnd();
    GL11.glPopMatrix();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
}

From source file:com.kodehawa.gui.api.render.ModGuiUtils.java

License:Open Source License

/**
 * Vertical line//www.  j  a v  a2  s.  com
 * 
 * @param x
 * @param y
 * @param y2
 * @param l1
 * @param col1
 */
public static void drawVerticalLine(int x, int y, int y2, float l1, int col1) {
    float f = ((col1 >> 24) & 0xFF) / 255F;
    float f1 = ((col1 >> 16) & 0xFF) / 255F;
    float f2 = ((col1 >> 8) & 0xFF) / 255F;
    float f3 = (col1 & 0xFF) / 255F;

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);

    GL11.glPushMatrix();
    GL11.glColor4f(f1, f2, f3, f);
    GL11.glLineWidth(l1);
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex2d(x, y);
    GL11.glVertex2d(x, y2);
    GL11.glEnd();
    GL11.glPopMatrix();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
}