Dauphine  0.1
A platforming/stealth game in a medieval fantasy setting, developed with SDL2.
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Window Class Reference

Represents actual window that game runs on. More...

#include <Window.h>

Public Member Functions

 Window (const unsigned int width_, const unsigned int height_, const std::string &title_="SDL Window")
 The constructor. More...
 
 ~Window ()
 The destructor. More...
 
void render ()
 Renders to screen. More...
 
void clear ()
 Clears the renderer. More...
 
void resize (const unsigned int width_, const unsigned int height_)
 Resizes the window. More...
 
void destroy ()
 Frees allocated members. More...
 
void minimize ()
 Minimizes window. More...
 
void maximize ()
 Maximizes window. More...
 

Static Public Member Functions

static SDL_Renderer * getRenderer ()
 
static void getLogicalSize (int *w, int *h)
 

Private Member Functions

void create (const unsigned int width_, const unsigned int height_)
 Creates the Window, with specified width and height. More...
 
void rescale (unsigned int size_)
 Rescales the renderization. More...
 

Private Attributes

const std::string windowTitle
 The game Window title. More...
 
SDL_Window * sdlWindow
 The SDL window, that will be the actual game window. More...
 

Static Private Attributes

static SDL_Renderer * sdlRenderer = nullptr
 The SDL renderer to render onto. More...
 

Detailed Description

Represents actual window that game runs on.

Contains the SDL_Window and the SDL_Renderer, and methods related to these.

Constructor & Destructor Documentation

Window::Window ( const unsigned int  width_,
const unsigned int  height_,
const std::string &  title_ = "SDL Window" 
)

The constructor.

Sets all attributes, and calls the initialize method.

Parameters
width_: The desired window width.
height_: The desired window height.
title_: The desired window title.
Note
If omitted, window title will be "SDL Window".
See Also
Window::initialize
Window::~Window ( )

The destructor.

Uses the destroy method to delete window.

See Also
Window::destroy

Member Function Documentation

void Window::clear ( )

Clears the renderer.

Sets the renderers draw color to black, and subsequently clears it.

void Window::create ( const unsigned int  width_,
const unsigned int  height_ 
)
private

Creates the Window, with specified width and height.

Can be used either as the creator, or as the resizer.

Todo:
Toggle VSync.
void Window::destroy ( )

Frees allocated members.

Frees the SDL_Renderer and the SDL_Window.

SDL_Renderer * Window::getRenderer ( )
static
Returns
The renderer attribute.
void Window::maximize ( )

Maximizes window.

Uses SDLs internal method to maximize the window.

void Window::minimize ( )

Minimizes window.

Uses SDLs internal method to minimize the window.

void Window::render ( )

Renders to screen.

Updates the screen with every change in the renderer.

void Window::rescale ( unsigned int  size_)
private

Rescales the renderization.

Set a device independent resolution for rendering.

Parameters
size_: Multiplies Configuration::resolutionWidth and Configuration::resolutionHeight for the new resolution.
Note
Practically, it looks like the camera has a larger field of view, the bigger the size_ parameter is.
See Also
SDL_RenderSetLogicalSize
void Window::resize ( const unsigned int  width_,
const unsigned int  height_ 
)

Resizes the window.

Todo:
Instead of directly choosing width and height, choose from a pre-defined list of resolutions.

Member Data Documentation

SDL_Renderer * Window::sdlRenderer = nullptr
staticprivate

The SDL renderer to render onto.

SDL_Window* Window::sdlWindow
private

The SDL window, that will be the actual game window.

const std::string Window::windowTitle
private

The game Window title.


The documentation for this class was generated from the following files: