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.sriramramani.droid.inspector.ui.InspectorCanvas.java

License:Mozilla Public License

private void drawOverdraw(int level) {
    GL11.glPushAttrib(GL11.GL_STENCIL_BUFFER_BIT);

    GL11.glStencilFunc(level == 5 ? GL11.GL_LEQUAL : GL11.GL_EQUAL, level, 0xf);
    GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP);

    GL11.glTranslatef(mNode.bounds.x, -mNode.bounds.y, 0.0f);

    if (level == 2) {
        loadColor(ColorType.OVERDRAW_BLUE);
    } else if (level == 3) {
        loadColor(ColorType.OVERDRAW_GREEN);
    } else if (level == 4) {
        loadColor(ColorType.OVERDRAW_RED_LOW);
    } else if (level > 4) {
        loadColor(ColorType.OVERDRAW_RED_HIGH);
    }//from  ww  w.  jav a2  s . c o  m

    GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex3f(0.0f, 0.0f, 0.0f);
    GL11.glVertex3f(mNode.bounds.width, 0.0f, 0.0f);
    GL11.glVertex3f(mNode.bounds.width, -mNode.bounds.height, 0.0f);
    GL11.glVertex3f(0.0f, -mNode.bounds.height, 0.0f);
    GL11.glEnd();

    GL11.glPopAttrib();
}

From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java

License:Mozilla Public License

private void drawImage(Node node, int textureId, boolean isBackground) {
    GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
    loadColor(ColorType.COLOR_WHITE);

    GL11.glEnable(GL11.GL_TEXTURE_2D);//from  w ww.  ja v a2  s  .  c o  m
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex3f(0.0f, 0.0f, 0.0f);
    GL11.glTexCoord2f(1.0f, 0.0f);
    GL11.glVertex3f(node.bounds.width, 0.0f, 0.0f);
    GL11.glTexCoord2f(1.0f, 1.0f);
    GL11.glVertex3f(node.bounds.width, -node.bounds.height, 0.0f);
    GL11.glTexCoord2f(0.0f, 1.0f);
    GL11.glVertex3f(0.0f, -node.bounds.height, 0.0f);
    GL11.glEnd();
    GL11.glDisable(GL11.GL_TEXTURE_2D);
}

From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java

License:Mozilla Public License

private void drawDepth(Node node, float depth, int mode) {
    GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, mode);
    GL11.glBegin(mode == GL11.GL_FILL ? GL11.GL_QUAD_STRIP : GL11.GL_LINES);

    // Top-left./*w  w  w.  j  av a2 s .  c o m*/
    GL11.glVertex3f(0.0f, 0.0f, 0.0f);
    GL11.glVertex3f(0.0f, 0.0f, depth);

    // Top-right.
    GL11.glVertex3f(node.bounds.width, 0.0f, 0.0f);
    GL11.glVertex3f(node.bounds.width, 0.0f, depth);

    // Bottom-right.
    GL11.glVertex3f(node.bounds.width, -node.bounds.height, 0.0f);
    GL11.glVertex3f(node.bounds.width, -node.bounds.height, depth);

    // Bottom-left.
    GL11.glVertex3f(0.0f, -node.bounds.height, 0.0f);
    GL11.glVertex3f(0.0f, -node.bounds.height, depth);

    // Complete the quad strip.
    if (mode == GL11.GL_FILL) {
        // Top-left.
        GL11.glVertex3f(0.0f, 0.0f, 0.0f);
        GL11.glVertex3f(0.0f, 0.0f, depth);
    }

    GL11.glEnd();
}

From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java

License:Mozilla Public License

private void drawFrontFace(Node node, float depth, int mode) {
    GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, mode);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex3f(0.0f, 0.0f, depth);/*from   w w w. ja v  a 2s .  c  om*/
    GL11.glVertex3f(node.bounds.width, 0.0f, depth);
    GL11.glVertex3f(node.bounds.width, -node.bounds.height, depth);
    GL11.glVertex3f(0.0f, -node.bounds.height, depth);
    GL11.glEnd();
}

From source file:com.teambr.bookshelf.client.gui.component.control.GuiComponentSideSelector.java

License:Creative Commons License

/**
 * Draws the highlights onto the block//from www  .java  2  s  . co m
 * @param selections The colors to render
 */
