e2d::graphics::Video Class Reference

Inheritance diagram for e2d::graphics::Video:


List of all members.

Detailed Description

This class is the base of all graphic operations on Easy2D. Before you draw anything to the screen, you MUST have a drawing surface (called "framebuffer") and a window to contain this surface. Video provides it all.

To query for the framebuffer's width and height after initalization, use methods GetW() and GetH() from its parent class Rect.

This class is a Singleton, what means you can't make an instance of Video yourself. It is available to you via Utilities.

Public Member Functions

void ClearScreen (Color *color=NULL, Rect *area=NULL)
 Clears the framebuffer with the selected color.
int GetColordepth (void)
 Returns colordepth.
SDL_Surface * GetFramebuffer (void)
 Returns the framebuffer.
void Init (int width, int height, int colordepth, unsigned int screen_mode, char *window_title="Easy2D - Object Oriented 2D Game Engine", char *icon_file=NULL)
 Creates a surface for drawing, and also a window.
void Quit (void)
 Destroys the surface allocated to main video buffer.
void SwapBuffers (void)
 Flips the buffer (double buffering).

Static Public Member Functions

static VideoGetInstance (void)
 Gets an object for this class.

Public Attributes

SDL_Surface * framebuffer
 main drawing surface

Static Public Attributes

static const unsigned int FULLSCREEN = SDL_FULLSCREEN
 Fullscreen video mode.
static const unsigned int WINDOWED = 0
 Windowed video mode.

Member Function Documentation

Video * e2d::graphics::Video::GetInstance ( void   )  [static]

This class is a Singleton. If you want an instance of this class to work with, get it via this method.

void e2d::graphics::Video::ClearScreen ( Color color = NULL,
Rect area = NULL 

Fills part of the framebuffer with the color selected. If the color is NULL, it defaults to black. If area is NULL, the whole framebuffer is filled.

color The color you want to use to clear the screen
area The area of the framebuffer to be cleared

int e2d::graphics::Video::GetColordepth ( void   ) 

The acquired colordepth after initialization

SDL_Surface * e2d::graphics::Video::GetFramebuffer ( void   ) 

Even if the framebuffer is publicly accessible, this method is available just for convenience.

Pointer to an SDL_Surface that is the main drawing surface (framebuffer). SDL_Surface is part of SDL.

void e2d::graphics::Video::Init ( int  width,
int  height,
int  colordepth,
unsigned int  screen_mode,
char *  window_title = "Easy2D - Object Oriented 2D Game Engine",
char *  icon_file = NULL 

Initializes the framebuffer, and creates a window to contain it. This framebuffer is where you may want to draw your images, so they shall appear on-screen. If the call succeeds, the framebuffer will be allocated in the main video memory (hardware), and will be double-buffered.

width desired width of the window
height desired height of the window
colordepth desired colordepth (bits per pixel - bpp) of the drawing surface
screen_mode one of Video::FULLSCREEN or Video::WINDOWED
window_title string your OS shall write as the window title
icon_file path to an image file your OS shall draw as the window icon
e2d::core::Exception if SDL fails to create the framebuffer.
The example below creates a window containing a framebuffer of size 640x480 with a color resolution of 24bpp:
  Init(640, 480, 24, Video::WINDOWED);

Do NOT create a fullscreen window if you didn't program a method to quit the application (for example, by making OnRun return false on pressing some key).

void e2d::graphics::Video::Quit ( void   ) 

Deallocates the framebuffer memory and quits the SDL video subsystem.

void e2d::graphics::Video::SwapBuffers ( void   ) 

When drawing to the framebuffer, you are actually drawing to the backbuffer. So, when you want to make the backbuffer visible, swap it with the frontbuffer (Easy2D always works with double-buffering).

Generated on Tue Dec 8 10:32:45 2009 for Easy2D by  doxygen 1.5.6