CSCE 441: Computer Graphics |
Fall 2017 |
Assignment 2: Polygon Scan Conversion and Clipping [150 points]Due 9/27/2017Purpose:This assignment is designed to help you become familiar with polygon scan conversion and clipping algorithms. The scan conversion section of this assignment will later be used in Assignment 4 as well. Description: In this assignment you will write a program that allows the user to input a set of polygons, scan converts those polygons onto the screen, allows the user to specify a clipping rectangle and displays the clipped polygons. You will NOT be using OpenGL's polygon or clipping commands. Instead, you will use the skeleton code provided. This code provides a 2D array for you to set color values and displays that 2D array. However, you may use OpenGL to draw anything else (lines, points, etc...) as part of the user interface for the assignment. You should write a program that:
Grading: [15] Capturing user polygon input correctly [55] Scan converting input polygons [5] Different color for each scanned polygon [5] Mode transition to clipping mode [15] Capturing clip rectangle correctly and drawing of clip rectangle [55] Clipping of polygons and scan conversion of clipped polygons FAQThe assignment says that we should use an active edge table to scan convert the polygons. Does that mean we cannot use glBegin(GL_POLYGON)? As stated in the assignment page, “You will NOT be using OpenGL's polygon or clipping commands.” The entire point of this assignment is to test your knowledge of the polygon drawing and clipping algorithms… not to see if they’re implemented correctly in OpenGL. What about drawing the edges of the window for the clipping region? Can we use glBegin(GL_LINES)? Yes. This assignment is not about line drawing. If you would like to use OpenGL to draw horizontal and vertical lines, you may. When the user drags the mouse during clipping, we need to draw the four edges of the clipping rectangle. Do we also need to change the background color inside the clipping rectangle to highlight it? You do not need to change the background color inside the clipped rectangle. You should only draw the outline of the rectangle. Should the polygons the users originally inputs always remain displayed in the screen? When the user is in clipping mode, only the portions of the polygons inside the clip rectangle should be visible. When the user is not in clipping mode, all of the polygons should be visible. Each time the user drags and lets go of the mouse, a clipping region is highlighted so nothing outside the clipping rectangle is displayed? Yes. While the user is dragging the clipping rectangle, you can show all of the polygons until they let go of the mouse button. Then you should clip the polygons and only draw what is inside the clipping rectangle. Alternatively, if your polygon drawing and clipping is fast enough, you can do it in real-time as the user drags the window. HonorsFor those taking the honors section of this course, you will be implementing a tile-based rasterizer. Divide the screen into roughly square regions (tiles) and place each polygon in the work queue of the tiles it intersects (you may use a bounding box to approximate this). Then rasterize each tile into a local buffer using the inside/outside test specified in lecture. You will implement clipping by not testing those pixels outside the clip region. Furthermore, you will implement the assignment using OpenMP (Note that you need to enable openmp in the Visual Studio project settings). OpenMP allows you to trivially parallelize portions of code using the #pragma omp parallel forconstruct. You should parallelize the individual pixel rasterization in each tile. Once your rasterizer is working, you will analyze its performance under different numbers of processors using omp_set_num_threadsMake sure you do not set the number of threads to be higher than the number of cores on your machine. You should also analyze how the size of the tiles affects performance as well. You should use an accurate timer and perform all of your tests on the same machine with the same conditions if possible. Here is some code you can use to capture timing data in Windows. You might also consider how you implement your algorithm. For example, you might only build an active edge table using the ymin/ymax extents of the polygons and restrict drawing to that area. In addition, if you want your code to perform well, you should keep memory allocations to a minimum (which may mean avoiding the STL depending on how you use it). If you need to allocate memory, you also might consider implementing a very simple fixed size memory pool allocator. Here's a simple fixed-size pool that I wrote if you want to use it. Write up your results in a short report to be included with your submission detailing any conclusions you arrived at as well as graphs showing your experiments to back up your conclusions. Your report will be graded based on the experiments you perform and conclusions you draw rather than achieving an expected result. Honors Section Grading:[15] Capturing user polygon input correctly [55] Scan converting input polygons [5] Different color for each scanned polygon [5] Mode transition to clipping mode [15] Capturing clip rectangle correctly and drawing of clip rectangle [30] Clipping of polygons and scan conversion of clipped polygons [25] Performance analysis |
|||