Anaglyph
display objects in 3-D
Classes | Defines | Enumerations | Functions | Variables
anaglyph.cpp File Reference

Framework for creating 3D stereo images (anaglyphs). More...

#include <config.h>
#include <cstdlib>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <cstring>
#include <inttypes.h>
#include <jwsc/math/constants.h>
#include <jwsc/vector/vector.h>
#include <jwsc/vector/vector_math.h>
#include <jwsc/matrix/matrix.h>
#include <jwsc/matrix/matrix_math.h>
#include <jwsc/image/image.h>
#include <jwsc/image/image_io.h>
#include <jwsc++/base/option.h>
#include <jwsc++/base/exception.h>
#include <jwsc++/graphics/camera.h>

Go to the source code of this file.

Classes

struct  Modes
 Modes the viewer can be in. More...

Defines

#define REDBLUE   1
#define REDGREEN   2
#define REDCYAN   3
#define BLUERED   4
#define GREENRED   5
#define CYANRED   6
#define DEFAULT_VIEW_WIDTH   400
#define DEFAULT_VIEW_HEIGHT   400
#define DEFAULT_APERTURE   60.0f
#define DEFAULT_CLIP_NEAR   10.0f
#define DEFAULT_CLIP_FAR   3000.0f
#define DEFAULT_GLASSES_TYPE   REDCYAN
#define DEFAULT_SCALE   1.0
#define DEFAULT_SEED   2537984
#define DEFAULT_CAPTURE_NAME   "capture.tiff"

Enumerations

enum  Object_type {
  SOLID_SPHERE, SOLID_CUBE, SOLID_TORUS, SOLID_TEAPOT,
  WIRE_SPHERE, WIRE_CUBE, WIRE_TORUS, WIRE_TEAPOT
}
 Types of objects that can be rendered. More...

Functions

void init_modes ()
 Initialize the viewer modes.
void init_camera () throw (Arg_error)
 Initializes the camera to default values.
void clean_up ()
 Cleans up the program to prepare for exit.
void reset ()
 Resets the state of the viewer.
void capture_view ()
 Capture the current view and write it as an image.
void render_world_axis ()
 Renders the 3D world axis.
void render_focal_plane ()
 Renders the focal plane.
void render_scene ()
 Renders the scene into the viewer.
void display_glut_anaglyph ()
 Display the model as an anaglyph (3D stereo pair).
void display_glut_regular ()
 Display the model under normal conditions.
void display_glut ()
 Display callback for the GLUT library.
void reshape_glut (int w, int h)
 Reshape callback for the GLUT library.
void keyboard_glut (unsigned char key, int a, int b)
 Keyboard callback for the GLUT library.
void main_menu_glut (int id)
 Main menu callback for the GLUT library.
void option_menu_glut (int id)
 Option submenu callback for the GLUT library.
void navigation_menu_glut (int id)
 Keyboard navigation submenu callback for the GLUT library.
void solid_objects_menu_glut (int id)
 Solid objects submenu callback for the GLUT library.
void wire_objects_menu_glut (int id)
 Wire objects submenu callback for the GLUT library.
void objects_menu_glut (int id)
 Objects submenu callback for the GLUT library.
void focal_length_menu_glut (int id)
 Focal length submenu callback for the GLUT library.
void init_glut (int argc, char **argv)
 Initializes the GLUT to default values.
void init_gl ()
 Initializes the GL to default values.
void print_usage (void)
 Prints the usage of the program.
void process_help_opt (void)
 Processes the 'help' program options.
void process_version_opt (void)
 Processes the 'version' program options.
void process_window_size_opt (const char *arg) throw (Arg_error)
 Processes the 'window-size' program options.
void process_seed_opt (const char *arg) throw (Arg_error)
 Processes the 'seed' program options.
void process_capture_opt (const char *arg) throw (Arg_error)
 Processes the 'capture' program options.
void process_glasses_opt (const char *arg) throw (Arg_error)
 Processes the 'glasses' program options.
void * operator new (size_t s) throw (std::bad_alloc)
void operator delete (void *ptr) throw ()
int main (int argc, char **argv)
 Main function of the program.

Variables

Optionsopts = 0
 Program options.
uint32_t view_width = DEFAULT_VIEW_WIDTH
 Width of the viewing window.
uint32_t view_height = DEFAULT_VIEW_HEIGHT
 Height of the viewing window.
