List of usage examples for org.lwjgl.opengl GL11 glEnd
public static native void glEnd();
From source file:fr.def.iss.vd2.lib_v3d.element.V3DTube.java
License:Open Source License
@Override protected void doDisplay(I3dCamera camera) { if (renderMode == RenderMode.PLAIN) { GL11.glEnable(GL11.GL_LIGHTING); GL11.glBegin(GL11.GL_QUADS);/* ww w . j a v a2 s. c om*/ for (int i = 0; i < pointList.size(); i++) { if (i == 0) { drawQuad(pointList.get(pointList.size() - 1), pointList.get(i)); } else { drawQuad(pointList.get(i - 1), pointList.get(i)); } } GL11.glEnd(); GL11.glDisable(GL11.GL_LIGHTING); } if (renderMode == RenderMode.SOLID) { GL11.glLineWidth(thickness); GL11.glBegin(GL11.GL_LINES); for (V3DVect3 point : pointList) { float z0 = -height / 2; float z1 = height / 2; GL11.glVertex3d(point.x, point.y, z1); GL11.glVertex3d(point.x, point.y, z0); } GL11.glEnd(); } /* Dessine des normales sur les sommets en gradients de couleurs GL11.glLineWidth(thickness); GL11.glEnable(GL11.GL_LINE_STIPPLE); GL11.GLLineStipple(1, (short) 0xFFFF); GL11.glPushAttrib(GL11.GL_COLOR); GL11.glBegin(GL11.GL_LINES); for (int i = 0; i < pointList.size(); i++) { drawNorm( pointList.get(i), radius * 0.6f); } GL11.glPopAttrib(); GL11.glEnd(); GL11.glDisable(GL11.GL_LINE_STIPPLE); */ }
From source file:fr.def.iss.vd2.lib_v3d.V3DCanvas.java
License:Open Source License
/** * The only method that you should implement by yourself. * * @see javax.media.openGL11.GLEventListener#display(javax.media.openGL11.GLAutoDrawable) *//*www .j av a 2 s. c o m*/ public void display() { GL11.glClear(GL11.GL_ACCUM_BUFFER_BIT); for (V3DCameraBinding binding : cameraList) { GL11.glViewport(binding.x, binding.y, binding.width, binding.height); //Clean Background I3dColor color = binding.camera.getBackgroundColor(); GL11.glClearColor(color.r, color.g, color.b, color.a); GL11.glScissor(binding.x, binding.y, binding.width, binding.height); GL11.glEnable(GL11.GL_SCISSOR_TEST); if (color.a == 1.0f) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); } else { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glOrtho(0, binding.width, 0, binding.height, -2000.0, 2000.0); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glColor4f(color.r, color.g, color.b, color.a); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex3f(0, 0, 0); GL11.glVertex3f(binding.width, 0, 0); GL11.glVertex3f(binding.width, binding.height, 0); GL11.glVertex3f(0, binding.height, 0); GL11.glEnd(); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); } GL11.glDisable(GL11.GL_SCISSOR_TEST); binding.camera.display(binding.width, binding.height); GL11.glDisable(GL11.GL_DEPTH_TEST); // binding.getGui().display(); GL11.glEnable(GL11.GL_DEPTH_TEST); if (select && binding == focusCamera) { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); //glu.gluPerspective(45.0f, h, 0.1, 2000.0); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); binding.camera.select(mouseX, mouseY); context.setMouseOverCameraBinding(binding); } } GL11.glFlush(); select = false; }
From source file:fr.def.iss.vd2.lib_v3d.v3draw.V3DrawReader.java
License:Open Source License
private void draw2dLineStripList() { int lineCount = buffer.getInt(); for (int lineIndex = 0; lineIndex < lineCount; lineIndex++) { int lineLenght = buffer.getInt(); GL11.glBegin(GL11.GL_LINE_STRIP); // Draw line for (int j = 0; j < lineLenght; j++) { GL11.glVertex3f(buffer.getFloat(), buffer.getFloat(), 0.0f); }/* w w w . j a v a2 s. c om*/ GL11.glEnd(); } }
From source file:fr.def.iss.vd2.lib_v3d.v3draw.V3DrawReader.java
License:Open Source License
private void draw3dQuadList() { int quadCount = buffer.getInt(); GL11.glBegin(GL11.GL_QUADS);// w w w . j a v a 2 s .c o m for (int quadIndex = 0; quadIndex < quadCount; quadIndex++) { for (int i = 0; i < 4; i++) { GL11.glTexCoord2f(buffer.getFloat(), buffer.getFloat()); GL11.glNormal3f(buffer.getFloat(), buffer.getFloat(), buffer.getFloat()); GL11.glVertex3f(buffer.getFloat(), buffer.getFloat(), buffer.getFloat()); } } GL11.glEnd(); }
From source file:fr.def.iss.vd2.lib_v3d.v3draw.V3DrawReader.java
License:Open Source License
private void draw3dTriangleList() { int triangleCount = buffer.getInt(); GL11.glBegin(GL11.GL_TRIANGLES);//from w w w . j a v a 2 s . com for (int triangleIndex = 0; triangleIndex < triangleCount; triangleIndex++) { for (int i = 0; i < 3; i++) { GL11.glTexCoord2f(buffer.getFloat(), buffer.getFloat()); GL11.glNormal3f(buffer.getFloat(), buffer.getFloat(), buffer.getFloat()); GL11.glVertex3f(buffer.getFloat(), buffer.getFloat(), buffer.getFloat()); } } GL11.glEnd(); }
From source file:fr.def.iss.vd2.lib_v3d.v3draw.V3DrawReader.java
License:Open Source License
private void draw3dPolygonList() { int polygonCount = buffer.getInt(); for (int polygonIndex = 0; polygonIndex < polygonCount; polygonIndex++) { GL11.glBegin(GL11.GL_POLYGON);//from ww w . j av a 2 s . c o m int vertexCount = buffer.getInt(); for (int i = 0; i < vertexCount; i++) { GL11.glTexCoord2f(buffer.getFloat(), buffer.getFloat()); GL11.glNormal3f(buffer.getFloat(), buffer.getFloat(), buffer.getFloat()); GL11.glVertex3f(buffer.getFloat(), buffer.getFloat(), buffer.getFloat()); } GL11.glEnd(); } }
From source file:fr.def.iss.vd2.lib_v3d.v3draw.V3DrawReader.java
License:Open Source License
private void drawRegistrated3dConcavePolygon() { int polygonIndex = buffer.getInt(); Tesselation tesselation = concavePolygonList.get(polygonIndex); List<Integer> vertexTypeList = tesselation.getVertexTypeList(); for (int i = 0; i < vertexTypeList.size(); i++) { List<V3DrawVertex> vertexList = tesselation.getVertexListList().get(i); GL11.glBegin(vertexTypeList.get(i)); for (V3DrawVertex vertex : vertexList) { GL11.glTexCoord2f(vertex.texture.x, vertex.texture.y); GL11.glNormal3f(vertex.normal.x, vertex.normal.y, vertex.normal.z); GL11.glVertex3f(vertex.position.x, vertex.position.y, vertex.position.z); }//from ww w .j a v a2 s . co m GL11.glEnd(); } }
From source file:fr.ign.cogit.geoxygene.appli.render.primitive.LinePrimitiveRenderer.java
License:Open Source License
/** * Render simple line./*from ww w . j a va 2s .com*/ * @param primitive primitive to paint */ private void renderLine(final ParameterizedPolyline line) { if (line.getPointCount() < 2) { logger.warn("Line has " + line.getPointCount() + " points and cannot be rendered"); return; } this.texture.initializeRendering(); this.texture.setRange(0., 0, line.getParameter(line.getPointCount() - 1), 1); // System.err.println("set range to " + this.texture.getMinX() + "x" + this.texture.getMinY() + " - " + this.texture.getMaxX() + "x" // + this.texture.getMaxY()); /** * p1 is the nth point, n1 the segment normal at p1 point * p2 is the (n+1)th point, n2 the segment normal at p2 point * * pXa, pXb are the */ Point2d p1 = line.getPoint(0); // nth point double p1t = line.getParameter(0); Point2d p2 = line.getPoint(1); // n+1 th point double p2t = line.getParameter(1); Point2d p3 = null; // n+2 th point Vector2d v1 = MathUtil.vector(p1, p2); // line direction at p1 Vector2d v2 = null; // line direction at p2 Vector2d n1 = MathUtil.computeNormal(v1); // line normal at p1 (perpendicular to segment direction) Vector2d n2 = null; // line normal at p2 (perpendicular to segment direction) Point2d p1a = MathUtil.pointOfLine(p1, n1, -this.getLineWidth() / 2); // first stretched point at p1 (p1 + lineWidth/2 * n1) Point2d p1b = MathUtil.pointOfLine(p1, n1, this.getLineWidth() / 2); // second stretched point at p1 (p1 - lineWidth/2 * n1) Point2d p2a = null; // first stretched point at p2 (p2 + lineWidth/2 * n2) Point2d p2b = null; // second stretched point at p2 (p2 - lineWidth/2 * n2) if (line.getPointCount() <= 2) { p3 = p2; n2 = n1; } GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); GL11.glBegin(GL11.GL_QUAD_STRIP); try { GL11.glTexCoord2d(p1t, 0); GLTools.glTexCoord(this.texture.vertexCoordinates(p1t, 0)); GL11.glVertex2d(p1a.x, p1a.y); GLTools.glTexCoord(this.texture.vertexCoordinates(p1t, 1)); GL11.glVertex2d(p1b.x, p1b.y); // System.err.println("set first point coordinates = " + p1t + "x" + "0" + " => " + this.texture.vertexCoordinates(p1t, 0)); // System.err.println("set first point coordinates = " + p1t + "x" + "1" + " => " + this.texture.vertexCoordinates(p1t, 1)); for (int nPoint = 0; nPoint < line.getPointCount() - 2; nPoint++) { p3 = line.getPoint(nPoint + 2); v2 = MathUtil.vector(p2, p3); n2 = MathUtil.computeNormal(v2); p2a = MathUtil.pointOfLine(p2, n2, -this.getLineWidth() / 2); p2b = MathUtil.pointOfLine(p2, n2, this.getLineWidth() / 2); p2t = line.getParameter(nPoint); Point2d Ia = MathUtil.intersectionPoint(p1a, v1, p2a, v2); Point2d Ib = MathUtil.intersectionPoint(p1b, v1, p2b, v2); if (Ia == null || Ib == null) { Ia = MathUtil.mean(p1a, p2a); Ib = MathUtil.mean(p1b, p2b); } GLTools.glTexCoord(this.texture.vertexCoordinates(p2t, 0)); GL11.glVertex2d(Ia.x, Ia.y); GLTools.glTexCoord(this.texture.vertexCoordinates(p2t, 1)); GL11.glVertex2d(Ib.x, Ib.y); // System.err.println("set #" + nPoint + " point coordinates = " + p2t + "x" + "0" + " => " + this.texture.vertexCoordinates(p2t, 0)); // System.err.println("set #" + nPoint + " point coordinates = " + p2t + "x" + "1" + " => " + this.texture.vertexCoordinates(p2t, 1)); // shift context to the next point p1 = p2; p1t = p2t; n1 = n2; v1 = v2; p1a = Ia; p1b = Ib; p2 = p3; } // draw the last point Point2d p3a = MathUtil.pointOfLine(p3, n2, -this.getLineWidth() / 2); Point2d p3b = MathUtil.pointOfLine(p3, n2, this.getLineWidth() / 2); double p3t = line.getParameter(line.getPointCount() - 1); GLTools.glTexCoord(this.texture.vertexCoordinates(p3t, 0)); GL11.glVertex2d(p3a.x, p3a.y); GLTools.glTexCoord(this.texture.vertexCoordinates(p3t, 1)); GL11.glVertex2d(p3b.x, p3b.y); // System.err.println("set last point coordinates = " + p3t + "x" + "0" + " => " + this.texture.vertexCoordinates(p3t, 0)); // System.err.println("set last point coordinates = " + p3t + "x" + "1" + " => " + this.texture.vertexCoordinates(p3t, 1)); } finally { GL11.glEnd(); } this.texture.initializeRendering(); }
From source file:fr.ign.cogit.geoxygene.appli.render.primitive.LinePrimitiveRenderer.java
License:Open Source License
/** * Render simple line.// ww w. j a va 2 s . c o m * @param primitive primitive to paint */ private void renderLineDebug(final ParameterizedPolyline line) { if (line.getPointCount() < 2) { logger.warn("Line has " + line.getPointCount() + " points and cannot be rendered"); return; } final double epsilon = 1E-1; /** * p1 is the nth point, n1 the segment normal at p1 point * p2 is the (n+1)th point, n2 the segment normal at p2 point * * pXa, pXb are the */ Point2d p1 = line.getPoint(0); // nth point Point2d p2 = line.getPoint(1); // n+1 th point Point2d p3 = null; // n+2 th point Vector2d v1 = MathUtil.vector(p1, p2); // line direction at p1 Vector2d v2 = null; // line direction at p2 Vector2d n1 = MathUtil.computeNormal(v1); // line normal at p1 (perpendicular to segment direction) Vector2d n2 = null; // line normal at p2 (perpendicular to segment direction) Point2d p1a = MathUtil.pointOfLine(p1, n1, -this.getLineWidth() / 2); // first stretched point at p1 (p1 + lineWidth/2 * n1) Point2d p1b = MathUtil.pointOfLine(p1, n1, this.getLineWidth() / 2); // second stretched point at p1 (p1 - lineWidth/2 * n1) Point2d p2a = null; // first stretched point at p2 (p2 + lineWidth/2 * n2) Point2d p2b = null; // second stretched point at p2 (p2 - lineWidth/2 * n2) if (line.getPointCount() <= 2) { p3 = p2; n2 = n1; } double s = 1; GL11.glLineWidth(2.f); GL11.glBegin(GL11.GL_LINES); // first point GL11.glColor3d(1, 0, 0); GL11.glVertex2d(p1a.x, p1a.y); GL11.glVertex2d(p1b.x, p1b.y); try { for (int nPoint = 0; nPoint < line.getPointCount() - 2; nPoint++) { p3 = line.getPoint(nPoint + 2); v2 = MathUtil.vector(p2, p3); n2 = MathUtil.computeNormal(v2); p2a = MathUtil.pointOfLine(p2, n2, -this.getLineWidth() / 2); p2b = MathUtil.pointOfLine(p2, n2, this.getLineWidth() / 2); GL11.glColor3d(.5, .5, .5); GL11.glVertex2d(p1a.x, p1a.y); GL11.glVertex2d(p1b.x, p1b.y); /* GL11.glColor3d(.5, .5, .5); GL11.glVertex2d(p1.x, p1.y); GL11.glVertex2d(p1.x + s * v1.x, p1.y + s * v1.y); GL11.glColor3d(.5, .5, .5); GL11.glVertex2d(p1.x, p1.y); GL11.glVertex2d(p1.x + s * n1.x, p1.y + s * n1.y); */ Point2d Ia = MathUtil.intersectionPoint(p1a, v1, p2a, v2, epsilon); Point2d Ib = MathUtil.intersectionPoint(p1b, v1, p2b, v2, epsilon); // debug if (first && Ia != null && Ib != null && MathUtil.norm(MathUtil.vector(Ia, Ib)) > 100) { first = false; JDialog dialog = new JDialog(); GraphPanel graphPanel = new GraphPanel(); dialog.getContentPane().add(graphPanel); dialog.pack(); dialog.setVisible(true); graphPanel.addPoint("p1", p1); graphPanel.addPoint("p2", p2); graphPanel.addPoint("p3", p3); // graphPanel.addVector("n1", p1, n1); // graphPanel.addVector("n2", p2, n2); graphPanel.addVector("v1", p1, v1); graphPanel.addVector("v2", p1, v2); graphPanel.addVector(".", p1a, v1); graphPanel.addVector(",", p1b, v1); graphPanel.addVector("`", p2a, v2); graphPanel.addVector("'", p2b, v2); graphPanel.addPoint("p1a", p1a); graphPanel.addPoint("p1b", p1b); graphPanel.addPoint("p2a", p2a); graphPanel.addPoint("p2b", p2b); System.out.println("v1.v2 = " + MathUtil.cross(v1, v2)); // graphPanel.addPoint("Ia", Ia); // graphPanel.addPoint("Ib", Ib); System.out.println(nPoint + " on " + line.getPointCount() + " =>"); System.out.println(" p1 = " + p1); System.out.println(" p2 = " + p2); System.out.println(" p3 = " + p3); System.out.println(" n1 = " + n1); System.out.println(" n2 = " + n2); System.out.println(" v1 = " + v1); System.out.println(" v2 = " + v2); System.out.println(" p1a = " + p1a); System.out.println(" p1b = " + p1b); System.out.println(" p2a = " + p2a); System.out.println(" p2b = " + p2b); System.out.println(" Ia = " + Ia); System.out.println(" Ib = " + Ib); p3 = line.getPoint(nPoint + 2); v2 = MathUtil.vector(p2, p3); n2 = MathUtil.computeNormal(v2); p2a = MathUtil.pointOfLine(p2, n2, -this.getLineWidth() / 2); p2b = MathUtil.pointOfLine(p2, n2, this.getLineWidth() / 2); Ia = MathUtil.intersectionPoint(p1a, v1, p2a, v2, epsilon); Ib = MathUtil.intersectionPoint(p1b, v1, p2b, v2, epsilon); } if (Ia == null || Ib == null) { Ia = MathUtil.mean(p1a, p2a); Ib = MathUtil.mean(p1b, p2b); } // if no intersection, use p2a & p2b if (Ia == null) { GL11.glColor3d(.5, .5, .5); GL11.glVertex2d(p2a.x, p2b.y); } else { GL11.glColor3d(0, 0, 1); GL11.glVertex2d(Ia.x, Ia.y); } if (Ib == null) { GL11.glColor3d(.5, .5, .5); GL11.glVertex2d(p2b.x, p2b.y); } else { GL11.glColor3d(0, 1, 0); GL11.glVertex2d(Ib.x, Ib.y); } // shift context to the next point p1 = p2; n1 = n2; v1 = v2; p1a = p2a; p1b = p2b; p2 = p3; } if (p3 == null || n2 == null) { System.err.println("p3 = " + p3 + " n2 = " + n2 + " nbpt = " + line.getPointCount()); } // draw the last point Point2d p3a = MathUtil.pointOfLine(p3, n2, -this.getLineWidth() / 2); Point2d p3b = MathUtil.pointOfLine(p3, n2, this.getLineWidth() / 2); GL11.glColor3d(1, 1, 0); GL11.glVertex2d(p3a.x, p3a.y); GL11.glVertex2d(p3b.x, p3b.y); } finally { GL11.glEnd(); } }
From source file:fr.ign.cogit.geoxygene.appli.render.RenderGL11Util.java
License:Open Source License
/** * Draw a shape polygon using open GL. It can either fill the polygon or * display only// w w w . j a va 2 s . c o m * the edges. No tesselation is done when filling, so the shape has to be * simple and convex * * @param shape * Java2D shape to paint * @param close * automatically close the polygon between start and end point * @param fill * if true fills the polygon with current color. if false, draw * only edges */ private static void glDrawRawShape(final Shape shape, final boolean close, final boolean fill) { final int glDrawType = fill ? GL11.GL_POLYGON : close ? GL11.GL_LINE_LOOP : GL_LINE_STRIP; // final int glDrawType = GL11.GL_LINE_LOOP; // glLineWidth(5.f); boolean polygonStarted = false; PathIterator pathIterator = shape.getPathIterator(null); // System.err.print("polygon "); while (!pathIterator.isDone()) { float[] coords = new float[6]; int segmentType = pathIterator.currentSegment(coords); switch (segmentType) { case PathIterator.SEG_CLOSE: if (polygonStarted) { GL11.glEnd(); polygonStarted = false; } case PathIterator.SEG_MOVETO: if (polygonStarted) { GL11.glEnd(); // close the current polygon polygonStarted = false; } GL11.glBegin(glDrawType); // open a new one polygonStarted = true; GL11.glVertex2f(coords[0], coords[1]); // starting at the given position break; case PathIterator.SEG_CUBICTO: if (!polygonStarted) { GL11.glBegin(glDrawType); // start a new polygon if not already done polygonStarted = true; } GL11.glVertex2f(coords[4], coords[5]); break; case PathIterator.SEG_QUADTO: if (!polygonStarted) { GL11.glBegin(glDrawType); // start a new polygon if not already done polygonStarted = true; } GL11.glVertex2f(coords[2], coords[3]); break; case PathIterator.SEG_LINETO: if (!polygonStarted) { GL11.glBegin(glDrawType); // start a new polygon if not already done polygonStarted = true; } GL11.glVertex2f(coords[0], coords[1]); break; default: logger.warn("Draw GL shape do not know how to handle segment type " + segmentType); } // if (coords[0] != 0. || coords[1] != 0.) // System.err.print(" - " + coords[0] + "x" + coords[1]); pathIterator.next(); } if (polygonStarted) { GL11.glEnd(); polygonStarted = false; } }