Added AssetPack and basic assets
This commit is contained in:
1 parent
933d3f1fe9
commit
29b3f8627e
7 files changed
+77
-1
No files matched your search
@@ -0,0 +1,34 @@
|
||||
#include "Assets.h"
|
||||
|
||||
#include "Utility.h"
|
||||
|
||||
namespace nf {
|
||||
Asset::~Asset() {
|
||||
|
||||
}
|
||||
|
||||
AGeometry::~AGeometry() {
|
||||
delete[] m_vertexBufferData;
|
||||
delete[] m_indexBufferData;
|
||||
delete[] m_textureCoordinatesBufferData;
|
||||
}
|
||||
|
||||
ATexture::~ATexture() {
|
||||
delete[] m_data;
|
||||
}
|
||||
|
||||
AssetPack::AssetPack() {
|
||||
|
||||
}
|
||||
|
||||
void AssetPack::load(const char* packName) {
|
||||
std::string path = "assets/" + (std::string)packName + ".nfpack";
|
||||
std::string contents = readFile(path.c_str(), true);
|
||||
}
|
||||
|
||||
AssetPack::~AssetPack() {
|
||||
for (auto curr : m_assets) {
|
||||
delete curr.second;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ namespace nf {
|
||||
void Entity::create(const void* vertexBufferData, const size_t vertexBufferSize, const void* indexBufferData, size_t indexBufferCount, const void* textureCoordinatesBufferData, size_t textureCoordinatesBufferSize, const char* textureName) {
|
||||
m_model = new Model;
|
||||
m_model->create(vertexBufferData, vertexBufferSize, indexBufferData, indexBufferCount, textureCoordinatesBufferData, textureCoordinatesBufferSize, textureName);
|
||||
//TODO: Replace this with getting the information from the AGeometry and ATexture structs
|
||||
}
|
||||
|
||||
void Entity::setPosition(float x, float y, float z) {
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace nf {
|
||||
unsigned char* texture = stbi_load(textureName, &width, &height, &nChannels, 0);
|
||||
//TODO: Load from memory
|
||||
if (!texture)
|
||||
Error("Texture failed to load from memory!");
|
||||
Error("Texture \"" + (std::string)textureName + "\" failed to load from memory!");
|
||||
glBindTexture(GL_TEXTURE_2D, m_id);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace nf {
|
||||
struct Asset {
|
||||
virtual ~Asset();
|
||||
};
|
||||
|
||||
struct AGeometry : Asset {
|
||||
const float* m_vertexBufferData;
|
||||
const unsigned int* m_indexBufferData;
|
||||
const float* m_textureCoordinatesBufferData;
|
||||
~AGeometry() override;
|
||||
};
|
||||
|
||||
struct ATexture : Asset {
|
||||
const void* m_data;
|
||||
~ATexture() override;
|
||||
};
|
||||
|
||||
class AssetPack {
|
||||
public:
|
||||
AssetPack();
|
||||
|
||||
void load(const char* packName);
|
||||
|
||||
~AssetPack();
|
||||
private:
|
||||
std::unordered_map<std::string, Asset*> m_assets;
|
||||
};
|
||||
}
|
||||
@@ -131,5 +131,6 @@ namespace nf {
|
||||
Renderer* m_renderer;
|
||||
};
|
||||
}
|
||||
#include "Assets.h"
|
||||
#include "Input.h"
|
||||
#include "Utility.h"
|
||||
Reference in new issue
Block a user