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:org.fenggui.binding.render.lwjgl.LWJGLOpenGL.java

License:Open Source License

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

From source file:org.jogamp.glg2d.impl.gl2.FastLineVisitor.java

License:Apache License

@Override
public void setStroke(BasicStroke stroke) {
    GL11.glLineWidth(glLineWidth);
    GL11.glPointSize(glLineWidth);/*www. j  a v  a2  s.  c  o m*/

    /*
     * Not perfect copy of the BasicStroke implementation, but it does get
     * decently close. The pattern is pretty much the same. I think it's pretty
     * much impossible to do with out a fragment shader and only the fixed
     * function pipeline.
     */
    float[] dash = stroke.getDashArray();
    if (dash != null) {
        float totalLength = 0;
        for (float f : dash) {
            totalLength += f;
        }

        float lengthSoFar = 0;
        int prevIndex = 0;
        int mask = 0;
        for (int i = 0; i < dash.length; i++) {
            lengthSoFar += dash[i];

            int nextIndex = (int) (lengthSoFar / totalLength * 16);
            for (int j = prevIndex; j < nextIndex; j++) {
                mask |= (~i & 1) << j;
            }

            prevIndex = nextIndex;
        }

        /*
         * XXX Should actually use the stroke phase, but not sure how yet.
         */

        GL11.glEnable(GL11.GL_LINE_STIPPLE);
        int factor = (int) totalLength;
        GL11.glLineStipple(factor >> 4, (short) mask);
    } else {
        GL11.glDisable(GL11.GL_LINE_STIPPLE);
    }

    this.stroke = stroke;
}

From source file:org.lwjgl.info.LWJGLTestView.java

License:Open Source License

/** 
 * {@inheritDoc}//from w  w  w. j  av  a2 s .  c om
 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
 */
@Override
public void createPartControl(Composite parent) {

    String strVersion = getFeatureVersion("org.lwjgl");
    this.setPartName("org.lwjgl " + strVersion);

    IStatusLineManager statusLine = this.getViewSite().getActionBars().getStatusLineManager();

    fpsstatuslineitem = new FpsStatusLineItem();
    statusLine.add(fpsstatuslineitem);

    GLData data = new GLData();
    data.doubleBuffer = true;
    canvas = new GLCanvas(parent, 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.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);

    Display.getCurrent().asyncExec(initRunnable());

}

From source file:org.minetweak.world.World.java

License:Apache License

