To query for the framebuffer's width and height after initalization, use methods GetW() and GetH() from its parent class Rect.
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 Video * | GetInstance (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. |
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.
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 | ) |
SDL_Surface * e2d::graphics::Video::GetFramebuffer | ( | void | ) |
Even if the framebuffer is publicly accessible, this method is available just for convenience.
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. |
Init(640, 480, 24, Video::WINDOWED);
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).