PROTO::KLUDGE  0.1
Quick prototyping library for games using SDL and OpenGL.
pk::Window Class Reference

Class for SDL window creation and management, implemented using the Facade pattern to provide a more intuitive interface. More...

#include <Window.hpp>

Collaboration diagram for pk::Window:
Collaboration graph

Public Member Functions

 Window (const char *windowTitle, glm::ivec2 position, int width, int height, Uint32 windowFlags)
 
virtual ~Window ()
 
void render ()
 Render to the window. More...
 
SDL_Window *const getWindow ()
 Get the raw SDL_Window pointer (read-only). More...
 
SDL_GLContext & getContext ()
 
SDL_Renderer *const getRenderer ()
 Get the raw SDL_Renderer pointer (read-only). More...
 
const char * getTitle ()
 Get the window's title. More...
 
void setTitle (const char *title)
 Set the title of the window. More...
 
const glm::ivec2 & getPosition ()
 Get the position of the window on screen. More...
 
void setPosition (glm::ivec2 position)
 Set the position of the window on screen. More...
 
glm::ivec2 getSize ()
 Get the SDL window size (width and height). More...
 
void setSize (const glm::ivec2 &windowSize)
 
const Uint32 & getFlags ()
 Get the SDL window flags. More...
 
void setFlags (const Uint32 &flags)
 Set the SDL window size (width and height). More...
 
const SDL_Rect & getWindowRect ()
 Get the SDL_Rect belonging to the Window. More...
 
void setWindowRect (SDL_Rect &rect)
 Set the SDL_Rect belonging to the Window. More...
 
const glm::tvec4< Uint8 > & getClearColor ()
 Get the clear color of the Window. More...
 
SDL_Color getSDLClearColor ()
 Get the clear color of the Window in SDL_Color format. More...
 
void draw (GLDrawable &drawable, GLStates &states)
 
void draw (Drawable &drawable)
 Draw a Drawable object in the Window. More...
 
void draw (Drawable *const drawables)
 Draw an array of Drawable objects in the Window. More...
 
void clear (glm::ivec4 color=glm::ivec4())
 Clear the window for rendering with SDL (not OpenGL). More...
 

Private Member Functions

 Window ()
 Default constructor - INACCESSIBLE! More...
 

Private Attributes

SDL_GLContext m_context
 OpenGL context provided by SDL. More...
 
SDL_Window * m_window
 SDL_Window object. More...
 
const char * m_title
 The window title. More...
 
SDL_Renderer * m_renderer
 SDL_Renderer object. More...
 
glm::ivec2 m_position
 Window position as a vector of integers. More...
 
int m_width
 Width of the Window. More...
 
int m_height
 Height of the Window. More...
 
Uint32 m_flags
 Display flags for the SDL_Window. More...
 
SDL_Rect m_rect
 SDL_Rect for drawing within a rectangular area of the window. More...
 
glm::tvec4< Uint8 > m_clearColor
 SDL_Color for clearing the screen. More...
 

Detailed Description

Class for SDL window creation and management, implemented using the Facade pattern to provide a more intuitive interface.

Constructor & Destructor Documentation

◆ Window() [1/2]

pk::Window::Window ( )
inlineprivate

Default constructor - INACCESSIBLE!

◆ Window() [2/2]

pk::Window::Window ( const char *  windowTitle,
glm::ivec2  position,
int  width,
int  height,
Uint32  windowFlags 
)

◆ ~Window()

virtual pk::Window::~Window ( )
virtual

Member Function Documentation

◆ clear()

void pk::Window::clear ( glm::ivec4  color = glm::ivec4())

Clear the window for rendering with SDL (not OpenGL).

Parameters
glm::ivec4color - a glm vector of integers specifying the window clear color.

◆ draw() [1/3]

void pk::Window::draw ( GLDrawable drawable,
GLStates states 
)

◆ draw() [2/3]

void pk::Window::draw ( Drawable drawable)