private void renderOverlay() {
    Configuration conf = Game.getInstance().getConfiguration();

    Game.getInstance().initOverlayRendering();

    GL11.glColor3f(1, 1, 1);//from ww w  .j  a  v  a  2 s  .c  om

    if (Game.RENDER_INFORMATION_OVERLAY) {
        GLFont infoFont = FontStorage.getFont("Monospaced_20");

        /* Down Left Info */
        infoFont.print(4, 4, "CraftMania");
        infoFont.print(4, 30, _player.coordinatesToString());
        infoFont.print(4, 45, "Visible Chunks:      " + _visibleChunks.size());
        infoFont.print(4, 60, "Updading Blocks:     " + _updatingBlocks);
        infoFont.print(4, 75, "Total Chunks in RAM: " + _chunkManager.getTotalChunkCount());
        infoFont.print(4, 90, "Local Chunks:        " + _localChunks.size());
        infoFont.print(4, 105, "Total Local Blocks:  " + _localBlockCount);
        infoFont.print(4, 120, "Time:  " + _time);
        infoFont.print(4, 135, "Sunlight:  " + _sunlight);

    }
    /** RENDER **/
    if (currentGui != null) {
        Game.getInstance().renderTransculentOverlayLayer();
        currentGui.render();
    } else {
        int width = conf.getWidth();
        int height = conf.getHeight();
        // Center Cross
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        if (CENTER_CROSS_CALL_LIST == 0) {
            CENTER_CROSS_CALL_LIST = GL11.glGenLists(1);
            GL11.glNewList(CENTER_CROSS_CALL_LIST, GL11.GL_COMPILE_AND_EXECUTE);

            int crossSize = 10;
            int crossHole = 5;

            GL11.glLineWidth(2.5f);

            GL11.glColor3f(0, 0, 0);
            GL11.glBegin(GL11.GL_LINES);
            GL11.glVertex3f(width / 2f - crossSize - crossHole, height / 2f, 0);
            GL11.glVertex3f(width / 2f - crossHole, height / 2f, 0);

            GL11.glVertex3f(width / 2f + crossSize + crossHole, height / 2f, 0);
            GL11.glVertex3f(width / 2f + crossHole, height / 2f, 0);

            GL11.glVertex3f(width / 2f, height / 2f - crossSize - crossHole, 0);
            GL11.glVertex3f(width / 2f, height / 2f - crossHole, 0);

            GL11.glVertex3f(width / 2f, height / 2f + crossSize + crossHole, 0);
            GL11.glVertex3f(width / 2f, height / 2f + crossHole, 0);

            GL11.glEnd();
            GL11.glEndList();
        } else {
            GL11.glCallList(CENTER_CROSS_CALL_LIST);
        }
        GL11.glEnable(GL11.GL_TEXTURE_2D);

        // Inventory bar
        GL11.glPushMatrix();
        Texture texGui = TextureStorage.getTexture("gui.gui");
        texGui.bind();
        float tileSize = 20.0f / texGui.getImageWidth();
        if (INVENTORY_BAR_CALL_LIST == 0) {
            INVENTORY_BAR_CALL_LIST = GL11.glGenLists(2);

            /* Bar */
            GL11.glNewList(INVENTORY_BAR_CALL_LIST, GL11.GL_COMPILE_AND_EXECUTE);

            GL11.glTranslatef(width / 2.0f - 9 * 20, 10, 0);
            GL11.glColor3f(1.0f, 1.0f, 1.0f);
            GL11.glBegin(GL11.GL_QUADS);

            GL11.glTexCoord2f(0, 0);
            GL11.glVertex2f(0, 40);

            GL11.glTexCoord2f(tileSize * 9, 0);
            GL11.glVertex2f(9 * 40, 40);

            GL11.glTexCoord2f(tileSize * 9, tileSize);
            GL11.glVertex2f(9 * 40, 0);

            GL11.glTexCoord2f(0, tileSize);
            GL11.glVertex2f(0, 0);

            GL11.glEnd();
            GL11.glEndList();

            /* Little frame around selected item */
            float frameTileSize = 24.0f / texGui.getImageWidth();
            float frameTileY = 22.0f / texGui.getImageHeight();

            GL11.glNewList(INVENTORY_BAR_CALL_LIST + 1, GL11.GL_COMPILE);
            GL11.glBegin(GL11.GL_QUADS);

            GL11.glTexCoord2f(0, frameTileY);
            GL11.glVertex2f(0, 48);

            GL11.glTexCoord2f(frameTileSize, frameTileY);
            GL11.glVertex2f(48, 48);

            GL11.glTexCoord2f(frameTileSize, frameTileY + frameTileSize);
            GL11.glVertex2f(48, 0);

            GL11.glTexCoord2f(0, frameTileY + frameTileSize);
            GL11.glVertex2f(0, 0);

            GL11.glEnd();
            GL11.glEndList();
        } else {
            GL11.glCallList(INVENTORY_BAR_CALL_LIST);
        }

        /* Content */
        GL11.glPushMatrix();
        GL11.glTranslatef(20, 20, 0);
        for (int i = 0; i < 9; ++i) {
            Inventory.InventoryPlace place = getActivePlayer().getInventory().getInventoryPlace(i);
            if (place != null) {
                place.render();
            }
            GL11.glTranslatef(40, 0, 0);
        }
        texGui.bind();
        GL11.glPopMatrix();
        GL11.glTranslatef(getActivePlayer().getSelectedInventoryItemIndex() * 40.0f - 4, -4, 0);
        GL11.glCallList(INVENTORY_BAR_CALL_LIST + 1);

        GL11.glPopMatrix();
    }
}

From source file:org.mudraker.blockplacer.Event.java

License:Open Source License

/**
 * Draws the selection box for the player. 
 * <p>Args: entityPlayer, rayTraceHit, i, partialTickTime 
 * <p>Based on net.minecraft.client.renderer.RenderGlobal.java. 
 * Which is called by net.minecraft.client.renderer.entityRenderer.java.
 * @@MCVERSION164@@/*from ww w.j  a v a 2  s.  c o m*/
 */
