Example usage for org.lwjgl.opengl GL11 glLineWidth

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

Introduction

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

Prototype

public static void glLineWidth(@NativeType("GLfloat") float width) 

Source Link

Document

Sets the width of rasterized line segments.

Usage

From source file:cn.academy.vanilla.teleporter.client.RenderMarker.java

License:GNU General Public License

protected void renderMark(float width, float height) {
    for (int i = 0; i < 8; ++i) {
        GL11.glPushMatrix();//from  ww  w .  ja  v a  2 s  .  c  om

        boolean rev = i < 4;
        double sx = width * mulArray[i][0], sy = height * mulArray[i][1], sz = width * mulArray[i][2];
        final double len = 0.2 * width;
        GL11.glTranslated(sx, sy, sz);
        GL11.glRotated(rotArray[i], 0, 1, 0);
        GL11.glLineWidth(3f);
        t.startDrawing(GL11.GL_LINES);
        t.setBrightness(15728880);
        t.addVertex(0, 0, 0);
        t.addVertex(0, rev ? len : -len, 0);
        t.addVertex(0, 0, 0);
        t.addVertex(len, 0, 0);
        t.addVertex(0, 0, 0);
        t.addVertex(0, 0, len);
        t.draw();

        GL11.glPopMatrix();
    }
}

From source file:cn.lambdalib.util.client.HudUtils.java

License:MIT License

public static void drawRectOutline(double x, double y, double w, double h, float lineWidth) {
    GL11.glLineWidth(lineWidth);
    Tessellator t = Tessellator.instance;
    GL11.glDisable(GL11.GL_TEXTURE_2D);/*from w w w  . jav a2  s  . c om*/
    t.startDrawing(GL11.GL_LINE_LOOP);
    double lw = lineWidth * 0.2;
    x -= lw;
    y -= lw;
    w += 2 * lw;
    h += 2 * lw;
    t.addVertex(x, y, zLevel);
    t.addVertex(x, y + h, zLevel);
    t.addVertex(x + w, y + h, zLevel);
    t.addVertex(x + w, y, zLevel);
    t.draw();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:cn.liutils.cgui.loader.ui.Window.java

License:Open Source License

protected void drawSplitLine(double y) {
    Tessellator t = Tessellator.instance;
    GuiEdit.bindColor(3);// ww  w  . j  a  v  a2 s.co  m
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glLineWidth(1.5f);
    t.startDrawing(GL11.GL_LINES);
    t.addVertex(0, y, -90);
    t.addVertex(transform.width, y, -90);
    t.draw();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:com.aelitis.azureus.plugins.view3d.ViewTest2.java

License:Open Source License

public static void main(String[] args) {
    final Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    Composite comp = new Composite(shell, SWT.NONE);
    comp.setLayout(new FillLayout());
    GLData data = new GLData();
    data.doubleBuffer = true;//  w w  w.java  2s. c  o  m
    data.accumAlphaSize = 8;
    data.accumBlueSize = 8;
    data.accumGreenSize = 8;
    data.accumRedSize = 8;

    final GLCanvas canvas = new GLCanvas(comp, SWT.NONE, data);

    canvas.setCurrent();
    try {
        GLContext.useContext(canvas);
    } catch (LWJGLException e) {
        e.printStackTrace();
    }

    canvas.addListener(SWT.Resize, new Listener() {
        public void handleEvent(Event event) {
            Rectangle bounds = canvas.getBounds();
            float fAspect = (float) bounds.width / (float) bounds.height;
            canvas.setCurrent();
            try {
                GLContext.useContext(canvas);
            } catch (LWJGLException e) {
                e.printStackTrace();
            }
            GL11.glViewport(0, 0, bounds.width, bounds.height);
            GL11.glMatrixMode(GL11.GL_PROJECTION);
            GL11.glLoadIdentity();
            GLU.gluPerspective(45.0f, fAspect, 0.5f, 400.0f);
            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glLoadIdentity();
        }
    });

    GL11.glLineWidth(1);
    GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    GL11.glColor3f(1.0f, 0.0f, 0.0f);
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
    GL11.glClearDepth(1.0);
    GL11.glLineWidth(2);
    GL11.glEnable(GL11.GL_DEPTH_TEST);

    GL11.glShadeModel(GL11.GL_FLAT);

    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    GL11.glClearAccum(0.0f, 0.0f, 0.0f, 0.0f);

    shell.setText("SWT/LWJGL Example");
    shell.setSize(640, 480);
    shell.open();

    final Runnable run = new Runnable() {
        float rot = 0;

        public void run() {
            if (!canvas.isDisposed()) {
                canvas.setCurrent();
                try {
                    GLContext.useContext(canvas);
                } catch (LWJGLException e) {
                    e.printStackTrace();
                }

                int ACSIZE = 8;

                int[] viewport = getViewport();

                GL11.glClear(GL11.GL_ACCUM_BUFFER_BIT);

                for (int jitter = 0; jitter < ACSIZE; jitter++) {
                    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

                    double jit_x = jits[jitter][0];
                    double jit_y = jits[jitter][1];

                    accPerspective(50.0, (double) viewport[2] / (double) viewport[3], 1.0, 15.0, jit_x, jit_y,
                            0.0, 0.0, 1.0);

                    {

                        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
                        GL11.glClearColor(.3f, .5f, .8f, 1.0f);
                        GL11.glLoadIdentity();
                        GL11.glTranslatef(0.0f, 0.0f, -10.0f);
                        float frot = rot;
                        GL11.glRotatef(0.15f * rot, 2.0f * frot, 10.0f * frot, 1.0f);
                        GL11.glRotatef(0.3f * rot, 3.0f * frot, 1.0f * frot, 1.0f);
                        GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
                        GL11.glColor3f(0.9f, 0.9f, 0.9f);
                        drawCylinder(2, 3, 50, 0);
                        drawTorus(1, 1.9f + ((float) Math.sin((0.004f * frot))), 15, 15);
                    }

                    GL11.glAccum(GL11.GL_ACCUM, 1.0f / ACSIZE);
                }

                GL11.glAccum(GL11.GL_RETURN, 1.0f);
                GL11.glFlush();

                rot += 0.1;

                canvas.swapBuffers();
                display.asyncExec(this);
            }
        }
    };
    canvas.addListener(SWT.Paint, new Listener() {
        public void handleEvent(Event event) {
            run.run();
        }
    });
    display.asyncExec(run);

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:com.ardor3d.renderer.lwjgl.LwjglRenderer.java

License:Open Source License

public void setupLineParameters(final float lineWidth, final int stippleFactor, final short stipplePattern,
        final boolean antialiased) {
    final LineRecord lineRecord = ContextManager.getCurrentContext().getLineRecord();

    if (!lineRecord.isValid() || lineRecord.width != lineWidth) {
        GL11.glLineWidth(lineWidth);
        lineRecord.width = lineWidth;/*from  w  ww .  j  av a2s. c  o  m*/
    }

    if (stipplePattern != (short) 0xFFFF) {
        if (!lineRecord.isValid() || !lineRecord.stippled) {
            GL11.glEnable(GL11.GL_LINE_STIPPLE);
            lineRecord.stippled = true;
        }

        if (!lineRecord.isValid() || stippleFactor != lineRecord.stippleFactor
                || stipplePattern != lineRecord.stipplePattern) {
            GL11.glLineStipple(stippleFactor, stipplePattern);
            lineRecord.stippleFactor = stippleFactor;
            lineRecord.stipplePattern = stipplePattern;
        }
    } else if (!lineRecord.isValid() || lineRecord.stippled) {
        GL11.glDisable(GL11.GL_LINE_STIPPLE);
        lineRecord.stippled = false;
    }

    if (antialiased) {
        if (!lineRecord.isValid() || !lineRecord.smoothed) {
            GL11.glEnable(GL11.GL_LINE_SMOOTH);
            lineRecord.smoothed = true;
        }
        if (!lineRecord.isValid() || lineRecord.smoothHint != GL11.GL_NICEST) {
            GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);
            lineRecord.smoothHint = GL11.GL_NICEST;
        }
    } else if (!lineRecord.isValid() || lineRecord.smoothed) {
        GL11.glDisable(GL11.GL_LINE_SMOOTH);
        lineRecord.smoothed = false;
    }

    if (!lineRecord.isValid()) {
        lineRecord.validate();
    }
}

From source file:com.badlogic.gdx.backends.jglfw.JglfwGL20.java

License:Apache License

public void glLineWidth(float width) {
    GL11.glLineWidth(width);
}

From source file:com.badlogic.gdx.backends.lwjgl.LwjglGL10.java

License:Apache License

public final void glLineWidth(float width) {
    GL11.glLineWidth(width);
}

From source file:com.darkcart.xdolf.util.RenderUtils.java

License:Open Source License

/**
 * Renders a box with any size and any color.
 *
 * @param x// w  w  w  . ja v a  2s.com
 * @param y
 * @param z
 * @param x2
 * @param y2
 * @param z2
 * @param color
 */
public static void box(double x, double y, double z, double x2, double y2, double z2, float red, float green,
        float blue, float alpha) {
    x = x - Minecraft.getMinecraft().getRenderManager().renderPosX;
    y = y - Minecraft.getMinecraft().getRenderManager().renderPosY;
    z = z - Minecraft.getMinecraft().getRenderManager().renderPosZ;
    x2 = x2 - Minecraft.getMinecraft().getRenderManager().renderPosX;
    y2 = y2 - Minecraft.getMinecraft().getRenderManager().renderPosY;
    z2 = z2 - Minecraft.getMinecraft().getRenderManager().renderPosZ;
    GL11.glBlendFunc(770, 771);
    GL11.glEnable(GL_BLEND);
    GL11.glLineWidth(2.0F);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL_DEPTH_TEST);
    GL11.glDepthMask(false);
    GL11.glDepthMask(false);
    GL11.glColor4f(red, green, blue, alpha);
    drawColorBox(new AxisAlignedBB(x, y, z, x2, y2, z2), red, green, blue, alpha);
    GL11.glColor4d(0, 0, 0, 0.5F);
    drawSelectionBoundingBox(new AxisAlignedBB(x, y, z, x2, y2, z2));
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL_DEPTH_TEST);
    GL11.glDepthMask(true);
    GL11.glDisable(GL_BLEND);
}

