Vis 2 Demo  1.0
Technical illustration type real-time rendering of geometry
 All Classes Namespaces Files Functions Variables Typedefs Macros
Macros | Functions | Variables
main.cpp File Reference

Go to the source code of this file.

Macros

#define WINDOW_WIDTH   1000
 
#define WINDOW_HEIGHT   750
 

Functions

HWND FindConsoleHandle ()
 Function for finding the handle to the opened console of this application. More...
 
LRESULT CALLBACK DlgProc (HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
 Callback function for the dialog at the start of the application. More...
 
void GLFWCALL myMousePosCallBack (int _x, int _y)
 Callback function for the mouse movement. More...
 
void GLFWCALL myMouseButtonCallBack (int _button, int _action)
 Callback function for the mouse buttons. More...
 
void GLFWCALL myMouseWheelCallBack (int _pos)
 Callback function for the mouse wheel. More...
 
void vis2_opengl_window_Init ()
 Function for initializing OpenGL. More...
 
void vis2_Init ()
 Function for initializing the scene to be displayed by the application. More...
 
void adjustCamera ()
 Function for updating the camera position according to mouse input. More...
 
void vis2_Update ()
 Main update function. More...
 
void vis2_Draw ()
 Main draw function. More...
 
void vis2_Cleanup ()
 Function for releasing resources. More...
 
int main ()
 MAIN. More...
 

Variables

double d_DELTA_TIME
 duration of last frame in seconds More...
 
glm::vec4 mouse_data = glm::vec4(0.0f)
 vector containing pos_x, pos_y, velocity_x, velocity_y for the mouse More...
 
glm::vec2 mouse_data_prev = glm::vec2(0.0f)
 vector storing the previous mouse position More...
 
int mouse_wheel_pos = 0
 position of the mouse wheel More...
 
int mouse_wheel_pos_prev = 0
 previous position of the mouse wheel More...
 
float zoom_dist_total = 0.0f
 the zoom distance measured form the initial viewer position More...
 
glm::vec2 zoom_limits
 
bool mouse_right_click = false
 has the value TRUE if the user cklicked the right mouse button, FALSE otherwise More...
 
unsigned int nr_steps = 16
 the number of frames a rotation or pan takes if the last frame had the duration of 10 ms More...
 
float delta_rotX
 
float delta_rotY
 rotation angles around the X and Y axes as a result of user input More...
 
float step_rotX
 
float step_rotY
 rotation increments per frame around the X and Y axes More...
 
float delta_panX
 
float delta_panY
 pan distances along the X and Y axes as a result of user input More...
 
float step_panX
 
float step_panY
 pan increments per frame along the X and Y axes More...
 
glm::vec4 axis_X
 the X axis in homogenous coordinates, calculated from the viewe position and target supplied by the loader_scene_Ptr More...
 
glm::vec4 axis_Y
 the Y axis in homogenous coordinates, calculated from the viewe position and target supplied by the loader_scene_Ptr More...
 
glm::vec4 axis_Z
 the Z axis in homogenous coordinates, calculated from the viewe position and target supplied by the loader_scene_Ptr More...
 
glm::mat4 transformAccum
 the matrix that holds all transformations since the start of the application More...
 
char * scene_path
 the path to the scene descrition file More...
 
vis2::LoaderSceneloader_scene_Ptr
 is the pointer to the scene loader for this application More...
 
vis2::Shadershader_axes_Ptr
 is the shader for the objects visualizing the world axes More...
 
glm::mat4 mM_VP
 is the initial model matrix for the object visualizing the position of the viewer More...
 
glm::mat4 mM_VD
 is the initial model matrix for the object visualizing the target of the viewer More...
 
vis2::SpinningCubecube_VP
 is the object visualizing the view position (for DEBUGGING) More...
 
vis2::SpinningCubecube_VD
 is the object visualizing the view direction (for DEBUGGING) More...
 

Macro Definition Documentation

#define WINDOW_HEIGHT   750

Definition at line 19 of file main.cpp.

#define WINDOW_WIDTH   1000

Definition at line 18 of file main.cpp.

Function Documentation

void adjustCamera ( )

Function for updating the camera position according to mouse input.

Definition at line 389 of file main.cpp.

LRESULT CALLBACK DlgProc ( HWND  hWndDlg,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)

Callback function for the dialog at the start of the application.

Parameters
[in]hWndDlgis the handle to the opened dialog window,
[in]Msgis the type of the message sent by the dialog,
[in]wParamis the command called on the dialog,
[in]lParamis additional message-specific infoemation.

Definition at line 93 of file main.cpp.

HWND FindConsoleHandle ( )

Function for finding the handle to the opened console of this application.

Definition at line 74 of file main.cpp.

int main ( )

MAIN.

Contains the calls to the initialization, update, draw and cleanup functions.
Terminates GLFW after user closes the application.

Returns
0 if no errors occured, an error code otherwise.

Definition at line 549 of file main.cpp.

void GLFWCALL myMouseButtonCallBack ( int  _button,
int  _action 
)

Callback function for the mouse buttons.

Calculates the rotation angle and the pan distance from the user input.

Parameters
[in]_buttonis the button that was pressed or released
[in]_actionis the type of action on the button: GLFW_RELEASE or GLFW_PRESS.

Definition at line 150 of file main.cpp.

void GLFWCALL myMousePosCallBack ( int  _x,
int  _y 
)

Callback function for the mouse movement.

Calculates the relative position and velocity of the mouse.
Also flips the origin of the screen from the upper-left to to the lower-left corner.

Parameters
[in]_xis the horizontal position of the mouse (0 is left, WINDOW_WIDTH is right)
[in]_yis the vertical position of the mouse (0 is top, WINDOW_HEIGHT is bottom)

Definition at line 135 of file main.cpp.

void GLFWCALL myMouseWheelCallBack ( int  _pos)

Callback function for the mouse wheel.

Calculates the zoom distance from the user input.

Parameters
[in]_posis the current position of the rotating mouse wheel.

Definition at line 223 of file main.cpp.

void vis2_Cleanup ( )

Function for releasing resources.

Deletes the scene loader, the drawable objects and the shaders in the application.

Definition at line 525 of file main.cpp.

void vis2_Draw ( )

Main draw function.

It calls the draw function on all drawable objects in the application.

Definition at line 494 of file main.cpp.

void vis2_Init ( )

Function for initializing the scene to be displayed by the application.

It calls the scene loader and all helper objects, including the world axes.

Definition at line 356 of file main.cpp.

void vis2_opengl_window_Init ( )

Function for initializing OpenGL.

This function calls GLFW to open the application window, set the OpenGl version,
the debugging environment, and obtain handles to GLEW functions.
It also registers the mouse callback functions.

Definition at line 255 of file main.cpp.

void vis2_Update ( )

Main update function.

It applies the transfromations due to user input to all objects in the scene.

Definition at line 471 of file main.cpp.

Variable Documentation

glm::vec4 axis_X

the X axis in homogenous coordinates, calculated from the viewe position and target supplied by the loader_scene_Ptr

Definition at line 45 of file main.cpp.

glm::vec4 axis_Y

the Y axis in homogenous coordinates, calculated from the viewe position and target supplied by the loader_scene_Ptr

Definition at line 46 of file main.cpp.

glm::vec4 axis_Z

the Z axis in homogenous coordinates, calculated from the viewe position and target supplied by the loader_scene_Ptr

Definition at line 47 of file main.cpp.

is the object visualizing the view direction (for DEBUGGING)

Definition at line 65 of file main.cpp.

is the object visualizing the view position (for DEBUGGING)

Definition at line 64 of file main.cpp.

double d_DELTA_TIME

duration of last frame in seconds

Definition at line 25 of file main.cpp.

float delta_panX

Definition at line 42 of file main.cpp.

float delta_panY

pan distances along the X and Y axes as a result of user input

Definition at line 42 of file main.cpp.

float delta_rotX

Definition at line 40 of file main.cpp.

float delta_rotY

rotation angles around the X and Y axes as a result of user input

Definition at line 40 of file main.cpp.

vis2::LoaderScene* loader_scene_Ptr

is the pointer to the scene loader for this application

Definition at line 54 of file main.cpp.

glm::mat4 mM_VD

is the initial model matrix for the object visualizing the target of the viewer

Definition at line 62 of file main.cpp.

glm::mat4 mM_VP

is the initial model matrix for the object visualizing the position of the viewer

Definition at line 61 of file main.cpp.

glm::vec4 mouse_data = glm::vec4(0.0f)

vector containing pos_x, pos_y, velocity_x, velocity_y for the mouse

Definition at line 29 of file main.cpp.

glm::vec2 mouse_data_prev = glm::vec2(0.0f)

vector storing the previous mouse position

Definition at line 30 of file main.cpp.

bool mouse_right_click = false

has the value TRUE if the user cklicked the right mouse button, FALSE otherwise

Definition at line 37 of file main.cpp.

int mouse_wheel_pos = 0

position of the mouse wheel

Definition at line 32 of file main.cpp.

int mouse_wheel_pos_prev = 0

previous position of the mouse wheel

Definition at line 33 of file main.cpp.

unsigned int nr_steps = 16

the number of frames a rotation or pan takes if the last frame had the duration of 10 ms

Definition at line 39 of file main.cpp.

char* scene_path

the path to the scene descrition file

Definition at line 53 of file main.cpp.

vis2::Shader* shader_axes_Ptr

is the shader for the objects visualizing the world axes

Definition at line 59 of file main.cpp.

float step_panX

Definition at line 43 of file main.cpp.

float step_panY

pan increments per frame along the X and Y axes

Definition at line 43 of file main.cpp.

float step_rotX

Definition at line 41 of file main.cpp.

float step_rotY

rotation increments per frame around the X and Y axes

Definition at line 41 of file main.cpp.

glm::mat4 transformAccum

the matrix that holds all transformations since the start of the application

Definition at line 49 of file main.cpp.

float zoom_dist_total = 0.0f

the zoom distance measured form the initial viewer position

Definition at line 34 of file main.cpp.

glm::vec2 zoom_limits

Definition at line 35 of file main.cpp.