private void drawSelectionBox(EntityPlayer par1EntityPlayer, MovingObjectPosition par2MovingObjectPosition,
        int par3, float par4) {
    // Add config instance declaration
    Config config = Config.getInstance();
    if (par3 == 0 && par2MovingObjectPosition.typeOfHit == EnumMovingObjectType.TILE) {
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        // Replaced to configure colour and width
        // GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.4F);
        // GL11.glLineWidth(2.0F);
        if (config.frameSwapInNether && par1EntityPlayer.dimension == DIMENSION_NETHER) {
            GL11.glColor4f(config.frameGreenF, config.frameRedF, config.frameBlueF, config.frameAlphaF);
        } else {
            GL11.glColor4f(config.frameRedF, config.frameGreenF, config.frameBlueF, config.frameAlphaF);
        }
        GL11.glLineWidth((float) config.frameLineWidth);
        // end change
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDepthMask(false);
        // Replaced to configure expansion
        //float f1 = 0.002F;
        float f1 = config.frameExpand;
        // end change
        int j = this.theWorld.getBlockId(par2MovingObjectPosition.blockX, par2MovingObjectPosition.blockY,
                par2MovingObjectPosition.blockZ);

        if (j > 0) {
            // Removed - Don't need to get block specific bounds
            // Block.blocksList[j].setBlockBoundsBasedOnState(this.theWorld, par2MovingObjectPosition.blockX, par2MovingObjectPosition.blockY, par2MovingObjectPosition.blockZ);
            double d0 = par1EntityPlayer.lastTickPosX
                    + (par1EntityPlayer.posX - par1EntityPlayer.lastTickPosX) * (double) par4;
            double d1 = par1EntityPlayer.lastTickPosY
                    + (par1EntityPlayer.posY - par1EntityPlayer.lastTickPosY) * (double) par4;
            double d2 = par1EntityPlayer.lastTickPosZ
                    + (par1EntityPlayer.posZ - par1EntityPlayer.lastTickPosZ) * (double) par4;
            // Replaced - Don't need to get block specific box
            // But do need to use the BlockPlacer position instead.
            //this.drawOutlinedBoundingBox(Block.blocksList[j].getSelectedBoundingBoxFromPool(this.theWorld, par2MovingObjectPosition.blockX, par2MovingObjectPosition.blockY, par2MovingObjectPosition.blockZ).expand((double)f1, (double)f1, (double)f1).getOffsetBoundingBox(-d0, -d1, -d2));
            this.drawOutlinedBoundingBox(
                    this.getFullBoundingBoxFromPool(drawPosition.x, drawPosition.y, drawPosition.z)
                            .expand((double) f1, (double) f1, (double) f1).getOffsetBoundingBox(-d0, -d1, -d2));
            // end change
        }

        GL11.glDepthMask(true);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_BLEND);
    }
}

From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java

License:Open Source License

/** 
 * @see DrawStuffApi#dsDrawLine(float[], float[])
 *///from w  ww . j  a  v  a 2s . c  o m
@Override
public void dsDrawLine(final float[] pos1, final float[] pos2) {
    setupDrawingMode();
    GL11.glColor3f(color[0], color[1], color[2]);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glLineWidth(2);
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex3f(pos1[0], pos1[1], pos1[2]);
    GL11.glVertex3f(pos2[0], pos2[1], pos2[2]);
    GL11.glEnd();
}

From source file:playn.java.JavaGL20.java

License:Apache License

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

From source file:processing.opengl.PLWJGL.java

License:Open Source License

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

From source file:shadowmage.ancient_framework.client.render.RenderTools.java

License:Open Source License

/**
 * draw a player-position-normalized bounding box (can only be called during worldRender)
 * @param bb//from   w  w w.j a v  a 2  s .  c  om
 */
