Organization of the Course

Seminar 01

PB009 Exercise 1

Chyba: Odkazovaný objekt neexistuje nebo nemáte právo jej číst.
https://is.muni.cz/el/fi/jaro2022/PB009/um/exercises/lecture_01.zip

Rasterization

In the first exercise, your task is to implement two different line rasterization algorithms. The exercise skeleton will handle the canvas; you will only tell it where and which color to draw a pixel.

The drawing canvas contains a grid with two separate points. You can position the points any way you like. The position of these points is also the input of your functions you will be implementing.

Make sure you test all the possible combinations of the two points' positions before handing in the exercise: horizontal lines, vertical lines (both directions!), almost vertical, and so on.

Make yourself comfortable using the debugger. Not just printing out to the console. The red dot is your closest friend. Use it often.

DDA line rasterization

Implement a basic DDA line algorithm. No bells nor whistles required.

DDA line anti-aliasing

Add one bell and a couple of whistles. Copy your finished DDA algorithm and add anti-aliasing.

If the resulting pixel position isn't exactly aligned to the grid, color both positions. If it falls 90% to one position, draw the 90% color intensity there and the rest 10% to the other position.

Bresenham line algorithm

Implement basic Bresenham line algorithm.



MAC quick fix

Since the framework by default has problems with retina, you may need to apply this quick fix:

framework/pb009/src/pb009_application.cpp

Replace line 43 with the following piece of code:

int framebufferWidth;
int framebufferHeight;
glfwGetFramebufferSize(this->window, &framebufferWidth, &framebufferHeight);
glViewport(0, 0, framebufferWidth, framebufferHeight);

courses/PB009/lecture_01/application.hpp

Add the following line between lines 156 and 157:

ImGui::SetWindowFontScale(0.5);