Skip to content

amengol/MinGL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MinGL

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.

Screenshot

screenshot of a cube rendered with the sample program

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

screenshot of a target rendered with the ShapeSample program

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

Usage

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 compile Main.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

License

MinGL is licensed under MIT License

About

Minimal Graphics Library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published