Skip to content

shubamuzumaki/OpenGL-Example_Programs

Repository files navigation

OpenGL-Examples_Programs

This repo contains various small graphics program made in c++ using OpenGL to get you started in OpenGL.

List of programs

1️⃣ Line Drawing Algos(DDA and Bresenham)

2️⃣ Circle Drawing Algos(DDA and Bresenham)

3️⃣ 2D Transformation

4️⃣ Color Pane

5️⃣ Patterns

6️⃣ Line Clipping

7️⃣ Koch Curve

8️⃣ Sedd Filling

9️⃣ Hilbert Curve

How to Run 🏃

Linux

Make Sure that your Device has OpenGL installed. If not, install it using this command :

$ sudo apt-get install libglu1-mesa-dev freeglut3-dev mesa-common-dev

Now open the terminal in the current directory and select the program u want to run. Compile that program using the following command :

g++ program_to_run.cpp -lglut -lGL -lGLU

And now you can execute the program using the command :

./a.out

Windows/Mac (Visual Studio)

Make Sure that Visual-Studio is set up for Open-GL projects. if not watch this tutorial.

1️⃣ Clone this repo.

2️⃣ Open the .sln file in Visual Studio.

3️⃣ Command/ctrl + F5 - Run default program.

4️⃣ To run different program go to solution explorer(ctrl+alt+L) window and right click on source files and exclude the ---.cpp file from the project.

5️⃣ shift + alt + a to add existing file in the project. open the current project directory and select the ---.cpp file you want to run.

watch this 👇 if you feel lost

tutorial

Line Drawing Algos

In this program we code basic line drawing algorithms used in graphics.

DDA(Digital Differential Analyzer)

Bresenham

DDA

In computer graphics, a digital differential analyzer (DDA) is hardware or software used for interpolation of variables over an interval between start and end point. DDAs are used for rasterization of lines, triangles and polygons.

👉 to learn more click here

Bresenham

Bresenham's line algorithm is a line drawing algorithm that determines the points of an n-dimensional raster that should be selected in order to form a close approximation to a straight line between two points.

👉 to learn more click here

Demo

line

Circle Drawing Algos

In this program we code various circle drawing algorithms used in graphics.

DDA

Bresenham

Mid-Point

Demo

circle

Color Pane

In this program basic color selection pane which can be used to color different polygons in different colors.

colorpane

Patterns

In this program we code different patterns by using line and circle drawing algorithms used above.

pattern pattern2

Line Clipping

This is cohen sutherland line clipping algorithm. In this we clip line from cliiping window

clip

Koch Curve

Easy to just demonstrate rather than explaining

koch

Hilbert Curve

A Hilbert curve is a continuous fractal space-filling curve first described by the German mathematician David Hilbert in 1891, as a variant of the space-filling Peano curves discovered by Giuseppe Peano in 1890

hilbert