Merge branch 'fix-glshort-uv-read' into 'master'

Convert GL_SHORT to proper float on conversion

See merge request simulant/GLdc!109
This commit is contained in:
Luke Benstead 2023-09-26 18:51:30 +00:00
commit 744dfb32f7
2 changed files with 7 additions and 6 deletions

View File

@ -3,6 +3,7 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
#include <limits.h>
#include "private.h" #include "private.h"
#include "platform.h" #include "platform.h"
@ -159,8 +160,8 @@ static void _readVertexData2us2f(const GLubyte* in, GLubyte* out) {
const GLushort* input = (const GLushort*) in; const GLushort* input = (const GLushort*) in;
float* output = (float*) out; float* output = (float*) out;
output[0] = input[0]; output[0] = (float)input[0] / SHRT_MAX;
output[1] = input[1]; output[1] = (float)input[1] / SHRT_MAX;
} }
static void _readVertexData2ui2f(const GLubyte* in, GLubyte* out) { static void _readVertexData2ui2f(const GLubyte* in, GLubyte* out) {

View File

@ -59,10 +59,10 @@ int ImageLoad(char *filename, Image *image) {
fread(&header, sizeof(header), 1, file); fread(&header, sizeof(header), 1, file);
GLboolean twiddled = (header.type & (1 << 25)) < 1; GLboolean twiddled = (header.type & (1 << 26)) < 1;
GLboolean compressed = (header.type & (1 << 29)) > 0; GLboolean compressed = (header.type & (1 << 30)) > 0;
GLboolean mipmapped = (header.type & (1 << 30)) > 0; GLboolean mipmapped = (header.type & (1 << 31)) > 0;
GLboolean strided = (header.type & (1 << 24)) > 0; GLboolean strided = (header.type & (1 << 25)) > 0;
GLuint format = (header.type >> 27) & 0b111; GLuint format = (header.type >> 27) & 0b111;
image->data = (char *) malloc (header.size); image->data = (char *) malloc (header.size);