tyrav2 init

This commit is contained in:
h4570
2022-07-17 10:21:35 +02:00
parent 44c1ee4fe8
commit c8b22ff331
249 changed files with 18187 additions and 0 deletions
@@ -0,0 +1,35 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2020, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include "loaders/loader.hpp"
#include "loaders/texture/builder/texture_builder_data.hpp"
#include "renderer/core/texture/models/texture_bpp.hpp"
#include <string>
namespace Tyra {
class TextureLoader : public Loader {
public:
/**
* @brief Loads texture data from file.
* Sets size, name and data.
* @param fullpath Full path to texture file. Example: "host:texture.png"
*/
virtual TextureBuilderData* load(const char* fullpath) = 0;
inline TextureBuilderData* load(const std::string& fullpath) {
return load(fullpath.c_str());
}
u32 getTextureSize(const u32& width, const u32& height,
const TextureBpp& bpp);
};
} // namespace Tyra
@@ -0,0 +1,34 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2020, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include "loaders/texture/base/texture_loader.hpp"
#include "loaders/texture/png_loader.hpp"
#include <string>
namespace Tyra {
class TextureLoaderSelector {
public:
TextureLoaderSelector();
~TextureLoaderSelector();
TextureLoader& getLoaderByFileName(const char* fullpath);
inline TextureLoader& getLoaderByFileName(const std::string& fullpath) {
return getLoaderByFileName(fullpath.c_str());
}
TextureLoader& getLoaderByExtension(const std::string& extension);
private:
PngLoader pngLoader;
};
} // namespace Tyra
@@ -0,0 +1,36 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2020, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include <tamtypes.h>
#include <string>
#include "renderer/core/texture/models/texture_bpp.hpp"
namespace Tyra {
class TextureBuilderData {
public:
TextureBuilderData();
~TextureBuilderData();
std::string name;
int width, height;
unsigned char* data;
TextureBpp bpp;
unsigned char gsComponents;
int clutWidth, clutHeight;
unsigned char* clut;
TextureBpp clutBpp;
unsigned char clutGsComponents;
};
} // namespace Tyra
+56
View File
@@ -0,0 +1,56 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2020, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include "loaders/texture/base/texture_loader.hpp"
#include "renderer/core/texture/models/texture.hpp"
#ifdef INTELLISENSE
typedef void* png_structp;
typedef void* png_bytep;
typedef void* png_infop;
typedef void* png_colorp;
#else
#include <png.h>
#endif
namespace Tyra {
class PngLoader : public TextureLoader {
public:
PngLoader();
~PngLoader();
TextureBuilderData* load(const char* fullpath);
private:
void handle32bpp(TextureBuilderData* result, png_structp pngPtr,
png_infop infoPtr, png_bytep* rowPointers);
void handle24bpp(TextureBuilderData* result, png_structp pngPtr,
png_infop infoPtr, png_bytep* rowPointers);
void handlePalletized(TextureBuilderData* result, png_structp pngPtr,
png_infop infoPtr, png_bytep* rowPointers,
const int& bitDepth);
void handle8bppPalletized(TextureBuilderData* result, png_structp pngPtr,
png_infop infoPtr, png_bytep* rowPointers,
png_colorp palette, png_bytep trans,
const int& numPallete, const int& numTrans);
void handle4bppPalletized(TextureBuilderData* result, png_structp pngPtr,
png_infop infoPtr, png_bytep* rowPointers,
png_colorp palette, png_bytep trans,
const int& numPallete, const int& numTrans);
};
} // namespace Tyra