Dawn/src/dawnopengl/display/BackBufferRenderTarget.cpp
2023-03-21 01:03:42 -07:00

44 lines
1.2 KiB
C++

// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "BackBufferRenderTarget.hpp"
using namespace Dawn;
BackBufferRenderTarget::BackBufferRenderTarget(RenderManager &renderManager) :
renderManager(renderManager)
{
}
float_t BackBufferRenderTarget::getWidth() {
return this->width;
}
float_t BackBufferRenderTarget::getHeight() {
return this->height;
}
void BackBufferRenderTarget::setSize(float_t width, float_t height) {
if(this->width == width && this->height == height) return;
this->width = width;
this->height = height;
this->eventRenderTargetResized.invoke(this, width, height);
}
void BackBufferRenderTarget::setClearColor(struct Color color) {
this->clearColor = color;
}
void BackBufferRenderTarget::clear(flag8_t clearFlags) {
auto clear = this->clearColor.precision();
glClearColor(clear.r, clear.g, clear.b, clear.a);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
void BackBufferRenderTarget::bind() {
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glViewport(0, 0, (GLsizei)this->width, (GLsizei)this->height);
}