bit of cleanup
This commit is contained in:
@ -60,7 +60,9 @@ int32_t assetDataLoaderArchiveClose(struct archive *a, void *d) {
|
||||
|
||||
// // // // // // // // // // // // // // // // // // // // // // // // // // //
|
||||
|
||||
AssetDataLoader::AssetDataLoader(std::string fileName) : fileName(fileName) {
|
||||
AssetDataLoader::AssetDataLoader(const std::string &fileName) :
|
||||
fileName(fileName)
|
||||
{
|
||||
assertTrue(
|
||||
fileName.size() > 0,
|
||||
"IAssetDataLoader::IAssetDataLoader: fileName must be greater than 0"
|
||||
@ -68,13 +70,16 @@ AssetDataLoader::AssetDataLoader(std::string fileName) : fileName(fileName) {
|
||||
}
|
||||
|
||||
size_t AssetDataLoader::getSize() {
|
||||
assertTrue(this->assetArchiveEntry != nullptr, "AssetDataLoader::getSize: Entry is NULL!");
|
||||
assertTrue(archive_entry_size_is_set(assetArchiveEntry), "assetGetSize: Entry size is not set!");
|
||||
assertTrue(this->assetArchiveEntry != nullptr, "Entry is NULL!");
|
||||
assertTrue(
|
||||
archive_entry_size_is_set(assetArchiveEntry),
|
||||
"Entry size is not set!"
|
||||
);
|
||||
return archive_entry_size(assetArchiveEntry);
|
||||
}
|
||||
|
||||
size_t AssetDataLoader::getPosition() {
|
||||
assertNotNull(this->assetArchiveFile, "AssetDataLoader::getPosition: File is not open!");
|
||||
assertNotNull(this->assetArchiveFile, "File is not open!");
|
||||
return this->position;
|
||||
}
|
||||
|
||||
@ -124,7 +129,9 @@ void AssetDataLoader::open() {
|
||||
|
||||
// Iterate over each file to find the one for this asset loader.
|
||||
while(archive_read_next_header(assetArchive, &assetArchiveEntry)==ARCHIVE_OK){
|
||||
const char_t *headerFile = (char_t*)archive_entry_pathname(assetArchiveEntry);
|
||||
const char_t *headerFile = (char_t*)archive_entry_pathname(
|
||||
assetArchiveEntry
|
||||
);
|
||||
if(std::string(headerFile) == this->fileName) return;
|
||||
int32_t ret = archive_read_data_skip(assetArchive);
|
||||
assertTrue(ret == ARCHIVE_OK, "Failed to skip data!");
|
||||
@ -151,11 +158,11 @@ int32_t AssetDataLoader::close() {
|
||||
return res;
|
||||
}
|
||||
|
||||
size_t AssetDataLoader::read(uint8_t *buffer, size_t size) {
|
||||
size_t AssetDataLoader::read(uint8_t *buffer, const size_t &size) {
|
||||
assertNotNull(buffer, "Buffer is NULL!");
|
||||
assertTrue(size > 0, "Size must be greater than 0!");
|
||||
assertNotNull(this->assetArchive, "assetRead: Archive is NULL!");
|
||||
assertNotNull(this->assetArchiveEntry, "assetRead: Entry is NULL!");
|
||||
assertNotNull(this->assetArchive, "Archive is NULL!");
|
||||
assertNotNull(this->assetArchiveEntry, "Entry is NULL!");
|
||||
|
||||
ssize_t read = archive_read_data(this->assetArchive, buffer, size);
|
||||
this->position += read;
|
||||
@ -164,8 +171,8 @@ size_t AssetDataLoader::read(uint8_t *buffer, size_t size) {
|
||||
assertUnreachable(archive_error_string(this->assetArchive));
|
||||
}
|
||||
|
||||
assertTrue(read != ARCHIVE_RETRY, "assetRead: Failed to read data (RETRY)!");
|
||||
assertTrue(read != ARCHIVE_WARN, "assetRead: Failed to read data (WARN)!");
|
||||
assertTrue(read != ARCHIVE_RETRY, "Failed to read data (RETRY)!");
|
||||
assertTrue(read != ARCHIVE_WARN, "Failed to read data (WARN)!");
|
||||
|
||||
return read;
|
||||
}
|
||||
@ -185,17 +192,19 @@ size_t AssetDataLoader::readUntil(
|
||||
return i;
|
||||
}
|
||||
|
||||
size_t AssetDataLoader::skip(size_t n) {
|
||||
assertTrue(n >= 0, "AssetDataLoader::skip: Byte count must be greater than 0.");
|
||||
size_t AssetDataLoader::skip(const size_t &n) {
|
||||
assertTrue(n >= 0, "Byte count must be greater than 0.");
|
||||
assertTrue(n < (this->getSize() - this->position), "Cannot skip past EOF!");
|
||||
|
||||
uint8_t dumpBuffer[ASSET_LOADER_BUFFER_SIZE];
|
||||
size_t skipped = 0;
|
||||
size_t n2, n3;
|
||||
while(n != 0) {
|
||||
size_t n2, n3, n4;
|
||||
n4 = n;
|
||||
while(n4 != 0) {
|
||||
n2 = Math::min<size_t>(n, ASSET_LOADER_BUFFER_SIZE);
|
||||
n3 = this->read(dumpBuffer, n2);
|
||||
assertTrue(n3 == n2, "AssetDataLoader::skip: Failed to skip bytes!");
|
||||
n -= n3;
|
||||
assertTrue(n3 == n2, "Failed to skip bytes!");
|
||||
n4 -= n3;
|
||||
}
|
||||
|
||||
return skipped;
|
||||
|
@ -88,7 +88,7 @@ namespace Dawn {
|
||||
*
|
||||
* @param fileName File name of the asset that is to be loaded.
|
||||
*/
|
||||
AssetDataLoader(std::string filename);
|
||||
AssetDataLoader(const std::string &filename);
|
||||
|
||||
/**
|
||||
* Get the size of the asset.
|
||||
@ -134,7 +134,7 @@ namespace Dawn {
|
||||
* @param size Length of the data buffer (How many bytes to read).
|
||||
* @return The count of bytes read.
|
||||
*/
|
||||
size_t read(uint8_t *buffer, size_t size);
|
||||
size_t read(uint8_t *buffer, const size_t &size);
|
||||
|
||||
/**
|
||||
* Reads bytes from the buffer until a given delimiter is found. Returned
|
||||
@ -157,7 +157,7 @@ namespace Dawn {
|
||||
* @param n Count of bytes to progress the read head by.
|
||||
* @return Count of bytes progressed.
|
||||
*/
|
||||
size_t skip(size_t n);
|
||||
size_t skip(const size_t &n);
|
||||
|
||||
/**
|
||||
* Rewind the read head to the beginning of the file.
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
AssetLoader::AssetLoader(const std::string name) : name(name) {
|
||||
AssetLoader::AssetLoader(const std::string &name) : name(name) {
|
||||
assertTrue(name.size() > 0, "Asset::Asset: Name cannot be empty");
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ namespace Dawn {
|
||||
*
|
||||
* @param name Name of the asset.
|
||||
*/
|
||||
AssetLoader(const std::string name);
|
||||
AssetLoader(const std::string &name);
|
||||
|
||||
/**
|
||||
* Virtual function that will be called by the asset manager on a
|
||||
|
@ -26,7 +26,7 @@ void AssetManager::update() {
|
||||
}
|
||||
}
|
||||
|
||||
void AssetManager::removeExisting(const std::string filename) {
|
||||
void AssetManager::removeExisting(const std::string &filename) {
|
||||
auto existing = std::find_if(
|
||||
pendingAssetLoaders.begin(), pendingAssetLoaders.end(),
|
||||
[&](auto &loader) {
|
||||
@ -52,7 +52,7 @@ bool_t AssetManager::isEverythingLoaded() {
|
||||
return pendingAssetLoaders.size() == 0;
|
||||
}
|
||||
|
||||
bool_t AssetManager::isLoaded(const std::string filename) {
|
||||
bool_t AssetManager::isLoaded(const std::string &filename) {
|
||||
auto existing = this->getExisting<AssetLoader>(filename);
|
||||
if(existing) return existing->loaded;
|
||||
return false;
|
||||
|
@ -20,7 +20,7 @@ namespace Dawn {
|
||||
* @return The asset loader if it exists, otherwise nullptr.
|
||||
*/
|
||||
template<class T>
|
||||
std::shared_ptr<T> getExisting(const std::string filename) {
|
||||
std::shared_ptr<T> getExisting(const std::string &filename) {
|
||||
auto existing = std::find_if(
|
||||
pendingAssetLoaders.begin(), pendingAssetLoaders.end(),
|
||||
[&](auto &loader) {
|
||||
@ -47,7 +47,7 @@ namespace Dawn {
|
||||
*
|
||||
* @param filename The filename of the asset to remove.
|
||||
*/
|
||||
void removeExisting(const std::string filename);
|
||||
void removeExisting(const std::string &filename);
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -74,7 +74,7 @@ namespace Dawn {
|
||||
* @param filename The filename of the asset to check.
|
||||
* @return True if the asset has been loaded.
|
||||
*/
|
||||
bool_t isLoaded(const std::string filename);
|
||||
bool_t isLoaded(const std::string &filename);
|
||||
|
||||
/**
|
||||
* Returns the asset loader for the given asset.
|
||||
@ -83,7 +83,7 @@ namespace Dawn {
|
||||
* @return The asset loader for the given asset.
|
||||
*/
|
||||
template<class T>
|
||||
std::shared_ptr<T> get(const std::string filename) {
|
||||
std::shared_ptr<T> get(const std::string &filename) {
|
||||
auto existing = this->getExisting<T>(filename);
|
||||
if(existing) return existing;
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
JSONLoader::JSONLoader(const std::string name) :
|
||||
JSONLoader::JSONLoader(const std::string &name) :
|
||||
AssetLoader(name),
|
||||
loader(name),
|
||||
state(JSONLoaderState::INITIAL)
|
||||
|
@ -25,7 +25,7 @@ namespace Dawn {
|
||||
public:
|
||||
json data;
|
||||
|
||||
JSONLoader(const std::string name);
|
||||
JSONLoader(const std::string &name);
|
||||
void updateSync() override;
|
||||
void updateAsync() override;
|
||||
~JSONLoader();
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
TextureLoader::TextureLoader(const std::string name) :
|
||||
TextureLoader::TextureLoader(const std::string &name) :
|
||||
AssetLoader(name),
|
||||
loader(name + ".texture"),
|
||||
state(TextureLoaderLoadState::INITIAL)
|
||||
|
@ -41,7 +41,7 @@ namespace Dawn {
|
||||
*
|
||||
* @param name File name asset to load, omitting the extension.
|
||||
*/
|
||||
TextureLoader(const std::string name);
|
||||
TextureLoader(const std::string &name);
|
||||
|
||||
void updateSync() override;
|
||||
void updateAsync() override;
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
TrueTypeLoader::TrueTypeLoader(const std::string name) :
|
||||
TrueTypeLoader::TrueTypeLoader(const std::string &name) :
|
||||
AssetLoader(name),
|
||||
loader(name + ".ttf")
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ namespace Dawn {
|
||||
*
|
||||
* @param name File name asset to load, omitting the extension.
|
||||
*/
|
||||
TrueTypeLoader(const std::string name);
|
||||
TrueTypeLoader(const std::string &name);
|
||||
|
||||
void updateSync() override;
|
||||
void updateAsync() override;
|
||||
|
@ -1,12 +0,0 @@
|
||||
// Copyright (c) 2024 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "Registry.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
void Dawn::someFunction(const char_t *someParam) {
|
||||
printf("Hello, %s!\n", someParam);
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
// Copyright (c) 2024 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "dawn.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
static void someFunction(const char_t *someParam);
|
||||
}
|
@ -23,7 +23,7 @@ void Camera::onDispose() {
|
||||
|
||||
std::shared_ptr<RenderTarget> Camera::getRenderTarget() {
|
||||
if(this->renderTarget) return this->renderTarget;
|
||||
return getGame()->renderHost.getBackBufferRenderTarget();
|
||||
return getGame()->renderHost->getBackBufferRenderTarget();
|
||||
}
|
||||
|
||||
glm::mat4 Camera::getProjection() {
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
IRenderHost::IRenderHost() : renderPipeline(), shaderManager() {
|
||||
IRenderHost::IRenderHost() {
|
||||
}
|
||||
|
||||
IRenderHost::~IRenderHost() {
|
||||
|
@ -33,12 +33,12 @@ namespace Dawn {
|
||||
|
||||
class ITexture {
|
||||
public:
|
||||
enum TextureWrapMode wrapModeX = TextureWrapMode::REPEAT;
|
||||
enum TextureWrapMode wrapModeY = TextureWrapMode::REPEAT;
|
||||
enum TextureFilterMode filterModeMin = TextureFilterMode::NEAREST;
|
||||
enum TextureFilterMode filterModeMag = TextureFilterMode::NEAREST;
|
||||
enum TextureFilterMode mipMapFilterModeMin = TextureFilterMode::NEAREST;
|
||||
enum TextureFilterMode mipMapFilterModeMag = TextureFilterMode::NEAREST;
|
||||
TextureWrapMode wrapModeX = TextureWrapMode::REPEAT;
|
||||
TextureWrapMode wrapModeY = TextureWrapMode::REPEAT;
|
||||
TextureFilterMode filterModeMin = TextureFilterMode::NEAREST;
|
||||
TextureFilterMode filterModeMag = TextureFilterMode::NEAREST;
|
||||
TextureFilterMode mipMapFilterModeMin = TextureFilterMode::NEAREST;
|
||||
TextureFilterMode mipMapFilterModeMag = TextureFilterMode::NEAREST;
|
||||
|
||||
/**
|
||||
* Returns the width of the texture.
|
||||
@ -65,8 +65,8 @@ namespace Dawn {
|
||||
virtual void setSize(
|
||||
const int32_t width,
|
||||
const int32_t height,
|
||||
const enum TextureFormat format,
|
||||
const enum TextureDataFormat dataFormat
|
||||
const TextureFormat format,
|
||||
const TextureDataFormat dataFormat
|
||||
) = 0;
|
||||
|
||||
/**
|
||||
|
@ -38,7 +38,7 @@ void RenderPipeline::renderScene(
|
||||
|
||||
// Get a list of all cameras in the scene
|
||||
auto cameras = scene->findComponents<Camera>();
|
||||
auto backBuffer = scene->getGame()->renderHost.getBackBufferRenderTarget();
|
||||
auto backBuffer = scene->getGame()->renderHost->getBackBufferRenderTarget();
|
||||
|
||||
std::shared_ptr<Camera> backbufferCamera = nullptr;
|
||||
for(auto camera : cameras) {
|
||||
|
@ -10,14 +10,14 @@
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
TrueTypeTexture::TrueTypeTexture(const uint32_t fontSize) :
|
||||
TrueTypeTexture::TrueTypeTexture(const uint32_t &fontSize) :
|
||||
fontSize(fontSize)
|
||||
{
|
||||
assertTrue(fontSize > 0, "Font size cannot be zero");
|
||||
texture = std::make_shared<Texture>();
|
||||
}
|
||||
|
||||
void TrueTypeTexture::setFace(const FT_Face face) {
|
||||
void TrueTypeTexture::setFace(const FT_Face &face) {
|
||||
this->face = face;
|
||||
assertTrue(fontSize < 256, "Font size cannot be greater than 256");
|
||||
|
||||
@ -130,7 +130,7 @@ void TrueTypeTexture::setFace(const FT_Face face) {
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
struct TrueTypeCharacter TrueTypeTexture::getCharacterData(wchar_t c) {
|
||||
struct TrueTypeCharacter TrueTypeTexture::getCharacterData(const wchar_t &c) {
|
||||
return this->characterData[c];
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ glm::vec2 TrueTypeTexture::bufferStringToMesh(
|
||||
std::shared_ptr<Mesh> mesh,
|
||||
const std::wstring text,
|
||||
glm::vec2 &position,
|
||||
bool_t flipY
|
||||
const bool_t flipY
|
||||
) {
|
||||
assertNotNull(mesh, "Mesh must be supplied and not null");
|
||||
assertTrue(text.size() > 0, "Text must be at least one character long.");
|
||||
|
@ -25,14 +25,14 @@ namespace Dawn {
|
||||
*
|
||||
* @param fontSize Size of the font.
|
||||
*/
|
||||
TrueTypeTexture(const uint32_t fontSize);
|
||||
TrueTypeTexture(const uint32_t &fontSize);
|
||||
|
||||
/**
|
||||
* Sets the face for this texture.
|
||||
*
|
||||
* @param face Face to set.
|
||||
*/
|
||||
void setFace(const FT_Face face);
|
||||
void setFace(const FT_Face &face);
|
||||
|
||||
/**
|
||||
* Returns the character data for the given character.
|
||||
@ -40,7 +40,7 @@ namespace Dawn {
|
||||
* @param c Character to get data for.
|
||||
* @return The Character data for the given character.
|
||||
*/
|
||||
struct TrueTypeCharacter getCharacterData(wchar_t c);
|
||||
struct TrueTypeCharacter getCharacterData(const wchar_t &c);
|
||||
|
||||
/**
|
||||
* Buffers a string to the given mesh.
|
||||
@ -55,7 +55,7 @@ namespace Dawn {
|
||||
std::shared_ptr<Mesh> mesh,
|
||||
const std::wstring text,
|
||||
glm::vec2 &position,
|
||||
bool_t flipY = false
|
||||
const bool_t flipY = false
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -55,7 +55,7 @@ namespace Dawn {
|
||||
{
|
||||
//Get the shader
|
||||
shader = (
|
||||
self.getGame()->renderHost.shaderManager.getShader<S>()
|
||||
self.getGame()->renderHost->shaderManager.getShader<S>()
|
||||
);
|
||||
assertNotNull(shader, "Shader cannot be null!");
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
size_t shaderParameterTypeGetSize(const enum ShaderParameterType type) {
|
||||
size_t shaderParameterTypeGetSize(const ShaderParameterType type) {
|
||||
switch(type) {
|
||||
case ShaderParameterType::VEC2:
|
||||
return sizeof(glm::vec2);
|
||||
|
@ -83,4 +83,4 @@ namespace Dawn {
|
||||
* @param type The type to get the size of.
|
||||
* @return Size of the type.
|
||||
*/
|
||||
size_t shaderParameterTypeGetSize(const enum Dawn::ShaderParameterType type);
|
||||
size_t shaderParameterTypeGetSize(const Dawn::ShaderParameterType type);
|
@ -7,7 +7,7 @@
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
IShaderStage::IShaderStage(const enum ShaderStageType type) :
|
||||
IShaderStage::IShaderStage(const ShaderStageType type) :
|
||||
type(type)
|
||||
{
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace Dawn {
|
||||
*
|
||||
* @param type Type of shader stage.
|
||||
*/
|
||||
IShaderStage(const enum ShaderStageType type);
|
||||
IShaderStage(const ShaderStageType type);
|
||||
|
||||
/**
|
||||
* Destroy the IShaderStage object
|
||||
|
@ -9,7 +9,7 @@
|
||||
namespace Dawn {
|
||||
class ShaderManager {
|
||||
private:
|
||||
std::vector<std::shared_ptr<IShaderBase>> shaders;
|
||||
std::vector<std::weak_ptr<IShaderBase>> shaders;
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -23,14 +23,12 @@ namespace Dawn {
|
||||
std::shared_ptr<T> getShader() {
|
||||
auto itShaders = shaders.begin();
|
||||
while(itShaders != shaders.end()) {
|
||||
// auto shader = itShaders->lock();
|
||||
// if(!shader) {
|
||||
// itShaders = shaders.erase(itShaders);
|
||||
// continue;
|
||||
// }
|
||||
// std::shared_ptr<T> casted = std::dynamic_pointer_cast<T>(shader);
|
||||
auto shader = itShaders->lock();
|
||||
if(!shader) {
|
||||
itShaders = shaders.erase(itShaders);
|
||||
continue;
|
||||
}
|
||||
|
||||
auto shader = *itShaders;
|
||||
std::shared_ptr<T> casted = std::dynamic_pointer_cast<T>(shader);
|
||||
if(casted) return casted;
|
||||
itShaders++;
|
||||
@ -41,5 +39,9 @@ namespace Dawn {
|
||||
newShader->init();
|
||||
return newShader;
|
||||
}
|
||||
|
||||
~ShaderManager() {
|
||||
shaders.clear();
|
||||
}
|
||||
};
|
||||
}
|
@ -14,8 +14,15 @@ Game::Game() {
|
||||
}
|
||||
|
||||
void Game::init() {
|
||||
localeManager.init(shared_from_this());
|
||||
renderHost.init(shared_from_this());
|
||||
renderHost = std::make_shared<RenderHost>();
|
||||
renderHost->init(shared_from_this());
|
||||
|
||||
assetManager = std::make_shared<AssetManager>();
|
||||
assetManager->init();
|
||||
|
||||
localeManager = std::make_shared<LocaleManager>();
|
||||
localeManager->init(shared_from_this());
|
||||
|
||||
inputManager.init(shared_from_this());
|
||||
saveManager.init(shared_from_this());
|
||||
|
||||
@ -24,7 +31,7 @@ void Game::init() {
|
||||
}
|
||||
|
||||
void Game::update() {
|
||||
this->assetManager.update();
|
||||
this->assetManager->update();
|
||||
|
||||
if(nextFrameScene) {
|
||||
nextFrameScene->stage();
|
||||
@ -34,12 +41,12 @@ void Game::update() {
|
||||
|
||||
timeManager.update();
|
||||
if(currentScene) currentScene->update();
|
||||
renderHost.update(shared_from_this());
|
||||
renderHost->update(shared_from_this());
|
||||
}
|
||||
|
||||
bool_t Game::isCloseRequested() {
|
||||
return (
|
||||
renderHost.isCloseRequested()
|
||||
renderHost->isCloseRequested()
|
||||
);
|
||||
}
|
||||
|
||||
@ -48,4 +55,8 @@ std::shared_ptr<Scene> Game::getCurrentScene() {
|
||||
}
|
||||
|
||||
Game::~Game() {
|
||||
currentScene = nullptr;
|
||||
nextFrameScene = nullptr;
|
||||
assetManager = nullptr;
|
||||
renderHost = nullptr;
|
||||
}
|
@ -21,11 +21,11 @@ namespace Dawn {
|
||||
std::shared_ptr<Scene> nextFrameScene = nullptr;
|
||||
|
||||
public:
|
||||
RenderHost renderHost;
|
||||
std::shared_ptr<RenderHost> renderHost;
|
||||
std::shared_ptr<AssetManager> assetManager;
|
||||
std::shared_ptr<LocaleManager> localeManager;
|
||||
InputManager inputManager;
|
||||
TimeManager timeManager;
|
||||
AssetManager assetManager;
|
||||
LocaleManager localeManager;
|
||||
SaveManager saveManager;
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@ void LocaleManager::init(const std::shared_ptr<Game> &game) {
|
||||
assertNotNull(game, "Game cannot be null.");
|
||||
this->game = game;
|
||||
|
||||
languageAsset = game->assetManager.get<JSONLoader>("en.json");
|
||||
languageAsset = game->assetManager->get<JSONLoader>("en.json");
|
||||
}
|
||||
|
||||
std::string LocaleManager::getString(
|
||||
|
@ -50,7 +50,7 @@ namespace Dawn {
|
||||
*
|
||||
* @param slot Slot to delete.
|
||||
*/
|
||||
void deleteSlot(int8_t slot);
|
||||
void deleteSlot(const int8_t slot);
|
||||
|
||||
/**
|
||||
* Returns the current slotted save file.
|
||||
@ -64,7 +64,7 @@ namespace Dawn {
|
||||
*
|
||||
* @param slot The slot to set.
|
||||
*/
|
||||
void useSlot(int8_t slot);
|
||||
void useSlot(const int8_t slot);
|
||||
|
||||
/**
|
||||
* Returns a list of used save slots, does not confirm if they are corrupt
|
||||
|
@ -21,7 +21,7 @@ namespace Dawn {
|
||||
* @return The larger of the two numbers
|
||||
*/
|
||||
template<typename T>
|
||||
static T max(T left, T right) {
|
||||
static T max(const T &left, const T &right) {
|
||||
return left < right ? right : left;
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ namespace Dawn {
|
||||
* @return Smaller of the two numbers.
|
||||
*/
|
||||
template<typename T>
|
||||
static T min(T left, T right) {
|
||||
static T min(const T &left, const T &right) {
|
||||
return left < right ? left : right;
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ namespace Dawn {
|
||||
* @return The value, or the closest clamped value.
|
||||
*/
|
||||
template<typename T>
|
||||
static T clamp(T val, T min, T max) {
|
||||
static T clamp(const T &val, const T &min, const T &max) {
|
||||
return mathMin<T>(mathMax<T>(val, min), max);
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ namespace Dawn {
|
||||
* @return The absolute value (-value if value < 0)
|
||||
*/
|
||||
template<typename T>
|
||||
static T abs(T value) {
|
||||
static T abs(const T &value) {
|
||||
return value < 0 ? -value : value;
|
||||
}
|
||||
|
||||
@ -71,11 +71,11 @@ namespace Dawn {
|
||||
* @returns The modulo result.
|
||||
*/
|
||||
template<typename T>
|
||||
static inline T mod(T value, T modulo) {
|
||||
static inline T mod(const T &value, const T &modulo) {
|
||||
return ((value % modulo) + modulo) % modulo;
|
||||
}
|
||||
|
||||
static inline float_t fmod(float_t value, float_t modulo) {
|
||||
static inline float_t fmod(const float_t &value, const float_t &modulo) {
|
||||
float_t n = fmod(value, modulo);
|
||||
return n;
|
||||
}
|
||||
@ -86,7 +86,7 @@ namespace Dawn {
|
||||
* @param n Degrees to convert.
|
||||
* @returns The number in radians.
|
||||
*/
|
||||
static float_t deg2rad(float_t degrees) {
|
||||
static float_t deg2rad(const float_t °rees) {
|
||||
return degrees * (MATH_PI / 180.0f);
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ namespace Dawn {
|
||||
* @param n Radians to convert.
|
||||
* @returns The number in degrees.
|
||||
*/
|
||||
static float_t rad2deg(float_t n) {
|
||||
static float_t rad2deg(const float_t &n) {
|
||||
return (n * 180.0f) / MATH_PI;
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ namespace Dawn {
|
||||
* @return Rounded number.
|
||||
*/
|
||||
template<typename T>
|
||||
static T round(const float_t n) {
|
||||
static T round(const float_t &n) {
|
||||
return (T)roundf(n);
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ namespace Dawn {
|
||||
* @return Rounded number.
|
||||
*/
|
||||
template<typename T>
|
||||
static T floor(const float_t n) {
|
||||
static T floor(const float_t &n) {
|
||||
return (T)floorf(n);
|
||||
}
|
||||
|
||||
@ -125,12 +125,12 @@ namespace Dawn {
|
||||
* @param n Number to get the square root of.
|
||||
* @return float_t
|
||||
*/
|
||||
static float_t sqrt(const float_t n) {
|
||||
static float_t sqrt(const float_t &n) {
|
||||
return sqrtf(n);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static T ceil(const float_t n) {
|
||||
static T ceil(const float_t &n) {
|
||||
return (T)ceilf(n);
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ void RenderHost::init(const std::shared_ptr<Game> game) {
|
||||
// if(this->window == nullptr || window != this->window) return;
|
||||
Game* game = (Game*)glfwGetWindowUserPointer(window);
|
||||
assertNotNull(game, "Game cannot be null!");
|
||||
game->renderHost.backBufferRenderTarget->setSize(width, height);
|
||||
game->renderHost->backBufferRenderTarget->setSize(width, height);
|
||||
});
|
||||
}
|
||||
|
||||
@ -94,12 +94,16 @@ void RenderHost::update(const std::shared_ptr<Game> game) {
|
||||
GL_ONE_MINUS_SRC_ALPHA
|
||||
);
|
||||
assertNoGLError();
|
||||
|
||||
glDepthMask(GL_TRUE);
|
||||
assertNoGLError();
|
||||
|
||||
glDepthFunc(GL_LESS);
|
||||
assertNoGLError();
|
||||
|
||||
// glEnable(GL_DEPTH_TEST);
|
||||
assertNoGLError();
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
assertNoGLError();
|
||||
|
||||
@ -123,6 +127,7 @@ std::shared_ptr<RenderTarget> RenderHost::getBackBufferRenderTarget() {
|
||||
}
|
||||
|
||||
RenderHost::~RenderHost() {
|
||||
std::cout << "RenderHost cleanup" << std::endl;
|
||||
if(this->window != nullptr) {
|
||||
glfwDestroyWindow(this->window);
|
||||
this->window = nullptr;
|
||||
|
@ -9,7 +9,7 @@
|
||||
using namespace Dawn;
|
||||
|
||||
void InputManager::init(const std::shared_ptr<Game> game) {
|
||||
auto window = game->renderHost.window;
|
||||
auto window = game->renderHost->window;
|
||||
|
||||
glfwSetCursorPosCallback(window, [](
|
||||
GLFWwindow* window,
|
||||
|
@ -73,5 +73,7 @@ int32_t main(int32_t argc, const char **argv) {
|
||||
game->update();
|
||||
}
|
||||
|
||||
game = nullptr;
|
||||
|
||||
return 0;
|
||||
}
|
@ -33,8 +33,8 @@ bool_t Texture::isReady() {
|
||||
void Texture::setSize(
|
||||
const int32_t width,
|
||||
const int32_t height,
|
||||
const enum TextureFormat format,
|
||||
const enum TextureDataFormat dataFormat
|
||||
const TextureFormat format,
|
||||
const TextureDataFormat dataFormat
|
||||
) {
|
||||
if(this->id != -1) {
|
||||
glDeleteTextures(1, &this->id);
|
||||
|
@ -17,8 +17,8 @@ namespace Dawn {
|
||||
int32_t width = -1;
|
||||
int32_t height = -1;
|
||||
GLuint id = -1;
|
||||
enum TextureFormat format;
|
||||
enum TextureDataFormat dataFormat;
|
||||
TextureFormat format;
|
||||
TextureDataFormat dataFormat;
|
||||
|
||||
void updateTextureProperties();
|
||||
void bufferRaw(const void *data);
|
||||
@ -29,8 +29,8 @@ namespace Dawn {
|
||||
void setSize(
|
||||
const int32_t width,
|
||||
const int32_t height,
|
||||
const enum TextureFormat format,
|
||||
const enum TextureDataFormat dataForat
|
||||
const TextureFormat format,
|
||||
const TextureDataFormat dataForat
|
||||
) override;
|
||||
bool_t isReady() override;
|
||||
void buffer(const struct ColorU8 pixels[]) override;
|
||||
|
@ -14,8 +14,8 @@
|
||||
using namespace Dawn;
|
||||
|
||||
void Dawn::helloWorldScene(Scene &s) {
|
||||
while(!s.getGame()->assetManager.isEverythingLoaded()) {
|
||||
s.getGame()->assetManager.update();
|
||||
while(!s.getGame()->assetManager->isEverythingLoaded()) {
|
||||
s.getGame()->assetManager->update();
|
||||
}
|
||||
|
||||
auto cameraItem = s.createSceneItem();
|
||||
|
Reference in New Issue
Block a user