Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: glTranslatef bug

  1. #1
    Intern Contributor
    Join Date
    Oct 2006
    Posts
    83

    glTranslatef bug

    Please Help,

    I have just finished codeing a viewer that will rotate (along X, Y, and Z Axis), Move the Object, and Zoom in and out. I works fine most of the time but sometimes has issues. Can someone take a quick look at my code and tell if there are some obvious problems and if so provide some suggestions as to how to address them? Thanks in advance.

    Inside of display():
    Code :
    gl.glViewport(0, 0, width, height);
    // Where stpModel is the Class with data 
    // on Object to be "drawn" ...
    double diameter = stpModel.getDiameter();
    float cenX = stpModel.getCenterX();
    float cenY = stpModel.getCenterY();
    float cenZ = stpModel.getCenterZ();
    double zNear = 1.0;
    double zFar = 2*(diameter + zNear);
    gl.glMatrixMode(GL.GL_PROJECTION);
    gl.glLoadIdentity();
    float ratio = (float)width/(float)height;
    glu.gluPerspective(45, ratio, zNear, zFar);
    gl.glMatrixMode(GL.GL_MODELVIEW);
    gl.glLoadIdentity();
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
    gl.glRotatef(angleX, 1.0f, 0.0f, 0.0f);
    gl.glRotatef(angleY, 0.0f, 1.0f, 0.0f);
    gl.glRotatef(angleZ, 0.0f, 0.0f, 1.0f);
     
    // Where xTrans and yTrans are calculate by Mouse
    // Event "clicks" --> taking the differences of
    // Points ...
    gl.glTranslatef(this.xTrans, this.yTrans, 1.0f);
     
    // Where zoom is adjusted by the user, starts at 
    // the value of 1.0f ...
    gl.glScalef(zoom, zoom, zoom);
     
    // Method draws the Object with primatives 
    // Triangles ...
    drawTriangles();

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    3,768

    Re: glTranslatef bug

    I works fine most of the time but sometimes has issues.
    You'll need to explain what these supposed "issues" are before we can help you with them.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •