summaryrefslogtreecommitdiff
path: root/gfx/models/texture.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-11-26 13:51:33 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-11-26 14:14:13 +0000
commit7fba471728f2216d7e3b7900297fc3b3531e286c (patch)
tree5caef3b2efc23aefccb215ec9005cd8e7d2e91b8 /gfx/models/texture.cpp
parentFix todo for handling a terrain walk from outside the mesh (diff)
parentModel positions as integers (diff)
downloadilt-7fba471728f2216d7e3b7900297fc3b3531e286c.tar.bz2
ilt-7fba471728f2216d7e3b7900297fc3b3531e286c.tar.xz
ilt-7fba471728f2216d7e3b7900297fc3b3531e286c.zip
Merge branch 'ints' into terrain
Conflicts fix, compiles, some test failures remain. Trees not added, possibility of OM invalid handle assertion failures, normals broken due to integer overflow in Newell's method.
Diffstat (limited to 'gfx/models/texture.cpp')
-rw-r--r--gfx/models/texture.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/gfx/models/texture.cpp b/gfx/models/texture.cpp
index 380f2e0..1685d34 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 <cache.h>
@@ -60,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;
@@ -136,14 +137,16 @@ 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);
+
struct Material {
glm::vec<2, uint16_t> position, size;
TextureOptions::MapMode wrapU;
TextureOptions::MapMode wrapV;
} material {position, size, to.wrapU, to.wrapV};
+
static_assert(sizeof(Material) <= 32);
glTextureSubImage2D(m_atlas, 0, 0, static_cast<GLsizei>(used), 2, 1, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, &material);
return ++used;