56 lines
1.1 KiB
C++
56 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <extra2d/core/types.h>
|
|
#include <functional>
|
|
#include <string>
|
|
|
|
#include <SDL.h>
|
|
|
|
namespace extra2d {
|
|
|
|
struct WindowConfig {
|
|
std::string title = "Extra2D Application";
|
|
int width = 1280;
|
|
int height = 720;
|
|
bool fullscreen = false;
|
|
bool resizable = true;
|
|
bool centerWindow = true;
|
|
};
|
|
|
|
class Window {
|
|
public:
|
|
using OnEvent = std::function<void(const SDL_Event &)>;
|
|
|
|
Window();
|
|
~Window();
|
|
|
|
bool create(const WindowConfig &config);
|
|
void destroy();
|
|
|
|
void poll();
|
|
bool shouldClose() const;
|
|
void close();
|
|
|
|
void setTitle(const std::string &title);
|
|
void setSize(int width, int height);
|
|
void setFullscreen(bool fullscreen);
|
|
|
|
int width() const { return width_; }
|
|
int height() const { return height_; }
|
|
bool fullscreen() const { return fullscreen_; }
|
|
|
|
void onEvent(OnEvent cb) { onEvent_ = cb; }
|
|
|
|
SDL_Window *native() const { return sdlWindow_; }
|
|
|
|
private:
|
|
SDL_Window *sdlWindow_ = nullptr;
|
|
int width_ = 1280;
|
|
int height_ = 720;
|
|
bool fullscreen_ = true;
|
|
bool shouldClose_ = false;
|
|
OnEvent onEvent_;
|
|
};
|
|
|
|
} // namespace extra2d
|