mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 13:37:42 -05:00
refactor: Get rid of this->m_
This commit is contained in:
@@ -46,15 +46,15 @@ namespace ImGuiExt {
|
||||
if (size == 0)
|
||||
return;
|
||||
|
||||
unsigned char *imageData = stbi_load_from_memory(buffer, size, &this->m_width, &this->m_height, nullptr, 4);
|
||||
unsigned char *imageData = stbi_load_from_memory(buffer, size, &m_width, &m_height, nullptr, 4);
|
||||
if (imageData == nullptr) {
|
||||
if (width * height * 4 > size)
|
||||
return;
|
||||
|
||||
imageData = static_cast<unsigned char *>(STBI_MALLOC(size));
|
||||
std::memcpy(imageData, buffer, size);
|
||||
this->m_width = width;
|
||||
this->m_height = height;
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
}
|
||||
if (imageData == nullptr)
|
||||
return;
|
||||
@@ -70,10 +70,10 @@ namespace ImGuiExt {
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
#endif
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this->m_width, this->m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_width, m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData);
|
||||
stbi_image_free(imageData);
|
||||
|
||||
this->m_textureId = reinterpret_cast<ImTextureID>(static_cast<intptr_t>(texture));
|
||||
m_textureId = reinterpret_cast<ImTextureID>(static_cast<intptr_t>(texture));
|
||||
}
|
||||
|
||||
Texture::Texture(std::span<const std::byte> bytes, Filter filter, int width, int height) : Texture(reinterpret_cast<const ImU8*>(bytes.data()), bytes.size(), filter, width, height) { }
|
||||
@@ -81,7 +81,7 @@ namespace ImGuiExt {
|
||||
Texture::Texture(const std::fs::path &path, Filter filter) : Texture(reinterpret_cast<const char *>(path.u8string().c_str()), filter) { }
|
||||
|
||||
Texture::Texture(const char *path, Filter filter) {
|
||||
unsigned char *imageData = stbi_load(path, &this->m_width, &this->m_height, nullptr, 4);
|
||||
unsigned char *imageData = stbi_load(path, &m_width, &m_height, nullptr, 4);
|
||||
if (imageData == nullptr)
|
||||
return;
|
||||
|
||||
@@ -96,10 +96,10 @@ namespace ImGuiExt {
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
#endif
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this->m_width, this->m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_width, m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData);
|
||||
stbi_image_free(imageData);
|
||||
|
||||
this->m_textureId = reinterpret_cast<ImTextureID>(static_cast<intptr_t>(texture));
|
||||
m_textureId = reinterpret_cast<ImTextureID>(static_cast<intptr_t>(texture));
|
||||
}
|
||||
|
||||
Texture::Texture(unsigned int texture, int width, int height) : m_textureId(reinterpret_cast<ImTextureID>(static_cast<intptr_t>(texture))), m_width(width), m_height(height) {
|
||||
@@ -107,19 +107,19 @@ namespace ImGuiExt {
|
||||
}
|
||||
|
||||
Texture::Texture(Texture&& other) noexcept {
|
||||
glDeleteTextures(1, reinterpret_cast<GLuint*>(&this->m_textureId));
|
||||
this->m_textureId = other.m_textureId;
|
||||
this->m_width = other.m_width;
|
||||
this->m_height = other.m_height;
|
||||
glDeleteTextures(1, reinterpret_cast<GLuint*>(&m_textureId));
|
||||
m_textureId = other.m_textureId;
|
||||
m_width = other.m_width;
|
||||
m_height = other.m_height;
|
||||
|
||||
other.m_textureId = nullptr;
|
||||
}
|
||||
|
||||
Texture& Texture::operator=(Texture&& other) noexcept {
|
||||
glDeleteTextures(1, reinterpret_cast<GLuint*>(&this->m_textureId));
|
||||
this->m_textureId = other.m_textureId;
|
||||
this->m_width = other.m_width;
|
||||
this->m_height = other.m_height;
|
||||
glDeleteTextures(1, reinterpret_cast<GLuint*>(&m_textureId));
|
||||
m_textureId = other.m_textureId;
|
||||
m_width = other.m_width;
|
||||
m_height = other.m_height;
|
||||
|
||||
other.m_textureId = nullptr;
|
||||
|
||||
@@ -127,10 +127,10 @@ namespace ImGuiExt {
|
||||
}
|
||||
|
||||
Texture::~Texture() {
|
||||
if (this->m_textureId == nullptr)
|
||||
if (m_textureId == nullptr)
|
||||
return;
|
||||
|
||||
auto glTextureId = static_cast<GLuint>(reinterpret_cast<intptr_t>(this->m_textureId));
|
||||
auto glTextureId = static_cast<GLuint>(reinterpret_cast<intptr_t>(m_textureId));
|
||||
glDeleteTextures(1, &glTextureId);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user