$24
In this assignment we will explore basic image rasterization algorithms. This is an individual assignment, i.e., you have to work independently. All information needed to complete this homework is covered in the lectures and discussed at our Canvas Discussion Boards. You shouldn’t have to use any textbooks or online resources, but if you choose to do so, you must reference these resources in in your final submission. It is strictly prohibited to reuse code or fragments of code from textbooks, online resources or other students -- in this course this is considered as academic misconduct ( https://www.cs.utah.edu/academic-misconduct/ ). Do not share your homework solution with anyone -- this is also treated as academic misconduct in this course,evenifnobodyendsupcopyingyourcode.
TheframeworkcodeiswritteninC++withthefollowingdependencies:
OpenGL1.0
GLUtilities(GLU)
C++STL
OpenGLExtensionWranglerLibrary(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 responsibilitytobuildthedependenciesandgettheprojecttowork.
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, shoulddisplayablackimage.Yourtaskwillbetodrawsomethingintothisimage!
1Linerasterization(50points)
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 savedintofile“data/out.ppm”.
2Circlerasterization(50points)
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.
3ExtraCredit(upto20bonuspointsatinstructor’sdiscretion)
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 createmoreinteresting i mages!
4Submission
Whenyou’refinished withTasks1and2,you’llneedtosubmitthefollowing:
Sourcecode(youshouldonlymodifythemain.cppfile).Themain.cppfileisallweneed --pleasedonotsubmitanyotherfiles,especiallyNOT.exefilesandotherfilescreated byVisualStudio.
PDFdocumentdescribingwhatyoudid,screenshots/graphsarerecommended.Ifyou usedanytextbooksoronlineresourcesthatmayhaveinspiredyourwayofthinking abouttheassignment,youmustreferencestheseresourcesinthisPDFdocument
Yourresultingimage“out.ppm”showcasingyourlineandcirclerasterizationroutines.
[optional]IfyouhavesucceededwithTask3,submitthecode“main-extra.cpp”andan image“out-extra.ppm”showingyourpiecewithellipses.ThiswayyoursolutionofTasks 1and2isclearlyseparatedfromtheextracreditTask3--thishelpstoprevent confusionwhengrading.
PleasepackallofyourfilestoasingleZIPfilenamedLastname_Firstname_HW3.zip
PleasesubmitthisZIPfileviaCanvas.