From d6e99a696aa582b81018078b68f6600c8030d643 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 7 Nov 2023 02:51:42 +0000 Subject: WIP typedefing all the things - headers --- gfx/models/texture.cpp | 1 + gfx/models/texture.h | 5 +++-- gfx/models/tga.h | 3 ++- gfx/models/vertex.h | 12 ++++++------ 4 files changed, 12 insertions(+), 9 deletions(-) (limited to 'gfx/models') diff --git a/gfx/models/texture.cpp b/gfx/models/texture.cpp index b7f1bee..f60d158 100644 --- a/gfx/models/texture.cpp +++ b/gfx/models/texture.cpp @@ -1,4 +1,5 @@ #include "texture.h" +#include "config/types.h" #include "glArrays.h" #include "tga.h" #include diff --git a/gfx/models/texture.h b/gfx/models/texture.h index 1b66c64..5e1b440 100644 --- a/gfx/models/texture.h +++ b/gfx/models/texture.h @@ -1,5 +1,6 @@ #pragma once +#include "config/types.h" #include #include #include @@ -42,7 +43,7 @@ public: protected: static void save(const glTexture &, GLenum, GLenum, uint8_t channels, const char * path, uint8_t tgaFormat); - static glm::ivec2 getSize(const glTexture &); + static TextureAbsCoord getSize(const glTexture &); glTexture m_texture; GLenum type; @@ -53,7 +54,7 @@ public: TextureAtlas(GLsizei width, GLsizei height, GLuint count); void bind(GLenum unit = GL_TEXTURE0) const override; - GLuint add(glm::ivec2 position, glm::ivec2 size, void * data, TextureOptions = {}); + GLuint add(TextureAbsCoord position, TextureAbsCoord size, void * data, TextureOptions = {}); private: glTexture m_atlas; diff --git a/gfx/models/tga.h b/gfx/models/tga.h index 52db220..3d072fb 100644 --- a/gfx/models/tga.h +++ b/gfx/models/tga.h @@ -4,10 +4,11 @@ #include struct TGAHead { + using XY = glm::vec<2, uint16_t>; uint8_t idLength {}, colorMapType {}, format {}; uint16_t __attribute__((packed)) colorMapFirst {}, colorMapLength {}; uint8_t colorMapEntrySize {}; - glm::vec<2, uint16_t> origin {}, size {}; + XY origin {}, size {}; uint8_t pixelDepth {}; uint8_t descriptor {}; }; diff --git a/gfx/models/vertex.h b/gfx/models/vertex.h index 0464ea7..5635fa1 100644 --- a/gfx/models/vertex.h +++ b/gfx/models/vertex.h @@ -1,12 +1,12 @@ #pragma once +#include "config/types.h" #include -#include class Vertex { public: #ifndef __cpp_aggregate_paren_init - constexpr Vertex(glm::vec3 pos, glm::vec2 texCoord, glm::vec3 normal, glm::vec4 colour = {}, GLuint material = 0) : + constexpr Vertex(Position3D pos, TextureRelCoord texCoord, Normal3D normal, RGBA colour = {}, GLuint material = 0) : pos {std::move(pos)}, texCoord {std::move(texCoord)}, normal {std::move(normal)}, colour {std::move(colour)}, material {material} { @@ -15,9 +15,9 @@ public: bool operator==(const Vertex &) const = default; - glm::vec3 pos; - glm::vec2 texCoord; - glm::vec3 normal; - glm::vec4 colour {}; + Position3D pos {}; + TextureRelCoord texCoord {}; + Normal3D normal {}; + RGBA colour {}; GLuint material {}; }; -- cgit v1.2.3 From 9c2c3f71065c94a18c02440111b6ff8ca977b90e Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 9 Nov 2023 00:40:40 +0000 Subject: WIP typedefing all the things - sources --- gfx/models/texture.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gfx/models') diff --git a/gfx/models/texture.cpp b/gfx/models/texture.cpp index f60d158..1685d34 100644 --- a/gfx/models/texture.cpp +++ b/gfx/models/texture.cpp @@ -61,10 +61,10 @@ Texture::bind(GLenum unit) const glBindTexture(type, m_texture); } -glm::ivec2 +TextureAbsCoord Texture::getSize(const glTexture & texture) { - glm::ivec2 size; + TextureAbsCoord size; glGetTextureLevelParameteriv(texture, 0, GL_TEXTURE_WIDTH, &size.x); glGetTextureLevelParameteriv(texture, 0, GL_TEXTURE_HEIGHT, &size.y); return size; @@ -137,7 +137,7 @@ TextureAtlas::bind(GLenum unit) const } GLuint -TextureAtlas::add(glm::ivec2 position, glm::ivec2 size, void * data, TextureOptions to) +TextureAtlas::add(TextureAbsCoord position, TextureAbsCoord size, void * data, TextureOptions to) { glTextureSubImage2D(m_texture, 0, position.x, position.y, size.x, size.y, GL_RGBA, GL_UNSIGNED_BYTE, data); -- cgit v1.2.3 From 14aa604389110f5da25e0c06ca4c6a753c497248 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 15 Dec 2023 01:46:22 +0000 Subject: Basic support for saving integer position buffer --- gfx/models/texture.cpp | 6 ++++++ gfx/models/texture.h | 1 + 2 files changed, 7 insertions(+) (limited to 'gfx/models') diff --git a/gfx/models/texture.cpp b/gfx/models/texture.cpp index 1685d34..35f8d35 100644 --- a/gfx/models/texture.cpp +++ b/gfx/models/texture.cpp @@ -103,6 +103,12 @@ Texture::save(const glTexture & texture, const char * path) save(texture, GL_BGR, GL_UNSIGNED_BYTE, 3, path, 2); } +void +Texture::savePosition(const glTexture & texture, const char * path) +{ + save(texture, GL_BGR_INTEGER, GL_UNSIGNED_BYTE, 3, path, 2); +} + void Texture::saveDepth(const glTexture & texture, const char * path) { diff --git a/gfx/models/texture.h b/gfx/models/texture.h index 5e1b440..5d40b39 100644 --- a/gfx/models/texture.h +++ b/gfx/models/texture.h @@ -40,6 +40,7 @@ public: static void save(const glTexture &, const char * path); static void saveDepth(const glTexture &, const char * path); static void saveNormal(const glTexture &, const char * path); + static void savePosition(const glTexture &, const char * path); protected: static void save(const glTexture &, GLenum, GLenum, uint8_t channels, const char * path, uint8_t tgaFormat); -- cgit v1.2.3 From 69e6b7d2d349dcc42d2d415a72181ba729d5a19d Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 1 Jan 2024 15:53:54 +0000 Subject: Remove more use of legacy types --- gfx/models/vertex.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'gfx/models') diff --git a/gfx/models/vertex.h b/gfx/models/vertex.h index 5635fa1..3c6215f 100644 --- a/gfx/models/vertex.h +++ b/gfx/models/vertex.h @@ -6,16 +6,17 @@ class Vertex { public: #ifndef __cpp_aggregate_paren_init - constexpr Vertex(Position3D pos, TextureRelCoord texCoord, Normal3D normal, RGBA colour = {}, GLuint material = 0) : - pos {std::move(pos)}, texCoord {std::move(texCoord)}, normal {std::move(normal)}, colour {std::move(colour)}, - material {material} + constexpr Vertex( + RelativePosition3D pos, TextureRelCoord texCoord, Normal3D normal, RGBA colour = {}, GLuint material = 0) : + pos {std::move(pos)}, + texCoord {std::move(texCoord)}, normal {std::move(normal)}, colour {std::move(colour)}, material {material} { } #endif bool operator==(const Vertex &) const = default; - Position3D pos {}; + RelativePosition3D pos {}; TextureRelCoord texCoord {}; Normal3D normal {}; RGBA colour {}; -- cgit v1.2.3