float aperture = DEFAULT_APERTURE
 Viewing aperture.
float clip_near = DEFAULT_CLIP_NEAR
 Near clipping plane.
float clip_far = DEFAULT_CLIP_FAR
 Far clipping plane.
int glasses_type = DEFAULT_GLASSES_TYPE
 Anaglyph glasses type.
float scale = DEFAULT_SCALE
 Scale of the objects.
uint32_t seed = DEFAULT_SEED
 Random seed.
const char * capture_fname = DEFAULT_CAPTURE_NAME
 Name of the file to write the captured view image to.
Stereo_camera_fcamera = 0
 3D viewing Camera.
GLUquadric * quad_fill = 0
 Filled quadric.
GLUquadric * quad_wire = 0
 Wire-frame quadric.
struct Modes modes

Detailed Description

Framework for creating 3D stereo images (anaglyphs).

Author:
Joseph Schlecht
License:
Creative Commons BY-NC-SA 3.0

Definition in file anaglyph.cpp.


Define Documentation

#define REDBLUE   1

Definition at line 113 of file anaglyph.cpp.

#define REDGREEN   2

Definition at line 114 of file anaglyph.cpp.

#define REDCYAN   3

Definition at line 115 of file anaglyph.cpp.

#define BLUERED   4

Definition at line 116 of file anaglyph.cpp.

#define GREENRED   5

Definition at line 117 of file anaglyph.cpp.

#define CYANRED   6

Definition at line 118 of file anaglyph.cpp.

#define DEFAULT_VIEW_WIDTH   400

Definition at line 121 of file anaglyph.cpp.

#define DEFAULT_VIEW_HEIGHT   400

Definition at line 122 of file anaglyph.cpp.

#define DEFAULT_APERTURE   60.0f

Definition at line 123 of file anaglyph.cpp.

#define DEFAULT_CLIP_NEAR   10.0f

Definition at line 124 of file anaglyph.cpp.

#define DEFAULT_CLIP_FAR   3000.0f

Definition at line 125 of file anaglyph.cpp.

#define DEFAULT_GLASSES_TYPE   REDCYAN

Definition at line 126 of file anaglyph.cpp.

#define DEFAULT_SCALE   1.0

Definition at line 127 of file anaglyph.cpp.

#define DEFAULT_SEED   2537984

Definition at line 128 of file anaglyph.cpp.

#define DEFAULT_CAPTURE_NAME   "capture.tiff"

Definition at line 129 of file anaglyph.cpp.


Enumeration Type Documentation

Types of objects that can be rendered.

Enumerator:
SOLID_SPHERE 
SOLID_CUBE 
SOLID_TORUS 
SOLID_TEAPOT 
WIRE_SPHERE 
WIRE_CUBE 
WIRE_TORUS 
WIRE_TEAPOT 

Definition at line 181 of file anaglyph.cpp.


Function Documentation

void init_modes ( )

Initialize the viewer modes.

Definition at line 228 of file anaglyph.cpp.

void init_camera ( ) throw (Arg_error)

Initializes the camera to default values.

Definition at line 243 of file anaglyph.cpp.

void clean_up ( )

Cleans up the program to prepare for exit.

Definition at line 253 of file anaglyph.cpp.

void reset ( )

Resets the state of the viewer.

Definition at line 263 of file anaglyph.cpp.

void capture_view ( )

Capture the current view and write it as an image.

Definition at line 273 of file anaglyph.cpp.

void render_world_axis ( )

Renders the 3D world axis.

Definition at line 301 of file anaglyph.cpp.

void render_focal_plane ( )

Renders the focal plane.

Definition at line 353 of file anaglyph.cpp.

void render_scene ( )

Renders the scene into the viewer.

Definition at line 404 of file anaglyph.cpp.

void display_glut_anaglyph ( )

Display the model as an anaglyph (3D stereo pair).

Reset the color mask.

Definition at line 457 of file anaglyph.cpp.

void display_glut_regular ( )

Display the model under normal conditions.

Definition at line 563 of file anaglyph.cpp.

void display_glut ( )

Display callback for the GLUT library.

Definition at line 597 of file anaglyph.cpp.

void reshape_glut ( int  w,
int  h 
)

Reshape callback for the GLUT library.

Definition at line 619 of file anaglyph.cpp.

void keyboard_glut ( unsigned char  key,
int  a,
int  b 
)

