示例#1
0
文件: dof.java 项目: jzy3d/glredbook
  /*
   * accFrustum() The first 6 arguments are identical to the glFrustum() call.
   * pixdx and pixdy are anti-alias jitter in pixels. Set both equal to 0.0
   * for no anti-alias jitter. eyedx and eyedy are depth-of field jitter in
   * pixels. Set both equal to 0.0 for no depth of field effects. focus is
   * distance from eye to plane in focus. focus must be greater than, but not
   * equal to 0.0. Note that accFrustum() calls glTranslatef(). You will
   * probably want to insure that your ModelView matrix has been initialized
   * to identity before calling accFrustum().
   */
  private void accFrustum(
      GL2 gl,
      double left,
      double right,
      double bottom,
      double top,
      double near,
      double far,
      double pixdx,
      double pixdy,
      double eyedx,
      double eyedy,
      double focus) {
    double xwsize, ywsize;
    double dx, dy;
    int viewport[] = new int[4];

    gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0);

    xwsize = right - left;
    ywsize = top - bottom;

    dx = -(pixdx * xwsize / (double) viewport[2] + eyedx * near / focus);
    dy = -(pixdy * ywsize / (double) viewport[3] + eyedy * near / focus);

    gl.glMatrixMode(GL2.GL_PROJECTION);
    gl.glLoadIdentity();
    gl.glFrustum(left + dx, right + dx, bottom + dy, top + dy, near, far);
    gl.glMatrixMode(GL2.GL_MODELVIEW);
    gl.glLoadIdentity();
    gl.glTranslatef((float) -eyedx, (float) -eyedy, 0.0f);
  }
  @Override
  public void reshape(GLAutoDrawable drawable, int arg1, int arg2, int width, int height) {
    GL2 gl = drawable.getGL().getGL2();

    // Computing the aspect ratio
    float aspect = (float) width / height;

    // Setting the viewport, the area that is displayed, to cover the whole window
    gl.glViewport(0, 0, width, height);

    // Setting the perspective projection with an aspect that matches that of the viewport
    // Choose Projection Matrix
    gl.glMatrixMode(GL_PROJECTION);

    // Resets the Projection Matrix
    gl.glLoadIdentity();

    // gluPerspective(fovy, aspect, zNear, zFar);
    // Instructions taken from http://www.opengl.org/sdk/docs/man2/xhtml/glTranslate.xml
    // fovy : Specifies the field of view angle, in degrees, in the y direction.
    // aspect : Specifies the aspect ratio that determines the field of view in the x direction. The
    // aspect ratio is the ratio of x (width) to y (height).
    // zNear : Specifies the distance from the viewer to the near clipping plane (always positive).
    // zFar : Specifies the distance from the viewer to the far clipping plane (always positive).
    glu.gluPerspective(45.0, aspect, 0.1, 100.0);
    gl.glMatrixMode(GL_MODELVIEW);
    gl.glLoadIdentity();
  }
示例#3
0
  /* (non-Javadoc)
   * @see javax.media.opengl.GLEventListener#reshape(javax.media.opengl.GLAutoDrawable, int, int, int, int)
   */
  public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
    this.width = width;
    this.height = height;
    //        GL gl = drawable.getGL();
    gl.glViewport(0, 0, width, height);
    gl.glMatrixMode(GL2.GL_PROJECTION);
    gl.glLoadIdentity();

    double ratio = (double) width / (double) height;
    double w = 2;
    double h = 2;
    if (width < height) {
      h = h / ratio;
    } else {
      w = w * ratio;
    }

    int mode = Options.getProjectionMode();
    if (mode == Options.PERSPECTIVE) {
      // 	For Perspective projection
      glu.gluPerspective(45, (double) (width) / (double) (height), 0.001, 1000);
    } else if (mode == Options.ORTHOGRAPHIC) {
      // For Orthogonal projection
      gl.glOrtho(-1 * w, w, -1 * h, h, -10000, 10000);
    }
    gl.glMatrixMode(GL2.GL_MODELVIEW);
    gl.glLoadIdentity();

    for (Iterator<GLBrush> it = displayList.iterator(); it.hasNext(); ) {
      GLBrush brush = it.next();
      brush.setScreenSize(width, height);
    }
  }
 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
   GL2 gl = drawable.getGL().getGL2();
   gl.glMatrixMode(GL2ES1.GL_PROJECTION);
   gl.glLoadIdentity();
   glu.gluOrtho2D(0, 1, 0, 1);
   gl.glMatrixMode(GL2ES1.GL_MODELVIEW);
   gl.glLoadIdentity();
 }
示例#5
0
  public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
    GL2 gl = drawable.getGL().getGL2();

    gl.glViewport(0, 0, w, h);
    gl.glMatrixMode(GL2.GL_PROJECTION);
    gl.glLoadIdentity();
    glu.gluOrtho2D(0.0, 3.0, 0.0, 3.0);
    gl.glMatrixMode(GL2.GL_MODELVIEW);
    gl.glLoadIdentity();
  }
示例#6
0
 public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4) {
   width = arg3;
   height = arg4;
   GL2 gl = arg0.getGL().getGL2();
   gl.glViewport(0, 0, width, height);
   gl.glMatrixMode(GL2.GL_PROJECTION);
   gl.glLoadIdentity();
   gl.glOrtho(0.0, 800, 0.0, 200, -100.0, 100.0);
   gl.glMatrixMode(GL2.GL_MODELVIEW);
   gl.glLoadIdentity();
 }
示例#7
0
文件: Test.java 项目: JibouLBF/Fablab
 @Override
 public void reshape(GLAutoDrawable gLDrawable, int x, int y, int width, int height) {
   GL2 gl = gLDrawable.getGL().getGL2();
   final float aspect = (float) width / (float) height;
   gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
   gl.glLoadIdentity();
   final float fh = 0.5f;
   final float fw = fh * aspect;
   gl.glFrustumf(-fw, fw, -fh, fh, 1.0f, 1000.0f);
   gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
   gl.glLoadIdentity();
 }
示例#8
0
  public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
    GL2 gl = drawable.getGL().getGL2();
    //
    gl.glViewport(0, 0, w, h);
    gl.glMatrixMode(GL2.GL_PROJECTION);
    gl.glLoadIdentity();

    glu.gluPerspective(45.0, 1.0, 0.25, 25.0);
    gl.glMatrixMode(GL2.GL_MODELVIEW);
    gl.glLoadIdentity();
    gl.glTranslatef(0.0f, 0.0f, -5.0f);
  }
示例#9
0
	public void reshape(GLAutoDrawable gLDrawable, int x, int y, int width,
			int height) {
		GL2 gl = gLDrawable.getGL().getGL2();
		if (height <= 0) {
			height = 1;
		}
		float h = (float) width / (float) height;
		gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
		gl.glLoadIdentity();
		glu.gluPerspective(50.0f, h, 1.0, 1000.0);
		gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
		gl.glLoadIdentity();
	}
示例#10
0
  public void reshape(GLAutoDrawable drawable, int xstart, int ystart, int width, int height) {
    GL2 gl = drawable.getGL().getGL2();

    height = (height == 0) ? 1 : height;

    gl.glViewport(0, 0, width, height);
    gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
    gl.glLoadIdentity();

    glu.gluPerspective(45, (float) width / height, 1, 1000);
    gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
    gl.glLoadIdentity();
  }
示例#11
0
 public void configureGL(GL2 gl) {
   gl.glEnable(GL2.GL_FOG);
   gl.glFogi(GL2.GL_FOG_MODE, GL2.GL_LINEAR);
   gl.glFogf(GL2.GL_FOG_DENSITY, 0.25f);
   gl.glFogf(GL2.GL_FOG_START, Math.max(getNearClippingPlane(), fadeOut * 1.0f));
   gl.glFogf(GL2.GL_FOG_END, Math.max(1.1f, fadeOut * 1.1f * getSpawnDistance()));
   gl.glMatrixMode(GL2.GL_PROJECTION);
   gl.glLoadIdentity();
   gl.glFrustumf(-1, 1, -man.vheight(), man.vheight(), getNearClippingPlane(), 128.0f);
   gl.glScalef(2.0f, 2.0f, 1);
   gl.glTranslatef(-0.5f, -man.vheight() / 2.0f, 0);
   gl.glMatrixMode(GL2.GL_MODELVIEW);
   gl.glLoadIdentity();
 }
