From 2745bb4f14e172363cbbd4cc268bf26c135fa499 Mon Sep 17 00:00:00 2001 From: raven02 Date: Wed, 20 Feb 2013 01:37:19 +0800 Subject: [PATCH] pos[0]/[1] are signed while pos[2] is unsigned in 2D transform --- GPU/GLES/VertexDecoder.h | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/GPU/GLES/VertexDecoder.h b/GPU/GLES/VertexDecoder.h index 4917965dd1..5357ee6621 100644 --- a/GPU/GLES/VertexDecoder.h +++ b/GPU/GLES/VertexDecoder.h @@ -212,16 +212,32 @@ public: break; case DEC_S16_3: { + // X and Y are signed 16 bit, Z is unsigned 16 bit const s16 *s = (const s16 *)(data_ + decFmt_.posoff); - for (int i = 0; i < 3; i++) - pos[i] = s[i] * (1.f / 32767.f); + const u16 *u = (const u16 *)(data_ + decFmt_.posoff); + if ((vtype_ >> 23) & 0x1) { + for (int i = 0; i < 2; i++) + pos[i] = s[i] ; + pos[2] = u[2] ; + } else { + for (int i = 0; i < 3; i++) + pos[i] = s[i] * (1.f / 32767.f); + } } break; case DEC_S8_3: { + // X and Y are signed 8 bit, Z is unsigned 8 bit const s8 *b = (const s8 *)(data_ + decFmt_.posoff); - for (int i = 0; i < 3; i++) - pos[i] = b[i] * (1.f / 127.f); + const u8 *u = (const u8 *)(data_ + decFmt_.posoff); + if ((vtype_ >> 23) & 0x1) { + for (int i = 0; i < 2; i++) + pos[i] = b[i] ; + pos[2] = u[2] ; + } else { + for (int i = 0; i < 3; i++) + pos[i] = b[i] * (1.f / 127.f); + } } break; default: