Skip to content

Latest commit

 

History

17 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenGl Exercises and Experiments

This is a collection of OpenGL exercises and experiments. The goal is to learn and understand OpenGL by doing experiments and exercises. This project is templeted from my base templete opengl-base

Experiment Categories

  • Understanding drawing algorithms (for lines, circles, bezier curves, etc) using Drawmode with GL_POINTS
  • Understanding transformations

Experiments

  • Default Blank Window
  • Lines using DDA & Bresenham Algorithm
  • Circles using Midpoint & Bresenham Algorithm
  • Circle Art: Illusive pattern using circles
  • Ellipses using Midpoint Algorithm
  • Ellipse Art: Toyota Logo using ellipses
  • Rook 2D: Rook using trangles & lines, demonstrating 2D transformations
  • House 3D: demonstrating 3D transformations
  • Fill Art: Fill the shapes using Boundry Fill & Flood Fill Algorithm

Algorithms

  • DDA Line Drawing Algorithm
  • Bresenham Line Drawing Algorithm
  • Midpoint Circle Drawing Algorithm
  • Breseham Circle Drawing Algorithm
  • Midpoint Ellipse Drawing Algorithm
  • 2D Transformations (Translation, Rotation, Scaling, Shearing, Reflection)
  • 3D Transformations (Translation, Rotation, Scaling, Reflection)
  • Boundry Fill Algorithm
  • Flood Fill Algorithm

Utilities

  • OB_CaptureFrame : To take screenshot of the current frame
  • GetWidthHeight : To get the width and height of the window
  • GetPixels : To get the pixels of the window
  • RenderPixels : To render the pixels to the window
  • GetPixelIndex : To get the index of the pixel in the pixel array
  • getPixelColor : To get the color of the pixel in the pixel array
  • setPixelColor : To set the color of the pixel in the pixel array

✅ tested on macos

Repository Structure

  • src/ - Contains the source code for the various algorithms
  • renderer/ - Contains the source code for the experiments done using Draw mode (each file is a seperate renderer [expreriment])
  • shaders/ - Contains the shaders for the experiments done using Shader mode
  • include/ - Contains the header files base setup

Getting Started

Prerequisites (macos)

brew install glfw3 glew

To switch between Draw Mode and Shader Mode

comment / uncomment out the #define OB_ENABLE_SHADER in include/ob.h to switch between Draw Mode and Shader Mode

To Select the Experiment in Draw Mode

update the RENDERER variable in Makefile to the file name of the renderer you want to run

To Select the Experiment in Shader Mode

update the shaders name in include/ob.h to the shaders you want to run

To Take Screenshot

call OB_CaptureFrame(filepath, context), it will save the current frame to the filepath

Build & Run

make

or

Run task Build & Run in vscode (cmd + shift + b)

About

Many Exercises and Experiments in OpenGL done by me during the CGVR labs

Resources

Stars

1 star

Watchers

1 watching

Forks

Contributors

Languages

Generated from iamabhi747/opengl-base