window

namespace window

Functions

void init(math::Vec2 size, int scale = 1)

Initialize the window.

Parameters:
  • size – The size of the window.

  • scale – The scale of the window.

void cls(Color color = {0, 0, 0, 255})

Clear the screen.

Parameters:

color – The color to clear the screen.

void flip()

Flip the render frame buffer.

void blit(const std::shared_ptr<Texture> &texture, Rect crop, Rect rect)

Draw a texture using rects.

Parameters:
  • texture – The texture to draw.

  • crop – The rectangle to draw from.

  • rect – The rectangle to draw to.

void blit(const std::shared_ptr<Texture> &texture, const math::Vec2 &position)

Draw a texture to a position.

Parameters:
  • texture – The texture to draw.

  • position – The position to draw at.

void blitEx(const std::shared_ptr<Texture> &texture, Rect crop, Rect rect, double angle = 0.0, bool flipX = false, bool flipY = false)

Draw a texture using rects.

Parameters:
  • texture – The texture to draw.

  • crop – The rectangle to draw from.

  • rect – The rectangle to draw to.

  • angle – The angle to draw the texture.

  • flipX – Whether to flip the texture on the x-axis.

  • flipY – Whether to flip the texture on the y-axis.

void blitEx(const std::shared_ptr<Texture> &texture, const math::Vec2 &position, double angle = 0.0, bool flipX = false, bool flipY = false)

Draw a texture to a position.

Parameters:
  • texture – The texture to draw.

  • position – The position to draw at.

  • angle – The angle to draw the texture.

  • flipX – Whether to flip the texture on the x-axis.

  • flipY – Whether to flip the texture on the y-axis.

SDL_Renderer *getRenderer()

Get the window renderer.

Returns:

The window renderer.

const std::vector<kn::Event> &getEvents()

Get user events.

Returns:

The user events.

bool getFullscreen()

Get whether the window is fullscreen or not.

Returns:

Whether the window is fullscreen or not.

int getScale()

Get the scale of the window.

Returns:

The scale of the window.

math::Vec2 getSize()

Get the size of the screen.

Returns:

The size of the screen.

void setTitle(const std::string &newTitle)

Set the title of the window.

Parameters:

newTitle – The new title for the window.

std::string getTitle()

Get the title of the window.

Returns:

The title of the window.

void setFullscreen(bool fullscreen)

Set whether the window is fullscreen or not.

Parameters:

fullscreentrue if setting fullscreen, false otherwise.

void quit()

Quit SDL and destroy the window.