示例#12
0
  public void drawTextureToOffScreenTexture(int texId, int attachment)
        // public void drawTextureToOffScreenTextureUsingShader(Texture tex, int attachment, Program
        // program)
      {
    GL2 gl = getGL();

    // program.bind(gl);

    gl.glBindTexture(GL_TEXTURE_2D, texId);
    // gl.glBindTexture(GL_TEXTURE_2D, tex.getTextureObject());
    // gl.glDrawBuffer(attachment);
    gl.glBindFramebuffer(GL_FRAMEBUFFER, attachment); // think this is the new way...

    gl.glEnable(GL_TEXTURE_2D);
    // gl.glActiveTexture(GL_TEXTURE0);
    gl.glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);

    gl.glViewport(0, 0, fboWidth, fboHeight);

    // gl.glUniform1i(program.uniform("theTexture"), 0);
    // set projection to ortho
    gl.glMatrixMode(GL_PROJECTION);
    gl.glTranslatef(1f, 1f, 1f);

    gl.glPushMatrix();
    {
      gl.glLoadIdentity();
      RenderUtils.getGLU().gluOrtho2D(0, fboWidth, fboHeight, 0);

      gl.glMatrixMode(gl.GL_MODELVIEW);

      gl.glPushMatrix();
      {
        gl.glLoadIdentity();

        gl.glColor4f(1f, 1f, 1f, 1f);
        drawSquare(gl, 0, 0, fboWidth, fboHeight);
      }
      gl.glPopMatrix();

      gl.glMatrixMode(gl.GL_PROJECTION);
    }
    gl.glPopMatrix();

    gl.glMatrixMode(gl.GL_MODELVIEW);

    gl.glDisable(GL_TEXTURE_2D);
    // program.unbind(gl);
  }
示例#13
0
  public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
    gl = drawable.getGL().getGL2();
    if (height < 1) {
      height = 1;
    }
    final float h = (float) width / (float) height;
    gl.glViewport(0, 0, width, height);

    gl.glMatrixMode(GL2.GL_PROJECTION);
    gl.glLoadIdentity();
    glu.gluPerspective(FPCamera.FOV, h, FPCamera.NEAR, FPCamera.FAR);

    gl.glMatrixMode(GL2.GL_MODELVIEW);
    gl.glLoadIdentity();
  }
示例#14
0
  // in pixels.
  @Override
  public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
    System.out.println(x + " " + y + " " + width + " " + height);

    GL2 gl = drawable.getGL().getGL2();
    // calculate the aspect ratio of window
    double aspect = 1.0 * width / height;

    // in OpenGL terms, we are changing the 'projection'
    // this will be explained later
    gl.glMatrixMode(GL2.GL_PROJECTION);
    gl.glLoadIdentity();

    // Use the GLU library to compute the new projection
    GLU glu = new GLU();

    // We are wider than high!
    if (aspect >= 1) {
      System.out.println("Showing world " + (-aspect) + " to " + (aspect) + " -1 to 1");
      glu.gluOrtho2D(-aspect, aspect, -1.0, 1.0); // left, right, top, bottom
    } else {
      System.out.println("Showing world from -1 to 1 " + (-1.0 / aspect) + " to " + (1.0 / aspect));
      glu.gluOrtho2D(-1, 1, -1.0 / aspect, 1.0 / aspect); // left, right, top, bottom
    }
  }
