mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-21 21:05:50 +12:00
[PICA] Proper texture wrapping
This commit is contained in:
parent
84db6052b3
commit
4632a62da2
4 changed files with 34 additions and 13 deletions
|
@ -1,15 +1,33 @@
|
|||
#include "renderer_gl/textures.hpp"
|
||||
#include "colour.hpp"
|
||||
#include <array>
|
||||
|
||||
void Texture::allocate() {
|
||||
glGenTextures(1, &texture.m_handle);
|
||||
texture.create(size.u(), size.v(), GL_RGBA8);
|
||||
texture.bind();
|
||||
|
||||
texture.setMinFilter(OpenGL::Nearest);
|
||||
texture.setMagFilter(OpenGL::Nearest);
|
||||
texture.setWrapS(OpenGL::Repeat);
|
||||
texture.setWrapT(OpenGL::Repeat);
|
||||
setNewConfig(config);
|
||||
}
|
||||
|
||||
// Set the texture's configuration, which includes min/mag filters, wrapping S/T modes, and so on
|
||||
void Texture::setNewConfig(u32 cfg) {
|
||||
config = cfg;
|
||||
// The wrapping mode field is 3 bits instead of 2 bits. The bottom 4 undocumented wrapping modes are taken from Citra.
|
||||
static constexpr std::array<OpenGL::WrappingMode, 8> wrappingModes = {
|
||||
OpenGL::ClampToEdge, OpenGL::ClampToBorder, OpenGL::Repeat, OpenGL::RepeatMirrored,
|
||||
OpenGL::ClampToEdge, OpenGL::ClampToBorder, OpenGL::Repeat, OpenGL::Repeat
|
||||
};
|
||||
|
||||
const auto magFilter = (cfg & 0x2) != 0 ? OpenGL::Linear : OpenGL::Nearest;
|
||||
const auto minFilter = (cfg & 0x4) != 0 ? OpenGL::Linear : OpenGL::Nearest;
|
||||
const auto wrapT = wrappingModes[(cfg >> 8) & 0x7];
|
||||
const auto wrapS = wrappingModes[(cfg >> 12) & 0x7];
|
||||
|
||||
texture.setMinFilter(minFilter);
|
||||
texture.setMagFilter(magFilter);
|
||||
texture.setWrapS(wrapS);
|
||||
texture.setWrapT(wrapT);
|
||||
}
|
||||
|
||||
void Texture::free() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue