com.jogamp.opengl.glu.GLU Java Examples
The following examples show how to use
com.jogamp.opengl.glu.GLU.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ViewportEntity.java From Robot-Overlord-App with GNU General Public License v2.0 | 6 votes |
public void renderPick(GL2 gl2,double pickX,double pickY) { gl2.glMatrixMode(GL2.GL_PROJECTION); gl2.glLoadIdentity(); // get the current viewport dimensions to set up the projection matrix int[] viewportDimensions = new int[4]; gl2.glGetIntegerv(GL2.GL_VIEWPORT,viewportDimensions,0); GLU glu = GLU.createGLU(gl2); // Set up a tiny viewport that only covers the area behind the cursor. // Tiny viewports are faster. glu.gluPickMatrix(pickX, canvasHeight-pickY, 5.0, 5.0, viewportDimensions,0); if(drawOrtho.get()) { renderOrtho(gl2); } else { renderPerspective(gl2); } renderShared(gl2); }
Example #2
Source File: CubeSample2.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
public CubeSample2() { GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2)); glu = new GLU(); glWindow = GLWindow.create(caps); glWindow.setTitle("Cube demo (Newt)"); glWindow.setSize(300, 300); glWindow.addGLEventListener(this); glWindow.addWindowListener(new WindowAdapter() { @Override public void windowDestroyed(WindowEvent arg0) { System.exit(0); } }); glWindow.addMouseListener(this); glWindow.addKeyListener(this); //animator = new FPSAnimator(30); animator = new FPSAnimator(glWindow, 30, false); animator.add(glWindow); animator.start(); animator.pause(); glWindow.setVisible(true); }
Example #3
Source File: JOGLOffscreenRenderer.java From cineast with MIT License | 6 votes |
/** * Default constructor. Defines the width and the height of this JOGLOffscreenRenderer and * initializes all the required OpenGL bindings. * * @param width Width in pixels. * @param height Height in pixels. */ public JOGLOffscreenRenderer(int width, int height) { /* Assign width and height. */ this.width = width; this.height = height; this.aspect = (float) width / (float) height; /* Initialize GLOffscreenAutoDrawable. */ GLDrawableFactory factory = GLDrawableFactory.getFactory(GL_PROFILE); this.drawable = factory.createOffscreenAutoDrawable(null, GL_CAPABILITIES,null,width,height); this.drawable.display(); /* Initialize GLU and GL2. */ this.glu = new GLU(); this.gl = drawable.getGL().getGL2(); /* Set default color. */ gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); }
Example #4
Source File: OneTriangle.java From clearvolume with GNU Lesser General Public License v3.0 | 6 votes |
protected static void setup(GL pGL, int width, int height) { pGL.getGL2().glMatrixMode(GLMatrixFunc.GL_PROJECTION); pGL.getGL2().glLoadIdentity(); // coordinate system origin at lower left with width and height same as // the // window final GLU glu = new GLU(); glu.gluOrtho2D(0.0f, width, 0.0f, height); pGL.getGL2().glMatrixMode(GLMatrixFunc.GL_MODELVIEW); pGL.getGL2().glLoadIdentity(); pGL.glViewport(0, 0, width, height); }
Example #5
Source File: SimpleTess.java From jaamsim with Apache License 2.0 | 6 votes |
public List<Vec4d> tesselate(List<? extends Vec3d> outline) { reset(); GLU.gluTessBeginPolygon(gluTess, null); GLU.gluTessNormal(gluTess, 0, 0, 1); GLU.gluTessBeginContour(gluTess); for (Vec3d v: outline) { double[] ps = new double[3]; ps[0] = v.x; ps[1] = v.y; ps[2] = v.z; GLU.gluTessVertex(gluTess, ps, 0, ps); } GLU.gluTessEndContour(gluTess); GLU.gluTessEndPolygon(gluTess); List<Vec4d> ret = verts; verts = null; return ret; }
Example #6
Source File: OpenGL.java From gama with GNU General Public License v3.0 | 6 votes |
public OpenGL(final IOpenGLRenderer renderer) { super(renderer); glut = new GLUT(); glu = new GLU(); pickingState = renderer.getPickingHelper(); geometryCache = new GeometryCache(renderer); glTesselatorDrawer = (final double[] ordinates) -> { tobj.gluTessVertex(ordinates, 0, ordinates); }; GLU.gluTessCallback(tobj, GLU.GLU_TESS_VERTEX, this); GLU.gluTessCallback(tobj, GLU.GLU_TESS_BEGIN, this); GLU.gluTessCallback(tobj, GLU.GLU_TESS_END, this); GLU.gluTessProperty(tobj, GLU.GLU_TESS_TOLERANCE, 0.1); geometryDrawer = new GeometryDrawer(this); fieldDrawer = new FieldDrawer(this); stringDrawer = new StringDrawer(this); resourceDrawer = new ResourceDrawer(this); }
Example #7
Source File: OneTriangle.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
protected static void setup( GL2 gl2, int width, int height ) { gl2.glMatrixMode( GL2.GL_PROJECTION ); gl2.glLoadIdentity(); // coordinate system origin at lower left with width and height same as the window GLU glu = new GLU(); glu.gluOrtho2D( 0.0f, width, 0.0f, height ); gl2.glMatrixMode( GL2.GL_MODELVIEW ); gl2.glLoadIdentity(); gl2.glViewport( 0, 0, width, height ); }
Example #8
Source File: PickingHelper.java From gama with GNU General Public License v3.0 | 5 votes |
/** * First pass prepare select buffer for select mode by clearing it, prepare openGL to select mode and tell it where * should draw object by using gluPickMatrix() method * * @return if returned value is true that mean the picking is enabled */ public void beginPicking() { final GL2 gl = getGL(); final OpenGL openGL = getOpenGL(); final CameraHelper camera = getRenderer().getCameraHelper(); final GLU glu = GLU.createGLU(); // 1. Selecting buffer selectBuffer.clear(); // prepare buffer for new objects gl.glSelectBuffer(selectBuffer.capacity(), selectBuffer); // Pass below is very similar to refresh method in GLrenderer // 2. Take the viewport attributes, final int viewport[] = new int[4]; gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0); // 3. Prepare openGL for rendering in select mode gl.glRenderMode(GL2.GL_SELECT); /* * The application must redefine the viewing volume so that it renders only a small area around the place where * the mouse was clicked. In order to do that it is necessary to set the matrix mode to GL_PROJECTION. * Afterwards, the application should push the current matrix to save the normal rendering mode settings. Next * initialise the matrix */ openGL.pushIdentity(GL2.GL_PROJECTION); /* * Define the viewing volume so that rendering is done only in a small area around the cursor. gluPickMatrix * method restrict the area where openGL will drawing objects * */ glu.gluPickMatrix(camera.getMousePosition().x, viewport[3] - camera.getMousePosition().y, 4, 4, viewport, 0); // JOGLRenderer r = getRenderer(); // FIXME Why do we have to call updatePerspective() here ? openGL.updatePerspective(); openGL.matrixMode(GL2.GL_MODELVIEW); }
Example #9
Source File: SimpleTess.java From jaamsim with Apache License 2.0 | 5 votes |
public void init() { gluTess = GLU.gluNewTess(); GLU.gluTessCallback(gluTess, GLU.GLU_TESS_VERTEX, this); GLU.gluTessCallback(gluTess, GLU.GLU_TESS_BEGIN, this); GLU.gluTessCallback(gluTess, GLU.GLU_TESS_END, this); GLU.gluTessCallback(gluTess, GLU.GLU_TESS_COMBINE, this); GLU.gluTessCallback(gluTess, GLU.GLU_TESS_ERROR, this); GLU.gluTessProperty(gluTess, GLU.GLU_TESS_WINDING_RULE, GLU.GLU_TESS_WINDING_NONZERO); }
Example #10
Source File: AbstractCamera.java From gama with GNU General Public License v3.0 | 4 votes |
public AbstractCamera(final IOpenGLRenderer renderer2) { this.renderer = renderer2; setUpVector(0.0, 1.0, 0.0); glu = new GLU(); }
Example #11
Source File: TessFont.java From jaamsim with Apache License 2.0 | 4 votes |
private TessOutput tesselateString(String s) { GlyphVector gv = _font.createGlyphVector(_frc, s); Shape shape = gv.getOutline(); // AffineTransform at = new AffineTransform(); at.scale(1, -1); PathIterator pIt = shape.getPathIterator(at, _font.getSize()/200.0); // Create a GLU tesselator GLUtessellator tess = GLU.gluNewTess(); CharTesselator tessAdapt = new CharTesselator(); GLU.gluTessCallback(tess, GLU.GLU_TESS_VERTEX, tessAdapt); GLU.gluTessCallback(tess, GLU.GLU_TESS_BEGIN, tessAdapt); GLU.gluTessCallback(tess, GLU.GLU_TESS_END, tessAdapt); GLU.gluTessCallback(tess, GLU.GLU_TESS_COMBINE, tessAdapt); GLU.gluTessCallback(tess, GLU.GLU_TESS_ERROR, tessAdapt); int winding = pIt.getWindingRule(); if (winding == PathIterator.WIND_EVEN_ODD) GLU.gluTessProperty(tess, GLU.GLU_TESS_WINDING_RULE, GLU.GLU_TESS_WINDING_ODD); else if (winding == PathIterator.WIND_NON_ZERO) GLU.gluTessProperty(tess, GLU.GLU_TESS_WINDING_RULE, GLU.GLU_TESS_WINDING_NONZERO); else assert(false); // PathIterator should only return these two winding rules GLU.gluBeginPolygon(tess); GLU.gluTessNormal(tess, 0, 0, 1); double[] first = null; double[] v; while (!pIt.isDone()) { v = new double[3]; int type = pIt.currentSegment(v); v[2] = 0.0; if (type == PathIterator.SEG_MOVETO) { first = v; GLU.gluNextContour(tess, GLU.GLU_UNKNOWN); GLU.gluTessVertex(tess, v, 0, v); } else if (type == PathIterator.SEG_LINETO) { GLU.gluTessVertex(tess, v, 0, v); } else if (type == PathIterator.SEG_CLOSE) { assert(first != null); // If this is true, there is an error in the AWT path iterator GLU.gluTessVertex(tess, first, 0, first); first = null; } else { assert(false); // The path itertor should not return other path types here } pIt.next(); } GLU.gluEndPolygon(tess); int numVerts = tessAdapt.getVerts().size(); double[] verts = new double[numVerts]; int count = 0; for (double d : tessAdapt.getVerts()) { verts[count++] = d; } TessOutput ret = new TessOutput(); ret.verts = verts; ret.bounds = gv.getVisualBounds(); ret.advances = new double[s.length()]; for (int i = 0; i < s.length(); ++i) { ret.advances[i] = gv.getGlyphMetrics(i).getAdvance(); } return ret; }
Example #12
Source File: TessFont.java From jaamsim with Apache License 2.0 | 4 votes |
@Override public void error(int errNum) { @SuppressWarnings("unused") String errorString = GLU.createGLU().gluErrorString(errNum); assert(false); // TODO: Handle this properly? }
Example #13
Source File: SimpleTess.java From jaamsim with Apache License 2.0 | 4 votes |
@Override public void error(int errNum) { @SuppressWarnings("unused") String errorString = GLU.createGLU().gluErrorString(errNum); assert(false); // TODO: Handle this properly? }
Example #14
Source File: Plot3DGL.java From MeteoInfo with GNU Lesser General Public License v3.0 | 4 votes |
public tessellCallBack(GL2 gl, GLU glu) { this.gl = gl; this.glu = glu; }
Example #15
Source File: Tessellation.java From MeteoInfo with GNU Lesser General Public License v3.0 | 4 votes |
public tessellCallBack(GL2 gl, GLU glu) { this.gl = gl; this.glu = glu; }
Example #16
Source File: Tessellation.java From MeteoInfo with GNU Lesser General Public License v3.0 | 4 votes |
public void display(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); gl.glClear(GL2.GL_COLOR_BUFFER_BIT); gl.glColor3f(1.0f, 1.0f, 1.0f); /* * jogl specific addition for tessellation */ tessellCallBack tessCallback = new tessellCallBack(gl, glu); double rect[][] = new double[][]{ // [4][3] in C; reverse here {50.0, 50.0, 0.0}, {200.0, 50.0, 0.0}, {200.0, 200.0, 0.0}, {50.0, 200.0, 0.0}}; double tri[][] = new double[][]{// [3][3] {75.0, 75.0, 0.0}, {125.0, 175.0, 0.0}, {175.0, 75.0, 0.0}}; double star[][] = new double[][]{// [5][6]; 6x5 in java {250.0, 50.0, 0.0, 1.0, 0.0, 1.0}, {325.0, 200.0, 0.0, 1.0, 1.0, 0.0}, {400.0, 50.0, 0.0, 0.0, 1.0, 1.0}, {250.0, 150.0, 0.0, 1.0, 0.0, 0.0}, {400.0, 150.0, 0.0, 0.0, 1.0, 0.0}}; gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); startList = gl.glGenLists(2); GLUtessellator tobj = glu.gluNewTess(); glu.gluTessCallback(tobj, GLU.GLU_TESS_VERTEX, tessCallback);// glVertex3dv); glu.gluTessCallback(tobj, GLU.GLU_TESS_BEGIN, tessCallback);// beginCallback); glu.gluTessCallback(tobj, GLU.GLU_TESS_END, tessCallback);// endCallback); glu.gluTessCallback(tobj, GLU.GLU_TESS_ERROR, tessCallback);// errorCallback); /* rectangle with triangular hole inside */ gl.glNewList(startList, GL2.GL_COMPILE); gl.glShadeModel(GL2.GL_FLAT); glu.gluTessBeginPolygon(tobj, null); glu.gluTessBeginContour(tobj); glu.gluTessVertex(tobj, rect[0], 0, rect[0]); glu.gluTessVertex(tobj, rect[1], 0, rect[1]); glu.gluTessVertex(tobj, rect[2], 0, rect[2]); glu.gluTessVertex(tobj, rect[3], 0, rect[3]); glu.gluTessEndContour(tobj); glu.gluTessBeginContour(tobj); glu.gluTessVertex(tobj, tri[0], 0, tri[0]); glu.gluTessVertex(tobj, tri[1], 0, tri[1]); glu.gluTessVertex(tobj, tri[2], 0, tri[2]); glu.gluTessEndContour(tobj); glu.gluTessEndPolygon(tobj); gl.glEndList(); glu.gluTessCallback(tobj, GLU.GLU_TESS_VERTEX, tessCallback);// vertexCallback); glu.gluTessCallback(tobj, GLU.GLU_TESS_BEGIN, tessCallback);// beginCallback); glu.gluTessCallback(tobj, GLU.GLU_TESS_END, tessCallback);// endCallback); glu.gluTessCallback(tobj, GLU.GLU_TESS_ERROR, tessCallback);// errorCallback); glu.gluTessCallback(tobj, GLU.GLU_TESS_COMBINE, tessCallback);// combineCallback); /* smooth shaded, self-intersecting star */ gl.glNewList(startList + 1, GL2.GL_COMPILE); gl.glShadeModel(GL2.GL_SMOOTH); glu.gluTessProperty(tobj, // GLU.GLU_TESS_WINDING_RULE, // GLU.GLU_TESS_WINDING_POSITIVE); glu.gluTessBeginPolygon(tobj, null); glu.gluTessBeginContour(tobj); glu.gluTessVertex(tobj, star[0], 0, star[0]); glu.gluTessVertex(tobj, star[1], 0, star[1]); glu.gluTessVertex(tobj, star[2], 0, star[2]); glu.gluTessVertex(tobj, star[3], 0, star[3]); glu.gluTessVertex(tobj, star[4], 0, star[4]); glu.gluTessEndContour(tobj); glu.gluTessEndPolygon(tobj); gl.glEndList(); glu.gluDeleteTess(tobj); gl.glCallList(startList); gl.glCallList(startList + 1); gl.glFlush(); }
Example #17
Source File: Tessellation.java From MeteoInfo with GNU Lesser General Public License v3.0 | 4 votes |
public void init(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); glu = new GLU(); }