Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

video_X Class Reference

The main X video surface. More...

#include <video_X.h>

Inheritance diagram for video_X:

Inheritance graph
[legend]
Collaboration diagram for video_X:

Collaboration graph
[legend]
List of all members.

Public Methods

 video_X (void)
 Default constructor.

virtual ~video_X (void)
 Destructor.

virtual bool init (unsigned int w, unsigned int h, unsigned int bpp, bool fs)
 Initializes the video system. More...

virtual bool init (unsigned int w, unsigned int h, unsigned int bpp, const int attributes[], bool fs)
 Initializes the video system. More...

virtual void set_title (const std::string &title)
 Sets the title of the window.

virtual void resize (unsigned int width, unsigned int height)
 Resizes the window to width by height.

virtual void start_frame (void)
 Starts a video frame. More...

virtual void end_frame (void)
 Ends a video frame. More...

virtual void toggle_fullscreen (void)
 Toggles fullscreen mode. More...

virtual void activate (void)
 Activates the GL context for the window.

virtual void shutdown (void)
 Shuts down the video system. More...

Display * get_display (void)
 Retrieves a pointer to the X windows display.

GLXContext get_context (void)
 Retrieves the GL context of the window.

virtual void set_eventmask (long eventmask)
 Changes the event mask for the window. More...

virtual void move_pointer (int x, int y)
 Moves the pointer to a location in the window. More...

virtual bool get_pointer (int *x, int *y)
 Get the pointer location in the window. More...

unsigned int get_width (void) const
 Returns the width of the video surface.

unsigned int get_height (void) const
 Returns the height of the video surface.

bool error (void) const
 Returns true if an error has occurred.

std::string get_error (void)
 Returns the error message.

double get_fps (void) const
 Returns the current frames per second. More...

double get_average_fps (void) const
 Returns the current frames per second. More...

double get_elapsed (void) const
 Returns how much time (in seconds) elapsed since the last frame.

bool get_2d (void) const
 Returns true if we are in 2d mode.

void enable_2d (void)
 Enables 2d mode.

void disable_2d (void)
 Disables 2d mode.

void render_string (real_t &x, real_t &y, const gl::ttf *font, real_t size, const std::string &text)
 Renders the string text to the screen. More...

void render_shadowed_string (real_t &x, real_t &y, const gl::ttf *font, real_t size, real_t shadow_offset, const std::string &text)
 Renders the string text to the screen with a shadow. More...

void render_image (const rectf &rect, const gl::texture &texture)
 Render a texture to screen. More...


Static Public Attributes

const int VISUAL_ATTRIBUTES_8BPP []
 Default visual attributes for 8bpp. More...

const int VISUAL_ATTRIBUTES_16BPP []
 Default visual attributes for 16bpp. More...

const int VISUAL_ATTRIBUTES_24BPP []
 Default visual attributes for 24bpp. More...

const int VISUAL_ATTRIBUTES_32BPP []
 Default visual attributes for 32bpp. More...


Protected Methods

void clear_error (void)
 Clears the internal error state.

void set_error (const std::string &msg)
 Sets the internal error state.


Protected Attributes

Display * m_display
 Pointer to X display for the main window.

Window m_window
 Main X window.

GLXContext m_window_context
 Main X window's GL context.

XVisualInfo * m_selected_visual
 The selected X windows visual for the main window.

XF86VidModeModeInfo m_desktop_mode
 The video mode of the X desktop.

std::string m_window_title
 The title of the X window.

int * m_GL_attributes
 OpenGL attributes for the window.

unsigned int m_width
 Video surface width.

unsigned int m_height
 Video surface height.

bool m_fullscreen
 true if in fullscreen mode.

unsigned int m_bpp
 Bits per pixel.

bool m_error
 If an error has occurred.

std::string m_error_msg
clocker m_clock
 Video system clock.

int m_2d_enabled
 How many time enable_2d( ) has been called without calling disable_2d( ).

double m_fps
 Instantanious frames per second.

double m_avg_fps
 Frames per second averaged over the last 500 ms.

double m_fps_sum
 Sum of fps over last 500ms.

unsigned int m_frame_count
 Elapsed frames since last avg fps calculation.


Detailed Description

The main X video surface.

X Windows implementation of video_base.

Definition at line 16 of file video_X.h.


Member Function Documentation

void video_X::end_frame void    [virtual]
 

Ends a video frame.

This method should be called at the end of each frame.

Implements video_base.

Definition at line 496 of file video_X.cpp.

References activate, m_display, and m_window.

double video_base::get_average_fps void    const [inline, inherited]
 

Returns the current frames per second.

