From 3b53691e4b64fa6a8e27955f430915043a710a09 Mon Sep 17 00:00:00 2001 From: Dave Date: Mon, 17 Apr 2023 19:33:59 +0200 Subject: [PATCH] Change float colors to GLubyte in cubes sample --- samples/cubes/main.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/samples/cubes/main.cpp b/samples/cubes/main.cpp index 2fe6329..eaeeaea 100644 --- a/samples/cubes/main.cpp +++ b/samples/cubes/main.cpp @@ -28,27 +28,25 @@ bool isDrawingArrays = false; bool isBlendingEnabled = true; bool isRunning = true; - typedef struct { - float r; - float g; - float b; - float a; + GLubyte r; + GLubyte g; + GLubyte b; + GLubyte a; } Color; Color colors[] = { - {1.0f, 0.0f, 0.0f, 0.5f}, // red - {0.0f, 1.0f, 0.0f, 0.5f}, // green - {0.0f, 0.0f, 1.0f, 0.5f}, // blue - {1.0f, 1.0f, 0.0f, 0.5f}, // yellow - {1.0f, 0.0f, 1.0f, 0.5f}, // magenta - {0.0f, 1.0f, 1.0f, 0.5f} // cyan + {255, 0, 0, 128}, + {0, 255, 0, 128}, + {0, 0, 255, 128}, + {255, 255, 0, 128}, + {255, 0, 255, 128}, + {0, 255, 255, 128} }; Color faceColors[24]; - float cubeVertices[] = { // Front face @@ -210,7 +208,7 @@ void renderUnitCube() glEnableClientState(GL_COLOR_ARRAY); glVertexPointer(3, GL_FLOAT, 0, cubeVertices); - glColorPointer(4, GL_FLOAT, 0, faceColors); + glColorPointer(4, GL_UNSIGNED_BYTE, 0, faceColors); if (isDrawingArrays) { glDrawArrays(GL_QUADS, 0, 24);