2016-06-22 12:29:39 +02:00
|
|
|
#ifndef GAMEWINDOW_HPP
|
|
|
|
#define GAMEWINDOW_HPP
|
|
|
|
|
2018-12-09 22:43:42 +01:00
|
|
|
#include <SDL_surface.h>
|
|
|
|
#include <SDL_video.h>
|
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
#include <glm/vec2.hpp>
|
2018-12-09 22:43:42 +01:00
|
|
|
#include <string>
|
2018-12-20 20:31:14 +01:00
|
|
|
#include <tuple>
|
|
|
|
#include <SDL.h>
|
2016-06-22 12:29:39 +02:00
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
class GameWindow {
|
2018-05-19 23:55:27 +02:00
|
|
|
SDL_Window* window = nullptr;
|
|
|
|
SDL_Surface* icon = nullptr;
|
|
|
|
SDL_GLContext glcontext{nullptr};
|
2016-06-22 12:29:39 +02:00
|
|
|
public:
|
2018-05-19 23:55:27 +02:00
|
|
|
GameWindow() = default;
|
2016-06-22 12:29:39 +02:00
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
void create(const std::string& title, size_t w, size_t h, bool fullscreen);
|
|
|
|
void close();
|
2016-06-22 12:29:39 +02:00
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
void showCursor();
|
|
|
|
void hideCursor();
|
2016-06-22 12:29:39 +02:00
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
glm::ivec2 getSize() const;
|
2016-06-22 12:29:39 +02:00
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
void swap() const {
|
|
|
|
SDL_GL_SwapWindow(window);
|
|
|
|
}
|
2016-06-22 12:29:39 +02:00
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
bool isOpen() const {
|
|
|
|
return !!window;
|
|
|
|
}
|
2018-12-20 20:31:14 +01:00
|
|
|
|
|
|
|
std::tuple<SDL_Window *, SDL_GLContext> getSDLContext() {
|
|
|
|
return std::make_tuple(window, glcontext);
|
|
|
|
}
|
2016-06-22 12:29:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|