This stat is updated every 500ms.

Definition at line 131 of file video_base.h.

References video_base::m_avg_fps.

double video_base::get_fps void    const [inline, inherited]
 

Returns the current frames per second.

This stat is updated every frame.

Definition at line 123 of file video_base.h.

References video_base::m_fps.

bool video_X::get_pointer int *    x,
int *    y
[virtual]
 

Get the pointer location in the window.

Find the location of the pointer in a window and stores that information into x and y.

Returns:
true if the pointer is on the screen the window is on.

Definition at line 636 of file video_X.cpp.

References m_display, and m_window.

bool video_X::init unsigned int    w,
unsigned int    h,
unsigned int    bpp,
const int    attributes[],
bool    fs
[virtual]
 

Initializes the video system.

Creates video surface w pixels wide by h pixels in height, using a set of framebuffer attributes passed as attributes.

Parameters:
w  Width of pixel buffer.
h  Height of pixel buffer.
bpp  Bits per pixel of the buffer (the framebuffer attributes may override this, but it should still be passed as a hint at least).
attributes  Desired framebuffer configuration attributes.
fs  Fullscreen (not used, somebody will have to add support for this).
Returns:
true if the pixel buffer was successfully initialized.

Definition at line 286 of file video_X.cpp.

References gl::init, video_base::m_bpp, video_base::m_clock, m_desktop_mode, m_display, video_base::m_fullscreen, m_GL_attributes, video_base::m_height, m_selected_visual, video_base::m_width, m_window, m_window_context, m_window_title, clocker::reset, and video_base::set_error.

bool video_X::init unsigned int    w,
unsigned int    h,
unsigned int    bpp,
bool    fs
[virtual]
 

Initializes the video system.

Creates a video surface w pixels wide by h pixels in height.

Parameters:
w  Width of surface.
h  Height of surface.
bpp  Bits per pixel of surface (generally 16, 24, 32).
fs  Fullscreen (not used, somebody will have to add support for this).
Returns:
true if the video system was successfully initialized.

Implements video_base.

Definition at line 125 of file video_X.cpp.

References gl::init, video_base::m_bpp, video_base::m_clock, m_desktop_mode, m_display, video_base::m_fullscreen, m_GL_attributes, video_base::m_height, m_selected_visual, video_base::m_width, m_window, m_window_context, m_window_title, clocker::reset, video_base::set_error, VISUAL_ATTRIBUTES_16BPP, VISUAL_ATTRIBUTES_24BPP, VISUAL_ATTRIBUTES_32BPP, and VISUAL_ATTRIBUTES_8BPP.

void video_X::move_pointer int    x,
int    y
[virtual]
 

Moves the pointer to a location in the window.

Moves the pointer to the pixel location x ,y from the upper left-hand corner of the window.

Definition at line 628 of file video_X.cpp.

References m_display, and m_window.

void video_base::render_image const rectf &    rect,
const gl::texture   texture
[inherited]
 

Render a texture to screen.

rect is expressed in a 1024x768 virtual window. If the current resolution is not 1024x768, the image will be scaled appropriately. (0,0) is located at the bottom left hand corner of the screen. (1024,768) is located at the top right hand corner of the screen.

Note:
If you plan on doing alot of 2D rendering, enter 2D mode before calling this method to avoid unnessecary 2d mode switches.

Definition at line 102 of file video_base.cpp.

References video_base::disable_2d, video_base::enable_2d, video_base::m_2d_enabled, video_base::m_width, real_t, gl::render_image, and rectangle::scale.

void video_base::render_shadowed_string real_t   x,
real_t   y,
const gl::ttf   font,
real_t    size,
real_t    shadow_offset,
const std::string &    text
[inherited]
 

Renders the string text to the screen with a shadow.

x and y are expressed in a 1024x768 virtual window. If the current resolution is not 1024x768, the font text will be scaled appropriately. (0,0) is located at the bottom left hand corner of the screen. (1024,768) is located at the top right hand corner of the screen. Both x and y will be updated with the last pixel drawn to the screen. This pixel is the upper right hand corner of the last character in the string and is expressed in the 1024x768 virtual window coordinate system.

Note:
If you plan on doing alot of 2D rendering, enter 2D mode before calling this method to avoid unnessecary 2d mode switches.
Parameters:
x  x coordinate of where to render the screen. x is updated with the final rendering position.
y  y coordinate of where to render the screen. y is updated with the final rendering position.
font  The font to be used to render the string.
size  Height of the largest glyph in font. Measured in pixels.
shadow_offset  The number of pixels to offset the shadow.
text  The string to render.

