List of usage examples for org.lwjgl.opengl GL11 glLineWidth
public static void glLineWidth(@NativeType("GLfloat") float width)
From source file:graphics.Graph.java
@Override public void draw() { //if (this.changed) { setMinMax();/*from w w w . ja v a2s.co m*/ float margin = 20; // White backdrop... GL11.glColor3f(1, 1, 1); GL11.glBegin(GL11.GL_POLYGON); GL11.glVertex2f(this.xPos, this.yPos); GL11.glVertex2f(this.xPos + this.sizeX, this.yPos); GL11.glVertex2f(this.xPos + this.sizeX, this.yPos + this.sizeY); GL11.glVertex2f(this.xPos, this.yPos + this.sizeY); GL11.glEnd(); // Black lines around... GL11.glColor3f(0, 0, 0); GL11.glBegin(GL11.GL_LINE_LOOP); GL11.glVertex2f(this.xPos, this.yPos); GL11.glVertex2f(this.xPos + this.sizeX, this.yPos); GL11.glVertex2f(this.xPos + this.sizeX, this.yPos + this.sizeY); GL11.glVertex2f(this.xPos, this.yPos + this.sizeY); GL11.glEnd(); // Moves origo where it should be, based on the dataset... GL11.glColor4f(0, 0, 0, 0.25f); float origo = this.yPos + 2 * margin; if (maxValue == 0 && minValue == 0) { origo += (this.sizeY - 3 * margin) / 2; } else if (maxValue <= 0 && minValue < 0) { origo += this.sizeY - 3 * margin; } else if (maxValue > 0 && minValue < 0) { origo += ((minValue * -1) / (maxValue + (minValue * -1))) * (this.sizeY - 3 * margin); } GL11.glBegin(GL11.GL_LINES); GL11.glVertex2f(this.xPos + margin, origo); GL11.glVertex2f(this.xPos + this.sizeX - margin, origo); GL11.glEnd(); // draws tabs on the origo-line where the values should be put... float tabs = 5; for (int i = 0; i < dataValues.length; i++) { GL11.glBegin(GL11.GL_LINES); GL11.glVertex2f(this.xPos + margin + (i * (this.sizeX - 2 * margin) / (this.dataValues.length - 1)), origo + tabs); GL11.glVertex2f(this.xPos + margin + (i * (this.sizeX - 2 * margin) / (this.dataValues.length - 1)), origo - tabs); GL11.glEnd(); } Line2D.Double[] lines = new Line2D.Double[dataValues.length - 1]; for (int i = 0; i < lines.length; i++) { if (dataValues[i] == null) { continue; } float x = this.xPos + margin + (i * (this.sizeX - 2 * margin) / (this.dataValues.length - 1)); float y = (this.yPos + 2 * margin) + ((this.sizeY - 3 * margin) * ((this.dataValues[i].getValue() + Math.abs(minValue)) / (maxValue + Math.abs(minValue)))); float x2 = this.xPos + margin + ((i + 1) * (this.sizeX - 2 * margin) / (this.dataValues.length - 1)); float y2 = (this.yPos + 2 * margin) + ((this.sizeY - 3 * margin) * ((this.dataValues[i + 1].getValue() + Math.abs(minValue)) / (maxValue + Math.abs(minValue)))); lines[i] = new Line2D.Double(x, y, x2, y2); } // Draws the value-lines on the graph... Line2D.Double origLine = new Line2D.Double(this.xPos + margin, origo, this.xPos + margin + (this.sizeX - 2 * margin), origo); GL11.glLineWidth(2); GL11.glShadeModel(GL11.GL_FLAT); GL11.glBegin(GL11.GL_LINE_STRIP); for (Line2D.Double line : lines) { if (line == null) { continue; } if (line.intersectsLine(origLine)) { Point2D interSect = getIntersection(line, origLine); if (line.y1 > origo) { GL11.glColor4f(0, 1, 0, 1); GL11.glVertex2d(line.x1, line.y1); GL11.glVertex2d(interSect.getX(), interSect.getY()); GL11.glColor4f(1, 0, 0, 1); GL11.glVertex2d(line.x2, line.y2); } else { GL11.glColor4f(1, 0, 0, 1); GL11.glVertex2d(line.x1, line.y1); GL11.glVertex2d(interSect.getX(), interSect.getY()); GL11.glColor4f(0, 1, 0, 1); GL11.glVertex2d(line.x2, line.y2); } } else { if (line.y1 > origo) { GL11.glColor4f(0, 1, 0, 1); GL11.glVertex2d(line.x1, line.y1); GL11.glVertex2d(line.x2, line.y2); } else { GL11.glColor4f(1, 0, 0, 1); GL11.glVertex2d(line.x1, line.y1); GL11.glVertex2d(line.x2, line.y2); } } } GL11.glEnd(); GL11.glLineWidth(1); GL11.glShadeModel(GL11.GL_SMOOTH); // Black lines around box inside the graph... GL11.glColor4f(0, 0, 0, 1); GL11.glBegin(GL11.GL_LINE_LOOP); GL11.glVertex2f(this.xPos + margin, this.yPos + 2 * margin); GL11.glVertex2f(this.xPos + this.sizeX - margin, this.yPos + 2 * margin); GL11.glVertex2f(this.xPos + this.sizeX - margin, this.yPos + this.sizeY - margin); GL11.glVertex2f(this.xPos + margin, this.yPos + this.sizeY - margin); GL11.glEnd(); //this.changed = false; origLine = null; //} }
From source file:hellfirepvp.astralsorcery.client.gui.journal.GuiProgressionClusterRenderer.java
License:Open Source License
private void drawConnection(double originX, double originY, double targetX, double targetY, float zLevel) { GL11.glPushMatrix();// w w w . ja va2 s. com GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glLineWidth(3.5F); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); long clientTicks = ClientScheduler.getClientTick(); Vector3 origin = new Vector3(originX, originY, 0); Vector3 line = origin.vectorFromHereTo(targetX, targetY, 0); int segments = (int) Math.ceil(line.length() / 1); //1 = max line segment length int activeSegment = (int) (clientTicks % segments); Vector3 segmentIter = line.divide(segments); for (int i = segments; i >= 0; i--) { double lx = origin.getX(); double ly = origin.getY(); origin.add(segmentIter); float brightness = 0.4F; brightness += (0.6F * evaluateBrightness(i, activeSegment)); drawLinePart(lx, ly, origin.getX(), origin.getY(), zLevel, brightness); } GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_LINE_SMOOTH); GL11.glLineWidth(2.0F); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); GL11.glPopMatrix(); }
From source file:hud.ManagerOverlay.java
License:Open Source License
public void draw() { GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_LINE); GL11.glColor4f(0.0f, 0.0f, 0.4f, 1.0f); GL11.glLineWidth(2.0f); GL11.glBegin(GL11.GL_QUADS);/*w w w .ja v a 2 s . co m*/ GL11.glVertex2i(x, y); GL11.glVertex2i(x, y + height); GL11.glVertex2i(x + width, y + height); GL11.glVertex2i(x + width, y); GL11.glEnd(); GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); GL11.glColor4f(0.0f, 0.5f, 1.0f, 0.5f); GL11.glEnable(GL11.GL_BLEND); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2i(x, y); GL11.glVertex2i(x, y + height); GL11.glVertex2i(x + width, y + height); GL11.glVertex2i(x + width, y); GL11.glEnd(); GL11.glDisable(GL11.GL_BLEND); drawSelectionArrow(selectableWidgets[curWidget]); GL11.glPushMatrix(); GL11.glTranslatef(x, y, 0); unitDisplay.draw(); ordersDisplay.draw(); mapDisplay.draw(); GL11.glPopMatrix(); }
From source file:hud.ManagerOverlay.java
License:Open Source License
private void drawSelectionArrow(HZWidget selected) { int x = selected.getX() - 16; int y = selected.getY() + selected.height / 2; GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_LINE); GL11.glColor4f(0.0f, 0.0f, 0.4f, 1.0f); GL11.glLineWidth(2.0f); GL11.glBegin(GL11.GL_TRIANGLES);//from w ww . j a v a2s. c o m GL11.glVertex2i(x, y); GL11.glVertex2i(x - 16, y - 32); GL11.glVertex2i(x - 16, y + 32); GL11.glEnd(); GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); GL11.glColor4f(0.0f, 0.5f, 1.0f, 0.5f); GL11.glBegin(GL11.GL_TRIANGLES); GL11.glVertex2i(x, y); GL11.glVertex2i(x - 16, y - 32); GL11.glVertex2i(x - 16, y + 32); GL11.glEnd(); }
From source file:hud.MapDisplay.java
License:Open Source License
public void draw() { GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_LINE); GL11.glColor4f(0.0f, 0.0f, 0.4f, 1.0f); GL11.glLineWidth(2.0f); GL11.glBegin(GL11.GL_QUADS);/* ww w. j a va2s .c o m*/ GL11.glVertex2i(x, y); GL11.glVertex2i(x, y + height); GL11.glVertex2i(x + width, y + height); GL11.glVertex2i(x + width, y); GL11.glEnd(); GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); game.getMap().getMinimap().bind(); GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0, 0); GL11.glVertex2i(x, y); GL11.glTexCoord2f(0, 1); GL11.glVertex2i(x, y + height); GL11.glTexCoord2f(1, 1); GL11.glVertex2i(x + width, y + height); GL11.glTexCoord2f(1, 0); GL11.glVertex2i(x + width, y); GL11.glEnd(); }
From source file:hud.OrdersDisplay.java
License:Open Source License
public void draw() { GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_LINE); GL11.glColor4f(0.0f, 0.0f, 0.4f, 1.0f); GL11.glLineWidth(2.0f); GL11.glBegin(GL11.GL_QUADS);/* www. j a v a 2s .co m*/ GL11.glVertex2i(x, y); GL11.glVertex2i(x, y + height); GL11.glVertex2i(x + width, y + height); GL11.glVertex2i(x + width, y); GL11.glEnd(); GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); GL11.glColor4f(0.0f, 0.5f, 1.0f, 0.8f); GL11.glEnable(GL11.GL_BLEND); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2i(x, y); GL11.glVertex2i(x, y + height); GL11.glVertex2i(x + width, y + height); GL11.glVertex2i(x + width, y); GL11.glEnd(); GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); GL11.glPushMatrix(); GL11.glTranslatef(x + 16, y + 16, 0); ais[curAI].draw(); GL11.glPopMatrix(); GL11.glDisable(GL11.GL_BLEND); Material.DEFAULT_WHITE.bind(); }
From source file:hud.UnitDisplay.java
License:Open Source License
public void draw() { GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_LINE); GL11.glColor4f(0.0f, 0.0f, 0.4f, 1.0f); GL11.glLineWidth(2.0f); GL11.glBegin(GL11.GL_QUADS);// w w w. ja va2 s . co m GL11.glVertex2i(x, y); GL11.glVertex2i(x, y + height); GL11.glVertex2i(x + width, y + height); GL11.glVertex2i(x + width, y); GL11.glEnd(); GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); GL11.glColor4f(0.0f, 0.5f, 1.0f, 0.8f); GL11.glEnable(GL11.GL_BLEND); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2i(x, y); GL11.glVertex2i(x, y + height); GL11.glVertex2i(x + width, y + height); GL11.glVertex2i(x + width, y); GL11.glEnd(); GL11.glDisable(GL11.GL_BLEND); int[] viewport = GLUtils.getViewport(); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_LIGHTING); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glLoadIdentity(); GLU.gluPerspective(45, 1.0f, 0.001f, 5.0f); GL11.glViewport(getX(), viewport[3] - (getY() + height), width, height); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); GLU.gluLookAt(2.0f * (float) Math.cos(angle), 2.0f * (float) Math.sin(angle), 1.0f, 0, 0, 0, 0, 0, 1); // GL11.glTranslatef(x + width/2, y + height/2,0); currentUnit.draw(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPopMatrix(); GL11.glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); }
From source file:illarion.graphics.lwjgl.DrawerLWJGL.java
License:Open Source License
/** * Draw a line between two points with a specified width and color. * /*from w w w .j av a 2 s. c o m*/ * @param x1 the x coordinate of the first point on the screen * @param y1 the y coordinate of the first point on the screen * @param x2 the x coordinate of the second point on the screen * @param y2 the y coordinate of the second point on the screen * @param width the width of the line * @param color the color of the line */ @Override public void drawLine(final int x1, final int y1, final int x2, final int y2, final float width, final SpriteColor color) { DriverSettingsLWJGL.getInstance().enableDrawLine(); GL11.glLineWidth(width); color.setActiveColor(); buffer.clear(); buffer.put(x1).put(y1); buffer.put(x2).put(y2); buffer.flip(); GL11.glVertexPointer(2, 0, buffer); GL11.glDrawArrays(GL11.GL_LINES, 0, 2); }
From source file:illarion.graphics.lwjgl.DrawerLWJGL.java
License:Open Source License
/** * Draw a rectangle that is not filled and consists just of the border. * /*from w ww . ja v a 2 s . co m*/ * @param x1 x coordinate of the first corner of the rectangle * @param y1 y coordinate of the first corner of the rectangle * @param x2 x coordinate of the second corner of the rectangle * @param y2 y coordinate of the second corner of the rectangle * @param color the color of the rectangle border line * @see illarion.graphics.Drawer#drawRectangleFrame(int, int, int, int, * float, SpriteColor) */ @Override public void drawRectangleFrame(final int x1, final int y1, final int x2, final int y2, final float width, final SpriteColor color) { DriverSettingsLWJGL.getInstance().enableDrawOther(); color.setActiveColor(); GL11.glLineWidth(width); buffer.clear(); buffer.put(x1).put(y1); buffer.put(x1).put(y2); buffer.put(x2).put(y2); buffer.put(x2).put(y1); buffer.flip(); GL11.glVertexPointer(2, 0, buffer); GL11.glDrawArrays(GL11.GL_LINE_LOOP, 0, 4); }
From source file:illarion.graphics.lwjgl.DrawerLWJGL.java
License:Open Source License
@Override public void drawRoundedRectangleFrame(final int x1, final int y1, final int x2, final int y2, final float width, final SpriteColor color) { final int quality = Graphics.getInstance().getQuality(); if (quality == Graphics.QUALITY_MIN) { drawRectangleFrame(x1 - ROUNDED_BORDER_WIDTH, y1 - ROUNDED_BORDER_WIDTH, x2 + ROUNDED_BORDER_WIDTH, y2 + ROUNDED_BORDER_WIDTH, width, color); return;//from w ww . j av a 2 s . c o m } DriverSettingsLWJGL.getInstance().enableDrawLine(); color.setActiveColor(); GL11.glLineWidth(width); buffer.clear(); buffer.put(x1 - ROUNDED_BORDER_WIDTH).put(y1); buffer.put(x1 - ROUNDED_BORDER_WIDTH).put(y2); buffer.put(x1 - ROUNDED_BORDER_WIDTH_1).put(y2 + ROUNDED_BORDER_WIDTH_2); buffer.put(x1 - ROUNDED_BORDER_WIDTH_2).put(y2 + ROUNDED_BORDER_WIDTH_1); buffer.put(x1).put(y2 + ROUNDED_BORDER_WIDTH); buffer.put(x2).put(y2 + ROUNDED_BORDER_WIDTH); buffer.put(x2 + ROUNDED_BORDER_WIDTH_2).put(y2 + ROUNDED_BORDER_WIDTH_1); buffer.put(x2 + ROUNDED_BORDER_WIDTH_1).put(y2 + ROUNDED_BORDER_WIDTH_2); buffer.put(x2 + ROUNDED_BORDER_WIDTH).put(y2); buffer.put(x2 + ROUNDED_BORDER_WIDTH).put(y1); buffer.put(x2 + ROUNDED_BORDER_WIDTH_1).put(y1 - ROUNDED_BORDER_WIDTH_2); buffer.put(x2 + ROUNDED_BORDER_WIDTH_2).put(y1 - ROUNDED_BORDER_WIDTH_1); buffer.put(x2).put(y1 - ROUNDED_BORDER_WIDTH); buffer.put(x1).put(y1 - ROUNDED_BORDER_WIDTH); buffer.put(x1 - ROUNDED_BORDER_WIDTH_2).put(y1 - ROUNDED_BORDER_WIDTH_1); buffer.put(x1 - ROUNDED_BORDER_WIDTH_1).put(y1 - ROUNDED_BORDER_WIDTH_2); buffer.flip(); GL11.glVertexPointer(2, 0, buffer); GL11.glDrawArrays(GL11.GL_LINE_LOOP, 0, 16); }