private void drawHighlights(List<Pair<SidePicker.Side, Color>> selections) {
    GlStateManager.disableLighting();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.enableBlend();
    GlStateManager.enableAlpha();
    GlStateManager.disableDepth();
    GlStateManager.disableTexture2D();

    GL11.glBegin(GL11.GL_QUADS);
    for (Pair<SidePicker.Side, Color> pair : selections) {
        if (pair.getRight() != null)
            RenderUtils.setColor(pair.getRight());

        switch (pair.getLeft()) {
        case XPos:
            GL11.glVertex3d(0.5, -0.5, -0.5);
            GL11.glVertex3d(0.5, 0.5, -0.5);
            GL11.glVertex3d(0.5, 0.5, 0.5);
            GL11.glVertex3d(0.5, -0.5, 0.5);
            break;
        case YPos:
            GL11.glVertex3d(-0.5, 0.5, -0.5);
            GL11.glVertex3d(-0.5, 0.5, 0.5);
            GL11.glVertex3d(0.5, 0.5, 0.5);
            GL11.glVertex3d(0.5, 0.5, -0.5);
            break;
        case ZPos:
            GL11.glVertex3d(-0.5, -0.5, 0.5);
            GL11.glVertex3d(0.5, -0.5, 0.5);
            GL11.glVertex3d(0.5, 0.5, 0.5);
            GL11.glVertex3d(-0.5, 0.5, 0.5);
            break;
        case XNeg:
            GL11.glVertex3d(-0.5, -0.5, -0.5);
            GL11.glVertex3d(-0.5, -0.5, 0.5);
            GL11.glVertex3d(-0.5, 0.5, 0.5);
            GL11.glVertex3d(-0.5, 0.5, -0.5);
            break;
        case YNeg:
            GL11.glVertex3d(-0.5, -0.5, -0.5);
            GL11.glVertex3d(0.5, -0.5, -0.5);
            GL11.glVertex3d(0.5, -0.5, 0.5);
            GL11.glVertex3d(-0.5, -0.5, 0.5);
            break;
        case ZNeg:
            GL11.glVertex3d(-0.5, -0.5, -0.5);
            GL11.glVertex3d(-0.5, 0.5, -0.5);
            GL11.glVertex3d(0.5, 0.5, -0.5);
            GL11.glVertex3d(0.5, -0.5, -0.5);
            break;
        default:
        }
    }

    GL11.glEnd();

    GlStateManager.disableBlend();
    GlStateManager.enableDepth();
    GlStateManager.enableTexture2D();
}

From source file:com.teambr.bookshelf.client.gui.component.display.GuiComponentColoredZone.java

License:Creative Commons License

/**
 * Called to render the component/*from ww  w.j  a v  a  2s.com*/
 */
@Override
public void render(int guiLeft, int guiTop, int mouseX, int mouseY) {
    color = getDynamicColor();
    GlStateManager.pushMatrix();
    GlStateManager.disableLighting();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.enableBlend();
    GlStateManager.enableAlpha();
    GlStateManager.disableDepth();
    GlStateManager.disableTexture2D();
    GlStateManager.translate(xPos, yPos, 10);
    RenderUtils.setColor(color);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex3d(0, 0, 0);
    GL11.glVertex3d(0, height, 0);
    GL11.glVertex3d(width, height, 0);
    GL11.glVertex3d(width, 0, 0);
    GL11.glEnd();
    GlStateManager.disableBlend();
    GlStateManager.enableDepth();
    GlStateManager.enableTexture2D();
    GlStateManager.popMatrix();
}

From source file:com.teambrmodding.luxetumbra.client.gui.GuiToggleMenu.java

License:Creative Commons License

