TinyLib 0.1.1
Loading...
Searching...
No Matches
tl::Window Class Reference

#include <Window.h>

Public Member Functions

 Window (Vec2i={800, 600}, const char *="Window", LONG style=WS_OVERLAPPEDWINDOW)
 Create a new window, all parameters are optional.
 
 ~Window ()
 Clean up window resources.
 
void create (Vec2i={800, 600}, const char *="Window", LONG style=WS_OVERLAPPEDWINDOW)
 Recreate the window.
 
bool isOpen ()
 Check if the window is open.
 
void draw (Rectangle &rectangle)
 Draw a rectangle to the screen.
 
void draw (Text &text)
 Draw text to the screen.
 
void close ()
 Close this window.
 
void clear (Color color=Color(255, 255, 255, 255))
 Clear the window.
 
Vec2i getSize () const
 Get size of the window.
 
void setSize (Vec2i)
 Set the size of the window.
 
void setTitle (const char *title)
 Change the window title.
 
void setPosition (Vec2i)
 Set the window's position on screen.
 
void move (Vec2i)
 Move the window from current position.
 
Vec2i getPosition () const
 Get the current position of the window.
 
void display ()
 Display what you've drawn to the window.
 
void limitFPS (u32 fps)
 Caps the framerate to given value, 0 for unlimited.
 
bit checkEvent (u8 event)
 Check if a window event activated this frame.
 

Detailed Description

Definition at line 35 of file Window.h.

Constructor & Destructor Documentation

◆ Window()

tl::Window::Window ( Vec2i size = {800, 600},
const char * title = "Window",
LONG style = WS_OVERLAPPEDWINDOW )

Create a new window, all parameters are optional.

Parameters
sizeThe width, height of this window in pixels.
titleThe title of the window.
styleAdditional window style flags.

Size is optional, default is 800x600. Title is optional, default is "Window". Style is optional, default is tl::Style::Default.

Definition at line 53 of file Window.cpp.

◆ ~Window()

tl::Window::~Window ( )

Clean up window resources.

Definition at line 60 of file Window.cpp.

Member Function Documentation

◆ checkEvent()

bit tl::Window::checkEvent ( u8 event)

Check if a window event activated this frame.

Parameters
eventWindow event to check.
Returns
True if specified event activated this frame.

Events are an enum defined in Window.h, tl::Event.

Definition at line 250 of file Window.cpp.

◆ clear()

void tl::Window::clear ( Color color = Color(255, 255, 255, 255))

Clear the window.

Parameters
colorColor to clear window with.

Definition at line 167 of file Window.cpp.

◆ close()

void tl::Window::close ( )

Close this window.

Definition at line 158 of file Window.cpp.

◆ create()

void tl::Window::create ( Vec2i size = {800, 600},
const char * title = "Window",
LONG style = WS_OVERLAPPEDWINDOW )

Recreate the window.

Parameters
sizeThe width, height of this window in pixels.
titleThe title of the window.
styleAdditional window style flags.

All parameters are optional, any you don't provide will stay the same.

Definition at line 73 of file Window.cpp.

◆ display()

void tl::Window::display ( )

Display what you've drawn to the window.

Definition at line 174 of file Window.cpp.

◆ draw() [1/2]

void tl::Window::draw ( Rectangle & rectangle)

Draw a rectangle to the screen.

Parameters
rectangleThe rectangle to draw.

Definition at line 143 of file Window.cpp.

◆ draw() [2/2]

void tl::Window::draw ( Text & text)

Draw text to the screen.

Parameters
textThe text you want to draw.

Definition at line 151 of file Window.cpp.

◆ getPosition()

Vec2i tl::Window::getPosition ( ) const

Get the current position of the window.

Returns
X-position, y-position.

Definition at line 224 of file Window.cpp.

◆ getSize()

Vec2i tl::Window::getSize ( ) const

Get size of the window.

Returns
Width, height.

Definition at line 182 of file Window.cpp.

◆ isOpen()

bool tl::Window::isOpen ( )

Check if the window is open.

Returns
True if window is open.

This method also makes sure the program doesn't go past the FPS cap if set with Window::limitFPS().

Definition at line 115 of file Window.cpp.

◆ limitFPS()

void tl::Window::limitFPS ( u32 fps)

Caps the framerate to given value, 0 for unlimited.

Parameters
fpsFramerate cap.

FPS cap is enforced in Window::isOpen().

Definition at line 236 of file Window.cpp.

◆ move()

void tl::Window::move ( Vec2i pos)

Move the window from current position.

Parameters
posMove the window by x, y.

Definition at line 216 of file Window.cpp.

◆ setPosition()

void tl::Window::setPosition ( Vec2i pos)

Set the window's position on screen.

Parameters
posNew x, y position for the window.

Definition at line 208 of file Window.cpp.

◆ setSize()

void tl::Window::setSize ( Vec2i size)

Set the size of the window.

Parameters
sizeSet the width, height of this window.

Definition at line 192 of file Window.cpp.

◆ setTitle()

void tl::Window::setTitle ( const char * title)

Change the window title.

Parameters
titleNew title

Definition at line 200 of file Window.cpp.


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