Results 1 to 2 of 2

Thread: How to save the previous LINE?

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2008
    Posts
    1

    How to save the previous LINE?

    Hi,

    In my program I am trying to draw a square, rectangle etc using my drawLine method. But I am loosing the previous line when I click on my left buttown to draw second line to complete the sqaure.

    Can you please help me on how to save the previous line?

    //FUNCTION TO DRAW A LINE
    void drawLine(int x1, int y1, int x2 , int y2)
    {
    glColor3f(r,g,b);
    glBegin(GL_LINES);
    glVertex2f(x1, y1);
    glVertex2f(x2, y2);
    glEnd();

    }

    // SELECTING MOUSE MOTION
    void choose_mouse_motion(int x, int y)
    {
    int z;

    if(mouse_track)
    {
    z = wh-y;
    currentX = x;
    currentY = z;
    }
    glutPostRedisplay();
    }

  2. #2
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,931

    Re: How to save the previous LINE?

    You don't "save" it. OpenG works by redrawing the screen (in most cases, anyway). So you will need to store the coordinates of your line, say, in a list and redraw them all each frame.

Similar Threads

  1. How to begin with openGL with no previous API background?
    By curious in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 07-29-2015, 11:32 PM
  2. Render onto previous frame with blending
    By paradoxresolved in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 02-12-2014, 10:43 AM
  3. fbo - read previous / write to current
    By powermax in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 06-18-2008, 01:33 PM
  4. Iterate on previous result?
    By xu in forum OpenGL: Advanced Coding
    Replies: 27
    Last Post: 12-17-2003, 06:00 PM
  5. Pan/Zoom Previous
    By Lackey-92 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 03-14-2001, 01:24 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