restructured everything

This commit is contained in:
Robert 2021-04-23 15:08:51 +02:00
parent 4225a524b9
commit c66cae17f2
61 changed files with 18406 additions and 1710 deletions

10
include/SDLU.hpp Normal file
View file

@ -0,0 +1,10 @@
#pragma once
#include <graphics/Graphics.hpp>
#include <structures/Mouse.hpp>
namespace sdlu {
// TODO: Eventually we should initialize things once the object gets created
extern int Initialize();
extern void Quit();
}

33
include/Util.hpp Normal file
View file

@ -0,0 +1,33 @@
/**
* @file Util.hpp
* @brief Basic utility macros, typedefs...
* @author Lauchmelder23
* @date 16.05.2020
*/
#pragma once
#include <cstdint>
#define PI 3.1415926f
#define IS_NULLPTR( x ) (x == nullptr)
#define RETURN_IF_NULLPTR( x, ... ) { if(IS_NULLPTR(x)) return __VA_ARGS__; }
#define RETURN_IF_NOT_NULLPTR( x, ... ) { if(!IS_NULLPTR(x)) return __VA_ARGS__; }
typedef uint8_t Uint8;
typedef int8_t Int8;
typedef uint16_t Uint16;
typedef int16_t Int16;
typedef uint32_t Uint32;
typedef int32_t Int32;
typedef uint64_t Uint64;
typedef int64_t Int64;
#define THROW_IF( condition, exception ) ( condition ? throw exception : false)
#define THROW_IF_NOT( condition, exception ) ( THROW_IF(!condition, exception) )
#define SDLU_BEGIN namespace sdlu {
#define SDLU_END }

View file

@ -0,0 +1,4 @@
#pragma once
#include "RenderWindow.hpp"
#include "drawable/shapes/Rectangle.hpp"

View file

@ -0,0 +1,79 @@
/**
* @file RenderTarget
* @brief Contains rendering related objects
* @author Lauchmelder23
* @date 20.05.2020
*/
#pragma once
#include <chrono>
#include "structures/Color.hpp"
#include "graphics/drawable/Drawable.hpp"
struct SDL_Window;
struct SDL_Surface;
SDLU_BEGIN
/**
* @brief Acts as a wrapper for SDL_Renderer*. You can't (and shouldn't)
* instantiate this, but rather derive from it.
*/
class RenderTarget
{
public:
virtual ~RenderTarget();
/**
* @brief Clears the display
*
* @param[in] color The color to clear the display with
*/
void Clear(const Color& color = Color::Black);
/**
* @brief Draws a sdlu::Drawable to the SDL_Renderer
*
* @param[in] drawable A reference to a derived class of Drawable
*/
void Draw(const Drawable& drawable);
/**
* @brief Display the current state of the renderer to the screen
*/
void Display();
/**
* @brief Sets a maximum framerate on the display function
*
* If the maximum framerate is not 0, SDL_Delay() will be called
* after each Display() to ensure that the time between displays
* is not shorter than the framerate limit.
*
* @param[in] max The new maximum framerate
*/
void SetMaxFramerate(Uint32 max);
protected:
/**
* @brief Create Renderer and bind it to a window
*
* @param[in] target The SDL_Window to bind to
*/
RenderTarget(SDL_Window* target);
/**
* @brief Create Renderer and bind it to a texture
*
* @param[in] target The SDL_Surface to bind to
*/
RenderTarget(SDL_Surface* target);
protected:
SDL_Renderer* renderer; ///< The renderer object
private:
Uint32 m_oFramerate; ///< The current maximum framerate of the window (0 = unlimited)
std::chrono::steady_clock::time_point m_oTimeSinceLastDisplay; ///< The timepoint at which Display() was last called
};
SDLU_END

View file

@ -0,0 +1,69 @@
/**
* @file RenderWindow.hpp
* @brief A wrapper around SDL_Window and SDL_Renderer
* @author Lauchmelder23
* @date 16.05.2020
*/
#pragma once
#include <string>
#include <chrono>
#include "structures/Vector2.hpp"
#include "structures/Color.hpp"
#include "structures/Window.hpp"
#include "graphics/RenderTarget.hpp"
SDLU_BEGIN
// TODO: Probably break up into sdlu::Window and sdlu::Renderer
// to avoid passing around the Renderer when only the Window is
// needed. (See Mouse::GetPosition for example)
/**
* @brief A class that handles window related functionality
*
* A class that combines the SDL_Window and SDL_Renderer and
* behaves similar to the sf::RenderWindow from SFML. It provides
* utility and wrappers for common operations on those objects.
*/
class RenderWindow : public Window, public RenderTarget
{
public:
/**
* @brief Default Constructor. No window or renderer is created.
*/
RenderWindow();
/**
* @brief Creates a window and renderer with the given parameters
*
* @param[in] dimension A vector containing the width and height
* @param[in] title The title of the create window
*/
RenderWindow(Vector2u dimension, const std::string& title,
Uint32 windowFlags = Window::Flags::Shown);
RenderWindow(const RenderWindow& other) = delete;
RenderWindow(const RenderWindow&& other) = delete;
virtual ~RenderWindow();
protected:
/**
* @brief Function called after Window creation
*/
virtual void OnCreate();
/**
* @brief Function called after resize event
*
* @return True if the resize event should not be returned via
* PollEvent()
*/
virtual bool OnResize();
/**
* @brief Function called after closing the window
*/
virtual void OnClose();
};
SDLU_END

View file

@ -0,0 +1,30 @@
/**
* @file Drawable.hpp
* @brief The base class of everything renderable by RenderTarget
* @author Lauchmelder23
* @date 20.05.2020
*/
#pragma once
#include "Util.hpp"
struct SDL_Renderer;
SDLU_BEGIN
/**
* @brief Everything that can be rendered derives from this class.
*/
class Drawable
{
public:
Drawable(const Drawable& other) = delete;
Drawable(Drawable&& other) = delete;
Drawable& operator=(const Drawable& other) = delete;
friend class RenderTarget;
protected:
Drawable() { }
virtual void Draw(SDL_Renderer* const target) const = 0;
};
SDLU_END

View file

@ -0,0 +1,157 @@
/**
* @file Transformable.hpp
* @brief Contains information for transformable objects
* @author Lauchmelder23
* @date 23.05.2020
*/
#pragma once
#include "structures/Vector2.hpp"
SDLU_BEGIN
/**
* @brief A class that stores locational information
*
* Stores position, rotation, scale and the origin of an
* object, and provides functions to get/set those values.
* "Origin" is the offset between the position and the top-left
* corner of the object.
*/
class Transformable
{
public:
/**
* @brief Default constructur
*/
Transformable();
/**
* @brief Deconstructor
*/
virtual ~Transformable();
/**
* @brief Returns the position of the object
*
* @return A 2D vector of the position
*/
Vector2f GetPosition();
/**
* @brief Sets a new position
*
* @param[in] position A 2D vector with the new position
*/
void SetPosition(const Vector2f& position);
/**
* @brief Sets a new position
*
* @param[in] x The new x position
* @param[in] y The new y position
*/
void SetPosition(float x, float y);
/**
* @brief Adds to the current position
*
* @param[in] position A 2D movement vector
*/
void Move(const Vector2f& position);
/**
* @brief Adds to the current position
*
* @param[in] x The offset in x direction
* @param[in] y The offset in y direction
*/
void Move(float x, float y);
/**
* @brief Gets the current local origin
*
* @return A 2D vector with the offset
*/
Vector2f GetOrigin();
/**
* @brief Sets a new local origin
*
* @param[in] origin A 2D vector with the new origin
*/
void SetOrigin(const Vector2f& origin);
/**
* @brief Sets a new local origin
*
* @param[in] x The new x component of the origin
* @param[in] y The new y component of the origin
*/
void SetOrigin(float x, float y);
/**
* @brief Gets the current scale of the object
*
* @return A 2D vector with the scale in x- and y-direction
*/
Vector2f GetScale();
/**
* @brief Sets a new scale
*
* @param[in] scale A 2D vector with the new scale
*/
void SetScale(const Vector2f& scale);
/**
* @brief Sets a new scale
*
* @param[in] x The new scale in x direction
* @param[in] y The new scale in y direction
*/
void SetScale(float x, float y);
/**
* @brief Scales the object by some amount
*
* @param[in] scale The amount to scale by in x- and y-direction
*/
void Scale(const Vector2f& scale);
/**
* @brief Scales the object by some amount
*
* @param[in] x The amount to scale by in x direction
* @param[in] y The amount to scale by in y direction
*/
void Scale(float x, float y);
/**
* @brief Gets the current rotation
*
* @return The rotation in degrees
*/
float GetRotation();
/**
* @brief Sets a new rotation
*
* @param[in] angle The new rotation in degrees
*/
void SetRotation(float angle);
/**
* @brief Rotates by some amount
*
* @param[in] angle The angle to rotate by in degrees
*/
void Rotate(float angle);
protected:
Vector2f position; ///< Position of the object
Vector2f origin; ///< Offset of the top-left corner from the position
Vector2f scale; ///< Scale of the object
float rotation; ///< Rotation of the object (in degrees)
};
SDLU_END

View file

@ -0,0 +1,62 @@
/**
* @file Rectangle.hpp
* @brief The primitive Rectangle shape
* @author Lauchmelder23
* @date 23.05.2020
*/
#pragma once
#include "Shape.hpp"
namespace sdlu
{
class Rectangle :
public Shape
{
public:
/**
* @brief Default constructor
*/
Rectangle();
/**
* @brief Constructor with default parameters
*
* @param[in] position A 2D position vector
* @param[in] size A 2D size vector
*/
Rectangle(const Vector2f& position, const Vector2f& size);
/**
* @brief Gets the size of the rectangle
*
* @return A 2D vector with the size information
*/
Vector2f GetSize();
/**
* @brief Sets a new size for the rectangle
*
* @param[in] size A 2D vector with the size information
*/
void SetSize(const Vector2f& size);
/**
* @brief Sets a new size for the rectangle
*
* @param[in] x The new size in x direction
* @param[in] y The new size in y direction
*/
void SetSize(float x, float y);
/**
* @brief Draws the Rectangle to the target
*
* @param[in] target The RenderTarget to draw to
*/
virtual void Draw(SDL_Renderer* const target) const override;
private:
Vector2f size; ///< Size of the rectangle
};
}

View file

@ -0,0 +1,45 @@
/**
* @file Shape.hpp
* @brief The base class for all native SDLU shapes
* @author Lauchmelder23
* @date 23.05.2020
*/
#pragma once
#include "graphics/drawable/Drawable.hpp"
#include "graphics/drawable/Transformable.hpp"
#include "structures/Color.hpp"
SDLU_BEGIN
/**
* @brief The non-instantiable base class for all SDLU shapes
*/
class Shape :
public Drawable, public Transformable
{
public:
/**
* @brief Deconstructor
*/
virtual ~Shape();
/**
* @brief Sets the color of the shape
*/
void SetColor(const Color& color);
/**
* @brief Gets the color of the shape
*/
Color GetColor();
protected:
/**
* @brief Default constructor
*/
Shape();
protected:
Color color;
};
SDLU_END

View file

