Added AssetPack and basic assets
This commit is contained in:
parent
933d3f1fe9
commit
29b3f8627e
@ -208,6 +208,7 @@
|
|||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="src\Application.cpp" />
|
<ClCompile Include="src\Application.cpp" />
|
||||||
|
<ClCompile Include="src\Assets.cpp" />
|
||||||
<ClCompile Include="src\Gamestate.cpp" />
|
<ClCompile Include="src\Gamestate.cpp" />
|
||||||
<ClCompile Include="src\IntroGamestate.cpp" />
|
<ClCompile Include="src\IntroGamestate.cpp" />
|
||||||
<ClCompile Include="src\Renderer\Drawable\Drawable.cpp" />
|
<ClCompile Include="src\Renderer\Drawable\Drawable.cpp" />
|
||||||
@ -222,6 +223,7 @@
|
|||||||
<ClCompile Include="src\Utility.cpp" />
|
<ClCompile Include="src\Utility.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="src\include\Assets.h" />
|
||||||
<ClInclude Include="src\include\Entity.h" />
|
<ClInclude Include="src\include\Entity.h" />
|
||||||
<ClInclude Include="src\include\resource.h" />
|
<ClInclude Include="src\include\resource.h" />
|
||||||
<ClInclude Include="src\include\Application.h" />
|
<ClInclude Include="src\include\Application.h" />
|
||||||
|
@ -54,6 +54,9 @@
|
|||||||
<ClCompile Include="src\Renderer\Texture.cpp">
|
<ClCompile Include="src\Renderer\Texture.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Assets.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="src\include\Config.h">
|
<ClInclude Include="src\include\Config.h">
|
||||||
@ -107,6 +110,9 @@
|
|||||||
<ClInclude Include="src\include\Texture.h">
|
<ClInclude Include="src\include\Texture.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\include\Assets.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Natvis Include="NatvisFile.natvis" />
|
<Natvis Include="NatvisFile.natvis" />
|
||||||
|
34
NothinFancy/src/Assets.cpp
Normal file
34
NothinFancy/src/Assets.cpp
Normal file
@ -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) {
|
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 = new Model;
|
||||||
m_model->create(vertexBufferData, vertexBufferSize, indexBufferData, indexBufferCount, textureCoordinatesBufferData, textureCoordinatesBufferSize, textureName);
|
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) {
|
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);
|
unsigned char* texture = stbi_load(textureName, &width, &height, &nChannels, 0);
|
||||||
//TODO: Load from memory
|
//TODO: Load from memory
|
||||||
if (!texture)
|
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);
|
glBindTexture(GL_TEXTURE_2D, m_id);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
32
NothinFancy/src/include/Assets.h
Normal file
32
NothinFancy/src/include/Assets.h
Normal file
@ -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;
|
Renderer* m_renderer;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
#include "Assets.h"
|
||||||
#include "Input.h"
|
#include "Input.h"
|
||||||
#include "Utility.h"
|
#include "Utility.h"
|
Reference in New Issue
Block a user