Ejemplo n.º 1
0
 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();
     }
   }
 }
Ejemplo n.º 2
0
 public void init(GLAutoDrawable drawable) {
   GL gl = drawable.getGL();
   gl.glMatrixMode(GL.GL_PROJECTION);
   gl.glLoadMatrixd(this._nyar.getGlProjectionMatrix(), 0);
   gl.glEnable(GL.GL_DEPTH_TEST);
   gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
   Animator animator = new Animator(drawable);
   animator.start();
   return;
 }
Ejemplo n.º 3
0
  public synchronized void bind(GL gl) {
    combine();

    if (id < 0) id = VisUtil.allocateID();

    int b[] = blocks.get(0);

    // the back-end special cases VBO_TYPE_COLOR, and uses gltype = unsigned byte.
    gl.glColor(Color.white);

    gl.gldBind(GL.VBO_TYPE_COLOR, id, b.length, 4, b);
  }
Ejemplo n.º 4
0
  protected void setDepthFunc(DrawContext dc, OrderedIcon uIcon, Vec4 screenPoint) {
    GL gl = dc.getGL();

    if (uIcon.icon.isAlwaysOnTop()) {
      gl.glDepthFunc(GL.GL_ALWAYS);
      return;
    }

    Position eyePos = dc.getView().getEyePosition();
    if (eyePos == null) {
      gl.glDepthFunc(GL.GL_ALWAYS);
      return;
    }

    double altitude = eyePos.getElevation();
    if (altitude < (dc.getGlobe().getMaxElevation() * dc.getVerticalExaggeration())) {
      double depth = screenPoint.z - (8d * 0.00048875809d);
      depth = depth < 0d ? 0d : (depth > 1d ? 1d : depth);
      gl.glDepthFunc(GL.GL_LESS);
      gl.glDepthRange(depth, depth);
    } else if (uIcon.eyeDistance > uIcon.horizonDistance) {
      gl.glDepthFunc(GL.GL_EQUAL);
      gl.glDepthRange(1d, 1d);
    } else {
      gl.glDepthFunc(GL.GL_ALWAYS);
    }
  }
Ejemplo n.º 5
0
  public void display(GLAutoDrawable drawable) {
    GL gl = drawable.getGL();

    gl.glClear(GL.GL_COLOR_BUFFER_BIT);

    gl.glRasterPos2i(1, 1);
    gl.glDrawPixels(
        dim.width,
        dim.height, //
        GL.GL_RGB,
        GL.GL_UNSIGNED_BYTE,
        pixels);

    gl.glFlush();
  }
Ejemplo n.º 6
0
  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();
    }
  }
Ejemplo n.º 7
0
  public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
    GL gl = drawable.getGL();

    gl.glViewport(0, 0, w, h);
    gl.glMatrixMode(GL.GL_PROJECTION);
    gl.glLoadIdentity();
    gl.glOrtho(0, w, 0, h, -1.0, 1.0);
    gl.glMatrixMode(GL.GL_MODELVIEW);
  }
Ejemplo n.º 8
0
  public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {

    _gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
    _gl.glViewport(0, 0, width, height);

    // 視体積の設定
    _gl.glMatrixMode(GL.GL_PROJECTION);
    _gl.glLoadIdentity();
    // 見る位置
    _gl.glMatrixMode(GL.GL_MODELVIEW);
    _gl.glLoadIdentity();
  }
Ejemplo n.º 9
0
  public void glInit(GeometryViewer viewer, GL gl, GLU glu) {
    surface = getNewSurface();

    float mat_diffuse[] = {0.7f, 0.7f, 0.7f, 1.0f};
    float mat_specular[] = {1.0f, 1.0f, 1.0f, 1.0f};
    float mat_shininess[] = {100.0f};

    gl.material(FRONT, DIFFUSE, mat_diffuse);
    gl.material(FRONT, SPECULAR, mat_specular);
    gl.material(FRONT, SHININESS, mat_shininess);

    gl.enable(LIGHTING);
    gl.enable(LIGHT0);
    gl.enable(DEPTH_TEST);
    gl.enable(AUTO_NORMAL);
    gl.enable(NORMALIZE);

    initSurface();

    surface.nurbsProperty(GLU_SAMPLING_TOLERANCE, 25.0f);
    surface.nurbsProperty(GLU_DISPLAY_MODE, GLU_FILL);
  }
