OpenMiner/include/core/Window.hpp

55 lines
1.3 KiB
C++
Raw Normal View History

2014-12-20 01:46:31 +01:00
/*
* =====================================================================================
*
* Filename: Window.hpp
*
2018-06-05 01:24:54 +02:00
* Description:
2014-12-20 01:46:31 +01:00
*
* Created: 20/12/2014 00:16:51
*
* Author: Quentin Bazin, <quent42340@gmail.com>
2014-12-20 01:46:31 +01:00
*
* =====================================================================================
*/
#ifndef WINDOW_HPP_
#define WINDOW_HPP_
2018-06-05 16:17:40 +02:00
#include <memory>
#include <string>
#include "RenderTarget.hpp"
2014-12-20 01:46:31 +01:00
#include "SDLHeaders.hpp"
#include "Types.hpp"
class Window : public RenderTarget {
2014-12-20 01:46:31 +01:00
public:
2018-06-05 16:17:40 +02:00
void open(const std::string &caption, u16 width, u16 height);
2018-06-05 01:24:54 +02:00
2014-12-20 01:46:31 +01:00
void clear();
void display();
2018-06-05 01:24:54 +02:00
2014-12-20 01:46:31 +01:00
void setVerticalSyncEnabled(bool enabled);
2018-06-05 01:24:54 +02:00
2014-12-20 01:46:31 +01:00
u16 width() const { return m_width; }
u16 height() const { return m_height; }
2018-06-05 01:24:54 +02:00
2014-12-20 01:46:31 +01:00
void close() { m_isOpen = false; }
bool isOpen() const { return m_isOpen; }
2018-06-05 01:24:54 +02:00
SDL_Window *window() const { return m_window.get(); }
2014-12-20 01:46:31 +01:00
private:
2018-06-05 16:17:40 +02:00
using SDL_WindowPtr = std::unique_ptr<SDL_Window, decltype(&SDL_DestroyWindow)>;
using SDL_GLContextPtr = std::unique_ptr<void, decltype(&SDL_GL_DeleteContext)>;
SDL_WindowPtr m_window{nullptr, SDL_DestroyWindow};
SDL_GLContextPtr m_context{nullptr, SDL_GL_DeleteContext};
2018-06-05 01:24:54 +02:00
2014-12-20 01:46:31 +01:00
u16 m_width;
u16 m_height;
2018-06-05 01:24:54 +02:00
2014-12-20 01:46:31 +01:00
bool m_isOpen;
};
#endif // WINDOW_HPP_