Results 1 to 3 of 3

Thread: Lines slightly shifting around after resize

  1. #1
    Member Newbie
    Join Date
    Jun 2006
    Posts
    31

    Lines slightly shifting around after resize

    I'm currently displaying parallel lines on the screen, and whenever I resize, the lines shift just a little bit. They move a little closer together or a little farther apart each time I resize. Further, the way they shift is never constant, i.e. the lines don't always/only move farther away each time, nor closer together. Does this have to do with a limitation on the precision that opengl can display things? I am not playing with any projections as this is in 2D.

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Lines slightly shifting around after resize

    Does this have to do with a limitation on the precision that opengl can display things?
    No. Probably your code or the way you use the API is not efficient.
    Do you have screenshots, more details, or even some code ?

  3. #3
    Member Newbie
    Join Date
    Jun 2006
    Posts
    31

    Re: Lines slightly shifting around after resize

    sure, it is code as simple as this
    glNewList(displayListID, GL_COMPILE_AND_EXECUTE);

    glDisable(GL_POINT_SMOOTH);
    glDisable(GL_LINE_SMOOTH);

    glColor3f(0,0,0);


    glBegin(GL_LINES);

    //Now draw the measures lines
    glVertex2f(xPos,yPos);
    glVertex2f(xPos + width, yPos);

    glVertex2f(xPos, yPos - containingStaff->getSpacing());
    glVertex2f(xPos + width, yPos - containingStaff->getSpacing());

    glVertex2f(xPos,yPos - (2*containingStaff->getSpacing()));
    glVertex2f(xPos + width, yPos - (2*containingStaff->getSpacing()));

    glVertex2f(xPos,yPos - (3*containingStaff->getSpacing()));
    glVertex2f(xPos + width, yPos - (3*containingStaff->getSpacing()));

    glVertex2f(xPos,yPos - (4*containingStaff->getSpacing()));
    glVertex2f(xPos + width, yPos - (4*containingStaff->getSpacing()));

    glEnd();


    glEnable(GL_POINT_SMOOTH);
    glEnable(GL_LINE_SMOOTH);

    glEndList();

    later the display list is called to show the lines. The resize function is as follows:

    void ChangeSize(int w, int h)
    {

    // Prevent a divide by zero
    if(h == 0)
    {
    h = 1;
    }

    // Set Viewport to window dimensions
    glViewport(0, 0, w, h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();


    gluOrtho2D(-800.0f, 800.0f, -800.0f, 800.0f);

    // Modelview matrix reset
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    }

Similar Threads

  1. problem with bit shifting
    By miujin in forum OpenGL: GLSL
    Replies: 2
    Last Post: 05-02-2011, 03:26 PM
  2. shifting graphics
    By bdub in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-26-2004, 05:45 PM
  3. Resize Window\Resize Image
    By Cerv36 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 02-16-2003, 04:42 AM
  4. Point shifting
    By Dmitry Samoyloff in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 01-06-2001, 04:12 PM
  5. Point shifting
    By Dmitry Samoyloff in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 12-28-2000, 12:53 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