Skip to content

Scene Viewer made using freeglut and C++, can be used on any modern C++ development software(s) (IDEs/ text editors + compilers), all you need is freeglut libraries installed in your OS.

Notifications You must be signed in to change notification settings

Anvith00/Scene-Viewer-freeglut

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 

Repository files navigation

Scene-Viewer-freeglut

Concept 3D Scene Viewer made using freeglut and C++, all you need is the freeglut development library and a few packages installed in your OS (check here). The source code is one single file, i.e., main.cpp.

image

Components used in this project:

  1. Three Primitives of geometries namely, Cube, Icosahedron and the Pyramid.
  2. Reshape function to maintain the shape of the geometry drawn on any window width and height.
  3. Lighting to imitate ambient, diffuse and specular lighting.
  4. Stars: Generated using point primitives kept inside a for loop with the location for the points kept random using srand() and rand().
  5. Mouse and keyboard callbacks to be able to perform actions on each mouse or keyboard event, to traverse around the three-dimensional world created in the code using two transform functions : Translation and Rotation.

Setting up

  • Linux: xxf86vm and g++ are required for Linux users. You can easily install libXxf86vm/ libxxf86vm/ xxf86vm (depending on the distro you have, package names vary oftentimes in different package families of distros) in the terminal with your package manager. Freeglut development libraries are also needed. Example:
# Fedora Workstation
sudo dnf install g++ libXxf86vm freeglut-devel
# Ubuntu 22.04 and Pop!_OS
sudo apt install g++ libxxf86vm freeglut3-dev
# Arch Linux
sudo pacman -S gcc libxxf86vm freeglut
  • Windows: Windows users will be required to install g++ using MYSYS2. mingw-w64-x86_64-gcc contains the 64-bit binaries of g++. Use the MYSYS2 MINGW64 shell:
# MYSYS2 MINGW64 shell on Windows
pacman -S git mingw-w64-x86_64-gcc mingw-w64-x86_64-freeglut
# (Installing git is kind of redundant and optional depending on what Terminal you use for git operations !).

Note to self: (I also plan to replace MYSYS2 MINGW64 with MSVC in the longer run, to keep the development environment as native as possible).

  • MacOS: Code hasn't been tested on MacOS yet.

Running the code (Terminal)

  • Linux: At the source root, run:
g++ main.cpp -lglut -lGL -lGLU
./a.out

(Linkers: glut, GL and GLU).

  • Windows: At the source root, run:
g++ main.cpp -lfreeglut -lopengl32 -lglu32
./a.exe

(Linkers: freeglut, opengl32 and glu32).

  • MacOS: Code hasn't been tested on MacOS.

About

Scene Viewer made using freeglut and C++, can be used on any modern C++ development software(s) (IDEs/ text editors + compilers), all you need is freeglut libraries installed in your OS.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages