D:/Basile/VisualCppProjects/hydroMEX3/hydroMEX3/oGL_graphics/graphics_main.cpp File Reference

#include "graphics_relative.h"
#include "../hydro_source/dataFillings.h"

Include dependency graph for graphics_main.cpp:

Go to the source code of this file.

Functions

GLvoid BuildFont (GLvoid)
 Create OSD font.
GLvoid KillFont (GLvoid)
 Delete font list.
GLvoid glPrint (const char *fmt,...)
 Custom GL "Print" Routine.
GLvoid ReSizeGLScene (GLsizei width, GLsizei height)
int InitGL (GLvoid)
 Initialize OpenGL stuff.
int DrawGLScene (datas *d)
 Draws the scene (openGL).
GLvoid KillGLWindow (GLvoid)
BOOL CreateGLWindow (char *title, int width, int height, int bits, bool fullscreenflag)
 Sub-function for window closing stuffs.
LRESULT CALLBACK WndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 Callback and keyboard management.
int draw_graphics_init (datas *d)
 General graphic stuff initialisation.
bool draw_graphics (datas *d)
 General graphic (scene) display and keyboard reading.
int draw_graphics_kill ()
 General graphic (scene/window) closing.
void pass_joy_parameters (joy_parameters *jP)
 Copy joystick parameters from MATLAB struct.

Variables

HGLRC hRC = NULL
HDC hDC = NULL
HWND hWnd = NULL
HINSTANCE hInstance
GLuint base
bool keys [256]
bool active = TRUE
bool fullscreen = TRUE
bool light
GLfloat viewAngle1 = 0.0
 horizontal camera view angle
GLfloat viewAngle2 = 0.3
 vertical camera view angle
GLfloat dviewAngle = 0.01
GLfloat viewDist = 50.0
 camera view distance
GLfloat dviewDist = 0.3
GLfloat LightAmbient [] = { 0.35f, 0.35f, 0.5f, 1.0f }
GLfloat LightDiffuse [] = { 0.6f, 0.6f, 0.6f, 1.0f }
GLfloat LightPosition [] = { -10.0f, 20.0f, 150.0f, 0.0f }
MSG msg
BOOL done = FALSE
int joystick_exist
bool doX = TRUE
bool doY = TRUE
bool doZ = TRUE
bool doR = TRUE
bool allowChangeDoX = TRUE
bool allowChangeDoY = TRUE
bool allowChangeDoZ = TRUE
bool allowChangeDoR = TRUE
float dirX = 1.0f
float dirY = 1.0f
float dirZ = 1.0f
float dirR = 1.0f
bool allowChangeDirX = TRUE
bool allowChangeDirY = TRUE
bool allowChangeDirZ = TRUE
bool allowChangeDirR = TRUE
float time_before = 0.0
float time_elapsed
float fps = 0.0


Detailed Description

Author:
basile.graf@epfl.ch
This is the main graphic code. Window management, (main) OpenGL drawing, ...

Definition in file graphics_main.cpp.


Function Documentation

GLvoid BuildFont GLvoid   ) 
 

Create OSD font.

Creates font for OSD (On Screen Display), i.e. displaying various informations on the screen... (Windows dependent)

Definition at line 74 of file graphics_main.cpp.

References base, and hDC.

Referenced by InitGL().

BOOL CreateGLWindow char *  title,
int  width,
int  height,
int  bits,
bool  fullscreenflag
 

Sub-function for window closing stuffs.

Definition at line 331 of file graphics_main.cpp.

References fullscreen, hDC, hInstance, hRC, hWnd, InitGL(), KillGLWindow(), ReSizeGLScene(), and WndProc().

Referenced by draw_graphics(), and draw_graphics_init().

bool draw_graphics datas d  ) 
 

General graphic (scene) display and keyboard reading.

A call to this function refreshes the entire scene. This function is to be used in the main computing loop.
It also reads the keyboard for the different keyboard controls...

Parameters:
*d : pointer to the datas data-structure
Returns:
true if all went OK

Definition at line 599 of file graphics_main.cpp.

References active, allowChangeDirR, allowChangeDirX, allowChangeDirY, allowChangeDirZ, allowChangeDoR, allowChangeDoX, allowChangeDoY, allowChangeDoZ, datas::angle_girouette, CreateGLWindow(), dirR, dirX, dirY, dirZ, done, doR, doX, doY, doZ, DrawGLScene(), dviewAngle, dviewDist, fullscreen, hDC, datas::Hslider_x, keys, KillGLWindow(), datas::max_abs_angle_baume, msg, datas::t, datas::tanAngle_sail, datas::target_x, datas::target_y, time_before, time_elapsed, viewAngle1, viewAngle2, viewDist, datas::Vslider_x, datas::Wave_amp, datas::Wave_amp0, datas::Wave_amp1, datas::Wave_amp2, datas::Wind, datas::Wind_angle, datas::Wind_x, and datas::Wind_y.

Referenced by mexFunction().