public static void drawOutlinedBoundingBox(AxisAlignedBB bb, float r, float g, float b) {
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(r, g, b, 0.4F);
    GL11.glLineWidth(8.0F);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDepthMask(false);
    Tessellator tess = Tessellator.instance;
    tess.startDrawing(3);
    tess.addVertex(bb.minX, bb.minY, bb.minZ);
    tess.addVertex(bb.maxX, bb.minY, bb.minZ);
    tess.addVertex(bb.maxX, bb.minY, bb.maxZ);
    tess.addVertex(bb.minX, bb.minY, bb.maxZ);
    tess.addVertex(bb.minX, bb.minY, bb.minZ);
    tess.draw();
    tess.startDrawing(3);
    tess.addVertex(bb.minX, bb.maxY, bb.minZ);
    tess.addVertex(bb.maxX, bb.maxY, bb.minZ);
    tess.addVertex(bb.maxX, bb.maxY, bb.maxZ);
    tess.addVertex(bb.minX, bb.maxY, bb.maxZ);
    tess.addVertex(bb.minX, bb.maxY, bb.minZ);
    tess.draw();
    tess.startDrawing(1);
    tess.addVertex(bb.minX, bb.minY, bb.minZ);
    tess.addVertex(bb.minX, bb.maxY, bb.minZ);
    tess.addVertex(bb.maxX, bb.minY, bb.minZ);
    tess.addVertex(bb.maxX, bb.maxY, bb.minZ);
    tess.addVertex(bb.maxX, bb.minY, bb.maxZ);
    tess.addVertex(bb.maxX, bb.maxY, bb.maxZ);
    tess.addVertex(bb.minX, bb.minY, bb.maxZ);
    tess.addVertex(bb.minX, bb.maxY, bb.maxZ);
    tess.draw();
    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
}

From source file:shadowmage.ancient_warfare.client.render.RenderOverlayAdvanced.java

License:Open Source License

public static void renderTorpedoPath(VehicleBase vehicle, EntityPlayer player, float partialTick) {
    GL11.glPushMatrix();/*from   ww  w  .ja va 2  s. c  o  m*/
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glColor4d(1, 1, 1, 0.6d);

    double x1 = vehicle.posX - player.posX;
    double y1 = vehicle.posY - player.posY;
    double z1 = vehicle.posZ - player.posZ;

    /**
     * vectors for a straight line
     */
    double x2 = x1
            - 20 * Trig.sinDegrees(vehicle.rotationYaw + partialTick * vehicle.moveHelper.getRotationSpeed());
    double y2 = y1;
    double z2 = z1
            - 20 * Trig.cosDegrees(vehicle.rotationYaw + partialTick * vehicle.moveHelper.getRotationSpeed());
    GL11.glLineWidth(3f);
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex3d(x1, y1 + 0.12d, z1);
    GL11.glVertex3d(x2, y2 + 0.12d, z2);
    GL11.glEnd();

    GL11.glLineWidth(4f);
    GL11.glColor4f(1.f, 0.4f, 0.4f, 0.4f);
    GL11.glBegin(GL11.GL_LINES);

    Pos3f offset = vehicle.getMissileOffset();
    x2 = x1 + offset.x;
    y2 = y1 + offset.y;
    z2 = z1 + offset.z;

    double gravity = 9.81d * 0.05d * 0.05d;
    double speed = vehicle.localLaunchPower * 0.05d;
    double angle = 90 - vehicle.localTurretPitch - vehicle.rotationPitch;
    double yaw = vehicle.localTurretRotation + partialTick * vehicle.moveHelper.getRotationSpeed();

    double vH = -Trig.sinDegrees((float) angle) * speed;
    double vY = Trig.cosDegrees((float) angle) * speed;
    double vX = Trig.sinDegrees((float) yaw) * vH;
    double vZ = Trig.cosDegrees((float) yaw) * vH;
    int rocketBurnTime = (int) (speed * 20.f * AmmoHwachaRocket.burnTimeFactor);

    float xAcc = (float) (vX / speed) * AmmoHwachaRocket.accelerationFactor;
    ;
    float yAcc = (float) (vY / speed) * AmmoHwachaRocket.accelerationFactor;
    ;
    float zAcc = (float) (vZ / speed) * AmmoHwachaRocket.accelerationFactor;
    ;
    vX = xAcc;
    vY = yAcc;
    vZ = zAcc;
    float dist = 0;

    while (dist < 100 * 100) {
        GL11.glVertex3d(x2, y2, z2);
        x2 += vX;
        z2 += vZ;
        y2 += vY;
        dist += x2 * x2 + z2 * z2 + y2 * y2;
        GL11.glVertex3d(x2, y2, z2);
    }
    GL11.glEnd();

    GL11.glPopMatrix();
    GL11.glDepthMask(true);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}