fullscreen setting checkbox + smth

This commit is contained in:
MihailRis
2024-04-26 00:34:15 +03:00
parent 8be0d157c2
commit 4861fedf1e
17 changed files with 97 additions and 76 deletions
+1
View File
@@ -36,6 +36,7 @@ function on_open()
create_setting("graphics.fog-curve", "Fog Curve", 0.1) create_setting("graphics.fog-curve", "Fog Curve", 0.1)
create_setting("graphics.gamma", "Gamma", 0.05) create_setting("graphics.gamma", "Gamma", 0.05)
create_setting("camera.fov", "FOV", 1, "°") create_setting("camera.fov", "FOV", 1, "°")
create_checkbox("display.fullscreen", "Fullscreen")
create_checkbox("display.vsync", "V-Sync") create_checkbox("display.vsync", "V-Sync")
create_checkbox("graphics.backlight", "Backlight") create_checkbox("graphics.backlight", "Backlight")
create_checkbox("camera.shaking", "Camera Shaking") create_checkbox("camera.shaking", "Camera Shaking")
+1
View File
@@ -42,6 +42,7 @@ settings.Load Speed=Скорость Загрузки
settings.Fog Curve=Кривая Тумана settings.Fog Curve=Кривая Тумана
settings.Backlight=Подсветка settings.Backlight=Подсветка
settings.Gamma=Гамма settings.Gamma=Гамма
settings.Fullscreen=Полноэкранный
settings.V-Sync=Вертикальная Синхронизация settings.V-Sync=Вертикальная Синхронизация
settings.Camera Shaking=Тряска Камеры settings.Camera Shaking=Тряска Камеры
settings.Master Volume=Общая Громкость settings.Master Volume=Общая Громкость
+8 -1
View File
@@ -206,7 +206,14 @@ public:
observers.notify(value); observers.notify(value);
} }
observer_handler observe(consumer<bool> callback) { void toggle() {
set(!get());
}
observer_handler observe(consumer<bool> callback, bool callOnStart=false) {
if (callOnStart) {
callback(value);
}
return observers.observe(callback); return observers.observe(callback);
} }
+2 -2
View File
@@ -60,7 +60,7 @@ Engine::Engine(EngineSettings& settings, EnginePaths* paths)
: settings(settings), settingsHandler(settings), paths(paths) : settings(settings), settingsHandler(settings), paths(paths)
{ {
controller = std::make_unique<EngineController>(this); controller = std::make_unique<EngineController>(this);
if (Window::initialize(settings.display)){ if (Window::initialize(&this->settings.display)){
throw initialize_error("could not initialize window"); throw initialize_error("could not initialize window");
} }
audio::initialize(settings.audio.enabled); audio::initialize(settings.audio.enabled);
@@ -102,7 +102,7 @@ void Engine::updateHotkeys() {
saveScreenshot(); saveScreenshot();
} }
if (Events::jpressed(keycode::F11)) { if (Events::jpressed(keycode::F11)) {
Window::toggleFullscreen(); settings.display.fullscreen.toggle();
} }
} }
+12 -9
View File
@@ -1,13 +1,14 @@
#include "settings_io.h" #include "settings_io.h"
#include <memory>
#include <iostream>
#include "../window/Events.h" #include "../window/Events.h"
#include "../window/input.h" #include "../window/input.h"
#include "../coders/toml.h" #include "../coders/toml.h"
#include "../coders/json.h" #include "../coders/json.h"
#include "../debug/Logger.hpp"
#include <memory>
static debug::Logger logger("settings_io");
SettingsHandler::SettingsHandler(EngineSettings& settings) { SettingsHandler::SettingsHandler(EngineSettings& settings) {
// public settings // public settings
@@ -18,9 +19,11 @@ SettingsHandler::SettingsHandler(EngineSettings& settings) {
map.emplace("audio.volume-music", &settings.audio.volumeMusic); map.emplace("audio.volume-music", &settings.audio.volumeMusic);
map.emplace("display.vsync", &settings.display.vsync); map.emplace("display.vsync", &settings.display.vsync);
map.emplace("display.fullscreen", &settings.display.fullscreen);
map.emplace("camera.sensitivity", &settings.camera.sensitivity); map.emplace("camera.sensitivity", &settings.camera.sensitivity);
map.emplace("camera.fov", &settings.camera.fov); map.emplace("camera.fov", &settings.camera.fov);
map.emplace("camera.fov-effects", &settings.camera.fovEffects);
map.emplace("camera.shaking", &settings.camera.shaking); map.emplace("camera.shaking", &settings.camera.shaking);
map.emplace("chunks.load-distance", &settings.chunks.loadDistance); map.emplace("chunks.load-distance", &settings.chunks.loadDistance);
@@ -111,7 +114,7 @@ toml::Wrapper* create_wrapper(EngineSettings& settings) {
audio.add("volume-music", &*settings.audio.volumeMusic); audio.add("volume-music", &*settings.audio.volumeMusic);
toml::Section& display = wrapper->add("display"); toml::Section& display = wrapper->add("display");
display.add("fullscreen", &settings.display.fullscreen); display.add("fullscreen", &*settings.display.fullscreen);
display.add("width", &settings.display.width); display.add("width", &settings.display.width);
display.add("height", &settings.display.height); display.add("height", &settings.display.height);
display.add("samples", &settings.display.samples); display.add("samples", &settings.display.samples);
@@ -123,7 +126,7 @@ toml::Wrapper* create_wrapper(EngineSettings& settings) {
chunks.add("padding", &*settings.chunks.padding); chunks.add("padding", &*settings.chunks.padding);
toml::Section& camera = wrapper->add("camera"); toml::Section& camera = wrapper->add("camera");
camera.add("fov-effects", &settings.camera.fovEvents); camera.add("fov-effects", &*settings.camera.fovEffects);
camera.add("fov", &*settings.camera.fov); camera.add("fov", &*settings.camera.fov);
camera.add("shaking", &*settings.camera.shaking); camera.add("shaking", &*settings.camera.shaking);
camera.add("sensitivity", &*settings.camera.sensitivity); camera.add("sensitivity", &*settings.camera.sensitivity);
@@ -132,8 +135,8 @@ toml::Wrapper* create_wrapper(EngineSettings& settings) {
graphics.add("gamma", &*settings.graphics.gamma); graphics.add("gamma", &*settings.graphics.gamma);
graphics.add("fog-curve", &*settings.graphics.fogCurve); graphics.add("fog-curve", &*settings.graphics.fogCurve);
graphics.add("backlight", &*settings.graphics.backlight); graphics.add("backlight", &*settings.graphics.backlight);
graphics.add("frustum-culling", &settings.graphics.frustumCulling); graphics.add("frustum-culling", &*settings.graphics.frustumCulling);
graphics.add("skybox-resolution", &settings.graphics.skyboxResolution); graphics.add("skybox-resolution", &*settings.graphics.skyboxResolution);
toml::Section& debug = wrapper->add("debug"); toml::Section& debug = wrapper->add("debug");
debug.add("generator-test-mode", &settings.debug.generatorTestMode); debug.add("generator-test-mode", &settings.debug.generatorTestMode);
@@ -179,7 +182,7 @@ void load_controls(std::string filename, std::string source) {
} else if (typestr == "mouse") { } else if (typestr == "mouse") {
type = inputtype::mouse; type = inputtype::mouse;
} else { } else {
std::cerr << "unknown input type '" << typestr << "'" << std::endl; logger.error() << "unknown input type '" << typestr << "'";
continue; continue;
} }
binding.type = type; binding.type = type;
+1 -1
View File
@@ -63,7 +63,7 @@ std::shared_ptr<UINode> create_debug_panel(
})); }));
panel->add(create_label([=](){ panel->add(create_label([=](){
auto& settings = engine->getSettings(); auto& settings = engine->getSettings();
bool culling = settings.graphics.frustumCulling; bool culling = settings.graphics.frustumCulling.get();
return L"frustum-culling: "+std::wstring(culling ? L"on" : L"off"); return L"frustum-culling: "+std::wstring(culling ? L"on" : L"off");
})); }));
panel->add(create_label([=]() { panel->add(create_label([=]() {
+1 -1
View File
@@ -450,7 +450,7 @@ void Hud::draw(const GfxContext& ctx){
// Crosshair // Crosshair
if (!pause && !inventoryOpen && !player->debug) { if (!pause && !inventoryOpen && !player->debug) {
GfxContext chctx = ctx.sub(); GfxContext chctx = ctx.sub();
chctx.setBlendMode(blendmode::inversion); chctx.setBlendMode(BlendMode::inversion);
auto texture = assets->getTexture("gui/crosshair"); auto texture = assets->getTexture("gui/crosshair");
batch->texture(texture); batch->texture(texture);
int chsizex = texture != nullptr ? texture->getWidth() : 16; int chsizex = texture != nullptr ? texture->getWidth() : 16;
+1 -1
View File
@@ -93,7 +93,7 @@ void LevelScreen::saveWorldPreview() {
void LevelScreen::updateHotkeys() { void LevelScreen::updateHotkeys() {
auto& settings = engine->getSettings(); auto& settings = engine->getSettings();
if (Events::jpressed(keycode::O)) { if (Events::jpressed(keycode::O)) {
settings.graphics.frustumCulling = !settings.graphics.frustumCulling; settings.graphics.frustumCulling.toggle();
} }
if (Events::jpressed(keycode::F1)) { if (Events::jpressed(keycode::F1)) {
hudVisible = !hudVisible; hudVisible = !hudVisible;
+18 -3
View File
@@ -5,6 +5,21 @@
#include "Batch2D.hpp" #include "Batch2D.hpp"
#include "Framebuffer.hpp" #include "Framebuffer.hpp"
static void set_blend_mode(BlendMode mode) {
switch (mode) {
case BlendMode::normal:
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
break;
case BlendMode::addition:
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
break;
case BlendMode::inversion:
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA);
break;
}
}
GfxContext::GfxContext( GfxContext::GfxContext(
const GfxContext* parent, const GfxContext* parent,
const Viewport& viewport, const Viewport& viewport,
@@ -53,7 +68,7 @@ GfxContext::~GfxContext() {
else glEnable(GL_CULL_FACE); else glEnable(GL_CULL_FACE);
} }
if (blendMode != parent->blendMode) { if (blendMode != parent->blendMode) {
Window::setBlendMode(parent->blendMode); set_blend_mode(parent->blendMode);
} }
} }
@@ -119,11 +134,11 @@ void GfxContext::setCullFace(bool flag) {
} }
} }
void GfxContext::setBlendMode(blendmode mode) { void GfxContext::setBlendMode(BlendMode mode) {
if (blendMode == mode) if (blendMode == mode)
return; return;
blendMode = mode; blendMode = mode;
Window::setBlendMode(mode); set_blend_mode(mode);
} }
void GfxContext::setScissors(glm::vec4 area) { void GfxContext::setScissors(glm::vec4 area) {
+3 -2
View File
@@ -1,6 +1,7 @@
#ifndef GRAPHICS_CORE_GFX_CONTEXT_HPP_ #ifndef GRAPHICS_CORE_GFX_CONTEXT_HPP_
#define GRAPHICS_CORE_GFX_CONTEXT_HPP_ #define GRAPHICS_CORE_GFX_CONTEXT_HPP_
#include "commons.hpp"
#include "Viewport.hpp" #include "Viewport.hpp"
#include "../../window/Window.h" #include "../../window/Window.h"
#include "../../typedefs.h" #include "../../typedefs.h"
@@ -16,7 +17,7 @@ class GfxContext {
bool depthMask = true; bool depthMask = true;
bool depthTest = false; bool depthTest = false;
bool cullFace = false; bool cullFace = false;
blendmode blendMode = blendmode::normal; BlendMode blendMode = BlendMode::normal;
int scissorsCount = 0; int scissorsCount = 0;
public: public:
GfxContext(const GfxContext* parent, const Viewport& viewport, Batch2D* g2d); GfxContext(const GfxContext* parent, const Viewport& viewport, Batch2D* g2d);
@@ -31,7 +32,7 @@ public:
void setDepthMask(bool flag); void setDepthMask(bool flag);
void setDepthTest(bool flag); void setDepthTest(bool flag);
void setCullFace(bool flag); void setCullFace(bool flag);
void setBlendMode(blendmode mode); void setBlendMode(BlendMode mode);
void setScissors(glm::vec4 area); void setScissors(glm::vec4 area);
}; };
+4
View File
@@ -7,4 +7,8 @@ enum class DrawPrimitive {
triangle, triangle,
}; };
enum class BlendMode {
normal, addition, inversion
};
#endif // GRAPHICS_CORE_COMMONS_HPP_ #endif // GRAPHICS_CORE_COMMONS_HPP_
+1 -1
View File
@@ -104,7 +104,7 @@ void Skybox::draw(
drawBackground(camera, assets, width, height); drawBackground(camera, assets, width, height);
GfxContext ctx = pctx.sub(); GfxContext ctx = pctx.sub();
ctx.setBlendMode(blendmode::addition); ctx.setBlendMode(BlendMode::addition);
Shader* shader = assets->getShader("ui3d"); Shader* shader = assets->getShader("ui3d");
shader->use(); shader->use();
+2 -2
View File
@@ -57,7 +57,7 @@ WorldRenderer::WorldRenderer(Engine* engine, LevelFrontend* frontend, Player* pl
); );
auto assets = engine->getAssets(); auto assets = engine->getAssets();
skybox = std::make_unique<Skybox>( skybox = std::make_unique<Skybox>(
settings.graphics.skyboxResolution, settings.graphics.skyboxResolution.get(),
assets->getShader("skybox_gen") assets->getShader("skybox_gen")
); );
} }
@@ -127,7 +127,7 @@ void WorldRenderer::drawChunks(Chunks* chunks, Camera* camera, Shader* shader) {
(b->z + 0.5f - pz)*(b->z + 0.5f - pz)); (b->z + 0.5f - pz)*(b->z + 0.5f - pz));
}); });
bool culling = engine->getSettings().graphics.frustumCulling; bool culling = engine->getSettings().graphics.frustumCulling.get();
if (culling) { if (culling) {
frustumCulling->update(camera->getProjView()); frustumCulling->update(camera->getProjView());
} }
+1 -1
View File
@@ -142,7 +142,7 @@ void CameraControl::update(PlayerInput& input, float delta, Chunks* chunks) {
if (settings.shaking.get() && !input.cheat) { if (settings.shaking.get() && !input.cheat) {
offset += updateCameraShaking(delta); offset += updateCameraShaking(delta);
} }
if (settings.fovEvents){ if (settings.fovEffects.get()){
updateFovEffects(input, delta); updateFovEffects(input, delta);
} }
if (input.cameraMode) { if (input.cameraMode) {
+15 -15
View File
@@ -1,5 +1,5 @@
#ifndef SRC_SETTINGS_H_ #ifndef SETTINGS_H_
#define SRC_SETTINGS_H_ #define SETTINGS_H_
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
@@ -21,7 +21,7 @@ struct AudioSettings {
struct DisplaySettings { struct DisplaySettings {
/// @brief Is window in full screen mode /// @brief Is window in full screen mode
bool fullscreen = false; FlagSetting fullscreen {false};
/// @brief Window width (pixels) /// @brief Window width (pixels)
int width = 1280; int width = 1280;
/// @brief Window height (pixels) /// @brief Window height (pixels)
@@ -29,8 +29,8 @@ struct DisplaySettings {
/// @brief Anti-aliasing samples /// @brief Anti-aliasing samples
int samples = 0; int samples = 0;
/// @brief VSync on /// @brief VSync on
FlagSetting vsync = {true}; FlagSetting vsync {true};
/// @brief Window title */ /// @brief Window title
std::string title = "VoxelEngine-Cpp v" + std::string title = "VoxelEngine-Cpp v" +
std::to_string(ENGINE_VERSION_MAJOR) + "." + std::to_string(ENGINE_VERSION_MAJOR) + "." +
std::to_string(ENGINE_VERSION_MINOR); std::to_string(ENGINE_VERSION_MINOR);
@@ -38,18 +38,18 @@ struct DisplaySettings {
struct ChunksSettings { struct ChunksSettings {
/// @brief Max milliseconds that engine uses for chunks loading only /// @brief Max milliseconds that engine uses for chunks loading only
IntegerSetting loadSpeed = {4, 1, 32}; IntegerSetting loadSpeed {4, 1, 32};
/// @brief Radius of chunks loading zone (chunk is unit) /// @brief Radius of chunks loading zone (chunk is unit)
IntegerSetting loadDistance = {22, 3, 66}; IntegerSetting loadDistance {22, 3, 66};
/// @brief Buffer zone where chunks are not unloading (chunk is unit) /// @brief Buffer zone where chunks are not unloading (chunk is unit)
IntegerSetting padding = {2, 1, 8}; IntegerSetting padding {2, 1, 8};
}; };
struct CameraSettings { struct CameraSettings {
/// @brief Camera dynamic field of view effects /// @brief Camera dynamic field of view effects
bool fovEvents = true; FlagSetting fovEffects {true};
/// @brief Camera movement shake /// @brief Camera movement shake
FlagSetting shaking = {true}; FlagSetting shaking {true};
/// @brief Camera field of view /// @brief Camera field of view
NumberSetting fov {90.0f, 10, 120}; NumberSetting fov {90.0f, 10, 120};
/// @brief Camera sensitivity /// @brief Camera sensitivity
@@ -60,12 +60,12 @@ struct GraphicsSettings {
/// @brief Fog opacity is calculated as `pow(depth*k, fogCurve)` where k depends on chunksLoadDistance. /// @brief Fog opacity is calculated as `pow(depth*k, fogCurve)` where k depends on chunksLoadDistance.
/// 1.0 is linear, 2.0 is quadratic /// 1.0 is linear, 2.0 is quadratic
NumberSetting fogCurve {1.6f, 1.0f, 6.0f}; NumberSetting fogCurve {1.6f, 1.0f, 6.0f};
NumberSetting gamma = {1.0f, 0.5f, 2.0f}; NumberSetting gamma {1.0f, 0.5f, 2.0f};
/// @brief Enable blocks backlight to prevent complete darkness /// @brief Enable blocks backlight to prevent complete darkness
FlagSetting backlight = {true}; FlagSetting backlight {true};
/// @brief Enable chunks frustum culling /// @brief Enable chunks frustum culling
bool frustumCulling = true; FlagSetting frustumCulling {true}; // redutant?
int skyboxResolution = 64 + 32; IntegerSetting skyboxResolution {64 + 32, 64, 128};
}; };
struct DebugSettings { struct DebugSettings {
@@ -90,4 +90,4 @@ struct EngineSettings {
UiSettings ui; UiSettings ui;
}; };
#endif // SRC_SETTINGS_H_ #endif // SETTINGS_H_
+24 -29
View File
@@ -4,6 +4,8 @@
#include "../debug/Logger.hpp" #include "../debug/Logger.hpp"
#include "../graphics/core/ImageData.hpp" #include "../graphics/core/ImageData.hpp"
#include "../graphics/core/Texture.hpp" #include "../graphics/core/Texture.hpp"
#include "../settings.h"
#include "../util/ObjectsKeeper.hpp"
#include <GL/glew.h> #include <GL/glew.h>
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@@ -18,6 +20,9 @@ uint Window::width = 0;
uint Window::height = 0; uint Window::height = 0;
int Window::posX = 0; int Window::posX = 0;
int Window::posY = 0; int Window::posY = 0;
bool Window::fullscreen = false;
static util::ObjectsKeeper observers_keeper;
void cursor_position_callback(GLFWwindow*, double xpos, double ypos) { void cursor_position_callback(GLFWwindow*, double xpos, double ypos) {
Events::setPosition(xpos, ypos); Events::setPosition(xpos, ypos);
@@ -103,10 +108,10 @@ void error_callback(int error, const char* description) {
} }
} }
int Window::initialize(DisplaySettings& settings){ int Window::initialize(DisplaySettings* settings){
Window::settings = &settings; Window::settings = settings;
Window::width = settings.width; Window::width = settings->width;
Window::height = settings.height; Window::height = settings->height;
glfwSetErrorCallback(error_callback); glfwSetErrorCallback(error_callback);
if (glfwInit() == GLFW_FALSE) { if (glfwInit() == GLFW_FALSE) {
@@ -124,9 +129,9 @@ int Window::initialize(DisplaySettings& settings){
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_ANY_PROFILE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_ANY_PROFILE);
#endif #endif
glfwWindowHint(GLFW_RESIZABLE, GL_TRUE); glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);
glfwWindowHint(GLFW_SAMPLES, settings.samples); glfwWindowHint(GLFW_SAMPLES, settings->samples);
window = glfwCreateWindow(width, height, settings.title.c_str(), nullptr, nullptr); window = glfwCreateWindow(width, height, settings->title.c_str(), nullptr, nullptr);
if (window == nullptr){ if (window == nullptr){
logger.error() << "failed to create GLFW window"; logger.error() << "failed to create GLFW window";
glfwTerminate(); glfwTerminate();
@@ -159,12 +164,15 @@ int Window::initialize(DisplaySettings& settings){
glfwSetWindowSizeCallback(window, window_size_callback); glfwSetWindowSizeCallback(window, window_size_callback);
glfwSetCharCallback(window, character_callback); glfwSetCharCallback(window, character_callback);
glfwSetScrollCallback(window, scroll_callback); glfwSetScrollCallback(window, scroll_callback);
if (settings.fullscreen) {
GLFWmonitor* monitor = glfwGetPrimaryMonitor(); observers_keeper = util::ObjectsKeeper();
const GLFWvidmode* mode = glfwGetVideoMode(monitor); observers_keeper.keepAlive(settings->fullscreen.observe([=](bool value) {
glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, mode->height, GLFW_DONT_CARE); if (value != isFullscreen()) {
} toggleFullscreen();
glfwSwapInterval(settings.vsync.get()); }
}, true));
glfwSwapInterval(settings->vsync.get());
const GLubyte* vendor = glGetString(GL_VENDOR); const GLubyte* vendor = glGetString(GL_VENDOR);
const GLubyte* renderer = glGetString(GL_RENDERER); const GLubyte* renderer = glGetString(GL_RENDERER);
logger.info() << "GL Vendor: " << (char*)vendor; logger.info() << "GL Vendor: " << (char*)vendor;
@@ -173,20 +181,6 @@ int Window::initialize(DisplaySettings& settings){
return 0; return 0;
} }
void Window::setBlendMode(blendmode mode) {
switch (mode) {
case blendmode::normal:
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
break;
case blendmode::addition:
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
break;
case blendmode::inversion:
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA);
break;
}
}
void Window::clear() { void Window::clear() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
} }
@@ -263,6 +257,7 @@ void Window::popScissor() {
} }
void Window::terminate(){ void Window::terminate(){
observers_keeper = util::ObjectsKeeper();
glfwTerminate(); glfwTerminate();
} }
@@ -279,14 +274,14 @@ void Window::swapInterval(int interval){
} }
void Window::toggleFullscreen(){ void Window::toggleFullscreen(){
settings->fullscreen = !settings->fullscreen; fullscreen = !fullscreen;
GLFWmonitor* monitor = glfwGetPrimaryMonitor(); GLFWmonitor* monitor = glfwGetPrimaryMonitor();
const GLFWvidmode* mode = glfwGetVideoMode(monitor); const GLFWvidmode* mode = glfwGetVideoMode(monitor);
if (Events::_cursor_locked) Events::toggleCursor(); if (Events::_cursor_locked) Events::toggleCursor();
if (settings->fullscreen) { if (fullscreen) {
glfwGetWindowPos(window, &posX, &posY); glfwGetWindowPos(window, &posX, &posY);
glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, mode->height, GLFW_DONT_CARE); glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, mode->height, GLFW_DONT_CARE);
} }
@@ -301,7 +296,7 @@ void Window::toggleFullscreen(){
} }
bool Window::isFullscreen() { bool Window::isFullscreen() {
return settings->fullscreen; return fullscreen;
} }
void Window::swapBuffers(){ void Window::swapBuffers(){
+2 -8
View File
@@ -2,7 +2,6 @@
#define WINDOW_WINDOW_H_ #define WINDOW_WINDOW_H_
#include "../typedefs.h" #include "../typedefs.h"
#include "../settings.h"
#include <stack> #include <stack>
#include <vector> #include <vector>
@@ -14,15 +13,12 @@ struct DisplaySettings;
struct GLFWwindow; struct GLFWwindow;
struct GLFWmonitor; struct GLFWmonitor;
enum class blendmode {
normal, addition, inversion
};
class Window { class Window {
static GLFWwindow* window; static GLFWwindow* window;
static DisplaySettings* settings; static DisplaySettings* settings;
static std::stack<glm::vec4> scissorStack; static std::stack<glm::vec4> scissorStack;
static glm::vec4 scissorArea; static glm::vec4 scissorArea;
static bool fullscreen;
static bool tryToMaximize(GLFWwindow* window, GLFWmonitor* monitor); static bool tryToMaximize(GLFWwindow* window, GLFWmonitor* monitor);
public: public:
@@ -30,7 +26,7 @@ public:
static int posY; static int posY;
static uint width; static uint width;
static uint height; static uint height;
static int initialize(DisplaySettings& settings); static int initialize(DisplaySettings* settings);
static void terminate(); static void terminate();
static void viewport(int x, int y, int width, int height); static void viewport(int x, int y, int width, int height);
@@ -58,8 +54,6 @@ public:
static void setClipboardText(const char* text); static void setClipboardText(const char* text);
static DisplaySettings* getSettings(); static DisplaySettings* getSettings();
static void setBlendMode(blendmode mode);
static glm::vec2 size() { static glm::vec2 size() {
return glm::vec2(width, height); return glm::vec2(width, height);
} }