Esempio n. 1
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();
   if (w <= (h * 3))
     gl.glOrtho(
         -6.0,
         6.0,
         -2.0 * ((float) h * 3) / (float) w,
         2.0 * ((float) h * 3) / (float) w,
         0.0,
         10.0);
   else
     gl.glOrtho(
         -6.0 * (float) w / ((float) h * 3), //
         6.0 * (float) w / ((float) h * 3),
         -2.0,
         2.0,
         0.0,
         10.0);
   gl.glMatrixMode(GL2.GL_MODELVIEW);
   gl.glLoadIdentity();
 }
Esempio n. 2
0
  public void init(GLAutoDrawable drawable) {
    drawable.setGL(new DebugGL2(drawable.getGL().getGL2()));
    final GL2 gl = drawable.getGL().getGL2();
    // drawable.getGL().getGL2();
    gl.glViewport(0, 0, SCREENW, SCREENH);

    // Clear color buffer with black
    // gl.glClearColor(1.0f, 0.5f, 1.0f, 1.0f);
    gl.glClearColor(.0f, .0f, .0f, 1.0f);
    gl.glClearDepth(1.0f);
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
    gl.glEnable(GL2.GL_DEPTH_TEST);
    gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1);

    gl.glCreateShader(GL2GL3.GL_VERTEX_SHADER);
    shader.init(gl);
    int programName = shader.getID();
    gl.glBindAttribLocation(programName, Object3D.VERTEXPOSITION, "inposition");
    gl.glBindAttribLocation(programName, Object3D.VERTEXCOLOR, "incolor");
    gl.glBindAttribLocation(programName, Object3D.VERTEXNORMAL, "innormal");
    gl.glBindAttribLocation(programName, Object3D.VERTEXTEXCOORD0, "intexcoord0");
    shader.link(gl);
    uniformMat = gl.glGetUniformLocation(programName, "mat");
    uniformLight = gl.glGetUniformLocation(programName, "lightdir");
    gl.glUseProgram(programName);
    gl.glUniform3f(uniformLight, 0f, 10f, -10f);
    obj.init(gl, mats, programName);
    gl.glUseProgram(0);
  }
Esempio n. 3
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, (double) w, 0.0, (double) h);
 }
Esempio n. 4
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();
   if (w <= h)
     gl.glOrtho(-2.5, 2.5, -2.5 * (float) h / (float) w, 2.5 * (float) h / (float) w, -10.0, 10.0);
   else
     gl.glOrtho(-2.5 * (float) w / (float) h, 2.5 * (float) w / (float) h, -2.5, 2.5, -10.0, 10.0);
   gl.glMatrixMode(GL2.GL_MODELVIEW);
 }
Esempio n. 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.gluPerspective(45.0, 1.0, 0.25, 25.0);
    gl.glMatrixMode(GL2.GL_MODELVIEW);
    gl.glLoadIdentity();
    gl.glTranslatef(0.0f, 0.0f, -5.0f);
  }
Esempio n. 6
0
  /**
   * Call-back handler for window re-size event. Also called when the drawable is first set to
   * visible.
   */
  @Override
  public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
    GL2 gl = drawable.getGL().getGL2(); // get the OpenGL 2 graphics context

    if (height == 0) height = 1; // prevent divide by zero
    float aspect = (float) width / height;

    // 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.gluPerspective(45.0, aspect, 0.1, 100.0); // fovy, aspect, zNear, zFar

    // Enable the model-view transform
    gl.glMatrixMode(GL_MODELVIEW);
    gl.glLoadIdentity(); // reset
  }
Esempio n. 7
0
  @Override
  public void init(GLAutoDrawable glAutoDrawable) {
    gl = glAutoDrawable.getGL().getGL2();
    glu = new GLU();
    glut = new GLUT();

    gl.glClearColor(0.549f, 0.675f, 0.227f, 0.0f);
    gl.glMatrixMode(GL2.GL_PROJECTION);
    gl.glLoadIdentity();
    glu.gluOrtho2D(left, right, bottom, top);
    gl.glViewport((int) bottom, (int) left, (int) top, (int) right);
    gl.glMatrixMode(GL2.GL_MODELVIEW);
    gl.glColor3f(.357f, .184f, .478f);

    maxFrames = 50 * ifsFiles.size() + 1000;
    base = gl.glGenLists(maxFrames);
    currentDrawList = base;

    ifsfile = "CS371/assignments/assignment02/tri.ifs";
    loadifs();
  }