@ -0,0 +1,169 @@
/**
* @file Color.hpp
* @brief Provides utility for creating and handling colors
* @author Lauchmelder23
* @date 16.05.2020
*/
#pragma once
#include "Util.hpp"
SDLU_BEGIN
/**
* @brief A structure holding color data
*
* This struct allows for the easy passing of color data between
* objects or functions. It holds RGBA values and allows for
* arithmetical operations.
*/
struct Color
{
Uint8 r; ///< Red component
Uint8 g; ///< Green component
Uint8 b; ///< Blue component
Uint8 a; ///< Alpha component
/**
* @brief Default constructor (Black)
*/
Color();
/**
* @brief Construct color from four 8-Bit integer values
*
* @param[in] r Red component
* @param[in] g Green component
* @param[in] b Blue component
* @param[in] a Alpha component
*/
Color(Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255);
/**
* @brief Construct color from a 32-Bit integer value
*
* @param[in] color The color data structured as RGBA
*/
Color(Uint32 color);
/**
* @brief Returns color data as a 32-Bit integer
*
* @return A 32-Bit containing the RGBA values
*/
Uint32 ToInt();
/**
* @brief Generate color from HSV values
*
* @return An RGBA Color object generated from HSV
*/
static Color FromHSV(Uint16 h, Uint8 s, Uint8 v);
/////////////////// DEFAULT COLORS ///////////////////
static const Color Black; ///< Default Color Black (#000000FF)
static const Color Red; ///< Default Color Red (#FF0000FF)
static const Color Green; ///< Default Color Green (#00FF00FF)
static const Color Blue; ///< Default Color Blue (#0000FFFF)
static const Color Yellow; ///< Default Color Yellow (#FFFF00FF)
static const Color Magenta; ///< Default Color Magenta (#FF00FFFF)
static const Color Cyan; ///< Default Color Cyan (#00FFFFFF)
static const Color White; ///< Default Color White (#FFFFFFFF)
static const Color Transparent; ///< Default Color Transparent (#00000000)
/////////////////// OPERATOR OVERLOADS ///////////////////
/**
* @brief Componentwise color addition
*
* @param[in] left Left operand
* @param[in] right Right operand
* @return left + right
*/
friend Color operator+(const Color& left, const Color& right);
/**
* @brief Componentwise color subtraction
*
* @param[in] left Left operand
* @param[in] right Right operand
* @return left - right
*/
friend Color operator-(const Color& left, const Color& right);
/**
* @brief Componentwise color multiplication
*
* @param[in] left Left operand
* @param[in] right Right operand
* @return left * right
*/
friend Color operator*(const Color& left, const Color& right);
/**
* @brief Componentwise color division
*
* @param[in] left Left operand
* @param[in] right Right operand
* @return left / right
*/
friend Color operator/(const Color& left, const Color& right);
/**
* @brief Componentwise color addition
*
* @param[in] left Left operand
* @param[in] right Right operand
* @return left += right
*/
friend Color& operator+=(Color& left, const Color& right);
/**
* @brief Componentwise color subtraction
*
* @param[in] left Left operand
* @param[in] right Right operand
* @return left -= right
*/
friend Color& operator-=(Color& left, const Color& right);
/**
* @brief Componentwise color multiplication
*
* @param[in] left Left operand
* @param[in] right Right operand
* @return left *= right
*/
friend Color& operator*=(Color& left, const Color& right);
/**
* @brief Componentwise color division
*
* @param[in] left Left operand
* @param[in] right Right operand
* @return left /= right
*/
friend Color& operator/=(Color& left, const Color& right);
/**
* @brief Componentwise color comparison
*
* @param[in] left Left operand
* @param[in] right Right operand
* @return True if the respective color components are equal, False if not
*/
friend bool operator==(const Color& left, const Color& right);
/**
* @brief Componentwise color comparison
*
* @param[in] left Left operand
* @param[in] right Right operand
* @return False if the respective color components are equal, True if not
*/
friend bool operator!=(const Color& left, const Color& right);
};
SDLU_END

View file