@Override
public void drawScreen(int mx, int my, float partialTicks) {
    super.drawScreen(mx, my, partialTicks);

    GlStateManager.pushMatrix();/*ww w.j ava  2 s  .  c  o  m*/
    GlStateManager.disableTexture2D();

    final int x = width / 2;
    final int y = height / 2;
    final int maxRadius = 60;

    final boolean mouseIn = true;
    final float angle = mouseAngle(x, y, mx, my);
    final float distance = mouseDistance(x, y, mx, my);

    final int highlight = 5;

    GlStateManager.enableBlend();
    GlStateManager.shadeModel(GL11.GL_SMOOTH);
    final int segments = 2; //TODO
    float totalDeg = 0F;
    final float degPer = 360F / segments;

    final List<int[]> stringPosition = new ArrayList<>();

    boolean wasSelected = false;

    for (int seg = 0; seg <= segments; seg++) {
        boolean mouseOverSection = distance <= maxRadius
                && (mouseIn && angle > totalDeg && angle < totalDeg + degPer);
        float radius = Math.max(0F, Math.min(timeIn * 10F, maxRadius));

        GL11.glBegin(GL11.GL_TRIANGLE_FAN);
        float gs = 0.25F;
        if (seg % 2 == 0)
            gs += 0.1F;
        float r = 200; //TODO
        float g = 200; //TODO
        float b = gs;
        float a = 0.4F;
        if (mouseOverSection) {
            selected = seg;
            wasSelected = true;
            r = 255; //TODO
            g = 255; //TODO
            a = 0.5F;
        }
        GlStateManager.color(r, g, b, a);
        GL11.glVertex2i(x, y);
        float i = degPer;
        while (i >= 0) {
            double rad = ((i + totalDeg) / 180F * Math.PI);
            double xp = x + Math.cos(rad) * radius;
            double yp = y + Math.sin(rad) * radius;
            if (i == (int) (degPer / 2))
                stringPosition.add(new int[] { seg, (int) xp, (int) yp, mouseOverSection ? 'n' : 'r' });
            GL11.glVertex2d(xp, yp);
            i -= 1;
        }
        totalDeg += degPer;

        GL11.glVertex2i(x, y);
        GL11.glEnd();

        if (mouseOverSection)
            radius -= highlight;
    }

    if (!wasSelected)
        selected = -1;

    GlStateManager.shadeModel(GL11.GL_FLAT);
    GlStateManager.enableTexture2D();

    for (int[] pos : stringPosition) {
        int slot = pos[0];
        float xp = pos[1];
        float yp = pos[2];
        char c = (char) pos[3];

        ItemStack displayStack = new ItemStack(Items.APPLE);
        if (displayStack != null) {
            float xsp = xp - 4;
            float ysp = yp;
            String name = "\u00a7" + c + "testing";
            int width = fontRendererObj.getStringWidth(name);

            float mod = 0.6F;
            int xdp = (int) ((xp - x) * mod + x);
            int ydp = (int) ((yp - y) * mod + y);

            RenderHelper.enableGUIStandardItemLighting();
            GlStateManager.pushMatrix();
            GlStateManager.translate(xdp - 10, ydp - 10, 2);
            GlStateManager.scale(1.25, 1.25, 1.25);
            Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(displayStack, 0, 0);
            GlStateManager.popMatrix();
            RenderHelper.disableStandardItemLighting();

            if (xsp < x)
                xsp -= width - 8;
            if (ysp < y)
                ysp -= 9;

            fontRendererObj.drawStringWithShadow(name, xsp, ysp, 0xFFFFFF);
        }
    }

    GlStateManager.popMatrix();
}

From source file:com.telinc1.rpjg.module.Module.java

License:Apache License

/**
 * Renders the module's graphics and UI elements.
 * Also applied the screen darkening effect for modal modules.<br />
 * Generally not a good idea to override this.
 *///from  ww  w.ja v  a2  s .co  m
public void render() {
    if (this.isModal()) {
        DrawingUtils.unbindTextures();

        // Not going to change this to use DrawingUtils until
        // I don't make actual modal modules.
        // Don't want untested code!
        GL11.glPushAttrib(DrawingUtils.GL_COLOR_BITS);
        GL11.glColor4f(0f, 0f, 0f, .5f);
        GL11.glBegin(GL11.GL_QUADS);
        GL11.glVertex2i(0, 0);
        GL11.glVertex2i(Display.getWidth(), 0);
        GL11.glVertex2i(Display.getWidth(), Display.getHeight());
        GL11.glVertex2i(0, Display.getHeight());
        GL11.glEnd();
        GL11.glPopAttrib();
    }

    this.renderGraphics();
    this.renderUI();

    for (Gui gui : this.getGUIs()) {
        gui.render();
    }
}

From source file:com.telinc1.rpjg.util.DrawingUtils.java

License:Apache License

/**
 * Begins to draw in a certain mode./*from  w  w w  . j  a  v  a  2s .  com*/
 * 
 * @param mode - The mode to draw in.
 */
public static void startDrawing(int mode) {
    if (DrawingUtils.drawMode == -1) {
        DrawingUtils.drawMode = mode;
        GL11.glBegin(mode);
    }
}

From source file:com.timvisee.voxeltex.architecture.component.drawable.line.AxisDrawComponent.java

License:Open Source License

@Override
public synchronized void onDraw() {
    // Set the thickness of the axis drawn
    GL11.glLineWidth(this.lineWidth);

    // Enable line drawing mode
    GL11.glBegin(GL11.GL_LINES);

    // Green for X
    GL11.glColor3f(1.0f, 0.0f, 0.0f);//w w w.ja  v a  2 s. co m
    GL11.glVertex3f(0.0f, 0.0f, 0.0f);
    GL11.glVertex3f(1.0f, 0.0f, 0.0f);

    // Green for Y
    GL11.glColor3f(0.0f, 1.0f, 0.0f);
    GL11.glVertex3f(0.0f, 0.0f, 0.0f);
    GL11.glVertex3f(0.0f, 1.0f, 0.0f);

    // Green for Z
    GL11.glColor3f(0.0f, 0.0f, 1.0f);
    GL11.glVertex3f(0.0f, 0.0f, 0.0f);
    GL11.glVertex3f(0.0f, 0.0f, 1.0f);

    // Finish drawing
    GL11.glEnd();
}