示例#15
0
 /** @param gl */
 private void loadDefaults(GL2 gl) {
   gl.glLoadIdentity();
   gl.glScaled(scale, scale, scale);
   if (Options.getProjectionMode() == Options.PERSPECTIVE) {
     gl.glTranslatef(0, 0, translate);
   }
 }
 @Override
 public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
   GL2 gl = drawable.getGL().getGL2();
   gl.glMatrixMode(GL2.GL_PROJECTION);
   gl.glLoadIdentity();
   gl.glFrustum(-1, 1, -1, 1, 1, 10);
 }
示例#17
0
  // Where the printing happens
  private void glPrint(GL2 gl, int x, int y, int set, String fmt) {

    // If There's No Text
    if (fmt == null) {
      return;
    }

    // Did User Choose An Invalid Character Set?
    if (set > 1) {
      // If So, Select Set 1 (Italic)
      set = 1;
    }

    gl.glEnable(GL.GL_TEXTURE_2D); // Enable Texture Mapping
    gl.glLoadIdentity(); // Reset The Modelview Matrix
    gl.glTranslated(x, y, 0); // Position The Text (0,0 - Top Left)
    gl.glListBase(base - 32 + (128 * set)); // Choose The Font Set (0 or 1)
    gl.glScalef(1.0f, 2.0f, 1.0f); // Make The Text 2X Taller

    if (stringBuffer.capacity() < fmt.length()) {
      stringBuffer = GLBuffers.newDirectByteBuffer(fmt.length());
    }

    stringBuffer.clear();
    stringBuffer.put(fmt.getBytes());
    stringBuffer.flip();
    // Write the text to the screen
    gl.glCallLists(fmt.length(), GL.GL_UNSIGNED_BYTE, stringBuffer);
    gl.glDisable(GL.GL_TEXTURE_2D); // Disable Texture Mapping
  }
示例#18
0
  // private void pickSquares(GL gl, int button, int state, int x, int y)
  private void pickSquares(GL2 gl) {
    int selectBuf[] = new int[BUFSIZE];
    IntBuffer selectBuffer = IntBuffer.wrap(selectBuf);
    int hits;
    int viewport[] = new int[4];

    // if (button != GLUT_LEFT_BUTTON || state != GLUT_DOWN) return;

    gl.glGetIntegerv(GL2.GL_VIEWPORT, viewport, 0);

    gl.glSelectBuffer(BUFSIZE, selectBuffer);
    gl.glRenderMode(GL2.GL_SELECT);

    gl.glInitNames();
    gl.glPushName(0);

    gl.glMatrixMode(GL2.GL_PROJECTION);
    gl.glPushMatrix();
    gl.glLoadIdentity();
    /* create 5x5 pixel picking region near cursor location */
    glu.gluPickMatrix(
        (double) pickPoint.x, (double) (viewport[3] - pickPoint.y), 5.0, 5.0, viewport, 0);
    glu.gluOrtho2D(0.0, 3.0, 0.0, 3.0);
    drawSquares(gl, GL2.GL_SELECT);

    gl.glMatrixMode(GL2.GL_PROJECTION);
    gl.glPopMatrix();
    gl.glFlush();

    hits = gl.glRenderMode(GL2.GL_RENDER);
    selectBuffer.get(selectBuf);
    processHits(hits, selectBuf);
  }
  public void display(GLAutoDrawable drawable) {

    GL2 gl = drawable.getGL().getGL2();

    // Clear the drawing area
    gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
    // Reset the current matrix to the "identity"
    gl.glLoadIdentity();

    // Move the "drawing cursor" around
    gl.glTranslatef(-1.5f, 0.0f, -6.0f);

    // Drawing Using Triangles
    gl.glBegin(GL2.GL_TRIANGLES);
    gl.glColor3f(1.0f, 0.0f, 0.0f); // Set the current drawing color to red
    gl.glVertex3f(0.0f, 1.0f, 0.0f); // Top
    gl.glColor3f(0.0f, 1.0f, 0.0f); // Set the current drawing color to green
    gl.glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left
    gl.glColor3f(0.0f, 0.0f, 1.0f); // Set the current drawing color to blue
    gl.glVertex3f(1.0f, -1.0f, 0.0f); // Bottom Right
    // Finished Drawing The Triangle
    gl.glEnd();

    // Move the "drawing cursor" to another position
    gl.glTranslatef(3.0f, 0.0f, 0.0f);
    // Draw A Quad
    gl.glBegin(GL2.GL_QUADS);
    gl.glColor3f(0.5f, 0.5f, 1.0f); // Set the current drawing color to light blue
    gl.glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left
    gl.glVertex3f(1.0f, 1.0f, 0.0f); // Top Right
    gl.glVertex3f(1.0f, -1.0f, 0.0f); // Bottom Right
    gl.glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left
    // Done Drawing The Quad
    gl.glEnd();
  }