Keyboard callback for the GLUT library.

Definition at line 629 of file anaglyph.cpp.

void main_menu_glut ( int  id)

Main menu callback for the GLUT library.

Definition at line 876 of file anaglyph.cpp.

void option_menu_glut ( int  id)

Option submenu callback for the GLUT library.

Definition at line 900 of file anaglyph.cpp.

void navigation_menu_glut ( int  id)

Keyboard navigation submenu callback for the GLUT library.

Definition at line 917 of file anaglyph.cpp.

void solid_objects_menu_glut ( int  id)

Solid objects submenu callback for the GLUT library.

Definition at line 934 of file anaglyph.cpp.

void wire_objects_menu_glut ( int  id)

Wire objects submenu callback for the GLUT library.

Definition at line 959 of file anaglyph.cpp.

void objects_menu_glut ( int  id)

Objects submenu callback for the GLUT library.

Definition at line 984 of file anaglyph.cpp.

void focal_length_menu_glut ( int  id)

Focal length submenu callback for the GLUT library.

Definition at line 991 of file anaglyph.cpp.

void init_glut ( int  argc,
char **  argv 
)

Initializes the GLUT to default values.

Definition at line 1008 of file anaglyph.cpp.

void init_gl ( )

Initializes the GL to default values.

Definition at line 1062 of file anaglyph.cpp.

void print_usage ( void  )

Prints the usage of the program.

Definition at line 1104 of file anaglyph.cpp.

void process_help_opt ( void  )

Processes the 'help' program options.

Definition at line 1113 of file anaglyph.cpp.

void process_version_opt ( void  )

Processes the 'version' program options.

Definition at line 1122 of file anaglyph.cpp.

void process_window_size_opt ( const char *  arg) throw (Arg_error)

Processes the 'window-size' program options.

Definition at line 1130 of file anaglyph.cpp.

void process_seed_opt ( const char *  arg) throw (Arg_error)

Processes the 'seed' program options.

Definition at line 1151 of file anaglyph.cpp.

void process_capture_opt ( const char *  arg) throw (Arg_error)

Processes the 'capture' program options.

Definition at line 1164 of file anaglyph.cpp.

void process_glasses_opt ( const char *  arg) throw (Arg_error)

Processes the 'glasses' program options.

Definition at line 1174 of file anaglyph.cpp.

void* operator new ( size_t  s) throw (std::bad_alloc)

Definition at line 1201 of file anaglyph.cpp.

void operator delete ( void *  ptr) throw ()

Definition at line 1207 of file anaglyph.cpp.

int main ( int  argc,
char **  argv 
)

Main function of the program.

Definition at line 1216 of file anaglyph.cpp.


Variable Documentation

Options* opts = 0

Program options.

Definition at line 142 of file anaglyph.cpp.

uint32_t view_width = DEFAULT_VIEW_WIDTH

Width of the viewing window.

Definition at line 145 of file anaglyph.cpp.

uint32_t view_height = DEFAULT_VIEW_HEIGHT

Height of the viewing window.

Definition at line 148 of file anaglyph.cpp.

float aperture = DEFAULT_APERTURE

Viewing aperture.

Definition at line 151 of file anaglyph.cpp.

float clip_near = DEFAULT_CLIP_NEAR

Near clipping plane.

Definition at line 154 of file anaglyph.cpp.

float clip_far = DEFAULT_CLIP_FAR

Far clipping plane.

Definition at line 157 of file anaglyph.cpp.

int glasses_type = DEFAULT_GLASSES_TYPE

Anaglyph glasses type.

Definition at line 160 of file anaglyph.cpp.

float scale = DEFAULT_SCALE

Scale of the objects.

Definition at line 163 of file anaglyph.cpp.

uint32_t seed = DEFAULT_SEED

Random seed.

Definition at line 166 of file anaglyph.cpp.

const char* capture_fname = DEFAULT_CAPTURE_NAME

Name of the file to write the captured view image to.

Definition at line 169 of file anaglyph.cpp.

3D viewing Camera.

Definition at line 172 of file anaglyph.cpp.

GLUquadric* quad_fill = 0

Filled quadric.

Definition at line 175 of file anaglyph.cpp.

GLUquadric* quad_wire = 0

Wire-frame quadric.

Definition at line 178 of file anaglyph.cpp.

struct Modes modes