From 79172452f24a1ac1af6934723273a3588dd9cf1d Mon Sep 17 00:00:00 2001 From: Spencer Elliott Date: Tue, 26 Sep 2023 18:51:29 +0000 Subject: [PATCH] Convert GL_SHORT to proper float on conversion --- GL/draw.c | 5 +++-- samples/nehe06_4444twid/main.c | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/GL/draw.c b/GL/draw.c index 38139d7..01d9cf7 100644 --- a/GL/draw.c +++ b/GL/draw.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "private.h" #include "platform.h" @@ -159,8 +160,8 @@ static void _readVertexData2us2f(const GLubyte* in, GLubyte* out) { const GLushort* input = (const GLushort*) in; float* output = (float*) out; - output[0] = input[0]; - output[1] = input[1]; + output[0] = (float)input[0] / SHRT_MAX; + output[1] = (float)input[1] / SHRT_MAX; } static void _readVertexData2ui2f(const GLubyte* in, GLubyte* out) { diff --git a/samples/nehe06_4444twid/main.c b/samples/nehe06_4444twid/main.c index b0649e5..3cc58d5 100644 --- a/samples/nehe06_4444twid/main.c +++ b/samples/nehe06_4444twid/main.c @@ -59,10 +59,10 @@ int ImageLoad(char *filename, Image *image) { fread(&header, sizeof(header), 1, file); - GLboolean twiddled = (header.type & (1 << 25)) < 1; - GLboolean compressed = (header.type & (1 << 29)) > 0; - GLboolean mipmapped = (header.type & (1 << 30)) > 0; - GLboolean strided = (header.type & (1 << 24)) > 0; + GLboolean twiddled = (header.type & (1 << 26)) < 1; + GLboolean compressed = (header.type & (1 << 30)) > 0; + GLboolean mipmapped = (header.type & (1 << 31)) > 0; + GLboolean strided = (header.type & (1 << 25)) > 0; GLuint format = (header.type >> 27) & 0b111; image->data = (char *) malloc (header.size);