A Simple Mesh Viewer Tutorial with C++ Source

Triangle Soup

The mesh models are represented as a list of triangles, each triangle has three vertices, three normals, three texture coordinates. The vertex may have color information as well. The data structure is called triangle soup. The viewer support two formats, obj file and m file.

Polygonal Rendering Mode

The simple viewer can do flat shading, smooth shading and wireframe rendering. The hot keys for three modes are 'f' for flat shading, 's' for smooth shading and 'w' for wireframe mode.
input surface
harmonic map image
Flat shading: 'f' key Smooth shading: 's' key Wireframe: 'w' key

Geometry Mode

The viewer can render both 3D geometry of the surface, or the 2D texture parameter of the surface. Press 'g' to toggle different geometry mode.
input surface
harmonic map image
3D Surface Geometry 2D Parameter Geometry

Texture Mode

There are three texture modes, no texture, texture blends with the shading, texture replaces the shading. By press 't' to toggle through the texture modes.
input surface
harmonic map image
No texture Blended texture Replacement texture

Arcball Interface

The simple mesh viewer uses arcball interface, left mouse button for rotation, right mouse button for zoom in/out, middle mouse button for translation.


The simple mesh viewer uses glut32 on windows and OpenGL. It is written in generic C++ and has been successfully compiled on both Windows and Ubuntu platforms.

Source Code

The code is written in C++ using VisualStudio on Windows platform.
  1. Download the SimpleViewer.zip file, unzip it.
  2. Enter SimpleViewer/Viewer/Test directory, double click on Test.sln file. Compile the project using Visual Studio.
  3. The output is SimpleViewer/bin/SimpleViewer.exe
  4. Go to SimpleViewer/demo/ directory, double click on view_test.bat


If you encounter any problem during the compilation and running the code, please contact the author David Gu at $gu@cs.stonybrook.edu$.