aboutsummaryrefslogtreecommitdiffstats
path: root/tex.c
diff options
context:
space:
mode:
Diffstat (limited to 'tex.c')
-rw-r--r--tex.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/tex.c b/tex.c
index 11c09f7..a24a430 100644
--- a/tex.c
+++ b/tex.c
@@ -9,6 +9,7 @@
#include "eprintf.h"
#include "tex.h"
+// png2tex: read a PNG and produce an OpenGL texture out of it
GLuint png2tex(FILE *f)
{
png_image pi = { .version = PNG_IMAGE_VERSION };
@@ -21,6 +22,7 @@ GLuint png2tex(FILE *f)
png_image_begin_read_from_stdio(&pi, f);
pi.format = PNG_FORMAT_RGB;
stride = sizeof *data * PNG_IMAGE_SAMPLE_CHANNELS(pi.format) * pi.width;
+ // OpenGL alignment requirement
stride = (stride + 3) & ~(size_t)3;
size = stride * pi.height;
data = emalloc(size);