voxelcore/src/graphics/core/DrawContext.hpp
loki5512344 708c276787 Add GUI scale setting and volume contrast setting
GUI scale (#737):
- add display.gui-scale setting (0 - auto, 1..4 - fixed integer scale)
- auto mode picks the largest scale keeping at least 640x480 UI units
- apply scale in GUI (root size, camera, cursor, tooltips, scissors)
- HUD layout and ModelViewer use scaled coordinates
- add GUI Scale trackbar to display settings

Volume contrast (#399):
- add audio.volume-contrast setting (100% - unchanged sounds,
  0% - loud sounds are lowered to the level of quiet ones)
- loudness (RMS) of a sound is calculated once and cached
- add trackbar to audio settings and reset page
2026-10-03 12:56:54 +00:00

55 lines
1.4 KiB
C++

#pragma once
#include <array>
#include <glm/vec2.hpp>
#include <glm/vec4.hpp>
#include "commons.hpp"
#include "typedefs.hpp"
class Window;
class Batch2D;
class Framebuffer;
class DrawContext {
Window& window;
const DrawContext* parent;
glm::uvec2 viewport;
Batch2D* g2d;
Flushable* flushable = nullptr;
Bindable* fbo = nullptr;
bool depthMask = true;
bool depthTest = false;
bool cullFace = false;
BlendMode blendMode = BlendMode::normal;
int scissorsCount = 0;
float lineWidth = 1.0f;
float uiScale = 1.0f;
std::array<const Bindable*, advanced_pipeline::TARGETS_COUNT> textures {};
public:
DrawContext(
const DrawContext* parent,
Window& window,
Batch2D* g2d
);
~DrawContext();
Batch2D* getBatch2D() const;
const glm::uvec2& getViewport() const;
[[nodiscard]] DrawContext sub(Flushable* flushable=nullptr) const;
void setViewport(const glm::uvec2& viewport);
void setFramebuffer(Bindable* fbo);
void setDepthMask(bool flag);
void setDepthTest(bool flag);
void setCullFace(bool flag);
void setBlendMode(BlendMode mode);
void setScissors(const glm::vec4& area);
void setLineWidth(float width);
/// @brief Set scale of UI coordinates (UI units -> window pixels).
/// Affects setScissors only
void setUiScale(float scale);
void useTexture(int target, const Bindable* texture);
};