示例#20
0
  /**
   * Builds the display list for a given display list index.
   *
   * @param gl Instance of GL2.
   * @param iGLDisplayListIndex Index of the display list.
   */
  private void buildDisplayList(final GL2 gl, int iGLDisplayListIndex) {
    if (pdRealRootElement != null && pdCurrentRootElement != null) {

      gl.glNewList(iGLDisplayListIndex, GL2.GL_COMPILE);

      float fXCenter = viewFrustum.getWidth() / 2;
      float fYCenter = viewFrustum.getHeight() / 2;

      gl.glLoadIdentity();

      upwardNavigationSlider.draw(
          gl,
          pickingManager,
          textureManager,
          uniqueID,
          iUpwardNavigationSliderID,
          iUpwardNavigationSliderButtonID,
          iUpwardNavigationSliderBodyID);

      float fCurrentSliderWidth = upwardNavigationSlider.getScaledWidth(gl);
      float fCurrentSliderHeight = upwardNavigationSlider.getScaledHeight(gl);

      controlBox.setRectangle(
          0, 0, fCurrentSliderWidth * 2, fCurrentSliderHeight + fCurrentSliderWidth);
      LabelManager.get().setControlBox(controlBox);
      drawingController.draw(fXCenter, fYCenter, gl, new GLU());

      gl.glEndList();
    } else {
      renderSymbol(gl, EIconTextures.RADIAL_SYMBOL.getFileName(), 0.5f);
    }
  }
示例#21
0
  /**
   * Call-back handler for window re-size event. Also called when the drawable is first set to
   * visible.
   */
  public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
    GL2 gl = drawable.getGL().getGL2(); // get the OpenGL 2 graphics context
    graphicsManager.setGraphics(gl);

    // Set the view port (display area) to cover the entire window
    gl.glViewport(0, 0, width, height);

    // Setup perspective projection, with aspect ratio matches viewport
    gl.glMatrixMode(GL_PROJECTION); // choose projection matrix
    gl.glLoadIdentity(); // reset projection matrix
    glu.gluOrtho2D(0, realWidth, 0, realHeight);

    // Enable the model-view transform
    gl.glMatrixMode(GL_MODELVIEW);
    gl.glLoadIdentity(); // reset
  }
示例#22
0
  /*
   * sets up selection mode, name stack, and projection matrix for picking.
   * Then the objects are drawn.
   */
  private void pickRects(GL2 gl) {
    int[] selectBuf = new int[BUFSIZE];
    IntBuffer selectBuffer = GLBuffers.newDirectIntBuffer(BUFSIZE);
    int hits;
    int viewport[] = new int[4];
    // int x, y;

    gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0);

    gl.glSelectBuffer(BUFSIZE, selectBuffer);
    gl.glRenderMode(GL2.GL_SELECT);

    gl.glInitNames();
    gl.glPushName(-1);

    gl.glMatrixMode(GL2.GL_PROJECTION);
    gl.glPushMatrix();
    gl.glLoadIdentity();
    /* create 5x5 pixel picking region near cursor location */
    glu.gluPickMatrix(
        (double) pickPoint.x,
        (double) (viewport[3] - pickPoint.y), //
        5.0,
        5.0,
        viewport,
        0);
    gl.glOrtho(0.0, 8.0, 0.0, 8.0, -0.5, 2.5);
    drawRects(gl, GL2.GL_SELECT);
    gl.glPopMatrix();
    gl.glFlush();

    hits = gl.glRenderMode(GL2.GL_RENDER);
    selectBuffer.get(selectBuf);
    processHits(hits, selectBuf);
  }
示例#23
0
文件: Test.java 项目: JibouLBF/Fablab
  @Override
  public void display(GLAutoDrawable gLDrawable) {
    final GL2 gl = gLDrawable.getGL().getGL2();
    gl.glClear(GL.GL_COLOR_BUFFER_BIT);
    gl.glClear(GL.GL_DEPTH_BUFFER_BIT);
    gl.glLoadIdentity();
    gl.glTranslatef(0.0f, 0.0f, -5.0f);

    // rotate about the three axes
    gl.glRotatef(rotateT, 1.0f, 0.0f, 0.0f);
    gl.glRotatef(rotateT, 0.0f, 1.0f, 0.0f);
    gl.glRotatef(rotateT, 0.0f, 0.0f, 1.0f);

    // Draw A Quad
    gl.glBegin(GL2.GL_QUADS);
    gl.glColor3f(0.0f, 1.0f, 1.0f); // set the color of the quad
    gl.glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left
    gl.glVertex3f(1.0f, 1.0f, 0.0f); // Top Right
    gl.glVertex3f(1.0f, -1.0f, 0.0f); // Bottom Right
    gl.glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left
    // Done Drawing The Quad
    gl.glEnd();

    // increasing rotation for the next iteration
    rotateT += 0.2f;
  }
示例#24
0
  /** Called back by the animator to perform rendering. */
  @Override
  public void display(GLAutoDrawable drawable) {
    GL2 gl = drawable.getGL().getGL2(); // get the OpenGL 2 graphics context
    gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear color and depth buffers
    gl.glLoadIdentity(); // reset the model-view matrix

    gl.glTranslatef(0.0f, 0.0f, -12.0f);
    gl.glRotatef(rotateAnleX, 1.0f, 0.0f, 0.0f);
    gl.glRotatef(rotateAnleY, 0.0f, 1.0f, 0.0f);
    gl.glRotatef(rotateAngleZ, 0.0f, 0.0f, 1.0f);

    // need to flip the image
    float textureHeight = textureTop - textureBottom;

    float x1, y1, x2, y2; // used to break the flag into tiny quads

    gl.glBegin(GL_QUADS);
    for (int x = 0; x < numPoints - 1; x++) {
      for (int y = 0; y < numPoints - 1; y++) {
        x1 = (float) x / 44.0f;
        y1 = (float) y / 44.0f;
        x2 = (float) (x + 1) / 44.0f;
        y2 = (float) (y + 1) / 44.0f;

        // Texture need to flip vertically
        gl.glTexCoord2f(x1, y1 * textureHeight + textureBottom);
        gl.glVertex3f(points[x][y][0], points[x][y][1], points[x][y][2]);

        gl.glTexCoord2f(x1, y2 * textureHeight + textureBottom);
        gl.glVertex3f(points[x][y + 1][0], points[x][y + 1][1], points[x][y + 1][2]);

        gl.glTexCoord2f(x2, y2 * textureHeight + textureBottom);
        gl.glVertex3f(points[x + 1][y + 1][0], points[x + 1][y + 1][1], points[x + 1][y + 1][2]);

        gl.glTexCoord2f(x2, y1 * textureHeight + textureBottom);
        gl.glVertex3f(points[x + 1][y][0], points[x + 1][y][1], points[x + 1][y][2]);
      }
    }
    gl.glEnd();

    if (wiggleCount == 2) { // Used To Slow Down The Wave (Every 2nd Frame Only)
      for (int y = 0; y < 45; y++) {
        float tempHold = points[0][y][2]; // Store current value One Left Side Of
        // Wave
        for (int x = 0; x < 44; x++) {
          // Current Wave Value Equals Value To The Right
          points[x][y][2] = points[x + 1][y][2];
        }
        points[44][y][2] = tempHold; // Last Value Becomes The Far Left Stored
        // Value
      }
      wiggleCount = 0; // Set Counter Back To Zero
    }
    wiggleCount++;

    // update the rotational position after each refresh
    rotateAnleX += roateSpeedX;
    rotateAnleY += rotateSpeedY;
    rotateAngleZ += rotateSpeedZ;
  }
  public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {

    GL2 gl = drawable.getGL().getGL2();
    GLU glu = new GLU();

    // avoid a divide by zero error!
    if (height <= 0) height = 1;

    final float h = (float) width / (float) height;
    gl.glViewport(0, 0, width, height);
    gl.glMatrixMode(GL2.GL_PROJECTION);
    gl.glLoadIdentity();

    glu.gluPerspective(45.0f, h, 1.0, 20.0);
    gl.glMatrixMode(GL2.GL_MODELVIEW);
    gl.glLoadIdentity();
  }
