diff --git a/GL/lighting.c b/GL/lighting.c index 4f2aa6a..3730df1 100644 --- a/GL/lighting.c +++ b/GL/lighting.c @@ -5,6 +5,7 @@ #include #include "private.h" +#include "platform.h" #define _MIN(x, y) (x < y) ? x : y @@ -455,7 +456,7 @@ GL_FORCE_INLINE void _glLightVertexPoint( #undef _PROCESS_COMPONENT } -void _glPerformLighting(Vertex* vertices, EyeSpaceData* es, const int32_t count) { +void _glPerformLighting(Vertex* vertices, EyeSpaceData* es, const uint32_t count) { GLubyte i; GLuint j; @@ -503,7 +504,7 @@ void _glPerformLighting(Vertex* vertices, EyeSpaceData* es, const int32_t count) float Vx = -data->xyz[0]; float Vy = -data->xyz[1]; float Vz = -data->xyz[2]; - vec3f_normalize(Vx, Vy, Vz); + VEC3_NORMALIZE(Vx, Vy, Vz); const float Nx = data->n[0]; const float Ny = data->n[1]; @@ -523,15 +524,15 @@ void _glPerformLighting(Vertex* vertices, EyeSpaceData* es, const int32_t count) float Hy = (Ly + 0); float Hz = (Lz + 1); - vec3f_normalize(Lx, Ly, Lz); - vec3f_normalize(Hx, Hy, Hz); + VEC3_NORMALIZE(Lx, Ly, Lz); + VEC3_NORMALIZE(Hx, Hy, Hz); float LdotN, NdotH; - vec3f_dot( + VEC3_DOT( Nx, Ny, Nz, Lx, Ly, Lz, LdotN ); - vec3f_dot( + VEC3_DOT( Nx, Ny, Nz, Hx, Hy, Hz, NdotH ); @@ -544,8 +545,7 @@ void _glPerformLighting(Vertex* vertices, EyeSpaceData* es, const int32_t count) ); } else { float D; - - vec3f_length(Lx, Ly, Lz, D); + VEC3_LENGTH(Lx, Ly, Lz, D); float att = ( LIGHTS[i].constant_attenuation + ( @@ -563,15 +563,15 @@ void _glPerformLighting(Vertex* vertices, EyeSpaceData* es, const int32_t count) float Hy = (Ly + Vy); float Hz = (Lz + Vz); - vec3f_normalize(Lx, Ly, Lz); - vec3f_normalize(Hx, Hy, Hz); + VEC3_NORMALIZE(Lx, Ly, Lz); + VEC3_NORMALIZE(Hx, Hy, Hz); float LdotN, NdotH; - vec3f_dot( + VEC3_DOT( Nx, Ny, Nz, Lx, Ly, Lz, LdotN ); - vec3f_dot( + VEC3_DOT( Nx, Ny, Nz, Hx, Hy, Hz, NdotH ); diff --git a/GL/matrix.c b/GL/matrix.c index 1cb3453..ef086cf 100644 --- a/GL/matrix.c +++ b/GL/matrix.c @@ -1,5 +1,5 @@ #include - +#include #include #include "private.h" diff --git a/GL/platform.h b/GL/platform.h index 374e1eb..875b70f 100644 --- a/GL/platform.h +++ b/GL/platform.h @@ -244,6 +244,8 @@ enum GPUCommand { GPU_CMD_SPRITE = 0xA0000000 }; +typedef float Matrix4x4[16]; + void SceneBegin(); void SceneListBegin(GPUList list); diff --git a/GL/platforms/x86.h b/GL/platforms/x86.h index e591877..8025ff1 100644 --- a/GL/platforms/x86.h +++ b/GL/platforms/x86.h @@ -14,21 +14,31 @@ #define FASTCPY(dst, src, bytes) memcpy(dst, src, bytes) #define FASTCPY4(dst, src, bytes) memcpy(dst, src, bytes) #define MEMSET4(dst, v, size) memset((dst), (v), (size)) +#define NORMALIZEVEC3(x, y, z) \ + do { \ + float l = MATH_fsrra((x) * (x) + (y) * (y) + (z) * (z)); \ + x *= l; \ + y *= l; \ + z *= l; \ + while(0); \ + +struct PolyHeader; +struct PolyContext; inline void CompilePolyHeader(PolyHeader* out, const PolyContext* in) { (void) out; (void) in; } -inline void UploadMatrix4x4(const float* mat) { +inline void UploadMatrix4x4(const Matrix4x4* mat) { (void) mat; } -inline void MultiplyMatrix4x4(const float* mat) { +inline void MultiplyMatrix4x4(const Matrix4x4* mat) { (void) mat; } -inline void DownloadMatrix4x4(float* mat) { +inline void DownloadMatrix4x4(Matrix4x4* mat) { (void) mat; } diff --git a/GL/private.h b/GL/private.h index 9553b1a..abe0c58 100644 --- a/GL/private.h +++ b/GL/private.h @@ -38,7 +38,6 @@ extern void* memcpy4 (void *dest, const void *src, size_t count); #define MAX_TEXTURE_SIZE 1024 -typedef float Matrix4x4[16]; /* This gives us an easy way to switch * internal matrix order if necessary */ @@ -341,7 +340,7 @@ typedef struct { float finalColour[4]; //16 bytes (to 40) } EyeSpaceData; -extern void _glPerformLighting(Vertex* vertices, EyeSpaceData *es, const int32_t count); +extern void _glPerformLighting(Vertex* vertices, EyeSpaceData *es, const uint32_t count); unsigned char _glIsClippingEnabled(); void _glEnableClipping(unsigned char v);