Sale!

Assignment 3: Rasterization

$30.00

Category:
Rate this product

Assignment 3: Rasterization

In this assignment we will explore basic image rasterization algorithms. This is an individual
assignment, i.e., you have to work independently.
The framework code is written in C++ with the following dependencies:
● OpenGL 1.0
● GL Utilities (GLU)
● C++ STL
● OpenGL Extension Wrangler Library (GLEW)
● GLFW3
The recommended IDE is Visual Studio 2017 Community Edition, which is available free of
charge for educational purposes. The framework code provides precompiled dependencies for
Visual Studio 2017. If you choose to use a different platform or IDE version it is your
responsibility to build the dependencies and get the project to work.
The assignment should be implemented inside the provided main.cpp file using the specified
subroutines. No other source code / dependencies / libraries are needed or allowed for this
assignment. The provided source code, after being successfully compiled, linked, and executed,
should display a black image. Your task will be to draw something into this image!
1 Line rasterization (50 points)
Your first task is to complete the function drawLine(int x1, int y1, int x2, int y2). Using the
Bresenham algorithm for line rasterization, this function should draw a line from pixel (x1, y1) to
pixel (x2, y2). Warning: some formulations of the Bresenham algorithm support only certain
combinations of points (x1, y1) and (x2, y2). Your function is supposed to be general and
support all possible inputs (x1, y1) and (x2, y2). The individual pixels of the line should be
written into the buffer g_image. You may use the provided function putPixel(int x, int y) which
writes a white pixel into g_image at point (x, y). Your line drawing algorithm needs to be able to
handle lines of all directions, but you can assume the points (x1, y1) and (x2, y2) are inside the
dimensions of g_image (600 x 600). After you’ve completed the function drawLine, the provided
function drawImage should draw a simple image on the screen. The same image will be also
saved into file “data/out.ppm”.
2 Circle rasterization (50 points)
The next task is to implement Bresenham’s algorithm for circle rasterization inside function
drawCircle(int x0, int y0, int R), where (x0, y0) is the center of the circle and R is the radius. Just
like in Task 1, you can assume that none of the pixels of the circle will lie outside of the g_image
window.
3 Extra Credit (up to 20 bonus points at instructor’s discretion)
If you are looking for additional challenges, implement Bresenham’s algorithm for drawing an
ellipse and use it to rasterize a new image which will use all of the three primitives (lines, circles,
and ellipses) in a creative way. You can also extend the code to support different colors to
create more interesting images!
4 Submission
When you’re finished with Tasks 1 and 2, you’ll need to submit the following:
– Source code (you should only modify the main.cpp file). The main.cpp file is all we need
— please do not submit any other files, especially NOT .exe files and other files created
by Visual Studio.
– PDF document describing what you did, screenshots / graphs are recommended. If you
used any textbooks or online resources that may have inspired your way of thinking
about the assignment, you must references these resources in this PDF document
– Your resulting image “out.ppm” showcasing your line and circle rasterization routines.
– [optional] If you have succeeded with Task 3, submit the code “main-extra.cpp” and an
image “out-extra.ppm” showing your piece with ellipses. This way your solution of Tasks
1 and 2 is clearly separated from the extra credit Task 3 — this helps to prevent
confusion when grading.
Please pack all of your files to a single ZIP file named Lastname_Firstname_HW3.zip
Please submit this ZIP file via Canvas.

Open chat
Need help?
Hello
Can we help you?