WindowHandler Class Reference

#include <WindowHandler.h>

List of all members.

Public Member Functions

 WindowHandler ()
 WindowHandler (GLuint screen_width, GLuint screen_height, GLuint screen_depth)
 ~WindowHandler ()
void createWindow ()
void initOpenGLDrawingSurface ()
void initOpenGL ()
void resizeVideoMode (GLuint screen_width, GLuint screen_height)
void toggleFullScreen ()

Protected Member Functions

void resetupPixelFormat ()

Protected Attributes

SDL_Surface * main_window_
 This holds the SDL window.

GLuint screen_width_
 This holds the screen width of the window.

GLuint screen_height_
 This holds the screen height of the window.

GLuint screen_depth_
 This holds the screen depth (i.e., bit per pixel) of the window.

GLuint pixel_format_flag_


Detailed Description

This class contains methods and member variables for creating and displaying of an window for drawing a scene on it.

Definition at line 19 of file WindowHandler.h.


Constructor & Destructor Documentation

WindowHandler::WindowHandler  )  [inline]
 

The default constructor.

Definition at line 39 of file WindowHandler.h.

References pixel_format_flag_, screen_depth_, screen_height_, and screen_width_.

00039 : 00040 pixel_format_flag_(0), 00041 screen_width_(800), 00042 screen_height_(600), 00043 screen_depth_(16) 00044 { 00045 }

WindowHandler::WindowHandler GLuint  screen_width,
GLuint  screen_height,
GLuint  screen_depth
[inline]
 

This constructor takes some screen preferences.

Parameters:
screen_width The screen width.
screen_height The screen height.
screen_ The screen height.

Definition at line 54 of file WindowHandler.h.

References screen_depth_, screen_height_, and screen_width_.

00055 : 00056 screen_width_(screen_width <= 0 ? 100 : screen_width), 00057 screen_height_(screen_height <= 0 ? 100 : screen_height), 00058 screen_depth_(screen_depth <= 0 ? 16 : screen_depth) 00059 { 00060 }

WindowHandler::~WindowHandler  )  [inline]
 

The destructor.

Definition at line 66 of file WindowHandler.h.

00067 { 00068 }


Member Function Documentation

void WindowHandler::createWindow  ) 
 

This creates a new SDL window in which virtual objects can be displayed and considered.

Parameters:
caption The caption of the window.
Precondition:
caption != NULL

pixel_format_flag_ != 0;

Definition at line 19 of file WindowHandler.cpp.

References main_window_, pixel_format_flag_, resetupPixelFormat(), screen_depth_, screen_height_, and screen_width_.

00020 { 00021 if (SDL_Init(SDL_INIT_VIDEO) < 0) 00022 { 00023 cerr << "Can't initialize SDL video: " << SDL_GetError() << endl; 00024 return; 00025 } 00026 resetupPixelFormat(); 00027 00028 main_window_ = SDL_SetVideoMode(screen_width_, screen_height_, screen_depth_, 00029 pixel_format_flag_); 00030 if (main_window_ == NULL) 00031 { 00032 cerr << "Can't create SDL window: " << SDL_GetError() << endl; 00033 quitApplication(1); 00034 } 00035 SDL_WM_SetCaption("InfoViz: Radial Tree Layout Technique", NULL); 00036 }

Here is the call graph for this function:

void WindowHandler::initOpenGL  ) 
 

This initializes OpenGL.

Definition at line 98 of file WindowHandler.cpp.

References screen_height_, screen_height_, screen_width_, and screen_width_.

Referenced by initOpenGLDrawingSurface(), and resizeVideoMode().

00099 { 00100 // resize OpenGL viewport 00101 screen_height_ <= 0 ? screen_height_ = 1 : screen_height_; 00102 screen_width_ <= 0 ? screen_width_ = 1 : screen_width_; 00103 00104 glViewport(0, 0, screen_width_, screen_height_); 00105 glMatrixMode(GL_PROJECTION); 00106 glLoadIdentity(); 00107 gluPerspective(45.0f, (GLfloat)screen_width_ / (GLfloat)screen_height_, 1, 00108 50.0f); 00109 glMatrixMode(GL_MODELVIEW); // select the modelview matrix 00110 glLoadIdentity(); // reset the modelview matrix 00111 }

void WindowHandler::initOpenGLDrawingSurface  ) 
 

This initializes the OpenGL drawing surface

Definition at line 87 of file WindowHandler.cpp.

References initOpenGL().

00088 { 00089 initOpenGL(); 00090 00091 // here comes stuff like loading models etc. 00092 }

Here is the call graph for this function:

void WindowHandler::resetupPixelFormat  )  [protected]
 