int draw_graphics_init datas d  ) 
 

General graphic stuff initialisation.

Ask for full-screen or not, creates window and try to initialize the joystick.

Parameters:
*d : pointer to the datas data-structure
Returns:
1 if window created sucessfully

Definition at line 568 of file graphics_main.cpp.

References CreateGLWindow(), fullscreen, joystick_exist, and joystick_init().

Referenced by mexFunction().

int draw_graphics_kill  ) 
 

General graphic (scene/window) closing.

Closes window and joystick

Returns:
msg.wParam (MS Windows !)

Definition at line 774 of file graphics_main.cpp.

References done, joystick_close(), KillGLWindow(), and msg.

Referenced by mexFunction().

int DrawGLScene datas d  ) 
 

Draws the scene (openGL).

Draws the scene by appling all necessary geometrical (spacial) transformations and by calling the different element drawing functions (for the boat, the sea, the instruments...). This is not the highest function for drwaing the current scene, see draw_graphics().

Definition at line 189 of file graphics_main.cpp.

References angles_update(), Boat_draw(), dirR, dirX, dirY, dirZ, doR, doX, doY, doZ, Draw_sea(), datas::dx, datas::dy, f(), fps, Girouette_draw(), glPrint(), HSlider_draw(), datas::Hslider_x, joystick_exist, joystick_getXYZR(), LightPosition, datas::phi, datas::psi, RelativeWind_draw(), Sail_create_and_draw(), Target_draw(), datas::target_x, datas::target_y, datas::theta, time_elapsed, viewAngle1, viewAngle2, viewDist, VSlider_draw(), datas::Vslider_x, wave_z_compute(), datas::Wind, datas::Wind_x, datas::Wind_y, datas::x, datas::y, and datas::z.

Referenced by draw_graphics().

GLvoid glPrint const char *  fmt,
  ...
 

Custom GL "Print" Routine.

A function that can be used like fprint(), but for writing on the OpenGL window

Definition at line 116 of file graphics_main.cpp.

References base.

Referenced by DrawGLScene().

int InitGL GLvoid   ) 
 

Initialize OpenGL stuff.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 159 of file graphics_main.cpp.

References BuildFont(), f(), LightAmbient, LightDiffuse, and LightPosition.

Referenced by CreateGLWindow().

GLvoid KillFont GLvoid   ) 
 

Delete font list.

Delete the font list created by BuildFont()

Definition at line 107 of file graphics_main.cpp.

References base.

GLvoid KillGLWindow GLvoid   ) 
 

Definition at line 287 of file graphics_main.cpp.

References fullscreen, hDC, hInstance, hRC, and hWnd.

Referenced by CreateGLWindow(), draw_graphics(), and draw_graphics_kill().

void pass_joy_parameters joy_parameters jP  ) 
 

Copy joystick parameters from MATLAB struct.

Copy the joystick parameters (doX, doY ,doZ ,doR and dirX ,dirY ,diZ ,dirR) from the MATLAB struct *jP to the local joystick parameters variables.

Parameters:
*jP : Structure comming from MATLAB or filled with default values defining joystick axes usage and direction.

Definition at line 788 of file graphics_main.cpp.

References dirR, joy_parameters::dirR, dirX, joy_parameters::dirX, dirY, joy_parameters::dirY, dirZ, joy_parameters::dirZ, doR, joy_parameters::doR, doX, joy_parameters::doX, doY, joy_parameters::doY, doZ, and joy_parameters::doZ.

Referenced by mexFunction().

GLvoid ReSizeGLScene GLsizei  width,
GLsizei  height
 

Definition at line 138 of file graphics_main.cpp.

References f().

Referenced by CreateGLWindow(), and WndProc().

LRESULT CALLBACK WndProc HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam
 

Callback and keyboard management.

Definition at line 510 of file graphics_main.cpp.

References active, keys, and ReSizeGLScene().

Referenced by CreateGLWindow().


Variable Documentation

bool active = TRUE
 

Definition at line 23 of file graphics_main.cpp.

Referenced by draw_graphics(), and WndProc().

bool allowChangeDirR = TRUE
 

Definition at line 62 of file graphics_main.cpp.

Referenced by draw_graphics().

bool allowChangeDirX = TRUE
 

Definition at line 59 of file graphics_main.cpp.

Referenced by draw_graphics().

bool allowChangeDirY = TRUE
 

Definition at line 60 of file graphics_main.cpp.

Referenced by draw_graphics().

bool allowChangeDirZ = TRUE
 

Definition at line 61 of file graphics_main.cpp.

Referenced by draw_graphics().

bool allowChangeDoR = TRUE
 

Definition at line 54 of file graphics_main.cpp.

Referenced by draw_graphics().

bool allowChangeDoX = TRUE
 

Definition at line 51 of file graphics_main.cpp.

Referenced by draw_graphics().

bool allowChangeDoY = TRUE
 

Definition at line 52 of file graphics_main.cpp.

Referenced by draw_graphics().

