- Linear Tex filter for TTF fonts

- Format Code
This commit is contained in:
2024-12-08 19:26:21 +01:00
parent 0fede0441f
commit d5c01b2988
14 changed files with 57 additions and 50 deletions

View File

@ -2,8 +2,8 @@
#include <3ds.h>
#include <pd/maths/NVec.hpp>
#include <pd/Texture.hpp>
#include <pd/maths/NVec.hpp>
#include <pd/nimg.hpp>
#include <pd/smart_ctor.hpp>
#include <string>
@ -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:

View File

@ -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;

View File

@ -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 {

View File

@ -1,24 +1,23 @@
#pragma once
#include <pd/smart_ctor.hpp>
#include <pd/Texture.hpp>
#include <pd/Image.hpp>
#include <tex3ds.h>
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 <pd/Image.hpp>
#include <pd/Texture.hpp>
#include <pd/smart_ctor.hpp>
private:
std::vector<Texture::Ref> 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<Texture::Ref> sprites;
Tex3DS_Texture sheet;
C3D_Tex* sheet_tex = nullptr;
};
} // namespace Palladium

View File

@ -58,6 +58,6 @@ class Sprite {
private:
///// @param sprite The Sprite
//C2D_Sprite sprite;
// C2D_Sprite sprite;
};
} // namespace Palladium

View File

@ -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<unsigned char>& data, int w, int h, Type type = RGBA32);
void LoadPixels(const std::vector<unsigned char>& 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<unsigned char>& buf, int w, int h, Type type = RGBA32);
void MakeTex(std::vector<unsigned char>& buf, int w, int h,
Type type = RGBA32, Filter filter = NEAREST);
C3D_Tex* tex = nullptr;
NVec2 img_size;
NVec4 uvs;