Skip to content

sksharan/OpenGLTest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

173 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenGLTest

OpenGLTest is a test program that I wrote to learn more about OpenGL and graphics programming in general. The libraries used include SDL, GLEW, GLM, SOIL, and libnoise. Images of the program in action can be found at https://github.com/sksharan/OpenGLTest/tree/master/OpenGLTest/photos.

Features

  • Procedurally generates a landscape using Perlin noise with textures based on the slope of the land (rock on steep land and grass on flat land). The landscape is infinite and generated in chunks, with grass blades generated on the terrain through the use of a geometry shader. A more advanced version of this terrain generation (with LOD and multithreading) can be found at https://github.com/sksharan/TerrainGenerator.
  • Implements the Phong reflection model for lighting in the fragment shader.
  • Supports multiple methods for creating objects in the scene. A RenderableObject is any object that can be rendered to the screen. An OBJObject is a RenderableObject with data that comes from Wavefront OBJ files (this project implements a basic parser for OBJ files). A HeightmapObject is a grid-based RenderableObject with height values given by a greyscale "heightmap" image. A PerlinHeightmapObject is much like a HeightmapObject, but with height values given by a Perlin noise equation. The infinite landscape is made up of multiple instances of PerlinHeightmapObject.
  • Creates axis-aligned bounding boxes (AABBs) and oriented bounding boxes (OBBs) for each object. AABBs and OBBs are called AABBObject and OBBObject in the code, and both are subclasses of RenderableObject.
  • Objects can be selected by clicking on them with the mouse cursor. A ray casting technique is used with AABBs to implement this mouse picking.
  • Objects can be transformed and manipulated independently of other objects (see the "Controls" section to see how objects can be manipulated).

Controls

Moving the mouse: Look around the scene.

Left-click: Select an object on the screen. The infinite landscape cannot be selected.

ESC: Ends the program.

W, A, S, D: Move around the scene.

M: Toggles mouselook mode on/off.

Q, E: Select the previous/next object on the list. Current object is shown on the console.

R: Change the rendering mode of the currently selected item.

H: Toggles the visibility of the currently selected object..

J: Toggles the visibility of the currently selected object’s AABB (red box).

K: Toggles the visibility of the currently selected object’s OBB (blue box).

L: Toggles lighting calculations on the current object on/off.

T: Toggles global wireframe rendering on/off.

Y: Toggles between walk mode and fly mode.

Z: Change to translate mode. Current object can then be translated using the ARROW KEYS, LSHIFT, and SPACEBAR.

X: Change to scale mode. Current object can then be scaled using the LEFT/RIGHT ARROW KEYS.

C: Change to rotate mode. Current object can then be rotated using the ARROW KEYS.

1: Generates a checkerboard-textured square (a RenderableObject) at the user’s current location.

2: Generates a tower object (an OBJObject) at the user’s current location.

3: Generates a HeightmapObject at the user’s current location.

4: Generates a PerlinHeightmapObject at the user’s current location.

About

Learning about computer graphics and OpenGL

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages