Removed RenderTarget event pointer.

This commit is contained in:
2023-11-12 19:28:01 -06:00
parent 31e922bb3e
commit ae800eb59c
8 changed files with 30 additions and 23 deletions

View File

@ -14,7 +14,11 @@
namespace Dawn { namespace Dawn {
class RenderTarget { class RenderTarget {
public: public:
StateEvent<RenderTarget*, float_t, float_t> eventRenderTargetResized; StateEvent<
RenderTarget&,
const float_t,
const float_t
> eventRenderTargetResized;
/** /**
* Return the width of the render target. * Return the width of the render target.

View File

@ -84,7 +84,11 @@ void Camera::onStart() {
this->eventRenderTargetResized.invoke(rt->getWidth(), rt->getHeight()); this->eventRenderTargetResized.invoke(rt->getWidth(), rt->getHeight());
// Subscribe to new render target resized. // Subscribe to new render target resized.
return evtResized = useEvent([&](RenderTarget *rt, float_t w, float_t h){ return evtResized = useEvent([&](
RenderTarget &rt,
const float_t w,
const float_t h
) {
this->projectionNeedsUpdating = true; this->projectionNeedsUpdating = true;
this->eventRenderTargetResized.invoke(w, h); this->eventRenderTargetResized.invoke(w, h);
}, rt->eventRenderTargetResized); }, rt->eventRenderTargetResized);
@ -102,7 +106,11 @@ void Camera::onStart() {
// Sub to evt legacy, we don't invoke the useTeardown to avoid invoking // Sub to evt legacy, we don't invoke the useTeardown to avoid invoking
// the state event for this camera when we don't need to. // the state event for this camera when we don't need to.
if(!this->getRenderTarget()) return; if(!this->getRenderTarget()) return;
evtResized = useEvent([&](RenderTarget *rt, float_t w, float_t h){ evtResized = useEvent([&](
RenderTarget &rt,
const float_t w,
const float_t h
) {
this->projectionNeedsUpdating = true; this->projectionNeedsUpdating = true;
this->eventRenderTargetResized.invoke(w, h); this->eventRenderTargetResized.invoke(w, h);
}, getRenderTarget()->eventRenderTargetResized); }, getRenderTarget()->eventRenderTargetResized);

View File

@ -43,7 +43,11 @@ void SimpleRenderTargetQuad::onStart() {
); );
// Subscribe to resize event. // Subscribe to resize event.
evtResized = useEvent([&](RenderTarget *target, float_t w, float_t h){ evtResized = useEvent([&](
RenderTarget &target,
const float_t w,
const float_t h
) {
QuadMesh::bufferQuadMesh( QuadMesh::bufferQuadMesh(
&this->meshHost->mesh, &this->meshHost->mesh,
glm::vec2(0, 0), glm::vec2(0, 0), glm::vec2(0, 0), glm::vec2(0, 0),

View File

@ -58,7 +58,11 @@ void SubSceneCameraAlign::onStart() {
this->realign(); this->realign();
return evtRenderResized = useEvent([&](RenderTarget *t, float_t w, float_t h) { return evtRenderResized = useEvent([&](
RenderTarget &rt,
const float_t w,
const float_t h
) {
this->realign(); this->realign();
}, renderTarget->eventRenderTargetResized); }, renderTarget->eventRenderTargetResized);
}, this->renderTarget); }, this->renderTarget);

View File

@ -7,18 +7,13 @@
using namespace Dawn; using namespace Dawn;
UsageLock::UsageLock() : UsageLock(&this->internalPool) { UsageLock::UsageLock() {
}
UsageLock::UsageLock(usagelockid_t *lockPool) {
assertNotNull(lockPool, "Lock pool cannot be null");
this->pool = lockPool;
this->onEmpty = []() {}; this->onEmpty = []() {};
this->onFirstLock = []() {}; this->onFirstLock = []() {};
} }
usagelockid_t UsageLock::createLock() { usagelockid_t UsageLock::createLock() {
usagelockid_t lock = (*this->pool)++; usagelockid_t lock = this->pool++;
this->locks.push_back(lock); this->locks.push_back(lock);
if(this->locks.size() == 1) this->onFirstLock(); if(this->locks.size() == 1) this->onFirstLock();
return lock; return lock;

View File

@ -10,8 +10,7 @@ namespace Dawn {
class UsageLock { class UsageLock {
protected: protected:
usagelockid_t internalPool = 0; usagelockid_t pool = 0;
usagelockid_t *pool = nullptr;
std::vector<usagelockid_t> locks; std::vector<usagelockid_t> locks;
public: public:
@ -24,13 +23,6 @@ namespace Dawn {
*/ */
UsageLock(); UsageLock();
/**
* Construct a new Usage Lock object
*
* @param lockPool Pool that will be used to create locks.
*/
UsageLock(usagelockid_t *lockPool);
/** /**
* Creates a new lock. * Creates a new lock.
* *

View File

@ -33,7 +33,7 @@ void BackBufferRenderTarget::setSize(float_t width, float_t height) {
this->width = width; this->width = width;
this->height = height; this->height = height;
this->eventRenderTargetResized.invoke(this, width, height); this->eventRenderTargetResized.invoke(*this, width, height);
} }
void BackBufferRenderTarget::setClearColor(struct Color color) { void BackBufferRenderTarget::setClearColor(struct Color color) {

View File

@ -30,7 +30,7 @@ void TextureRenderTarget::setSize(float_t width, float_t height) {
// Resize texture // Resize texture
this->texture.setSize((int32_t)width, (int32_t)height, TEXTURE_FORMAT_RGBA, TEXTURE_DATA_FORMAT_FLOAT); this->texture.setSize((int32_t)width, (int32_t)height, TEXTURE_FORMAT_RGBA, TEXTURE_DATA_FORMAT_FLOAT);
this->eventRenderTargetResized.invoke(this, width, height); this->eventRenderTargetResized.invoke(*this, width, height);
// Create Frame Buffer // Create Frame Buffer
glGenFramebuffers(1, &this->fboId); glGenFramebuffers(1, &this->fboId);