@ -0,0 +1,75 @@
/**
* @file Mouse.hpp
* @brief A static class to provide easy handling of the mouse
* @author Lauchmelder23
* @date 19.05.2020
*/
#pragma once
#include "structures/Vector2.hpp"
#include "graphics/RenderWindow.hpp"
SDLU_BEGIN
/**
* @brief A static class that contains/handles data about
* mouse position and button states
*/
class Mouse
{
public:
/**
* @brief Mouse buttons
*/
enum class Button {
Left = 1,
Right = 2,
Middle = 3,
XButton1 = 4,
XButton2 = 5
};
/**
* @brief Returns the current mouse button state
*
* @return A 32-bit mask of the current button state
*/
static Uint32 GetButtonState();
/**
* @brief Checks if a specific button is pressed
*
* @param[in] button The button to check
* @return True if the button is pressed
*/
static bool IsButtonDown(Button button);
/**
* @brief Gets the absolute position of the mouse
*
* @return Current mouse position relative to screen
*/
static Vector2i GetPosition();
/**
* @brief Gets current relative position of the mouse
*
* @param[in] relativeTo The window the mouse position should be relative to
* @return The position of the mouse relative to the top left of the passed window object
*/
static Vector2i GetPosition(const RenderWindow& relativeTo);
/**
* @brief Sets the absolute position of the mouse
*
* @param[in] position A 2D vector of the new position
*/
static void SetPosition(const Vector2i& position);
/**
* @brief Sets current relative position of the mouse
*
* @param[in] position A 2D vector of the new position
* @param[in] relativeTo The window the mouse position should be relative to
*/
static void SetPosition(const Vector2i& position, const RenderWindow& relativeTo);
};
SDLU_END

View file

@ -0,0 +1,154 @@
/**
* @file Vector2.hpp
* @brief Provides a structure for simple vector calculations
* @author Lauchmelder23
* @date 16.05.2020
*/
#pragma once
#include <type_traits>
#include "Util.hpp"
SDLU_BEGIN
/**
* @brief A struct to handle basic 2D vector operations.
*
* @tparam T The (arithmetical) type of the vector components
*/
template<
typename T,
typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type
> struct Vector2
{
T x; ///< x component
T y; ///< y component
//################## CONSTRUCTORS ##################//
/// Initializes a zero vector
Vector2() :
x(0), y(0)
{
// Empty
}
/// Initializes a vector with default values
Vector2(T x, T y) :
x(x), y(y)
{
// Empty
}
/// Copies the components of a vector
Vector2(const Vector2<T>& other) :
x(other.x), y(other.y)
{
// Empty
}
//################## OPERATORS ##################//
friend Vector2<T> operator-(const Vector2<T>& right)
{
return Vector2<T>(-right.x, -right.y);
}
friend Vector2<T> operator+(const Vector2<T>& left, const Vector2<T>& right)
{
return Vector2<T>(left.x + right.x, left.y + right.y);
}
friend Vector2<T> operator-(const Vector2<T>& left, const Vector2<T>& right)
{
return left + (-right);
}
friend Vector2<T> operator*(const Vector2<T>& left, const Vector2<T>& right)
{
return Vector2<T>(left.x * right.x, left.y * right.y);
}
friend Vector2<T> operator/(const Vector2<T>& left, const Vector2<T>& right)
{
return Vector2<T>(left.x / right.x, left.y / right.y);
}
friend Vector2<T> operator*(T left, const Vector2<T>& right)
{
return Vector2<T>(left * right.x, left * right.y);
}
friend Vector2<T> operator*(const Vector2<T>& left, T right)
{
return right * left;
}
friend Vector2<T> operator/(const Vector2<T>& left, T right)
{
return Vector2<T>(left.x / right, left.y / right);
}
friend Vector2<T>& operator+=(Vector2<T>& left, const Vector2<T>& right)
{
left.x += right.x;
left.y += right.y;
return left;
}
friend Vector2<T>& operator-=(Vector2<T>& left, const Vector2<T>& right)
{
left += (-right);
return left;
}
friend Vector2<T>& operator*=(Vector2<T>& left, const Vector2<T>& right)
{
left.x *= right.x;
left.y *= right.y;
return left;
}
friend Vector2<T>& operator/(Vector2<T>& left, const Vector2<T>& right)
{
left.x /= right.x;
left.y /= right.y;
return left;
}
friend Vector2<T>& operator*=(Vector2<T>& left, T right)
{
left.x *= right;
left.y *= right;
return left;
}
friend Vector2<T>& operator/=(Vector2<T>& left, T right)
{
left.x /= right;
left.y /= right;
return left;
}
friend bool operator==(const Vector2<T>& left, const Vector2<T>& right)
{
return ((left.x == right.x) && (left.y == right.y));
}
friend bool operator!=(const Vector2<T>& left, const Vector2<T>& right)
{
return !(left == right);
}
};
//################## TYPEDEFS ##################//
typedef Vector2<unsigned int> Vector2u, Vec2u;
typedef Vector2<int> Vector2i, Vec2i;
typedef Vector2<float> Vector2f, Vec2f;
typedef Vector2<double> Vector2d, Vec2d;
SDLU_END

