Browse Source

Render: Change RenderCommand::clearBit function

master
Riyyi 4 months ago
parent
commit
fd72f6610e
  1. 6
      src/inferno/application.cpp
  2. 2
      src/inferno/render/framebuffer.cpp
  3. 2
      src/inferno/render/framebuffer.h
  4. 10
      src/inferno/render/render-command.cpp
  5. 3
      src/inferno/render/render-command.h

6
src/inferno/application.cpp

@ -178,7 +178,7 @@ int Application::run()
render();
RenderCommand::clearColor({ 0.2f, 0.3f, 0.3f, 1.0f });
RenderCommand::clearColorDepthBit();
RenderCommand::clearBit(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
std::pair<glm::mat4, glm::mat4> projectionView = m_scene->cameraProjectionView();
RendererCubemap::the().beginScene(projectionView.first, projectionView.second); // camera, lights, environment
@ -200,7 +200,7 @@ int Application::run()
// Framebuffer
RenderCommand::clearColor({ 1.0f, 1.0f, 1.0f, 1.0f });
RenderCommand::clearColorBit();
RenderCommand::clearBit(GL_COLOR_BUFFER_BIT);
Renderer2D::the().setEnableDepthBuffer(false);
Renderer2D::the().beginScene(matIdentity, matIdentity);
@ -242,7 +242,7 @@ bool Application::onWindowResize(WindowResizeEvent& e)
ruc::info("WindowResizeEvent {}x{}", e.getWidth(), e.getHeight());
RenderCommand::setViewport(0, 0, e.getWidth(), e.getHeight());
m_framebuffer->setSize(e.getWidth(), e.getHeight());
m_framebuffer->resize(e.getWidth(), e.getHeight());
return true;
}

2
src/inferno/render/framebuffer.cpp

@ -52,7 +52,7 @@ void Framebuffer::unbind() const
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
void Framebuffer::setSize(uint32_t width, uint32_t height)
void Framebuffer::resize(uint32_t width, uint32_t height)
{
if (m_width == width && m_height == height) {
return;

2
src/inferno/render/framebuffer.h

@ -43,7 +43,7 @@ public:
void bind() const;
void unbind() const;
void setSize(uint32_t width, uint32_t height);
void resize(uint32_t width, uint32_t height);
Type type() const { return m_type; }
uint32_t width() const { return m_width; }

10
src/inferno/render/render-command.cpp

@ -29,14 +29,10 @@ void RenderCommand::destroy()
{
}
void RenderCommand::clearColorDepthBit()
void RenderCommand::clearBit(uint32_t bits)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
void RenderCommand::clearColorBit()
{
glClear(GL_COLOR_BUFFER_BIT);
// GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT
glClear(bits);
}
void RenderCommand::clearColor(const glm::vec4& color)

3
src/inferno/render/render-command.h

@ -19,8 +19,7 @@ public:
static void initialize();
static void destroy();
static void clearColorDepthBit();
static void clearColorBit();
static void clearBit(uint32_t bits);
static void clearColor(const glm::vec4& color);
static void drawIndexed(std::shared_ptr<VertexArray> vertexArray, uint32_t indexCount = 0);

Loading…
Cancel
Save