Added appropriate delete statements.
This commit is contained in:
@ -26,11 +26,11 @@
|
||||
assertTrue(false);
|
||||
}
|
||||
|
||||
void assertNotNull(const void *pointer) {
|
||||
void assertNotNull(void *pointer) {
|
||||
assertTrue(pointer != nullptr && pointer != NULL);
|
||||
}
|
||||
|
||||
void assertNull(const void *pointer) {
|
||||
void assertNull(void *pointer) {
|
||||
assertTrue(pointer == NULL || pointer == nullptr);
|
||||
}
|
||||
|
||||
|
@ -38,13 +38,13 @@ static inline void assertTrue(bool_t x) {}
|
||||
* Assert a given pointer to not point to a null pointer.
|
||||
* @param pointer Pointer to assert is not a null pointer.
|
||||
*/
|
||||
void assertNotNull(const void *pointer);
|
||||
void assertNotNull(void *pointer);
|
||||
|
||||
/**
|
||||
* Asserts a given pointer to be a nullptr.
|
||||
* @param pointer Pointer to assert is nullptr.
|
||||
*/
|
||||
void assertNull(const void *pointer);
|
||||
void assertNull(void *pointer);
|
||||
|
||||
/**
|
||||
* Asserts a function as being deprecated.
|
||||
|
@ -37,6 +37,12 @@ namespace Dawn {
|
||||
return asset;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void unload(std::string name) {
|
||||
assertUnreachable();
|
||||
//should delete the asset for you
|
||||
}
|
||||
|
||||
~AssetManager();
|
||||
};
|
||||
}
|
@ -12,6 +12,7 @@ using namespace Dawn;
|
||||
|
||||
RenderPipeline::RenderPipeline(RenderManager *renderManager) {
|
||||
assertNotNull(renderManager);
|
||||
|
||||
this->renderManager = renderManager;
|
||||
}
|
||||
|
||||
@ -24,6 +25,8 @@ void RenderPipeline::render() {
|
||||
}
|
||||
|
||||
void RenderPipeline::renderScene(Scene *scene) {
|
||||
assertNotNull(scene);
|
||||
|
||||
auto backBuffer = this->renderManager->getBackBuffer();
|
||||
auto cameras = scene->findComponents<Camera>();
|
||||
Camera *backBufferCamera = nullptr;
|
||||
@ -57,7 +60,12 @@ void RenderPipeline::renderScene(Scene *scene) {
|
||||
}
|
||||
|
||||
void RenderPipeline::renderSceneCamera(Scene *scene, Camera *camera) {
|
||||
assertNotNull(scene);
|
||||
assertNotNull(camera);
|
||||
|
||||
RenderTarget *renderTarget = camera->getRenderTarget();
|
||||
assertNotNull(renderTarget);
|
||||
|
||||
renderTarget->bind();
|
||||
renderTarget->clear(
|
||||
RENDER_TARGET_CLEAR_FLAG_DEPTH |
|
||||
@ -96,7 +104,10 @@ void RenderPipeline::renderUI(
|
||||
Camera *camera,
|
||||
UICanvas *canvas
|
||||
) {
|
||||
// Get the
|
||||
assertNotNull(scene);
|
||||
assertNotNull(camera);
|
||||
assertNotNull(canvas);
|
||||
|
||||
RenderTarget *renderTarget;
|
||||
|
||||
glm::mat4 transform;
|
||||
@ -108,8 +119,10 @@ void RenderPipeline::renderUI(
|
||||
renderTarget = camera->getRenderTarget();
|
||||
break;
|
||||
default:
|
||||
throw "UI Draw modes are not yet supported.";
|
||||
assertUnreachable();
|
||||
}
|
||||
|
||||
assertNotNull(renderTarget);
|
||||
|
||||
// Clear / Bind / Update the render target.
|
||||
renderTarget->bind();
|
||||
@ -124,6 +137,8 @@ void RenderPipeline::renderUI(
|
||||
|
||||
// Prepare the UI Shader
|
||||
auto shader = this->renderManager->getUIShader();
|
||||
assertNotNull(shader);
|
||||
|
||||
shader->bind();
|
||||
shader->setUICamera(transform, projection);
|
||||
|
||||
|
@ -13,6 +13,7 @@ Transform::Transform(SceneItem *item) :
|
||||
transformWorld(1.0f)
|
||||
{
|
||||
assertNotNull(item);
|
||||
|
||||
this->item = item;
|
||||
this->updateLocalValuesFromLocalTransform();
|
||||
}
|
||||
|
@ -30,15 +30,18 @@ void TrueTypeFont::bakeQuad(truetypequad_t *quad,float_t *x,float_t *y,char c){
|
||||
|
||||
|
||||
float_t TrueTypeFont::getScale(float_t scale) {
|
||||
assertTrue(scale > 0);
|
||||
return scale / this->fontSize;
|
||||
}
|
||||
|
||||
|
||||
float_t TrueTypeFont::getSpaceSize(float_t fontSize) {
|
||||
assertTrue(fontSize > 0);
|
||||
return mathRoundFloat(this->fontSize * 0.3f);
|
||||
}
|
||||
|
||||
float_t TrueTypeFont::getInitialLineHeight(float_t fontSize) {
|
||||
assertTrue(fontSize > 0);
|
||||
return 8.0f;
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,8 @@ namespace Dawn {
|
||||
* @param callback Callback method that invokes back.
|
||||
*/
|
||||
EventListener(T *instance, void (T::*callback)(A... args)) {
|
||||
assertNotNull(instance);
|
||||
|
||||
this->instance = instance;
|
||||
this->callback = callback;
|
||||
}
|
||||
@ -59,7 +61,10 @@ namespace Dawn {
|
||||
T *instance,
|
||||
void (T::*callback)(A... args)
|
||||
) {
|
||||
assertNotNull(instance);
|
||||
|
||||
auto listener = new EventListener<T,A...>(instance, callback);
|
||||
assertNotNull(listener);
|
||||
this->listeners.push_back(listener);
|
||||
return listener;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
#pragma once
|
||||
#include "dawnlibs.hpp"
|
||||
#include "util/mathutils.hpp"
|
||||
#include "assert/assert.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class DawnGame;
|
||||
@ -32,6 +33,7 @@ namespace Dawn {
|
||||
DawnGame *game;
|
||||
|
||||
IInputManager(DawnGame *game) {
|
||||
assertNotNull(game);
|
||||
this->game = game;
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,8 @@
|
||||
using namespace Dawn;
|
||||
|
||||
Scene::Scene(DawnGame *game) {
|
||||
assertNotNull(game);
|
||||
|
||||
this->game = game;
|
||||
this->nextId = 0;
|
||||
}
|
||||
@ -38,5 +40,15 @@ SceneItem * Scene::createSceneItem() {
|
||||
}
|
||||
|
||||
Scene::~Scene() {
|
||||
|
||||
auto it = this->items.begin();
|
||||
while(it != this->items.end()) {
|
||||
delete it->second;
|
||||
++it;
|
||||
}
|
||||
|
||||
auto it2 = this->itemsNotInitialized.begin();
|
||||
while(it2 != this->itemsNotInitialized.end()) {
|
||||
delete it2->second;
|
||||
++it2;
|
||||
}
|
||||
}
|
@ -9,6 +9,8 @@
|
||||
using namespace Dawn;
|
||||
|
||||
SceneItem::SceneItem(Scene *scene, sceneitemid_t id) : transform(this) {
|
||||
assertNotNull(scene);
|
||||
|
||||
this->id = id;
|
||||
this->scene = scene;
|
||||
}
|
||||
@ -53,5 +55,9 @@ void SceneItem::init() {
|
||||
}
|
||||
|
||||
SceneItem::~SceneItem() {
|
||||
std::cout << "Scene item disposed" << std::endl;
|
||||
auto it = this->components.begin();
|
||||
while(it != this->components.end()) {
|
||||
delete *it;
|
||||
++it;
|
||||
}
|
||||
}
|
@ -45,6 +45,12 @@ void UICanvas::onBackBufferResize(
|
||||
}
|
||||
|
||||
UICanvas::~UICanvas() {
|
||||
auto it = this->children.begin();
|
||||
while(it != this->children.end()) {
|
||||
delete *it;
|
||||
++it;
|
||||
}
|
||||
|
||||
this->getGame()->renderManager.getBackBuffer()->eventRenderTargetResized
|
||||
.removeListener(this, &UICanvas::onBackBufferResize)
|
||||
;
|
||||
|
@ -131,4 +131,8 @@ glm::vec2 UIBorder::getInnerSize() {
|
||||
|
||||
glm::vec2 UIBorder::getBorderSize() {
|
||||
return this->edgeDimensions;
|
||||
}
|
||||
|
||||
UIBorder::~UIBorder() {
|
||||
delete this->texture;
|
||||
}
|
@ -44,5 +44,7 @@ namespace Dawn {
|
||||
* @return The inner content area size.
|
||||
*/
|
||||
glm::vec2 getInnerSize();
|
||||
|
||||
~UIBorder();
|
||||
};
|
||||
}
|
@ -126,6 +126,7 @@ void DawnHost::unload(DawnGame *game) {
|
||||
}
|
||||
|
||||
DawnHost::~DawnHost() {
|
||||
delete this->data;
|
||||
DAWN_HOST = nullptr;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user