69 lines
1.6 KiB
C++
69 lines
1.6 KiB
C++
#pragma once
|
|
#ifndef _NB_WINDOW
|
|
#define _NB_WINDOW
|
|
|
|
#include "GLLoad.h"
|
|
|
|
#include <atomic>
|
|
#include <array>
|
|
#include <iostream>
|
|
#include <map>
|
|
#include <stdexcept>
|
|
#include <string>
|
|
|
|
namespace NB {
|
|
|
|
class GLError : public std::runtime_error {
|
|
public:
|
|
GLError(const std::string&);
|
|
};
|
|
|
|
class WindowError : public std::runtime_error {
|
|
public:
|
|
WindowError(const std::string&);
|
|
};
|
|
|
|
class Window {
|
|
public:
|
|
static bool StrictInitialization;
|
|
|
|
static int getGLFWHint(int);
|
|
static int setGLFWHint(int, int);
|
|
static Window* getCurrent();
|
|
|
|
Window(const std::array<uint16_t, 2>, const char*, GLFWmonitor* initMonitor=NULL, GLFWwindow* initWindow=NULL);
|
|
Window(const uint16_t, const uint16_t, const char*, GLFWmonitor* initMonitor=NULL, GLFWwindow* initWindow=NULL);
|
|
~Window();
|
|
|
|
int getWindowHint(int) const;
|
|
GLFWwindow* getWindow() const;
|
|
std::array<uint16_t, 2> getSize() const;
|
|
float getAspectRatio() const;
|
|
std::string getName() const;
|
|
|
|
int init();
|
|
int setWindowHint(int, int);
|
|
void setCurrent();
|
|
void resize(const std::array<uint16_t, 2>);
|
|
void resize(const uint16_t x, const uint16_t y);
|
|
|
|
protected:
|
|
static std::map<GLFWwindow*, Window*> WindowContexts;
|
|
static std::map<int, int> GLFWHints;
|
|
static Window* _current;
|
|
static bool _glfw_init;
|
|
static bool checkKillGLFW();
|
|
|
|
std::map<int, int> windowHints;
|
|
std::array<uint16_t, 2> windowSize;
|
|
float _aspect_ratio;
|
|
std::string windowName;
|
|
GLFWwindow* window;
|
|
GLFWmonitor* monitor;
|
|
GLFWwindow* shareWindow;
|
|
bool _init = false;
|
|
int gladResponse = -1;
|
|
};
|
|
|
|
};
|
|
#endif |