diff --git a/include/pd.hpp b/include/pd.hpp index 63c0821..7da6178 100644 --- a/include/pd.hpp +++ b/include/pd.hpp @@ -1,8 +1,6 @@ #pragma once -#include #include -#include #include #include #include @@ -11,11 +9,13 @@ #include #include #include +#include #include #include -#include #include #include +#include +#include #include #include diff --git a/include/pd/Image.hpp b/include/pd/Image.hpp index 79086b7..a9af01c 100644 --- a/include/pd/Image.hpp +++ b/include/pd/Image.hpp @@ -2,8 +2,8 @@ #include <3ds.h> -#include #include +#include #include #include #include @@ -22,9 +22,7 @@ class Image { Texture::Ref Get(); void Set(Texture::Ref i, NVec4 uvs = NVec4(-1, -1, -1, -1)); NVec2 GetSize(); - NVec4 GetUV() { - return (custom_uvs.x() != -1) ? custom_uvs : img->GetUV(); - } + NVec4 GetUV() { return (custom_uvs.x() != -1) ? custom_uvs : img->GetUV(); } bool Loadet(); private: diff --git a/include/pd/Lithium.hpp b/include/pd/Lithium.hpp index f549340..eb9c97f 100644 --- a/include/pd/Lithium.hpp +++ b/include/pd/Lithium.hpp @@ -113,7 +113,7 @@ class LI { NVec4 uv; int layer = 0; int cmd_type = 0; - bool fcs = false; // Floor Coords System + bool fcs = false; // Floor Coords System unsigned int clr = 0; bool sfr = false; // SysFontRender Texture::Ref tex = nullptr; diff --git a/include/pd/Overlays.hpp b/include/pd/Overlays.hpp index 1e21a71..6fb6c7e 100644 --- a/include/pd/Overlays.hpp +++ b/include/pd/Overlays.hpp @@ -26,8 +26,9 @@ enum PDKeyboardFlags_ { PDKeyboardFlags_BlendTop = 1 << 0, PDKeyboardFlags_BlendBottom = 1 << 1, PDKeyboardFlags_LockControls = 1 << 2, - PDKeyboardFlags_Default = - PDKeyboardFlags_BlendTop | PDKeyboardFlags_BlendBottom | PDKeyboardFlags_LockControls, + PDKeyboardFlags_Default = PDKeyboardFlags_BlendTop | + PDKeyboardFlags_BlendBottom | + PDKeyboardFlags_LockControls, }; namespace Palladium { diff --git a/include/pd/Sheet.hpp b/include/pd/Sheet.hpp index 7b38af4..49d11aa 100644 --- a/include/pd/Sheet.hpp +++ b/include/pd/Sheet.hpp @@ -1,24 +1,23 @@ #pragma once -#include -#include -#include - #include -namespace Palladium -{ - class Sheet { - public: - Sheet() = default; - ~Sheet() = default; - PD_SMART_CTOR(Sheet) - void LoadT3X(const std::string& path); - Texture::Ref Get(int idx); - Image::Ref GetImage(int idx); +#include +#include +#include - private: - std::vector sprites; - Tex3DS_Texture sheet; - C3D_Tex* sheet_tex = nullptr; - }; -} // namespace Palladium +namespace Palladium { +class Sheet { + public: + Sheet() = default; + ~Sheet() = default; + PD_SMART_CTOR(Sheet) + void LoadT3X(const std::string& path); + Texture::Ref Get(int idx); + Image::Ref GetImage(int idx); + + private: + std::vector sprites; + Tex3DS_Texture sheet; + C3D_Tex* sheet_tex = nullptr; +}; +} // namespace Palladium diff --git a/include/pd/Sprite.hpp b/include/pd/Sprite.hpp index 31e134b..1876ffd 100644 --- a/include/pd/Sprite.hpp +++ b/include/pd/Sprite.hpp @@ -58,6 +58,6 @@ class Sprite { private: ///// @param sprite The Sprite - //C2D_Sprite sprite; + // C2D_Sprite sprite; }; } // namespace Palladium \ No newline at end of file diff --git a/include/pd/Texture.hpp b/include/pd/Texture.hpp index d33ae9e..23d4bcf 100644 --- a/include/pd/Texture.hpp +++ b/include/pd/Texture.hpp @@ -17,6 +17,11 @@ class Texture { RGB24, A8, }; + + enum Filter { + NEAREST, + LINEAR, + }; Texture() { // Set Default UV this->uvs[0] = 0.0f; @@ -45,10 +50,11 @@ class Texture { /// @param w Width of data /// @param h Height of Data /// @param type Type of Data (default is RGBA32) - void LoadPixels(const std::vector& data, int w, int h, Type type = RGBA32); + void LoadPixels(const std::vector& data, int w, int h, + Type type = RGBA32, Filter filter = NEAREST); /// @brief This function sets up a texture Object based on the input - /// Data and a self setup C3D_Tex. You dont need to delete it as + /// Data and a self setup C3D_Tex. You dont need to delete it as /// This class does this automatically void ExternalLoad(C3D_Tex* tex, NVec2 rszs, NVec4 uvs); @@ -61,7 +67,8 @@ class Texture { void AutoDelete(bool enable) { ad = enable; } private: - void MakeTex(std::vector& buf, int w, int h, Type type = RGBA32); + void MakeTex(std::vector& buf, int w, int h, + Type type = RGBA32, Filter filter = NEAREST); C3D_Tex* tex = nullptr; NVec2 img_size; NVec4 uvs; diff --git a/source/Error.cpp b/source/Error.cpp index d1bc231..af9de15 100644 --- a/source/Error.cpp +++ b/source/Error.cpp @@ -1,10 +1,10 @@ #include <3ds.h> +#include #include #include #include #include -#include void pdi_save_report(const std::string& msg) { auto ts = Palladium::GetTimeStr(); diff --git a/source/Image.cpp b/source/Image.cpp index 2eb8bb5..703998a 100644 --- a/source/Image.cpp +++ b/source/Image.cpp @@ -29,7 +29,7 @@ Texture::Ref Image::Get() { void Image::Set(Texture::Ref i, NVec4 uvs) { Delete(); - if(uvs.x() != -1) custom_uvs = uvs; + if (uvs.x() != -1) custom_uvs = uvs; img = i; } diff --git a/source/Lithium.cpp b/source/Lithium.cpp index 88fec70..23dd0bd 100644 --- a/source/Lithium.cpp +++ b/source/Lithium.cpp @@ -130,7 +130,8 @@ void LIFont::LoadTFF(const std::string path, int px_size) { free(bitmap); cpmap[c] = codepoint; } - ftex->LoadPixels(fmap, type, type); + ftex->LoadPixels(fmap, type, type, Palladium::Texture::RGBA32, + Palladium::Texture::LINEAR); this->tex.push_back(ftex); } diff --git a/source/Message.cpp b/source/Message.cpp index 37ea66d..8d96e50 100644 --- a/source/Message.cpp +++ b/source/Message.cpp @@ -1,9 +1,9 @@ #include #include -#include -#include -#include #include +#include +#include +#include #include extern bool pdi_debugging; @@ -61,13 +61,13 @@ void ProcessMessages() { LI::DrawText(pos + NVec2(5, 17), tc, msg_lst[i]->message); if (pdi_debugging) LI::DrawText(pos + NVec2(msg_box.x() + 5, 1), tc, - std::to_string((int)msg_lst[i]->animtime)); + std::to_string((int)msg_lst[i]->animtime)); // fix for Startup lol // Todo: Only do this on AppStart if (msg_lst[i]->animtime == 0) { msg_lst[i]->animtime += 1; } else { - msg_lst[i]->animtime += Palladium::GetDeltaTime()*0.1f; + msg_lst[i]->animtime += Palladium::GetDeltaTime() * 0.1f; } if (msg_lst[i]->animtime > anim_len) { msg_lst.erase(msg_lst.begin() + i); diff --git a/source/Rubidium.cpp b/source/Rubidium.cpp index d924928..b728fd5 100644 --- a/source/Rubidium.cpp +++ b/source/Rubidium.cpp @@ -1,7 +1,7 @@ #include -#include #include +#include void d7_pixel_blend(Palladium::Rubidium* rb, int x, int y, unsigned int clr, float blend) { diff --git a/source/Texture.cpp b/source/Texture.cpp index 6bde309..37ca85d 100644 --- a/source/Texture.cpp +++ b/source/Texture.cpp @@ -1,9 +1,9 @@ #include #include +#include #include #include -#include namespace pdi { static bool single_bit(unsigned int v) { return v && !(v & (v - 1)); } @@ -54,8 +54,8 @@ int GetBPP(Texture::Type type) { return 1; return 0; // Error } -void Texture::MakeTex(std::vector &buf, int w, int h, - Type type) { +void Texture::MakeTex(std::vector &buf, int w, int h, Type type, + Filter filter) { if (!tex) { return; } @@ -104,9 +104,10 @@ void Texture::MakeTex(std::vector &buf, int w, int h, this->uvs.w() = 1.0 - ((float)h / (float)tex_size.y()); // Texture Setup + auto fltr = (filter == NEAREST ? GPU_NEAREST : GPU_LINEAR); auto tex_fmt = GetTexFmt(type); C3D_TexInit(tex, (u16)tex_size.x(), (u16)tex_size.y(), tex_fmt); - C3D_TexSetFilter(tex, GPU_NEAREST, GPU_NEAREST); + C3D_TexSetFilter(tex, fltr, fltr); memset(tex->data, 0, tex->size); @@ -202,7 +203,7 @@ NVec2 Texture::GetTexSize() { } void Texture::LoadPixels(const std::vector &data, int w, int h, - Type type) { + Type type, Filter filter) { Delete(); int bpp = GetBPP(type); Palladium::InlineAssert(bpp, "Invalid Type"); @@ -216,7 +217,7 @@ void Texture::LoadPixels(const std::vector &data, int w, int h, } tex = new C3D_Tex; std::vector wimg(data); - MakeTex(wimg, w, h, type); + MakeTex(wimg, w, h, type, filter); } void Texture::ExternalLoad(C3D_Tex *tex, NVec2 rszs, NVec4 uvs) { diff --git a/source/UI7.cpp b/source/UI7.cpp index f1756f7..085f810 100644 --- a/source/UI7.cpp +++ b/source/UI7.cpp @@ -198,7 +198,7 @@ class DrawCmd { NVec2 text_box = NVec2(); // Maximum text Box bool screen = false; // Defines Top or Bottom int layer = 0; // Defines the Rendering Layer - bool fcs = false; // Floor Coords System + bool fcs = false; // Floor Coords System }; void UI7DrawList::AddRectangle(NVec2 pos, NVec2 szs, PDColor clr) {