From 9960f7335136906ddeeba34a4c99ea6faaedf464 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sat, 21 Apr 2012 22:32:24 +0000 Subject: [PATCH] gpu: normalize 8-bit integer data in 0..1 by default. --- src/gpu/vertexbuffer.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gpu/vertexbuffer.cpp b/src/gpu/vertexbuffer.cpp index 29c5bac3..016e6861 100644 --- a/src/gpu/vertexbuffer.cpp +++ b/src/gpu/vertexbuffer.cpp @@ -294,8 +294,13 @@ void VertexDeclaration::SetStream(VertexBuffer *vb, ShaderAttrib attr1, if (type_index < 0 || type_index >= sizeof(tlut) / sizeof(*tlut)) type_index = 0; + /* Normalize unsigned bytes by default, because it's usually + * some color information. */ + GLboolean normalize = (tlut[type_index].type == GL_UNSIGNED_BYTE) + || (tlut[type_index].type == GL_BYTE); + glVertexAttribPointer((GLint)reg, tlut[type_index].size, - tlut[type_index].type, GL_FALSE, + tlut[type_index].type, normalize, stride, (GLvoid const *)(uintptr_t)offset); } #endif