Handles the window.
More...
#include <window.h>
|
static void | Init (std::string title="Window") |
|
static void | Quit () |
| Quit SDL.
|
|
static void | DrawTexture (SDL_Texture *tex, const Rectf &dstRect, Recti *clip=NULL, float angle=0.0, Vector2f pivot=Vector2f(0, 0), SDL_RendererFlip flip=SDL_FLIP_NONE) |
|
static void | Draw (Image *image, const Rectf &dstRect, Recti *clip=NULL, float angle=0.0, Vector2f pivot=Vector2f(0, 0), int flip=SDL_FLIP_NONE) |
|
static void | Draw (AnimatedImage *img, const Rectf &dstRect, float angle=0.0, Vector2f pivot=Vector2f(0, 0), int flip=SDL_FLIP_NONE) |
|
static void | Draw (Text *text, const Rectf &dstRect, float angle=0.0, Vector2f pivot=Vector2f(0, 0), int flip=SDL_FLIP_NONE) |
|
static SDL_Texture * | LoadTexture (std::string file) |
|
static SDL_Texture * | RenderText (std::string message, std::string fontFile, Color color, int fontSize) |
|
static SDL_Texture * | SurfaceToTexture (SDL_Surface *surf) |
|
static void | Clear () |
| Clear the renderer.
|
|
static void | Present () |
| Present the renderer, ie. update screen.
|
|
static void | HandleEvents (SDL_Event &e) |
|
static Recti | Box () |
| Get the window's box.
|
|
static void | ShowAvgFps (bool log) |
|
Handles the window.
Window management class, provides a simple wrapper around the SDL_Window and SDL_Renderer functionalities
void Window::Draw |
( |
Image * |
image, |
|
|
const Rectf & |
dstRect, |
|
|
Recti * |
clip = NULL , |
|
|
float |
angle = 0.0 , |
|
|
Vector2f |
pivot = Vector2f(0, 0) , |
|
|
int |
flip = SDL_FLIP_NONE |
|
) |
| |
|
static |
Draw an Image to the screen and apply some rotation and flip if desired
- Parameters
-
image | The image to draw |
dstRect | The destination rectangle to draw too |
clip | The clip rect to apply to the texture |
angle | The angle to rotate the image in degrees |
pivot | The point to rotate around, note: default (0, 0) corresponds to destination rect center, offsets correspond to distance from image center |
flip | The flip to apply to the image, default is none |
Draw an Image to the screen with no extra effects
- Parameters
-
image | The image to draw |
dstRect | The destination rectangle to draw too Drawn an Image to the screen with some clip applied the version passing with reference is for testing only |
image | The image to draw |
dstRect | The destination rectangle to draw too |
clip | The clip to apply to the image Draw an AnimatedImage object to the screen using the active animation clip |
img | The AnimatedImage to draw |
dstRect | The destination rect to draw too Draw an AnimatedImage object to the screen using the active animation clip and apply some rotation and flip if desired |
img | The AnimatedImage to draw |
dstRect | The destination rectangle to draw too |
angle | The angle to rotate the image in degrees |
pivot | The point to rotate around, note: default (0, 0) corresponds to destination rect center, offsets correspond to distance from image center |
flip | The flip to apply to the image, default is none |
void Window::Draw |
( |
Text * |
text, |
|
|
const Rectf & |
dstRect, |
|
|
float |
angle = 0.0 , |
|
|
Vector2f |
pivot = Vector2f(0, 0) , |
|
|
int |
flip = SDL_FLIP_NONE |
|
) |
| |
|
static |
Draw a Text object to the screen at some position
- Parameters
-
text | The text type to draw |
dstRect | The destination rect to draw too, w and h vals will be queried from texture Draw a Text object to the screen at some position |
text | The text type to draw |
dstRect | The destination rect to draw too, w and h vals will be queried from texture |
angle | The angle to rotate the image in degrees |
pivot | The point to rotate around, default (0, 0) corresponds to destination rect center, offsets correspond to distance from image center |
flip | The flip to apply to the image, default is none |
void Window::DrawTexture |
( |
SDL_Texture * |
tex, |
|
|
const Rectf & |
dstRect, |
|
|
Recti * |
clip = NULL , |
|
|
float |
angle = 0.0 , |
|
|
Vector2f |
pivot = Vector2f(0, 0) , |
|
|
SDL_RendererFlip |
flip = SDL_FLIP_NONE |
|
) |
| |
|
static |
Draw a texture to the screen with optional stretching applied
- Parameters
-
tex | The SDL_Texture* to draw |
dstRect | The destination rect to draw to, specifies x,y,w,h of image |
clip | The clip rect to apply to the texture, if desired |
angle | The angle to rotate the image in degrees, default is 0 |
pivot | The point to rotate around, default (0, 0) corresponds to destination rect center, offsets correspond to distance from image center |
flip | The flip to apply to the image, default is none |
- Note
- Why are there copies of this function instead of default paramaters? LuaBind doesn't seem to recognize default paramaters, or I didn't figure it out and as such had to write a version of the function for each call
void Window::HandleEvents |
( |
SDL_Event & |
e | ) |
|
|
static |
Handle window events
- Parameters
-
void Window::Init |
( |
std::string |
title = "Window" | ) |
|
|
static |
Initialize SDL, setup the window and renderer
- Parameters
-
SDL_Texture * Window::LoadTexture |
( |
std::string |
file | ) |
|
|
static |
Load an image file as a SDL_Texture and return it
- Parameters
-
file | The image file to load |
- Returns
- SDL_Texture* of the texture loaded
- Exceptions
-
runtime_error | if image failed to load |
SDL_Texture * Window::RenderText |
( |
std::string |
message, |
|
|
std::string |
fontFile, |
|
|
Color |
color, |
|
|
int |
fontSize |
|
) |
| |
|
static |
Generate a texture containing the message we want to display
- Parameters
-
message | The message we want to display |
fontFile | The font we want to use to render the text |
color | The color we want the text to be |
fontSize | The size we want the font to be |
- Returns
- An SDL_Texture containing the rendered message
void Window::ShowAvgFps |
( |
bool |
log | ) |
|
|
static |
Print the average framerate. To limit io action, will only print every 5 seconds
- Parameters
-
log | If we want to print to the debug log or not, True for debug log |
SDL_Texture * Window::SurfaceToTexture |
( |
SDL_Surface * |
surf | ) |
|
|
static |
Convert an SDL_Surface to a texture and return the texture and free the surface
- Parameters
-
surf | The SDL_Surface* to be converted |
- Returns
- The SDL_Texture* created from the surface
The documentation for this class was generated from the following files:
- C:/Users/Will/Documents/Programs/LPCGame/src/core/window.h
- C:/Users/Will/Documents/Programs/LPCGame/src/core/window.cpp