List of usage examples for org.lwjgl.opengl GL11 glLineWidth
public static void glLineWidth(@NativeType("GLfloat") float width)
From source file:com.replaymod.pixelcam.renderer.PathVisualizer.java
License:Apache License
private void drawConnection(double playerX, double playerY, double playerZ, Position pos1, Position pos2, Color color) {/*from ww w.j ava 2 s . co m*/ GlStateManager.pushMatrix(); GlStateManager.pushAttrib(); double x = pos1.getX() - playerX; double y = pos1.getY() - playerY; double z = pos1.getZ() - playerZ; GL11.glLineWidth(3); GlStateManager.disableTexture2D(); GlStateManager.color(color.getRed(), color.getGreen(), color.getBlue(), 0.7f); VertexBuffer vb = Tessellator.getInstance().getBuffer(); vb.setTranslation(x, y + mc.player.eyeHeight, z); vb.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); vb.pos(pos2.getX() - pos1.getX(), pos2.getY() - pos1.getY(), pos2.getZ() - pos1.getZ()).endVertex(); vb.pos(0, 0, 0).endVertex(); Tessellator.getInstance().draw(); vb.setTranslation(0, 0, 0); GlStateManager.enableTexture2D(); GlStateManager.popAttrib(); GlStateManager.popMatrix(); }
From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java
License:Mozilla Public License
public InspectorCanvas(Composite parent, int style, GLData data) { super(parent, style, data); setCurrent();/* w ww . j a v a 2s . c om*/ // Clear the canvas. GL11.glClearColor(CLEAR_COLOR[0], CLEAR_COLOR[1], CLEAR_COLOR[2], CLEAR_COLOR[3]); GL11.glClearDepth(1.0f); GL11.glLineWidth(1.0f); GL11.glPointSize(1.0f); GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); GL11.glEnable(GL11.GL_POLYGON_SMOOTH); GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_NICEST); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(true); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glAlphaFunc(GL11.GL_GREATER, 0.01f); GL11.glEnable(GL11.GL_STENCIL_TEST); GL11.glStencilFunc(GL11.GL_ALWAYS, 0x1, 0xf); GL11.glStencilOp(GL11.GL_INCR, GL11.GL_KEEP, GL11.GL_INCR); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); reset(); mTransform = new Matrix4f(); mTransform.setIdentity(); addListener(SWT.Resize, this); addListener(SWT.Paint, this); addMouseListener(this); addMouseWheelListener(this); }
From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java
License:Mozilla Public License
private void drawHierarchy(Node node) { if (node == null || node.bounds.width == 0 || node.bounds.height == 0 || !node.isShowing() || !node.isVisible()) {//from www . j a v a 2 s .c o m return; } // Give a 3d depth. GL11.glPushMatrix(); final float depth = node.depth * mDepth; // Node's translation. GL11.glTranslatef(node.bounds.x, -node.bounds.y, depth); final Drawable background = node.getBackground(); final Drawable content = node.getContent(); final boolean hasBackground = node.isBackgroundShown && (background.displayListId != -1); final boolean hasContent = node.isContentShown && (content.displayListId != -1); if (mIsPicking) { GL11.glColor4f(node.pickColor[0], node.pickColor[1], node.pickColor[2], node.pickColor[3]); drawFrontFace(node, 0.0f, GL11.GL_FILL); // Draw the depth, only if we show in actual mode. // If not, if we are splitting content, draw a layer for it. if (mShowDepth) { drawDepth(node, -mDepth, GL11.GL_FILL); } else if (mSplitContent && hasBackground && hasContent) { drawFrontFace(node, -mDepth / 2.0f, GL11.GL_FILL); } } else { if (!mIsOrtho && mShowDepth) { GL11.glPushAttrib(GL11.GL_STENCIL_BUFFER_BIT); GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP); drawDepthCube(node, depth); GL11.glPopAttrib(); } if (hasBackground && hasContent) { // Both background and content are available. // Draw background at a depth if needed. if (mSplitContent) GL11.glTranslatef(0.0f, 0.0f, -mDepth / 2.0f); GL11.glCallList(background.displayListId); if (mSplitContent) GL11.glTranslatef(0.0f, 0.0f, mDepth / 2.0f); GL11.glCallList(content.displayListId); } else if (hasBackground) { GL11.glCallList(background.displayListId); } else if (hasContent) { GL11.glCallList(content.displayListId); } // Stencil shouldn't know about bounds. GL11.glPushAttrib(GL11.GL_STENCIL_BUFFER_BIT | GL11.GL_LINE_BIT); GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP); // Show bounds. if (!mIsOrtho && mShowDepth) { loadColor(ColorType.BOUNDS_NORMAL); } else { if (node.isSelected) { GL11.glLineWidth(2.0f); loadColor(ColorType.BOUNDS_SELECTION); } else { loadColor(ColorType.BOUNDS_NORMAL); } } if (node.isSelected || !mIsOrtho || mShowBounds) { drawFrontFace(node, 0.0f, GL11.GL_LINE); } // Show a bounding box for split content in perspective mode. if (!mIsOrtho && !mShowDepth && mSplitContent && hasBackground && hasContent) { drawFrontFace(node, -mDepth / 2.0f, GL11.GL_LINE); } GL11.glPopAttrib(); } for (Node child : node.children) { drawHierarchy(child); } GL11.glPopMatrix(); }
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);/*from ww w. java 2s.c o m*/ // Green for X GL11.glColor3f(1.0f, 0.0f, 0.0f); 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(); }
From source file:com.timvisee.voxeltex.architecture.component.drawable.line.GridDrawComponent.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);/*from w w w. j av a 2 s . c o m*/ // Set the grid color GL11.glColor3f(0.2f, 0.2f, 0.2f); // Draw the grid for (int i = -20; i <= 20; i++) { GL11.glVertex3f(-20.0f, 0.0f, i); GL11.glVertex3f(20.0f, 0.0f, i); GL11.glVertex3f(i, 0.0f, -20.0f); GL11.glVertex3f(i, 0.0f, 20.0f); } // Finish drawing GL11.glEnd(); }
From source file:com.timvisee.voxeltex.module.render.RenderOverlayHelper.java
License:Open Source License
/** * Set the width of lines being rendered. * * @param lineWidth Line width./*from w w w . j av a 2 s . c o m*/ */ public static void lineWidth(float lineWidth) { GL11.glLineWidth(lineWidth); }
From source file:com.wicpar.sinkingsimulatorclassic.Sea.java
License:Open Source License
@Override public void draw() { GL11.glEnable(GL11.GL_DEPTH_TEST);//from ww w . java2 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_POLYGON_SMOOTH); time = Base.getTimePassed(); GL11.glBegin(GL11.GL_QUAD_STRIP); GL11.glColor4f(SeaColor.r, SeaColor.g, SeaColor.b, SeaColor.a); for (int i = 0; i <= divisions; i++) { double pos = ((double) (i) / (divisions)) * 2 - 1; GL11.glVertex3d(pos, -1, -0.07); GL11.glVertex3d(pos, cam.transformY(getHeight(cam.untransformX(pos), time)), -0.07); } GL11.glEnd(); GL11.glEnable(GL11.GL_POLYGON_SMOOTH); GL11.glLineWidth(2); GL11.glBegin(GL11.GL_LINE_STRIP); GL11.glColor4f(SeaColor.r, SeaColor.g, SeaColor.b, 1); for (int i = 0; i <= divisions; i++) { double pos = ((double) (i) / (divisions)) * 2 - 1; GL11.glVertex3d(pos, cam.transformY(getHeight(cam.untransformX(pos), time)), -0.07); } GL11.glEnd(); GL11.glLineWidth(1); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glLineWidth(1); }
From source file:com.wicpar.sinkingsimulatorclassic.Ship.java
License:Open Source License
@Override public void draw() { final Camera cam = Main.ClassicSinkingSim.getInstance().getCam(); GL11.glEnable(GL11.GL_DEPTH_TEST);/*from w w 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.glPointSize((float) Main.ClassicSinkingSim.getInstance().getCam().scaleSize(0.1)); GL11.glBegin(GL11.GL_POINTS); for (Shipsel[] s : shipsels) { if (s != null) for (Shipsel shipsel : s) { if (shipsel != null) { Color c = shipsel.getColor(); Vector3d pos = shipsel.getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.8); } } } GL11.glEnd(); GL11.glPointSize(1); GL11.glLineWidth((float) Main.ClassicSinkingSim.getInstance().getCam().scaleSize(0.1)); boolean t, b, l, r, e, f; Color c; Vector3d pos; GL11.glBegin(GL11.GL_LINES); for (int y = 0; y < springs[1].length; y++) { for (int x = 0; x < springs[1][y].length; x++) { t = springs[0][y][x]; l = springs[2][y][x]; e = springs[1][y][x]; f = springs[3][y][x]; if (t && (shipsels[y][x] == null || shipsels[y][x + 1] == null)) { springs[0][y][x] = false; } if (l && (shipsels[y][x] == null || shipsels[y + 1][x] == null)) { springs[2][y][x] = false; } if (e && (shipsels[y][x] == null || shipsels[y + 1][x + 1] == null)) { springs[1][y][x] = false; } if (f && (shipsels[y][x + 1] == null || shipsels[y + 1][x] == null)) { springs[3][y][x] = false; } t = springs[0][y][x]; b = springs[0][y + 1][x]; l = springs[2][y][x]; r = springs[2][y][x + 1]; e = springs[1][y][x]; f = springs[3][y][x]; if (t && b && l && r && e && f) continue; if (t && r && e) continue; if (b && l && e) continue; if (t && l && f) continue; if (b && r && f) continue; if (t) { c = shipsels[y][x].getColor(); pos = shipsels[y][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.9); c = shipsels[y][x + 1].getColor(); pos = shipsels[y][x + 1].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.9); } if (l) { c = shipsels[y][x].getColor(); pos = shipsels[y][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.9); c = shipsels[y + 1][x].getColor(); pos = shipsels[y + 1][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.9); } if (e) { c = shipsels[y][x].getColor(); pos = shipsels[y][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.9); c = shipsels[y + 1][x + 1].getColor(); pos = shipsels[y + 1][x + 1].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.9); } if (f) { c = shipsels[y][x + 1].getColor(); pos = shipsels[y][x + 1].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.9); c = shipsels[y + 1][x].getColor(); pos = shipsels[y + 1][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.9); } } } GL11.glEnd(); GL11.glBegin(GL11.GL_TRIANGLES); for (int y = 0; y < springs[1].length; y++) { for (int x = 0; x < springs[1][y].length; x++) { t = springs[0][y][x]; b = springs[0][y + 1][x]; l = springs[2][y][x]; r = springs[2][y][x + 1]; e = springs[1][y][x]; f = springs[3][y][x]; if (t && b && l && r && e && f) { c = shipsels[y][x].getColor(); pos = shipsels[y][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y][x + 1].getColor(); pos = shipsels[y][x + 1].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y + 1][x].getColor(); pos = shipsels[y + 1][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y][x + 1].getColor(); pos = shipsels[y][x + 1].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y + 1][x].getColor(); pos = shipsels[y + 1][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y + 1][x + 1].getColor(); pos = shipsels[y + 1][x + 1].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); } else { if (t && r && e) { c = shipsels[y][x].getColor(); pos = shipsels[y][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y][x + 1].getColor(); pos = shipsels[y][x + 1].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y + 1][x + 1].getColor(); pos = shipsels[y + 1][x + 1].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); } if (b && l && e) { c = shipsels[y][x].getColor(); pos = shipsels[y][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y + 1][x].getColor(); pos = shipsels[y + 1][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y + 1][x + 1].getColor(); pos = shipsels[y + 1][x + 1].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); } if (t && l && f) { c = shipsels[y][x].getColor(); pos = shipsels[y][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y][x + 1].getColor(); pos = shipsels[y][x + 1].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y + 1][x].getColor(); pos = shipsels[y + 1][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); } if (b && r && f) { c = shipsels[y + 1][x].getColor(); pos = shipsels[y + 1][x].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y + 1][x + 1].getColor(); pos = shipsels[y + 1][x + 1].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); c = shipsels[y][x + 1].getColor(); pos = shipsels[y][x + 1].getPos(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1); } } } } GL11.glEnd(); GL11.glLineWidth(1); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_DEPTH_TEST); }
From source file:de.sanandrew.mods.turretmod.client.render.tileentity.RenderItemTransmitter.java
License:Creative Commons License
private static void renderTooltipRod(Tessellator tessellator, float size) { GL11.glDisable(GL11.GL_TEXTURE_2D);/* w ww .j ava 2 s. c o m*/ GL11.glLineWidth(10.0F); tessellator.startDrawing(GL11.GL_LINES); tessellator.setColorOpaque_I(0x001E10); tessellator.addVertex(0.0D, 0.5D * size + 0.635D, -0.01D); tessellator.addVertex(0.0D, 0.635D, -0.01D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); }
From source file:eu.over9000.veya.Veya.java
License:Open Source License
private static void init() throws LWJGLException { final Canvas canvas = new Canvas(); frame = new Frame(); frame.add(canvas);//from w w w.jav a 2 s . com frame.setSize(1280, 720); frame.setLocationByPlatform(true); frame.setVisible(true); frame.setExtendedState(Frame.MAXIMIZED_BOTH); frame.setIconImage(loadIcon()); Display.setParent(canvas); Display.create(new PixelFormat().withSamples(4).withDepthBits(24), new ContextAttribs(3, 3)); System.out.println("OpenGL version: " + GL11.glGetString(GL11.GL_VERSION)); System.out.println("Java version: " + System.getProperty("java.version")); System.out.println("graphics adapter: " + Display.getAdapter()); Veya.program_normal = new Program("normal", new String[] { "modelMatrix", "viewMatrix", "projectionMatrix", "lightPosition", "lightColor", "lightFactors", "colorSwitch", "aoSwitch", "cameraPosition", "lightSpaceMatrix", "textureData", "shadowMap" }); Veya.program_shadow = new Program("shadow", new String[] { "modelMatrix", "lightSpaceMatrix" }); Veya.program_debug = new Program("debug", new String[] { "near_plane", "far_plane" }); Util.checkGLError(); Veya.camera = new Camera(-40, 120, -40); Veya.scene = new Scene(1337); Util.checkGLError(); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glLineWidth(2.5f); Util.checkGLError(); GL11.glEnable(GL31.GL_PRIMITIVE_RESTART); GL31.glPrimitiveRestartIndex(Veya.RESTART); GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight()); GL11.glClearColor(124f / 255f, 169f / 255f, 255f / 255f, 1.0f); Mouse.setGrabbed(true); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); Console.start(); }