Ejemplo n.º 10
0
  public void init(GLAutoDrawable drawable) {
    GL gl = drawable.getGL();

    float m[] = {
      0.0f, 1.0f, 0.0f, 0.0f, //
      0.0f, 0.0f, 1.0f, 0.0f, //
      1.0f, 0.0f, 0.0f, 0.0f, //
      0.0f, 0.0f, 0.0f, 1.0f
    };

    pixels = readImage("Data/leeds.bin", dim);
    System.out.println(pixels.toString());

    gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1);
    gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    gl.glMatrixMode(GL.GL_COLOR);
    gl.glLoadMatrixf(m, 0);
    gl.glMatrixMode(GL.GL_MODELVIEW);
  }
Ejemplo n.º 11
0
  public void paint(GeometryViewer viewer, GL gl, GLU glu) {
    float knots[] = {0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f};
    float flatControlPoints[];
    int i, j, k, flatCounter = 0;

    flatControlPoints = new float[4 * 4 * 3];
    for (i = 0; i < 4; i++)
      for (j = 0; j < 4; j++)
        for (k = 0; k < 3; k++) flatControlPoints[flatCounter++] = controlPoints[i][j][k];

    gl.pushMatrix();
    gl.rotate(330.0f, 1.f, 0.f, 0.f);
    gl.scale(0.5f, 0.5f, -0.5f);

    surface.beginSurface();
    surface.nurbsSurface(knots, knots, 4 * 3, 3, flatControlPoints, 4, 4, MAP2_VERTEX_3);
    surface.endSurface();

    if (showPoints == true) {
      gl.pointSize(5.0f);
      gl.disable(LIGHTING);
      gl.color(1.0f, 1.0f, 0.0f);
      gl.begin(POINTS);
      for (i = 0; i < 4; i++) {
        for (j = 0; j < 4; j++) {
          gl.vertex(controlPoints[i][j][0], controlPoints[i][j][1], controlPoints[i][j][2]);
        }
      }
      gl.end();
      gl.enable(LIGHTING);
    }
    gl.popMatrix();
  }
Ejemplo n.º 12
0
  public synchronized void unbind(GL gl) {
    int b[] = blocks.get(0);

    gl.gldUnbind(GL.VBO_TYPE_COLOR, id);
  }