View file

@ -0,0 +1,279 @@
/**
* @file Window.hpp
* @brief Contains window related objects
* @author Lauchmelder23
* @date 20.05.20
*/
#pragma once
#include <string>
#include <chrono>
#include "Util.hpp"
#include "structures/Vector2.hpp"
struct SDL_Window;
union SDL_Event;
struct SDL_Surface;
struct SDL_Cursor;
SDLU_BEGIN
/**
* @brief Stores information about a window. You probably want RenderWindow.
*/
class Window
{
public:
enum Flags {
Fullscreen = ((Uint32)1 << 0),
OpenGL = ((Uint32)1 << 1),
Shown = ((Uint32)1 << 2),
Hidden = ((Uint32)1 << 3),
Borderless = ((Uint32)1 << 4),
Resizable = ((Uint32)1 << 5),
Minimized = ((Uint32)1 << 6),
Maximized = ((Uint32)1 << 7),
InputGrabbed = ((Uint32)1 << 8),
InputFocus = ((Uint32)1 << 9),
MouseFocus = ((Uint32)1 << 10),
Foregin = ((Uint32)1 << 11),
FullscreenDesktop = (Fullscreen | ((Uint32)1 << 12)),
};
public:
/**
* @brief Default Constructor. No window is created.
*/
Window();
/**
* @brief Creates a window with the given parameters
*
* @param[in] dimension A vector containing the width and height
* @param[in] title The title of the create window
*/
Window(Vector2u dimension, const std::string& title,
Uint32 windowFlags);
Window(const Window& other) = delete;
Window(Window&& other) = delete;
virtual ~Window();
/**
* @brief Creates the window.
*
* This function creates the SDL_Window object. If
* they were already created the function does nothing and returns.
* If it fails to create either, an ObjectCreationException is thrown.
*
* @param[in] dimension A vector containing the width and height
* @param[in] title The title of the create window
*/
void Create(Vector2u dimension, const std::string& title,
Uint32 windowFlags);
/**
* @brief Destroys the window.
*/
void Close();
/**
* @brief Wether or not the window object is created
*
* @return True if the window is open, False if not
*/
bool IsOpen() const;
/**
* @brief A non-blocking event polling function
*
* @param[out] event An object to write the latest event to
* @return True if there was an event, False if there wasn't
*/
bool PollEvent(SDL_Event* event);
/**
* @brief A blocking event polling function
*
* @param[out] event An object to write the latest event to
* @return True if an event was polled
*/
bool WaitEvent(SDL_Event* event);
/**
* @brief Returns the current position of the window
*
* @return A vector with the current position relative to the top left corner of the display
*/
Vector2i GetPosition() const;
/**
* @brief Sets a new window position
*
* @param[in] position A vector with the new position
*/
void SetPosition(Vector2i position);
/**
* @brief Sets a new window position
*
* @param[in] x The new x position
* @param[in] y The new y position
*/
void SetPosition(int x, int y);
/**
* @brief Gets the current window size
*
* @return A vector with the windows size
*/
Vector2u GetSize() const;
/**
* @brief Sets a new window size
*
* @param[in] size A vector with the new size
*/
void SetSize(Vector2u size);
/**
* @brief Sets a new window size
*
* @param[in] width The new width of the window
* @param[in] height The new height of the window
*/
void SetSize(unsigned int width, unsigned int height);
/**
* @brief Gets the current window title
*
* @return The title of the widnow
*/
std::string GetTitle() const;
/**
* @brief Sets a new window title
*
* @param[in] title The new window title
*/
void SetTitle(std::string title);
/**
* @brief Returns a constant pointer to the SDL_Window
*
* @return A constant pointer to SDL_Window
*/
SDL_Window* const GetWindow() const;
/**
* @brief Set the windows visibility
*
* @param[in] visible The new visibility setting
*/
void SetVisible(bool visible);
/**
* @brief (De)activates VSync !globally!
*
* @param[in] vsync Wether to enable or disable vsync
*/
void SetVsync(bool vsync);
/**
* @brief Hides/Shows the mouse cursor inside the windos
*
* @param[in] visible The new visibility of the cursor
*/
void SetMouseCursorVisible(bool visible);
/**
* @brief Traps the mouse cursor inside the window
*
* @param[in] grabbed Wether to (un)trap the cursor
*/
void SetMouseCursorGrabbed(bool grabbed);
/**
* @brief Sets the window icon to an array of RGBA values
*
* @param[in] width Width of the icon (in px)
* @param[in] height Height of the icon (in px)
* @param[in] pixels Array of color data (RGBA as seperate 8-Bit integer values)
*/
void SetIcon(Uint32 width, Uint32 height, const Uint8* pixels);
/**
* @brief Sets the window icon to an array of RGBA values
*
* @param[in] width Width of the icon (in px)
* @param[in] height Height of the icon (in px)
* @param[in] pixels Array of color data (RGBA as one 32-Bit integer value)
*/
void SetIcon(Uint32 width, Uint32 height, const Uint32* pixels);
/**
* @brief Sets the window icon to a SDL_Surface
*
* @param[in] icon A SDL_Surface* holding the icon data
*/
void SetIcon(SDL_Surface* icon);
/**
* @brief Changes the mouse cursor
*
* @param[in] cursor A pointer to a SDL_Cursor containing cursor data
*/
void SetMouseCursor(SDL_Cursor* cursor);
/**
* @brief Changes the mouse cursor
*
* @param[in] surface A pointer to a SDL_Surface containing sprite data
* @param[in] clickspot The effective position of the cursor relative to the top left of the sprite
*/
void SetMouseCursor(SDL_Surface* surface, Vector2u clickspot);
/**
* @brief Changes the mouse cursor
*
* @param[in] pixels An array of color data (RGBA as seperate 8-bit values)
* @param[in] size Size of the cursor
* @param[in] clickspot The effective position of the cursor relative to the top left of the sprite
*/
void SetMouseCursor(const Uint8* pixels, Vector2u size, Vector2u clickspot);
/**
* @brief Changes the mouse cursor
*
* @param[in] pixels An array of color data (RGBA as one 32-bit value)
* @param[in] size Size of the cursor
* @param[in] clickspot The effective position of the cursor relative to the top left of the sprite
*/
void SetMouseCursor(const Uint32* pixels, Vector2u size, Vector2u clickspot);
protected:
SDL_Window* window;
protected:
/**
* @brief This function is called after Create() finishes
*/
virtual void OnCreate();
/**
* @brief This function is called after a SDL_WINDOWEVENT_RESIZED is polled.
* (PollEvent() must be called for this to work)
*
* @return True if the resize event should be popped from the event queue before
returning the polled event to the user
*/
virtual bool OnResize();
/**
* @brief This function is called after Close() finishes.
*/
virtual void OnClose();
};
SDLU_END