- Linear Tex filter for TTF fonts
- Format Code
This commit is contained in:
parent
0fede0441f
commit
d5c01b2988
@ -1,8 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <pd/base/Allocator.hpp>
|
|
||||||
#include <pd/Error.hpp>
|
#include <pd/Error.hpp>
|
||||||
#include <pd/base/FileSystem.hpp>
|
|
||||||
#include <pd/Hid.hpp>
|
#include <pd/Hid.hpp>
|
||||||
#include <pd/Image.hpp>
|
#include <pd/Image.hpp>
|
||||||
#include <pd/Installer.hpp>
|
#include <pd/Installer.hpp>
|
||||||
@ -11,11 +9,13 @@
|
|||||||
#include <pd/Net.hpp>
|
#include <pd/Net.hpp>
|
||||||
#include <pd/Overlays.hpp>
|
#include <pd/Overlays.hpp>
|
||||||
#include <pd/Rubidium.hpp>
|
#include <pd/Rubidium.hpp>
|
||||||
|
#include <pd/Sheet.hpp>
|
||||||
#include <pd/Sound.hpp>
|
#include <pd/Sound.hpp>
|
||||||
#include <pd/Texture.hpp>
|
#include <pd/Texture.hpp>
|
||||||
#include <pd/Sheet.hpp>
|
|
||||||
#include <pd/Timer.hpp>
|
#include <pd/Timer.hpp>
|
||||||
#include <pd/UI7.hpp>
|
#include <pd/UI7.hpp>
|
||||||
|
#include <pd/base/Allocator.hpp>
|
||||||
|
#include <pd/base/FileSystem.hpp>
|
||||||
#include <pd/global_db.hpp>
|
#include <pd/global_db.hpp>
|
||||||
#include <pd/palladium.hpp>
|
#include <pd/palladium.hpp>
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
|
|
||||||
#include <pd/maths/NVec.hpp>
|
|
||||||
#include <pd/Texture.hpp>
|
#include <pd/Texture.hpp>
|
||||||
|
#include <pd/maths/NVec.hpp>
|
||||||
#include <pd/nimg.hpp>
|
#include <pd/nimg.hpp>
|
||||||
#include <pd/smart_ctor.hpp>
|
#include <pd/smart_ctor.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -22,9 +22,7 @@ class Image {
|
|||||||
Texture::Ref Get();
|
Texture::Ref Get();
|
||||||
void Set(Texture::Ref i, NVec4 uvs = NVec4(-1, -1, -1, -1));
|
void Set(Texture::Ref i, NVec4 uvs = NVec4(-1, -1, -1, -1));
|
||||||
NVec2 GetSize();
|
NVec2 GetSize();
|
||||||
NVec4 GetUV() {
|
NVec4 GetUV() { return (custom_uvs.x() != -1) ? custom_uvs : img->GetUV(); }
|
||||||
return (custom_uvs.x() != -1) ? custom_uvs : img->GetUV();
|
|
||||||
}
|
|
||||||
bool Loadet();
|
bool Loadet();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -26,8 +26,9 @@ enum PDKeyboardFlags_ {
|
|||||||
PDKeyboardFlags_BlendTop = 1 << 0,
|
PDKeyboardFlags_BlendTop = 1 << 0,
|
||||||
PDKeyboardFlags_BlendBottom = 1 << 1,
|
PDKeyboardFlags_BlendBottom = 1 << 1,
|
||||||
PDKeyboardFlags_LockControls = 1 << 2,
|
PDKeyboardFlags_LockControls = 1 << 2,
|
||||||
PDKeyboardFlags_Default =
|
PDKeyboardFlags_Default = PDKeyboardFlags_BlendTop |
|
||||||
PDKeyboardFlags_BlendTop | PDKeyboardFlags_BlendBottom | PDKeyboardFlags_LockControls,
|
PDKeyboardFlags_BlendBottom |
|
||||||
|
PDKeyboardFlags_LockControls,
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Palladium {
|
namespace Palladium {
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <pd/smart_ctor.hpp>
|
|
||||||
#include <pd/Texture.hpp>
|
|
||||||
#include <pd/Image.hpp>
|
|
||||||
|
|
||||||
#include <tex3ds.h>
|
#include <tex3ds.h>
|
||||||
|
|
||||||
namespace Palladium
|
#include <pd/Image.hpp>
|
||||||
{
|
#include <pd/Texture.hpp>
|
||||||
class Sheet {
|
#include <pd/smart_ctor.hpp>
|
||||||
|
|
||||||
|
namespace Palladium {
|
||||||
|
class Sheet {
|
||||||
public:
|
public:
|
||||||
Sheet() = default;
|
Sheet() = default;
|
||||||
~Sheet() = default;
|
~Sheet() = default;
|
||||||
@ -20,5 +19,5 @@ namespace Palladium
|
|||||||
std::vector<Texture::Ref> sprites;
|
std::vector<Texture::Ref> sprites;
|
||||||
Tex3DS_Texture sheet;
|
Tex3DS_Texture sheet;
|
||||||
C3D_Tex* sheet_tex = nullptr;
|
C3D_Tex* sheet_tex = nullptr;
|
||||||
};
|
};
|
||||||
} // namespace Palladium
|
} // namespace Palladium
|
||||||
|
@ -58,6 +58,6 @@ class Sprite {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
///// @param sprite The Sprite
|
///// @param sprite The Sprite
|
||||||
//C2D_Sprite sprite;
|
// C2D_Sprite sprite;
|
||||||
};
|
};
|
||||||
} // namespace Palladium
|
} // namespace Palladium
|
@ -17,6 +17,11 @@ class Texture {
|
|||||||
RGB24,
|
RGB24,
|
||||||
A8,
|
A8,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum Filter {
|
||||||
|
NEAREST,
|
||||||
|
LINEAR,
|
||||||
|
};
|
||||||
Texture() {
|
Texture() {
|
||||||
// Set Default UV
|
// Set Default UV
|
||||||
this->uvs[0] = 0.0f;
|
this->uvs[0] = 0.0f;
|
||||||
@ -45,7 +50,8 @@ class Texture {
|
|||||||
/// @param w Width of data
|
/// @param w Width of data
|
||||||
/// @param h Height of Data
|
/// @param h Height of Data
|
||||||
/// @param type Type of Data (default is RGBA32)
|
/// @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
|
/// @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
|
||||||
@ -61,7 +67,8 @@ class Texture {
|
|||||||
void AutoDelete(bool enable) { ad = enable; }
|
void AutoDelete(bool enable) { ad = enable; }
|
||||||
|
|
||||||
private:
|
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;
|
C3D_Tex* tex = nullptr;
|
||||||
NVec2 img_size;
|
NVec2 img_size;
|
||||||
NVec4 uvs;
|
NVec4 uvs;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
#include <pd/Error.hpp>
|
#include <pd/Error.hpp>
|
||||||
#include <pd/UI7.hpp>
|
#include <pd/UI7.hpp>
|
||||||
#include <pd/internal_db.hpp>
|
#include <pd/internal_db.hpp>
|
||||||
#include <pd/palladium.hpp>
|
#include <pd/palladium.hpp>
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
void pdi_save_report(const std::string& msg) {
|
void pdi_save_report(const std::string& msg) {
|
||||||
auto ts = Palladium::GetTimeStr();
|
auto ts = Palladium::GetTimeStr();
|
||||||
|
@ -29,7 +29,7 @@ Texture::Ref Image::Get() {
|
|||||||
|
|
||||||
void Image::Set(Texture::Ref i, NVec4 uvs) {
|
void Image::Set(Texture::Ref i, NVec4 uvs) {
|
||||||
Delete();
|
Delete();
|
||||||
if(uvs.x() != -1) custom_uvs = uvs;
|
if (uvs.x() != -1) custom_uvs = uvs;
|
||||||
img = i;
|
img = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,8 @@ void LIFont::LoadTFF(const std::string path, int px_size) {
|
|||||||
free(bitmap);
|
free(bitmap);
|
||||||
cpmap[c] = codepoint;
|
cpmap[c] = codepoint;
|
||||||
}
|
}
|
||||||
ftex->LoadPixels(fmap, type, type);
|
ftex->LoadPixels(fmap, type, type, Palladium::Texture::RGBA32,
|
||||||
|
Palladium::Texture::LINEAR);
|
||||||
this->tex.push_back(ftex);
|
this->tex.push_back(ftex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <pd/base/Color.hpp>
|
|
||||||
#include <pd/Message.hpp>
|
|
||||||
#include <pd/palladium.hpp>
|
|
||||||
#include <pd/Lithium.hpp>
|
#include <pd/Lithium.hpp>
|
||||||
|
#include <pd/Message.hpp>
|
||||||
|
#include <pd/base/Color.hpp>
|
||||||
|
#include <pd/palladium.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
extern bool pdi_debugging;
|
extern bool pdi_debugging;
|
||||||
@ -67,7 +67,7 @@ void ProcessMessages() {
|
|||||||
if (msg_lst[i]->animtime == 0) {
|
if (msg_lst[i]->animtime == 0) {
|
||||||
msg_lst[i]->animtime += 1;
|
msg_lst[i]->animtime += 1;
|
||||||
} else {
|
} else {
|
||||||
msg_lst[i]->animtime += Palladium::GetDeltaTime()*0.1f;
|
msg_lst[i]->animtime += Palladium::GetDeltaTime() * 0.1f;
|
||||||
}
|
}
|
||||||
if (msg_lst[i]->animtime > anim_len) {
|
if (msg_lst[i]->animtime > anim_len) {
|
||||||
msg_lst.erase(msg_lst.begin() + i);
|
msg_lst.erase(msg_lst.begin() + i);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <pd/external/stb_image.h>
|
#include <pd/external/stb_image.h>
|
||||||
|
|
||||||
#include <pd/base/Color.hpp>
|
|
||||||
#include <pd/Rubidium.hpp>
|
#include <pd/Rubidium.hpp>
|
||||||
|
#include <pd/base/Color.hpp>
|
||||||
|
|
||||||
void d7_pixel_blend(Palladium::Rubidium* rb, int x, int y, unsigned int clr,
|
void d7_pixel_blend(Palladium::Rubidium* rb, int x, int y, unsigned int clr,
|
||||||
float blend) {
|
float blend) {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#include <pd/external/stb_image.h>
|
#include <pd/external/stb_image.h>
|
||||||
#include <pd/external/stb_image_write.h>
|
#include <pd/external/stb_image_write.h>
|
||||||
|
|
||||||
|
#include <pd/Error.hpp>
|
||||||
#include <pd/Texture.hpp>
|
#include <pd/Texture.hpp>
|
||||||
#include <pd/internal_db.hpp>
|
#include <pd/internal_db.hpp>
|
||||||
#include <pd/Error.hpp>
|
|
||||||
|
|
||||||
namespace pdi {
|
namespace pdi {
|
||||||
static bool single_bit(unsigned int v) { return v && !(v & (v - 1)); }
|
static bool single_bit(unsigned int v) { return v && !(v & (v - 1)); }
|
||||||
@ -54,8 +54,8 @@ int GetBPP(Texture::Type type) {
|
|||||||
return 1;
|
return 1;
|
||||||
return 0; // Error
|
return 0; // Error
|
||||||
}
|
}
|
||||||
void Texture::MakeTex(std::vector<unsigned char> &buf, int w, int h,
|
void Texture::MakeTex(std::vector<unsigned char> &buf, int w, int h, Type type,
|
||||||
Type type) {
|
Filter filter) {
|
||||||
if (!tex) {
|
if (!tex) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -104,9 +104,10 @@ void Texture::MakeTex(std::vector<unsigned char> &buf, int w, int h,
|
|||||||
this->uvs.w() = 1.0 - ((float)h / (float)tex_size.y());
|
this->uvs.w() = 1.0 - ((float)h / (float)tex_size.y());
|
||||||
|
|
||||||
// Texture Setup
|
// Texture Setup
|
||||||
|
auto fltr = (filter == NEAREST ? GPU_NEAREST : GPU_LINEAR);
|
||||||
auto tex_fmt = GetTexFmt(type);
|
auto tex_fmt = GetTexFmt(type);
|
||||||
C3D_TexInit(tex, (u16)tex_size.x(), (u16)tex_size.y(), tex_fmt);
|
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);
|
memset(tex->data, 0, tex->size);
|
||||||
|
|
||||||
@ -202,7 +203,7 @@ NVec2 Texture::GetTexSize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Texture::LoadPixels(const std::vector<unsigned char> &data, int w, int h,
|
void Texture::LoadPixels(const std::vector<unsigned char> &data, int w, int h,
|
||||||
Type type) {
|
Type type, Filter filter) {
|
||||||
Delete();
|
Delete();
|
||||||
int bpp = GetBPP(type);
|
int bpp = GetBPP(type);
|
||||||
Palladium::InlineAssert(bpp, "Invalid Type");
|
Palladium::InlineAssert(bpp, "Invalid Type");
|
||||||
@ -216,7 +217,7 @@ void Texture::LoadPixels(const std::vector<unsigned char> &data, int w, int h,
|
|||||||
}
|
}
|
||||||
tex = new C3D_Tex;
|
tex = new C3D_Tex;
|
||||||
std::vector<unsigned char> wimg(data);
|
std::vector<unsigned char> wimg(data);
|
||||||
MakeTex(wimg, w, h, type);
|
MakeTex(wimg, w, h, type, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Texture::ExternalLoad(C3D_Tex *tex, NVec2 rszs, NVec4 uvs) {
|
void Texture::ExternalLoad(C3D_Tex *tex, NVec2 rszs, NVec4 uvs) {
|
||||||
|
Loading…
Reference in New Issue
Block a user