GfxContext renamed to DrawContext

This commit is contained in:
MihailRis
2024-04-30 00:31:13 +03:00
parent 4af0a8acf7
commit bcf2f5029d
37 changed files with 101 additions and 101 deletions
@@ -1,4 +1,4 @@
#include "GfxContext.hpp"
#include "DrawContext.hpp"
#include <GL/glew.h>
@@ -20,8 +20,8 @@ static void set_blend_mode(BlendMode mode) {
}
GfxContext::GfxContext(
const GfxContext* parent,
DrawContext::DrawContext(
const DrawContext* parent,
const Viewport& viewport,
Batch2D* g2d
) : parent(parent),
@@ -29,7 +29,7 @@ GfxContext::GfxContext(
g2d(g2d)
{}
GfxContext::~GfxContext() {
DrawContext::~DrawContext() {
if (g2d) {
g2d->flush();
}
@@ -72,22 +72,22 @@ GfxContext::~GfxContext() {
}
}
const Viewport& GfxContext::getViewport() const {
const Viewport& DrawContext::getViewport() const {
return viewport;
}
Batch2D* GfxContext::getBatch2D() const {
Batch2D* DrawContext::getBatch2D() const {
return g2d;
}
GfxContext GfxContext::sub() const {
auto ctx = GfxContext(this, viewport, g2d);
DrawContext DrawContext::sub() const {
auto ctx = DrawContext(this, viewport, g2d);
ctx.depthTest = depthTest;
ctx.cullFace = cullFace;
return ctx;
}
void GfxContext::setViewport(const Viewport& viewport) {
void DrawContext::setViewport(const Viewport& viewport) {
this->viewport = viewport;
Window::viewport(
0, 0,
@@ -96,7 +96,7 @@ void GfxContext::setViewport(const Viewport& viewport) {
);
}
void GfxContext::setFramebuffer(Framebuffer* fbo) {
void DrawContext::setFramebuffer(Framebuffer* fbo) {
if (this->fbo == fbo)
return;
this->fbo = fbo;
@@ -105,14 +105,14 @@ void GfxContext::setFramebuffer(Framebuffer* fbo) {
}
}
void GfxContext::setDepthMask(bool flag) {
void DrawContext::setDepthMask(bool flag) {
if (depthMask == flag)
return;
depthMask = flag;
glDepthMask(GL_FALSE + flag);
}
void GfxContext::setDepthTest(bool flag) {
void DrawContext::setDepthTest(bool flag) {
if (depthTest == flag)
return;
depthTest = flag;
@@ -123,7 +123,7 @@ void GfxContext::setDepthTest(bool flag) {
}
}
void GfxContext::setCullFace(bool flag) {
void DrawContext::setCullFace(bool flag) {
if (cullFace == flag)
return;
cullFace = flag;
@@ -134,14 +134,14 @@ void GfxContext::setCullFace(bool flag) {
}
}
void GfxContext::setBlendMode(BlendMode mode) {
void DrawContext::setBlendMode(BlendMode mode) {
if (blendMode == mode)
return;
blendMode = mode;
set_blend_mode(mode);
}
void GfxContext::setScissors(glm::vec4 area) {
void DrawContext::setScissors(glm::vec4 area) {
Window::pushScissor(area);
scissorsCount++;
}
@@ -9,8 +9,8 @@
class Batch2D;
class Framebuffer;
class GfxContext {
const GfxContext* parent;
class DrawContext {
const DrawContext* parent;
Viewport viewport;
Batch2D* const g2d;
Framebuffer* fbo = nullptr;
@@ -20,12 +20,12 @@ class GfxContext {
BlendMode blendMode = BlendMode::normal;
int scissorsCount = 0;
public:
GfxContext(const GfxContext* parent, const Viewport& viewport, Batch2D* g2d);
~GfxContext();
DrawContext(const DrawContext* parent, const Viewport& viewport, Batch2D* g2d);
~DrawContext();
Batch2D* getBatch2D() const;
const Viewport& getViewport() const;
GfxContext sub() const;
DrawContext sub() const;
void setViewport(const Viewport& viewport);
void setFramebuffer(Framebuffer* fbo);
+2 -2
View File
@@ -19,7 +19,7 @@ PostProcessing::PostProcessing() {
PostProcessing::~PostProcessing() {
}
void PostProcessing::use(GfxContext& context) {
void PostProcessing::use(DrawContext& context) {
const auto& vp = context.getViewport();
if (fbo) {
fbo->resize(vp.getWidth(), vp.getHeight());
@@ -29,7 +29,7 @@ void PostProcessing::use(GfxContext& context) {
context.setFramebuffer(fbo.get());
}
void PostProcessing::render(const GfxContext& context, Shader* screenShader) {
void PostProcessing::render(const DrawContext& context, Shader* screenShader) {
if (fbo == nullptr) {
throw std::runtime_error("'use(...)' was never called");
}
+3 -3
View File
@@ -2,7 +2,7 @@
#define GRAPHICS_CORE_POST_PROCESSING_HPP_
#include "Viewport.hpp"
#include "GfxContext.hpp"
#include "DrawContext.hpp"
#include <memory>
@@ -24,14 +24,14 @@ public:
/// @brief Prepare and bind framebuffer
/// @param context graphics context will be modified
void use(GfxContext& context);
void use(DrawContext& context);
/// @brief Render fullscreen quad using the passed shader
/// with framebuffer texture bound
/// @param context graphics context
/// @param screenShader shader used for fullscreen quad
/// @throws std::runtime_error if use(...) wasn't called before
void render(const GfxContext& context, Shader* screenShader);
void render(const DrawContext& context, Shader* screenShader);
/// @brief Make an image from the last rendered frame
std::unique_ptr<ImageData> toImage();