Ejemplo n.º 13
0
 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
   GL gl = drawable.getGL();
   gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
   gl.glViewport(0, 0, width, height);
   return;
 }
    public void init(GLAutoDrawable glAutoDrawable) {
      StringBuilder sb = new StringBuilder();

      sb.append(gov.nasa.worldwind.Version.getVersion() + "\n");

      sb.append("\nSystem Properties\n");
      sb.append("Processors: " + Runtime.getRuntime().availableProcessors() + "\n");
      sb.append("Free memory: " + Runtime.getRuntime().freeMemory() + " bytes\n");
      sb.append("Max memory: " + Runtime.getRuntime().maxMemory() + " bytes\n");
      sb.append("Total memory: " + Runtime.getRuntime().totalMemory() + " bytes\n");

      for (Map.Entry prop : System.getProperties().entrySet()) {
        sb.append(prop.getKey() + " = " + prop.getValue() + "\n");
      }

      GL gl = glAutoDrawable.getGL();

      sb.append("\nOpenGL Values\n");

      String oglVersion = gl.glGetString(GL.GL_VERSION);
      sb.append("OpenGL version: " + oglVersion + "\n");

      String oglVendor = gl.glGetString(GL.GL_VENDOR);
      sb.append("OpenGL vendor: " + oglVendor + "\n");

      String oglRenderer = gl.glGetString(GL.GL_RENDERER);
      sb.append("OpenGL renderer: " + oglRenderer + "\n");

      int[] intVals = new int[2];
      for (Attr attr : attrs) {
        sb.append(attr.name).append(": ");

        if (attr.attr instanceof Integer) {
          gl.glGetIntegerv((Integer) attr.attr, intVals, 0);
          sb.append(intVals[0]).append(intVals[1] > 0 ? ", " + intVals[1] : "");
        }

        sb.append("\n");
      }

      String extensionString = gl.glGetString(GL.GL_EXTENSIONS);
      String[] extensions = extensionString.split(" ");
      sb.append("Extensions\n");
      for (String ext : extensions) {
        sb.append("    " + ext + "\n");
      }

      sb.append("\nJOGL Values\n");
      String pkgName = "javax.media.opengl";
      try {
        getClass().getClassLoader().loadClass(pkgName + ".GL");

        Package p = Package.getPackage(pkgName);
        if (p == null) {
          sb.append("WARNING: Package.getPackage(" + pkgName + ") is null\n");
        } else {
          sb.append(p + "\n");
          sb.append("Specification Title = " + p.getSpecificationTitle() + "\n");
          sb.append("Specification Vendor = " + p.getSpecificationVendor() + "\n");
          sb.append("Specification Version = " + p.getSpecificationVersion() + "\n");
          sb.append("Implementation Vendor = " + p.getImplementationVendor() + "\n");
          sb.append("Implementation Version = " + p.getImplementationVersion() + "\n");
        }
      } catch (ClassNotFoundException e) {
        sb.append("Unable to load " + pkgName + "\n");
      }

      this.outputArea.setText(sb.toString());
    }
Ejemplo n.º 15
0
  private void renderOneside(Point2D a, Point2D b, GL gl, double d) {
    gl.glClear(0);
    Vector3D t = new Vector3D(b.x - a.x, 0, b.y - a.y);
    Vector3D n = new Vector3D(0, 1, 0);
    Vector3D cross = n.cross(t);
    gl.glNormal3d(cross.x, cross.y, cross.z);

    // Texture adjustment vars
    double length =
        scale * Math.sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)) / 100 + 0.1;
    double height = scale;

    // draw the 4 points of it
    gl.glBegin(GL.GL_POLYGON);
    gl.glTexCoord2d(0, 0);
    gl.glVertex3d(a.x, d, a.y);
    gl.glTexCoord2d(0, height);
    gl.glVertex3d(a.x, d + 100, a.y);
    gl.glTexCoord2d(length, height);
    gl.glVertex3d(b.x, d + 100, b.y);
    gl.glTexCoord2d(length, 0);
    gl.glVertex3d(b.x, d, b.y);
    gl.glEnd();
  }
Ejemplo n.º 16
0
  /** paint the portal using gl. */
  public void paint(GL gl, GLDrawable glc) {

    if (fill != null) {
      setColor(gl, fill);
      gl.glDisable(GL.GL_TEXTURE_2D);
    }
    gl.glLineWidth(lineWidth());
    gl.glBegin(GL.GL_LINES); // draw each wall
    for (int i = 0; i < pts2d.size(); i++) {
      Point2D p = (Point2D) (pts2d.get(i));
      gl.glVertex2d(p.x, p.y);
    }
    gl.glEnd();

    if (pts2d.size() == 4) {
      /* Connect mid point of the two line segments with dotted line*/
      gl.glLineStipple(1, (short) 0x0F0F);
      gl.glEnable(GL.GL_LINE_STIPPLE);
      gl.glLineWidth(1);
      gl.glBegin(GL.GL_LINES);
      Point2D mid = pts2d.get(0).interp(pts2d.get(1), 0.5);
      gl.glVertex2d(mid.x, mid.y);
      mid = pts2d.get(2).interp(pts2d.get(3), 0.5);
      gl.glVertex2d(mid.x, mid.y);
      gl.glEnd();
      gl.glDisable(GL.GL_LINE_STIPPLE);
    }
  }