This resets the pixel format flag.

Precondition:
pixel_format_flag_ == 0;

Definition at line 43 of file WindowHandler.cpp.

References pixel_format_flag_, and screen_depth_.

Referenced by createWindow().

00044 { 00045 pixel_format_flag_ != 0 ? pixel_format_flag_ = 0 : pixel_format_flag_ ; 00046 00047 pixel_format_flag_ |= SDL_OPENGL; // it's an OpenGL window 00048 pixel_format_flag_ |= SDL_HWPALETTE; // access to hardware color palette 00049 pixel_format_flag_ |= SDL_RESIZABLE; // resizable window 00050 00051 const SDL_VideoInfo *video_card_info = SDL_GetVideoInfo(); 00052 if (video_card_info == NULL) 00053 { 00054 cerr << "Can't get video card information: " << SDL_GetError() << endl; 00055 exit(pixel_format_flag_); 00056 quitApplication(1); 00057 } 00058 // try to use hardware surface (i.e. window) 00059 if (video_card_info -> hw_available) 00060 { 00061 pixel_format_flag_ |= SDL_HWSURFACE; 00062 } 00063 else 00064 { 00065 pixel_format_flag_ |= SDL_SWSURFACE; 00066 } 00067 00068 // blitting is fast copying/moving/swapping of contiguous sections of memory 00069 if (video_card_info -> blit_hw) 00070 { 00071 pixel_format_flag_ |= SDL_HWACCEL; 00072 } 00073 00074 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); 00075 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, screen_depth_); 00076 SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0); 00077 SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE, 0); 00078 SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE, 0); 00079 SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE, 0); 00080 SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, 0); 00081 }

void WindowHandler::resizeVideoMode GLuint  screen_width,
GLuint  screen_height
 

This resizes the video mode.

Parameters:
screen_width The screen width of the new window.
screen_height The screen height of the new window.

Definition at line 119 of file WindowHandler.cpp.

References initOpenGL(), main_window_, pixel_format_flag_, resizeVideoMode(), screen_depth_, screen_height_, and screen_width_.

Referenced by resizeVideoMode(), and RenderingHandler::runMainLoop().

00120 { 00121 screen_width_ = screen_width; 00122 screen_height_ = screen_height; 00123 main_window_ = SDL_SetVideoMode(screen_width_, screen_height_, screen_depth_, 00124 pixel_format_flag_); 00125 initOpenGL(); 00126 if (main_window_ == NULL) 00127 { 00128 cerr << "Can't resize SDL window: " << SDL_GetError() << endl; 00129 quitApplication(1); 00130 } 00131 }

Here is the call graph for this function:

void WindowHandler::toggleFullScreen  ) 
 

This toggles full screen.

Definition at line 137 of file WindowHandler.cpp.

References main_window_.

Referenced by RenderingHandler::handleKeyPressEvent().

00138 { 00139 if (SDL_WM_ToggleFullScreen(main_window_) == 0) 00140 { 00141 cerr << "Can't toggle full screen mode: " << SDL_GetError() << endl; 00142 quitApplication(0); 00143 } 00144 }


Member Data Documentation

SDL_Surface* WindowHandler::main_window_ [protected]
 

This holds the SDL window.

Definition at line 23 of file WindowHandler.h.

Referenced by createWindow(), resizeVideoMode(), and toggleFullScreen().

GLuint WindowHandler::pixel_format_flag_ [protected]
 

This holds the video flag which holds the rendering mode(s) for the OpenGL scene.

Definition at line 32 of file WindowHandler.h.

Referenced by createWindow(), resetupPixelFormat(), resizeVideoMode(), and WindowHandler().

GLuint WindowHandler::screen_depth_ [protected]
 

This holds the screen depth (i.e., bit per pixel) of the window.

Definition at line 29 of file WindowHandler.h.

Referenced by createWindow(), resetupPixelFormat(), resizeVideoMode(), and WindowHandler().

GLuint WindowHandler::screen_height_ [protected]
 

This holds the screen height of the window.

Definition at line 27 of file WindowHandler.h.

Referenced by createWindow(), initOpenGL(), resizeVideoMode(), and WindowHandler().

GLuint WindowHandler::screen_width_ [protected]
 

This holds the screen width of the window.

Definition at line 25 of file WindowHandler.h.

Referenced by createWindow(), initOpenGL(), resizeVideoMode(), and WindowHandler().


The documentation for this class was generated from the following files:
Generated on Mon Jun 14 12:49:13 2004 for InfoVis by doxygen 1.3.7