示例#26
0
  public void display(GLAutoDrawable drawable) {
    GL2 gl = drawable.getGL().getGL2();
    gl.glClearColor(0, 0, 0, 0);
    gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);

    gl.glMatrixMode(GL2.GL_PROJECTION);
    gl.glLoadIdentity();
    // new GLU().gluPerspective(45f, (float)width/(float)height, 0.1f, 1000f);
    gl.glOrtho(0.0, 800, 0.0, 800, -100.0, 100.0);
    gl.glMatrixMode(GL2.GL_MODELVIEW);
    gl.glLoadIdentity();

    tr.beginRendering(800, 800);
    tr.draw("die Marktwirtschaft. Da regelt sich � angeblich", 16, 32);
    tr.draw("Hello World! This text is scrambled", 16, 16);
    tr.endRendering();
  }
示例#27
0
 @Override
 public void init(GLAutoDrawable drawable) {
   GL2 gl = drawable.getGL().getGL2();
   gl.glClearColor(0, 0, 0, 0); // dene a cor de fundo
   gl.glEnable(GL2.GL_DEPTH_TEST); // remoção de superfície oculta
   gl.glMatrixMode(GL2.GL_PROJECTION); // dene que a matrix é a de projeção
   gl.glLoadIdentity(); // carrega a matrix de identidade
   gl.glOrtho(-5, 5, -5, 5, -5, 5); // dene uma projeção ortográca
 }
示例#28
0
 @Override
 public void reshape(GLAutoDrawable dr, int x, int y, int width, int height) {
   GL2 gl = dr.getGL().getGL2();
   gl.glViewport(x, y, width, height);
   gl.glMatrixMode(GL2.GL_PROJECTION);
   gl.glLoadIdentity();
   glu.gluPerspective(45.0f, (float) width / (float) height, 1.0, 100.0);
   gl.glMatrixMode(GL2.GL_MODELVIEW);
 }
示例#29
0
  public void reshape(GLAutoDrawable drawable, int xstart, int ystart, int width, int height) {
    GL2 gl = drawable.getGL().getGL2();

    height = (height == 0) ? 1 : height;
    swidth = width; // Set Scissor Width To Window Width
    sheight = height; // Set Scissor Height To Window Height

    gl.glViewport(0, 0, width, height);
    gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); // Select The Projection
    // Matrix
    gl.glLoadIdentity(); // Reset The Projection Matrix
    gl.glOrtho(0.0f, 640, 480, 0.0f, -1.0f, 1.0f); // Create Ortho 640x480
    // View (0,0 At Top
    // Left)
    gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); // Select The Modelview
    // Matrix
    gl.glLoadIdentity();
  }
示例#30
0
文件: clip.java 项目: jzy3d/glredbook
 public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
   GL2 gl = drawable.getGL().getGL2();
   //
   gl.glViewport(0, 0, w, h);
   gl.glMatrixMode(GL2.GL_PROJECTION);
   gl.glLoadIdentity();
   glu.gluPerspective(60.0, (float) w / (float) h, 1.0, 20.0);
   gl.glMatrixMode(GL2.GL_MODELVIEW);
 }