Project #1: 2D drawing tool
Due: 8 Oct. 11:59pm
- Due: 8 Oct. 11:59pm
- Send an e-mail with your code attached.
- Describe, in detail, how your code can be compiled.
- Send all the files required to compile. Otherwise, you may lose points.
- Make sure your code is compiled correctly.
- You can use other languages other than C,
(C++, Java, etc.) but describe how to compile (or run) your code carefully.
Objective: To implement a simple 2D drawing tool.
Let me know if you have any problem with the executables!
Let the user draw 2D shapes.
- White background
- Use double-buffering to avoid blinking
The user can draw a shape
by dragging the mouse with
the left button pressed.
- While dragging,
a bounding box with black dashed line
should be shown.
The bounding box should be
changing dynamically while dragging.
When the user is drawing an oval,
an oval with dashed line
should be shown, too.
When the user stops dragging
by releasing the left mouse button,
a shape should be drawn with
(shape, color, fill type, and line width).
New shapes should "overwrite" old ones.
Let the user change the properties
from the pop-up menu.
- The menu
should pop up when the right button is clicked.
The menu should be organized as follows:
- Line width
- "Reset" clears all the shapes drawn so far.
Let the user change the window size.
To make things easy,
use a 2D orthographic projection
whose x- and y-dimensions are is the same
as the window size.
The shapes should stay the same
even when the window is resized.
The bottom-left corner should be fixed.
- How to implement menus?
- How to set up the orthographic projetion as required?
- How to figure out where the mouse position where the user clicks?
- How to handle "dragging"?
- How to render an oval?
- How to render dashed lines? (glLineStipple)
- How to change the line width? (glLineWidth)
- How to render a filled polygon? (glPolygonMode)
- How to render a bounding box while dragging?
- When the user selects an item from the pop-up menu,
a "mouse button up" event is triggered.
Handle this situation carefully.