133 lines
3.3 KiB
C++

/**
This file is a part of our_dick
Copyright (C) 2020 rexy712
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OUR_DICK_GRAPHICS_WINDOW_HPP
#define OUR_DICK_GRAPHICS_WINDOW_HPP
#include "gl_include.hpp"
#include "math/math.hpp"
#include "util/init_constants.hpp"
#include "fbo.hpp"
namespace gfx{
using namespace math;
class window
{
public:
enum class mousemode : int{
DISABLED,
HIDDEN,
NORMAL,
};
private:
//opengl 4.5 has been supported since intel broadwell, nvidia 400 series, and radeon hd 5000
//should be supported on any system I care about
static constexpr int s_default_cver_maj = 4;
static constexpr int s_default_cver_min = 5;
private:
GLFWwindow* m_window = nullptr;
fbo m_root_fbo{util::no_initialize};
char* m_title = nullptr;
int m_antialias_level = 0;
int m_refresh_rate = GLFW_DONT_CARE;
int m_swap_interval = 1;
public:
window(int width, int height, const char* title);
window(int context_vmaj, int context_vmin, int width, int height, const char* title, int antialias = 0, int refresh = GLFW_DONT_CARE);
window(const window&);
window(window&&);
~window();
window& operator=(const window&);
window& operator=(window&&);
GLFWwindow* raw();
const GLFWwindow* raw()const;
operator GLFWwindow*();
operator const GLFWwindow*()const;
void make_current();
void swap_buffers();
void destroy();
fbo& framebuffer();
const fbo& framebuffer()const;
void set_size(const vec2<int>&);
void set_size(int w, int h);
void set_width(int w);
void set_height(int h);
void set_title(const char* t);
void set_pos(const vec2<int>&);
void set_pos(int x, int y);
void set_x(int x);
void set_y(int y);
void set_visible(bool b = true);
void toggle_visible();
void set_resizable(bool b = true);
void set_decorated(bool b = true);
void set_always_on_top(bool b = true);
void set_antialias(int level);
void set_refresh_rate(int rate);
void set_swap_interval(int i);
void set_should_close(bool b = true);
void set_mousemode(mousemode m);
void set_key_callback();
//TODO callbacks
void set_active();
vec2<int> get_size()const;
int get_width()const;
int get_height()const;
vec2<int> get_pos()const;
int get_posx()const;
int get_posy()const;
vec2<int> get_context_version()const;
int get_context_vmaj()const;
int get_context_vmin()const;
int get_swap_interval()const;
vec2<double> get_cursor_pos()const;
double get_cursor_posx()const;
double get_cursor_posy()const;
bool get_key(int key, int action)const;
bool is_visible()const;
bool is_resizable()const;
bool is_decorated()const;
bool is_always_on_top()const;
bool is_fullscreen()const;
bool should_close()const;
mousemode get_mousemode()const;
};
}
#endif