From 171ca9a657c639ec169058c798de596c01775086 Mon Sep 17 00:00:00 2001 From: Bim Overbohm Date: Thu, 27 Jun 2013 12:31:16 +0200 Subject: [PATCH] Slightly better color array function Converting only once should be faster. --- src/Renderer_draw_gl.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Renderer_draw_gl.cpp b/src/Renderer_draw_gl.cpp index 22dcf4c1e..afa0b1d4b 100644 --- a/src/Renderer_draw_gl.cpp +++ b/src/Renderer_draw_gl.cpp @@ -14,18 +14,22 @@ namespace Renderer { void setColor4bArray(GLubyte* array, unsigned int color) { - array[0] = (color & 0xff000000) / 0x1000000; - array[1] = (color & 0x00ff0000) / 0x10000; - array[2] = (color & 0x0000ff00) / 0x100; + array[0] = (color & 0xff000000) >> 24; + array[1] = (color & 0x00ff0000) >> 16; + array[2] = (color & 0x0000ff00) >> 8; array[3] = (color & 0x000000ff); } void buildGLColorArray(GLubyte* ptr, unsigned int color, unsigned int vertCount) { + //convert color from ???? to RGBA? + unsigned int colorRGBA; + setColor4bArray((GLubyte *)&colorRGBA, color); + //write color to unsigned int array + GLuint * uiPtr = (GLuint *)ptr; for(unsigned int i = 0; i < vertCount; i++) { - setColor4bArray(ptr, color); - ptr += 4; + uiPtr[i] = colorRGBA; } }