Results 1 to 2 of 2

Thread: moving/changing object (when it shouldn't)

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2010

    moving/changing object (when it shouldn't)

    I am using glut.
    when the program runs, and I drag the window to a new location, one of the objects moves position and also gets smaller. When I resize the window, it goes back to where it should be. Its not making sense to me.

    Code :
    #include <GLUT/glut.h>
    #include <stdlib.h>
    void init(void) 
       glClearColor (0.0, 0.0, 0.0, 0.0);
       glShadeModel (GL_FLAT);
    void display(void)
       glColor3f(1.0, 1.0, 1.0);
    glTranslatef(0, -3.0, -10);
    glutSolidSphere(1.0, 10, 8);   /* mid sphere */  //this is the one that changes
    glTranslatef(-3, -3.0, -10);
    glutWireSphere(1.0, 10, 8);   /* left sphere */
    glTranslatef(3, -3.0, -10);
    glutWireSphere(1.0, 10, 8);   /* right sphere */
    void reshape(int w, int h)
       glViewport (0, 0, (GLsizei) w, (GLsizei) h);
    	gluPerspective(65.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0);
       glMatrixMode (GL_MODELVIEW);
    int main(int argc, char** argv)
       glutInit(&amp;argc, argv);
       glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
       glutInitWindowSize (1024, 768); 
       glutInitWindowPosition (100, 100);
       glutCreateWindow (argv[0]);
       init ();
    //   glutMouseFunc(mouse);
    //   glutKeyboardFunc(keyb);
       return 0;

    anyone know why this is happening?

    btw im using:
    mac os x 10.4 ppc

  2. #2
    Senior Member Frequent Contributor scratt's Avatar
    Join Date
    May 2008

    Re: moving/changing object (when it shouldn't)

    Not quite sure about the resizing, but glut needs to be told to redraw stuff on certain actions, or at a designated refresh rate. It doesn't just keep drawing your view. So it is probably related to that.

    When you resize the window reshape(..) is called and this will setup your matrices again and then display(..) will redraw your objects correctly.

    Check this web page out :

Similar Threads

  1. moving object in circle across of other object
    By openGLWriter in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 11-19-2015, 09:18 AM
  2. changing position of an object continuously
    By david419 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 10-21-2013, 06:53 AM
  3. Moving a light when changing the viewpoint
    By Lefteris in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-18-2010, 04:18 PM
  4. Changing a viewpoint of an object without cam move
    By heavenssake007 in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 01-21-2009, 01:21 AM
  5. Re-render for One object changing?
    By lobstah in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 01-14-2002, 09:35 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