Fixed crash; Added dev screenshot; Added dependencies into repository

This commit is contained in:
grayson committed 2021-09-27 23:00:04 -05:00
1 parent bf649f5d9f
commit bf2c02e240
496 files changed
+126276 -56

No files matched your search

+5
View File
@@ -1,6 +1,7 @@
#include "Gamestate.h"
#include "Application.h"
#include "Model.h"
#include "Utility.h"
namespace nf {
@@ -51,6 +52,10 @@ namespace nf {
curr->destroy();
m_nfObjects.clear();
for (Model* curr : m_modelsToDelete)
delete curr;
m_modelsToDelete.clear();
delete camera;
app = nullptr;
}
+16 -7
View File
@@ -120,17 +120,26 @@ namespace nf {
}
void Button::destroy() {
if (m_constructed) {
delete m_vao;
m_vao = nullptr;
if (!m_idleTexture->isBaseAsset()) {
delete m_idleTexture;
m_idleTexture = nullptr;
}
if (!m_hoverTexture->isBaseAsset()) {
delete m_hoverTexture;
m_hoverTexture = nullptr;
}
if (!m_pressedTexture->isBaseAsset()) {
delete m_pressedTexture;
m_pressedTexture = nullptr;
}
}
m_constructed = false;
m_clicked = false;
m_position = Vec2(0.0);
m_centeredX = m_centeredY = false;
if (!m_idleTexture->isBaseAsset())
delete m_idleTexture;
if (!m_hoverTexture->isBaseAsset())
delete m_hoverTexture;
if (!m_pressedTexture->isBaseAsset())
delete m_pressedTexture;
delete m_vao;
}
Button::~Button() {
+4 -2
View File
@@ -135,11 +135,13 @@ namespace nf {
}
void Cubemap::destroy() {
if (m_constructed)
if (m_constructed) {
glDeleteTextures(1, &m_id);
delete m_vao;
m_vao = nullptr;
}
m_constructed = false;
m_id = 0;
delete m_vao;
}
Cubemap::~Cubemap() {
+4 -3
View File
@@ -90,10 +90,11 @@ namespace nf {
}
void Entity::destroy() {
if (m_constructed && m_model && !m_model->isBaseAsset()) {
Application::getApp()->getCurrentState()->m_modelsToDelete.insert(m_model);
m_model = nullptr;
}
m_constructed = false;
if (m_model && !m_model->isBaseAsset())
delete m_model;
m_model = nullptr;
m_position = Vec3(0.0);
m_rotation = Vec3(0.0);
m_scale = Vec3(1.0);
+6 -3
View File
@@ -24,11 +24,11 @@ namespace nf {
if ((sound = dynamic_cast<ASound*>(soundAsset)) == nullptr)
Error("Non-sound asset passed to Sound::create!");
std::string data(sound->data, sound->size);
if(data.find("RIFF") == std::string::npos)
if (data.find("RIFF") == std::string::npos)
Error("Sound asset not of correct format!");
unsigned int fileSize = *(unsigned int*)&data[4];
unsigned int fmtPos;
if((fmtPos = data.find("fmt")) == std::string::npos)
if ((fmtPos = data.find("fmt")) == std::string::npos)
Error("Sound asset not of correct format!");
std::memcpy(&m_format, &data[fmtPos + 8], 16);
unsigned int dataPos;
@@ -71,11 +71,14 @@ namespace nf {
}
void Sound::destroy() {
if (m_constructed) {
delete m_buffer;
m_buffer = nullptr;
}
m_constructed = false;
m_dataSize = 0;
m_volume = 1.0f;
m_format = { 0 };
delete m_buffer;
m_currentVoice = nullptr;
}
+8 -2
View File
@@ -168,12 +168,18 @@ namespace nf {
}
void Text::destroy() {
if (m_constructed) {
delete m_vao;
m_vao = nullptr;
if (!m_font->isBase) {
delete m_font;
m_font = nullptr;
}
}
m_constructed = false;
m_position = Vec2(0.0);
m_centeredX = m_centeredY = false;
m_string = std::string();
if (!m_font->isBase)
delete m_font;
m_color = Vec3(0.0);
m_scale = 1.0f;
m_opacity = 1.0f;
+8 -3
View File
@@ -92,14 +92,19 @@ namespace nf {
}
void UITexture::destroy() {
if (m_constructed) {
delete m_vao;
m_vao = nullptr;
if (!m_texture->isBaseAsset()) {
delete m_texture;
m_texture = nullptr;
}
}
m_constructed = false;
m_position = Vec2(0.0);
m_centeredX = m_centeredY = false;
if (!m_texture->isBaseAsset())
delete m_texture;
m_scale = 1.0f;
m_opacity = 1.0f;
delete m_vao;
}
UITexture::~UITexture() {
+4
View File
@@ -1,5 +1,6 @@
#pragma once
#include <vector>
#include <unordered_set>
#include "Camera.h"
#include "NFObject.h"
@@ -8,6 +9,8 @@ namespace nf {
class Application;
class Renderer;
class Camera;
class Model;
class Gamestate {
public:
Gamestate();
@@ -28,6 +31,7 @@ namespace nf {
void cleanup();
std::vector<NFObject*> m_nfObjects;
std::unordered_set<Model*> m_modelsToDelete;
protected:
Application* app;
Camera* camera;
+1
View File
@@ -93,6 +93,7 @@ namespace nf {
void setWindowIcon(HANDLE hIcon);
void setWindowCursor(HCURSOR hCursor);
AudioEngine* getAudioEngine() const;
void addState(Gamestate* state, const std::string& stateName);
void addDefaultState(const std::string& stateName);
const std::string& getDefaultState();