/** @see OpenGLTab#renderScene() */ void renderScene() { GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); GL.glLoadIdentity(); GL.glTranslatef(xPos, yPos, zPos); GL.glRotatef(rotY, 0.0f, 1.0f, 0.0f); GL.glCallList(cubeListIndexBase); GL.glPushMatrix(); GL.glTranslatef(3, 0, -3); GL.glCallList(cubeListIndexBase); GL.glPopMatrix(); GL.glPushMatrix(); GL.glTranslatef(-3, 0, -3); GL.glCallList(cubeListIndexBase); GL.glPopMatrix(); GL.glPushMatrix(); GL.glTranslatef(0, 0, 4); GL.glCallList(cubeListIndexBase); GL.glPopMatrix(); rotY += 0.6f; }
public void display(GLAutoDrawable drawable) { GL gl = drawable.getGL(); synchronized (this._camera) { try { gl.glClear( GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // Clear the buffers for new frame. NyARGLDrawUtil.drawBackGround(gl, this._camera.getSourceImage(), 1.0); this._nyar.update(this._camera); if (this._nyar.isExistMarker(this.ids[0])) { gl.glMatrixMode(GL.GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadMatrixd(this._nyar.getGlMarkerMatrix(this.ids[0]), 0); NyARGLDrawUtil.drawColorCube(gl, 40); gl.glPopMatrix(); } if (this._nyar.isExistMarker(this.ids[1])) { gl.glMatrixMode(GL.GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadMatrixd(this._nyar.getGlMarkerMatrix(this.ids[1]), 0); NyARGLDrawUtil.drawColorCube(gl, 40); gl.glPopMatrix(); } Thread.sleep(1); } catch (Exception e) { e.printStackTrace(); } } }
public void render(VisCanvas vc, VisLayer layer, VisCanvas.RenderInfo rinfo, GL gl) { gl.glMatrixMode(GL.GL_PROJECTION); gl.glPushMatrix(); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glPushMatrix(); gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); gl.glMatrixMode(GL.GL_MODELVIEW); int viewport[] = rinfo.layerPositions.get(layer); double width = viewport[2]; double height = viewport[3]; switch (origin) { case BOTTOM_LEFT: // nothing to do. break; case LEFT: gl.glTranslated(0, height / 2, 0); break; case TOP_LEFT: gl.glTranslated(0, height, 0); break; case TOP: gl.glTranslated(width / 2, height, 0); break; case TOP_RIGHT: gl.glTranslated(width, height, 0); break; default: System.out.println("Unsupported Origin"); break; } vo.render(vc, layer, rinfo, gl); gl.glMatrixMode(GL.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glPopMatrix(); }
/** Draws circular particle using a display list. */ public void display(GL gl) { if (PARTICLE_DISPLAY_LIST < 0) { // MAKE DISPLAY LIST: int displayListIndex = gl.glGenLists(1); gl.glNewList(displayListIndex, GL.GL_COMPILE); drawParticle(gl, new Point3d(), radius); // /particle at origin gl.glEndList(); System.out.println("MADE LIST " + displayListIndex + " : " + gl.glIsList(displayListIndex)); PARTICLE_DISPLAY_LIST = displayListIndex; } // / COLOR: DEFAULT WHITE; GREEN IF HIGHLIGHTED; ADD RED IF PINNED Color3f c = new Color3f(1, 1, 1); // default: white if (pin) { c.x = 1f; // add red c.y *= 0.2f; c.z = 0; } if (highlight) { c.y = 1; c.z = 0; } if (GooParticle.class.isInstance(this)) { c.x = 0; c.y = 0; // now its blue } gl.glColor3f(c.x, c.y, c.z); // / DRAW ORIGIN-CIRCLE TRANSLATED TO "p": gl.glPushMatrix(); gl.glTranslated(x.x, x.y, x.z); gl.glCallList(PARTICLE_DISPLAY_LIST); gl.glPopMatrix(); }
public void render3D(GL gl, GLDrawable glc) { if (pts2d.size() < 4) return; if (fill != null || texture != null) { if (texture == null) { setColor(gl, fill); gl.glDisable(GL.GL_TEXTURE_2D); } else { setColor(gl, Color.white); Texture gltexture = texture.getTexture(glc); gltexture.enable(); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT); gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_MODULATE); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); gltexture.bind(); } gl.glPushMatrix(); // get 4 control points of portal Point2D p0 = pts2d.get(0); Point2D p1 = pts2d.get(1); Point2D p2 = pts2d.get(2); Point2D p3 = pts2d.get(3); // render 1st side of portal with height extra[0] renderOneside(p0, p1, gl, extra[0]); // render 1st side of portal with height extra[1] renderOneside(p2, p3, gl, extra[1]); gl.glPopMatrix(); } }
/** Draws a canonical circular particle. */ private static void drawParticle(GL gl, Point3d p, double r) { double radius = r; double vectorY1 = p.y; double vectorX1 = p.x; double vectorZ1 = p.z; GLU glu = new GLU(); GLUquadric quadratic = glu.gluNewQuadric(); glu.gluQuadricNormals(quadratic, GLU.GLU_SMOOTH); glu.gluQuadricTexture(quadratic, true); gl.glPushMatrix(); gl.glTranslated(p.x, p.y, p.z); glu.gluSphere(quadratic, radius, 12, 12); gl.glPopMatrix(); }
public void restoreGLMatrices() { gl.glMatrixMode(GL.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glPopMatrix(); }