Definition at line 44 of file video_base.cpp.

References video_base::disable_2d, video_base::enable_2d, video_base::m_2d_enabled, video_base::m_width, real_t, and gl::ttf::render_string.

void video_base::render_string real_t   x,
real_t   y,
const gl::ttf   font,
real_t    size,
const std::string &    text
[inherited]
 

Renders the string text to the screen.

x and y are expressed in a 1024x768 virtual window. If the current resolution is not 1024x768, the font text will be scaled appropriately. (0,0) is located at the bottom left hand corner of the screen. (1024,768) is located at the top right hand corner of the screen. Both x and y will be updated with the last pixel drawn to the screen. This pixel is the upper right hand corner of the last character in the string and is expressed in the 1024x768 virtual window coordinate system.

Note:
If you plan on doing alot of 2D rendering, enter 2D mode before calling this method to avoid unnessecary 2d mode switches.
Parameters:
x  x coordinate of where to render the screen. x is updated with the final rendering position.
y  y coordinate of where to render the screen. y is updated with the final rendering position.
font  The font to be used to render the string.
size  Height of the largest glyph in font. Measured in pixels.
text  The string to render.

Definition at line 9 of file video_base.cpp.

References video_base::disable_2d, video_base::enable_2d, video_base::m_2d_enabled, video_base::m_width, real_t, and gl::ttf::render_string.

void video_X::set_eventmask long    eventmask [virtual]
 

Changes the event mask for the window.

By default the window only looks for expose events, so the event mask should be enlarged to include events that will be handled by a program using the video_X object.

Definition at line 620 of file video_X.cpp.

References m_display, and m_window.

void video_X::shutdown void    [virtual]
 

Shuts down the video system.

This method should be called to release the video system back to the operating system.

Implements video_base.

Definition at line 602 of file video_X.cpp.

References m_desktop_mode, m_display, and m_window_context.

void video_X::start_frame void    [virtual]
 

Starts a video frame.

This method should be called at the beginning of each frame.

Implements video_base.

Definition at line 474 of file video_X.cpp.

References clocker::elapsed, video_base::m_avg_fps, video_base::m_clock, video_base::m_fps, video_base::m_fps_sum, video_base::m_frame_count, and clocker::update.

void video_X::toggle_fullscreen void    [virtual]
 

Toggles fullscreen mode.

Switches a currently initialized window from fullscreen mode to windowed mode and back as necessary.

Implements video_base.

Definition at line 505 of file video_X.cpp.

References m_desktop_mode, m_display, video_base::m_fullscreen, video_base::m_height, video_base::m_width, m_window, m_window_title, and video_base::set_error.


Member Data Documentation

const int video_X::VISUAL_ATTRIBUTES_16BPP [static]
 

Initial value:

 {
  GLX_DOUBLEBUFFER, GL_TRUE,
  GLX_RED_SIZE, 4,
  GLX_GREEN_SIZE, 4,
  GLX_BLUE_SIZE, 4,
  GLX_ALPHA_SIZE, 4,
  None
}
Default visual attributes for 16bpp.

Definition at line 62 of file video_X.cpp.

Referenced by init.

const int video_X::VISUAL_ATTRIBUTES_24BPP [static]
 

Initial value:

 {
  GLX_DOUBLEBUFFER, GL_TRUE,
  GLX_RED_SIZE, 6,
  GLX_GREEN_SIZE, 6,
  GLX_BLUE_SIZE, 6,
  GLX_ALPHA_SIZE, 6,
  None  
}
Default visual attributes for 24bpp.

Definition at line 71 of file video_X.cpp.

Referenced by init.

const int video_X::VISUAL_ATTRIBUTES_32BPP [static]
 

Initial value:

 {
  GLX_DOUBLEBUFFER, GL_TRUE,
  GLX_RED_SIZE, 8,
  GLX_GREEN_SIZE, 8,
  GLX_BLUE_SIZE, 8,
  GLX_ALPHA_SIZE, 8,
  None
}
Default visual attributes for 32bpp.

Definition at line 80 of file video_X.cpp.

Referenced by init.

const int video_X::VISUAL_ATTRIBUTES_8BPP [static]
 

Initial value:

 {
  GLX_DOUBLEBUFFER, GL_TRUE,
  GLX_RED_SIZE, 2,
  GLX_GREEN_SIZE, 2,
  GLX_BLUE_SIZE, 2,
  GLX_ALPHA_SIZE, 2,
  None
}
Default visual attributes for 8bpp.

Definition at line 53 of file video_X.cpp.

Referenced by init.


Generated on Tue Feb 11 18:49:46 2003 for uber by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002