Draw a Drawable object in the Window.

Parameters
Drawable&drawable - the Drawable object.

◆ draw() [3/3]

void pk::Window::draw ( Drawable *const  drawables)

Draw an array of Drawable objects in the Window.

Parameters
Drawable* const drawables - an array of drawables for drawing to the window.

◆ getClearColor()

const glm::ivec4 & pk::Window::getClearColor ( )
inline

Get the clear color of the Window.

Returns
glm::ivec4 - the clear color of the Window.

◆ getContext()

SDL_GLContext& pk::Window::getContext ( )
inline

◆ getFlags()

const Uint32 & pk::Window::getFlags ( )
inline

Get the SDL window flags.

Returns
Uint32

◆ getPosition()

glm::ivec2 pk::Window::getPosition ( )
inline

Get the position of the window on screen.

Returns
glm::ivec2 - window position.

◆ getRenderer()

SDL_Renderer * pk::Window::getRenderer ( )
inline

Get the raw SDL_Renderer pointer (read-only).

Returns
SDL_Renderer * const - pointer to an SDL_Renderer.

◆ getSDLClearColor()

SDL_Color pk::Window::getSDLClearColor ( )
inline

Get the clear color of the Window in SDL_Color format.

Returns
SDL_Color - the clear color of the Window.

◆ getSize()

glm::ivec2 pk::Window::getSize ( )
inline

Get the SDL window size (width and height).

Returns
const glm::ivec2 & - a glm vector of 2 integers.

◆ getTitle()

const char * pk::Window::getTitle ( )
inline

Get the window's title.

Returns
char * const - a const pointer to a C-style string.

◆ getWindow()

SDL_Window * pk::Window::getWindow ( )
inline

Get the raw SDL_Window pointer (read-only).

Returns
SDL_Window * const - pointer to an SDL_Window.

◆ getWindowRect()

const SDL_Rect & pk::Window::getWindowRect ( )
inline

Get the SDL_Rect belonging to the Window.

◆ render()

void pk::Window::render ( )

Render to the window.

◆ setFlags()

void pk::Window::setFlags ( const Uint32 &  flags)
inline

Set the SDL window size (width and height).

Set the SDL window flags.

Parameters
constglm::ivec2 &windowSize - a glm vector of 2 integers.
Uint32flags - a Uint32.

◆ setPosition()

void pk::Window::setPosition ( glm::ivec2  position)
inline

Set the position of the window on screen.

Parameters
glm::ivec2- x and y coordinates to set the window position to.
Returns
void

◆ setSize()

void pk::Window::setSize ( const glm::ivec2 &  windowSize)
inline

◆ setTitle()

void pk::Window::setTitle ( const char *  title)
inline

Set the title of the window.

◆ setWindowRect()

void pk::Window::setWindowRect ( SDL_Rect &  rect)
inline

Set the SDL_Rect belonging to the Window.

Parameters
SDL_Rect&rect - Reference to an SDL_Rect.

Member Data Documentation

◆ m_clearColor

glm::tvec4<Uint8> pk::Window::m_clearColor
private

SDL_Color for clearing the screen.

◆ m_context

SDL_GLContext pk::Window::m_context
private

OpenGL context provided by SDL.

◆ m_flags

Uint32 pk::Window::m_flags
private

Display flags for the SDL_Window.

◆ m_height

int pk::Window::m_height
private

Height of the Window.

◆ m_position

glm::ivec2 pk::Window::m_position
private

Window position as a vector of integers.

◆ m_rect

SDL_Rect pk::Window::m_rect
private

SDL_Rect for drawing within a rectangular area of the window.

◆ m_renderer

SDL_Renderer* pk::Window::m_renderer
private

SDL_Renderer object.

◆ m_title

const char* pk::Window::m_title
private

The window title.

◆ m_width

int pk::Window::m_width
private

Width of the Window.

◆ m_window

SDL_Window* pk::Window::m_window
private

SDL_Window object.


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