bool allowChangeDoZ = TRUE
 

Definition at line 53 of file graphics_main.cpp.

Referenced by draw_graphics().

GLuint base
 

Definition at line 19 of file graphics_main.cpp.

Referenced by BuildFont(), glPrint(), and KillFont().

float dirR = 1.0f
 

Definition at line 58 of file graphics_main.cpp.

Referenced by draw_graphics(), DrawGLScene(), and pass_joy_parameters().

float dirX = 1.0f
 

Definition at line 55 of file graphics_main.cpp.

Referenced by draw_graphics(), DrawGLScene(), and pass_joy_parameters().

float dirY = 1.0f
 

Definition at line 56 of file graphics_main.cpp.

Referenced by draw_graphics(), DrawGLScene(), and pass_joy_parameters().

float dirZ = 1.0f
 

Definition at line 57 of file graphics_main.cpp.

Referenced by draw_graphics(), DrawGLScene(), and pass_joy_parameters().

BOOL done = FALSE
 

Definition at line 43 of file graphics_main.cpp.

Referenced by draw_graphics(), and draw_graphics_kill().

bool doR = TRUE
 

Definition at line 50 of file graphics_main.cpp.

Referenced by draw_graphics(), DrawGLScene(), and pass_joy_parameters().

bool doX = TRUE
 

Definition at line 47 of file graphics_main.cpp.

Referenced by draw_graphics(), DrawGLScene(), and pass_joy_parameters().

bool doY = TRUE
 

Definition at line 48 of file graphics_main.cpp.

Referenced by draw_graphics(), DrawGLScene(), and pass_joy_parameters().

bool doZ = TRUE
 

Definition at line 49 of file graphics_main.cpp.

Referenced by draw_graphics(), DrawGLScene(), and pass_joy_parameters().

GLfloat dviewAngle = 0.01
 

Definition at line 32 of file graphics_main.cpp.

Referenced by draw_graphics().

GLfloat dviewDist = 0.3
 

Definition at line 34 of file graphics_main.cpp.

Referenced by draw_graphics().

float fps = 0.0
 

Definition at line 65 of file graphics_main.cpp.

Referenced by DrawGLScene().

bool fullscreen = TRUE
 

Definition at line 24 of file graphics_main.cpp.

Referenced by CreateGLWindow(), draw_graphics(), draw_graphics_init(), and KillGLWindow().

HDC hDC = NULL
 

Definition at line 15 of file graphics_main.cpp.

Referenced by BuildFont(), CreateGLWindow(), draw_graphics(), and KillGLWindow().

HINSTANCE hInstance
 

Definition at line 17 of file graphics_main.cpp.

Referenced by CreateGLWindow(), and KillGLWindow().

HGLRC hRC = NULL
 

Definition at line 14 of file graphics_main.cpp.

Referenced by CreateGLWindow(), and KillGLWindow().

HWND hWnd = NULL
 

Definition at line 16 of file graphics_main.cpp.

Referenced by CreateGLWindow(), and KillGLWindow().

int joystick_exist
 

Definition at line 46 of file graphics_main.cpp.

Referenced by draw_graphics_init(), and DrawGLScene().

bool keys[256]
 

Definition at line 22 of file graphics_main.cpp.

Referenced by draw_graphics(), and WndProc().

bool light
 

Definition at line 26 of file graphics_main.cpp.

GLfloat LightAmbient[] = { 0.35f, 0.35f, 0.5f, 1.0f }
 

Definition at line 37 of file graphics_main.cpp.

Referenced by InitGL().

GLfloat LightDiffuse[] = { 0.6f, 0.6f, 0.6f, 1.0f }
 

Definition at line 38 of file graphics_main.cpp.

Referenced by InitGL().

GLfloat LightPosition[] = { -10.0f, 20.0f, 150.0f, 0.0f }
 

Definition at line 39 of file graphics_main.cpp.

Referenced by DrawGLScene(), and InitGL().

MSG msg
 

Definition at line 42 of file graphics_main.cpp.

Referenced by draw_graphics(), and draw_graphics_kill().

float time_before = 0.0
 

Definition at line 63 of file graphics_main.cpp.

Referenced by draw_graphics().

float time_elapsed
 

Definition at line 64 of file graphics_main.cpp.

Referenced by draw_graphics(), and DrawGLScene().

GLfloat viewAngle1 = 0.0
 

horizontal camera view angle

Definition at line 30 of file graphics_main.cpp.

Referenced by draw_graphics(), and DrawGLScene().

GLfloat viewAngle2 = 0.3
 

vertical camera view angle

Definition at line 31 of file graphics_main.cpp.

Referenced by draw_graphics(), and DrawGLScene().

GLfloat viewDist = 50.0
 

camera view distance

Definition at line 33 of file graphics_main.cpp.

Referenced by draw_graphics(), and DrawGLScene().


Generated on Fri Jun 9 19:10:34 2006 for hydroMex3 by  doxygen 1.4.6-NO