Results 1 to 2 of 2

Thread: glTranslatef bug

  1. #1
    Member 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,574

    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.

Similar Threads

  1. Cant glTranslatef
    By ethereal in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-23-2012, 08:04 AM
  2. glTranslatef
    By vikramsingh in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 06-22-2011, 06:53 AM
  3. glTranslatef
    By nick2price in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 01-11-2009, 11:56 PM
  4. glTranslatef
    By G in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 07-01-2003, 09:02 AM
  5. glTranslatef....PLEASE HELP!
    By blide in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 06-28-2000, 02:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean