fullscreen setting checkbox + smth
This commit is contained in:
@@ -5,6 +5,21 @@
|
||||
#include "Batch2D.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(
|
||||
const GfxContext* parent,
|
||||
const Viewport& viewport,
|
||||
@@ -53,7 +68,7 @@ GfxContext::~GfxContext() {
|
||||
else glEnable(GL_CULL_FACE);
|
||||
}
|
||||
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)
|
||||
return;
|
||||
blendMode = mode;
|
||||
Window::setBlendMode(mode);
|
||||
set_blend_mode(mode);
|
||||
}
|
||||
|
||||
void GfxContext::setScissors(glm::vec4 area) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef GRAPHICS_CORE_GFX_CONTEXT_HPP_
|
||||
#define GRAPHICS_CORE_GFX_CONTEXT_HPP_
|
||||
|
||||
#include "commons.hpp"
|
||||
#include "Viewport.hpp"
|
||||
#include "../../window/Window.h"
|
||||
#include "../../typedefs.h"
|
||||
@@ -16,7 +17,7 @@ class GfxContext {
|
||||
bool depthMask = true;
|
||||
bool depthTest = false;
|
||||
bool cullFace = false;
|
||||
blendmode blendMode = blendmode::normal;
|
||||
BlendMode blendMode = BlendMode::normal;
|
||||
int scissorsCount = 0;
|
||||
public:
|
||||
GfxContext(const GfxContext* parent, const Viewport& viewport, Batch2D* g2d);
|
||||
@@ -31,7 +32,7 @@ public:
|
||||
void setDepthMask(bool flag);
|
||||
void setDepthTest(bool flag);
|
||||
void setCullFace(bool flag);
|
||||
void setBlendMode(blendmode mode);
|
||||
void setBlendMode(BlendMode mode);
|
||||
void setScissors(glm::vec4 area);
|
||||
};
|
||||
|
||||
|
||||
@@ -7,4 +7,8 @@ enum class DrawPrimitive {
|
||||
triangle,
|
||||
};
|
||||
|
||||
enum class BlendMode {
|
||||
normal, addition, inversion
|
||||
};
|
||||
|
||||
#endif // GRAPHICS_CORE_COMMONS_HPP_
|
||||
|
||||
@@ -104,7 +104,7 @@ void Skybox::draw(
|
||||
drawBackground(camera, assets, width, height);
|
||||
|
||||
GfxContext ctx = pctx.sub();
|
||||
ctx.setBlendMode(blendmode::addition);
|
||||
ctx.setBlendMode(BlendMode::addition);
|
||||
|
||||
Shader* shader = assets->getShader("ui3d");
|
||||
shader->use();
|
||||
|
||||
@@ -57,7 +57,7 @@ WorldRenderer::WorldRenderer(Engine* engine, LevelFrontend* frontend, Player* pl
|
||||
);
|
||||
auto assets = engine->getAssets();
|
||||
skybox = std::make_unique<Skybox>(
|
||||
settings.graphics.skyboxResolution,
|
||||
settings.graphics.skyboxResolution.get(),
|
||||
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));
|
||||
});
|
||||
|
||||
bool culling = engine->getSettings().graphics.frustumCulling;
|
||||
bool culling = engine->getSettings().graphics.frustumCulling.get();
|
||||
if (culling) {
|
||||
frustumCulling->update(camera->getProjView());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user