Drawing lines with OpenGL(like the Paint program in windows)
-
Hi everyone, I'm new to programming in C++ and have the following problem: I would like to Drawing lines (and other objects, ie squares, circles, etc) with OpenGL(like the Paint program in windows)with a MFC application. I've created a MFC application that is linked to OpenGL. How do I created functions like the ones we see in the "Paint" program found in windows accesories? For example, if I click on the menu which as a "draw lines" function and after clicking on that, I would like to use the mouse to draw lines, (line starts when the mouse is clicked and dragged. Then the line stops when mouse is released). I'm having great difficulty doing this and if anyone can help it would be greatly appreciated. Thank you in advance! Steve
-
Hi everyone, I'm new to programming in C++ and have the following problem: I would like to Drawing lines (and other objects, ie squares, circles, etc) with OpenGL(like the Paint program in windows)with a MFC application. I've created a MFC application that is linked to OpenGL. How do I created functions like the ones we see in the "Paint" program found in windows accesories? For example, if I click on the menu which as a "draw lines" function and after clicking on that, I would like to use the mouse to draw lines, (line starts when the mouse is clicked and dragged. Then the line stops when mouse is released). I'm having great difficulty doing this and if anyone can help it would be greatly appreciated. Thank you in advance! Steve
1. Override OnLeftMouseDwn Store the position of the mouse when clicked, set a flag to tell that the left button is down, 2. Override OnMove Store the position of the actual position of the mouse, ask for redraw, (InvalidateRect(NULL,FALSE); 3. In OnDraw, check if left button is down, if so, draw a line from initial position to actual position, 4. Override OnLeftMouseUp, unset the flag. This is the basic idea, of course you can refine the concept. Jonathan de Halleux, Belgium.