[Scummvm-git-logs] scummvm master -> b98a8d4383aecefb8fac2490ef074572804a1031
aquadran
noreply at scummvm.org
Wed Feb 8 05:49:41 UTC 2023
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
b98a8d4383 TINYGL: Normalize decimal values for color and normal array arguments.
Commit: b98a8d4383aecefb8fac2490ef074572804a1031
https://github.com/scummvm/scummvm/commit/b98a8d4383aecefb8fac2490ef074572804a1031
Author: PaweÅ KoÅodziejski (aquadran at gmail.com)
Date: 2023-02-08T06:49:34+01:00
Commit Message:
TINYGL: Normalize decimal values for color and normal array arguments.
Changed paths:
graphics/tinygl/arrays.cpp
diff --git a/graphics/tinygl/arrays.cpp b/graphics/tinygl/arrays.cpp
index a48bafd67d7..81594dd2496 100644
--- a/graphics/tinygl/arrays.cpp
+++ b/graphics/tinygl/arrays.cpp
@@ -27,6 +27,15 @@
#include "graphics/tinygl/zgl.h"
+#define NORLALIZE_SBYTE(n) ( ( (float) n * 2.0f + 1.0f ) / 255.0f )
+#define NORLALIZE_UBYTE(n) ( (float) n / 255.0f )
+
+#define NORLALIZE_SSHORT(n) ( ( (float) n * 2.0f + 1.0f ) / 65535.0f )
+#define NORLALIZE_USHORT(n) ( (float) n / 65535.0f )
+
+#define NORLALIZE_SINT(n) ( ( (float) n * 2.0f + 1.0f ) / 4294967295.0f )
+#define NORLALIZE_UINT(n) ( (float) n / 4294967295.0f )
+
namespace TinyGL {
void GLContext::glopArrayElement(GLParam *param) {
@@ -41,50 +50,50 @@ void GLContext::glopArrayElement(GLParam *param) {
switch (color_array_type) {
case TGL_UNSIGNED_BYTE: {
TGLubyte *array = (TGLubyte *)color_array + offset;
- p[1].f = array[0];
- p[2].f = array[1];
- p[3].f = array[2];
- p[4].f = size > 3 ? array[3] : 1.0f;
+ p[1].f = NORLALIZE_UBYTE(array[0]);
+ p[2].f = NORLALIZE_UBYTE(array[1]);
+ p[3].f = NORLALIZE_UBYTE(array[2]);
+ p[4].f = size > 3 ? NORLALIZE_UBYTE(array[3]) : 1.0f;
break;
}
case TGL_BYTE: {
TGLbyte *array = (TGLbyte *)color_array + offset;
- p[1].f = array[0];
- p[2].f = array[1];
- p[3].f = array[2];
- p[4].f = size > 3 ? array[3] : 1.0f;
+ p[1].f = NORLALIZE_SBYTE(array[0]);
+ p[2].f = NORLALIZE_SBYTE(array[1]);
+ p[3].f = NORLALIZE_SBYTE(array[2]);
+ p[4].f = size > 3 ? NORLALIZE_SBYTE(array[3]) : 1.0f;
break;
}
case TGL_UNSIGNED_INT: {
TGLuint *array = (TGLuint *)((TGLbyte *)color_array + offset);
- p[1].f = array[0];
- p[2].f = array[1];
- p[3].f = array[2];
- p[4].f = size > 3 ? array[3] : 1.0f;
+ p[1].f = NORLALIZE_UINT(array[0]);
+ p[2].f = NORLALIZE_UINT(array[1]);
+ p[3].f = NORLALIZE_UINT(array[2]);
+ p[4].f = size > 3 ? NORLALIZE_UINT(array[3]) : 1.0f;
break;
}
case TGL_INT: {
TGLint *array = (TGLint *)((TGLbyte *)color_array + offset);
- p[1].f = array[0];
- p[2].f = array[1];
- p[3].f = array[2];
- p[4].f = size > 3 ? array[3] : 1.0f;
+ p[1].f = NORLALIZE_SINT(array[0]);
+ p[2].f = NORLALIZE_SINT(array[1]);
+ p[3].f = NORLALIZE_SINT(array[2]);
+ p[4].f = size > 3 ? NORLALIZE_SINT(array[3]) : 1.0f;
break;
}
case TGL_UNSIGNED_SHORT: {
TGLushort *array = (TGLushort *)((TGLbyte *)color_array + offset);
- p[1].f = array[0];
- p[2].f = array[1];
- p[3].f = array[2];
- p[4].f = size > 3 ? array[3] : 1.0f;
+ p[1].f = NORLALIZE_USHORT(array[0]);
+ p[2].f = NORLALIZE_USHORT(array[1]);
+ p[3].f = NORLALIZE_USHORT(array[2]);
+ p[4].f = size > 3 ? NORLALIZE_USHORT(array[3]) : 1.0f;
break;
}
case TGL_SHORT: {
TGLshort *array = (TGLshort *)((TGLbyte *)color_array + offset);
- p[1].f = array[0];
- p[2].f = array[1];
- p[3].f = array[2];
- p[4].f = size > 3 ? array[3] : 1.0f;
+ p[1].f = NORLALIZE_SSHORT(array[0]);
+ p[2].f = NORLALIZE_SSHORT(array[1]);
+ p[3].f = NORLALIZE_SSHORT(array[2]);
+ p[4].f = size > 3 ? NORLALIZE_SSHORT(array[3]) : 1.0f;
break;
}
case TGL_FLOAT: {
@@ -128,16 +137,16 @@ void GLContext::glopArrayElement(GLParam *param) {
}
case TGL_INT: {
TGLint *array = (TGLint *)((TGLbyte *)normal_array + offset);
- current_normal.X = array[0];
- current_normal.Y = array[1];
- current_normal.Z = array[2];
+ current_normal.X = NORLALIZE_SINT(array[0]);
+ current_normal.Y = NORLALIZE_SINT(array[1]);
+ current_normal.Z = NORLALIZE_SINT(array[2]);
break;
}
case TGL_SHORT: {
TGLshort *array = (TGLshort *)((TGLbyte *)normal_array + offset);
- current_normal.X = array[0];
- current_normal.Y = array[1];
- current_normal.Z = array[2];
+ current_normal.X = NORLALIZE_SSHORT(array[0]);
+ current_normal.Y = NORLALIZE_SSHORT(array[1]);
+ current_normal.Z = NORLALIZE_SSHORT(array[2]);
break;
}
default:
More information about the Scummvm-git-logs
mailing list