MinGL (Minimal Graphics Library) is a tiny graphics rendering class built on top of OpenGL. Its core function is MinGL::putPixel()
, which receives the x/y coordinates and a color to draw a single pixel on the screen.
The idea is to serve as the most basic graphics API to try computer graphics concepts and algorithms such as line drawing, triangle rasterization, perspective projection etc, without the need to deal with complicated API states and calls. Without a graphics API, such concepts are usually tested using still images rendered to disc, but with MinGL you can see the results immediately.
Note: Since ray-tracing is very demanding, you better of writing an image to disc in such cases.
The above image was drawn using MinGL drawLine()
function based on Bresenham’s Line Algorithm
Bresenham’s Line Algorithm used in the example's drawCube() function is based on https://github.com/ssloy/tinyrenderer/wiki
The above image was drawn using MinGL functions drawLine()
, drawRectangle()
, and drawCircle()
, the code can be found in Example.cpp drawShapes() function
drawLine()
function is based on Bresenham’s Line Algorithm
drawRectangle()
function utilises drawLine()
function mentioned above
drawCircle()
function is based on Bresenham's Circle Drawing Algorithm
MinGL depends on glad and GLFW to work. Following is an example of how files could be organized:
.
├── Example
│ ├── Example.cpp
│ ├── Example.h
| └── Main.cpp
├── glad
│ ├── glad.c
│ ├── glad.h
│ └── khrplatform.h
├── GLFW
│ ├── glfw3.h
│ └── glfw3native.h
├── MinGL.h
└── MinGL.cpp
Note:
-
If you are trying to run the example, don't forget to link the glfw2 binaries: https://www.glfw.org/download.
-
Make sure to include the necessary files and link the libraries.
If you are using
g++
for compiling you can use the following command to compileMain.cpp
.g++ -std=c++14 -I./ -IExample Example/Main.cpp glad/glad.c MinGL.cpp Example/Example.cpp -lglfw -o Main
If you want to compile your own file and not include the example code, use the following
g++ -std=c++14 -I./ <filename>.cpp glad/glad.c MinGL.cpp -lglfw -o <output filename>
-
Use C++ 14 or higher
MinGL is licensed under MIT License
- glad is licensed under MIT License
- GLFW is licensed zlib license