From source file:com.darkcart.xdolf.util.RenderUtils.java

License:Open Source License

/**
 * Renders a frame with any size and any color.
 *
 * @param x/*from  w w  w .j a va2  s .c om*/
 * @param y
 * @param z
 * @param x2
 * @param y2
 * @param z2
 * @param color
 */
public static void frame(double x, double y, double z, double x2, double y2, double z2, Color color) {
    x = x - Minecraft.getMinecraft().getRenderManager().renderPosX;
    y = y - Minecraft.getMinecraft().getRenderManager().renderPosY;
    z = z - Minecraft.getMinecraft().getRenderManager().renderPosZ;
    x2 = x2 - Minecraft.getMinecraft().getRenderManager().renderPosX;
    y2 = y2 - Minecraft.getMinecraft().getRenderManager().renderPosY;
    z2 = z2 - Minecraft.getMinecraft().getRenderManager().renderPosZ;
    GL11.glBlendFunc(770, 771);
    GL11.glEnable(GL_BLEND);
    GL11.glLineWidth(2.0F);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL_DEPTH_TEST);
    GL11.glDepthMask(false);
    setColor(color);
    drawSelectionBoundingBox(new AxisAlignedBB(x, y, z, x2, y2, z2));
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL_DEPTH_TEST);
    GL11.glDepthMask(true);
    GL11.glDisable(GL_BLEND);
}

From source file:com.darkcart.xdolf.util.RenderUtils.java

License:Open Source License

/**
 * Renders an ESP box with the size of a normal block at the specified
 * BlockPos.//from ww  w .j  av a 2 s.  c om
 */
public static void blockEsp(BlockPos blockPos, Color c, double length, double length2) {
    double x = blockPos.getX() - Minecraft.getMinecraft().getRenderManager().renderPosX;
    double y = blockPos.getY() - Minecraft.getMinecraft().getRenderManager().renderPosY;
    double z = blockPos.getZ() - Minecraft.getMinecraft().getRenderManager().renderPosZ;
    GL11.glPushMatrix();
    GL11.glBlendFunc(770, 771);
    GL11.glEnable(GL_BLEND);
    GL11.glLineWidth(2.0F);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL_DEPTH_TEST);
    GL11.glDepthMask(false);
    GL11.glColor4d(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, 0.15);
    drawColorBox(new AxisAlignedBB(x, y, z, x + length2, y + 1.0, z + length), 0F, 0F, 0F, 0F);
    GL11.glColor4d(0, 0, 0, 0.5);
    drawSelectionBoundingBox(new AxisAlignedBB(x, y, z, x + length2, y + 1.0, z + length));
    GL11.glLineWidth(2.0F);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL_DEPTH_TEST);
    GL11.glDepthMask(true);
    GL11.glDisable(GL_BLEND);
    GL11.glPopMatrix();
}