From bd602b20ebbcad5d03fa7ec6cd63fc1bdda93239 Mon Sep 17 00:00:00 2001 From: cxl Date: Thu, 17 Oct 2013 18:42:29 +0000 Subject: [PATCH] .rainbow: developing GLES git-svn-id: svn://ultimatepp.org/upp/trunk@6442 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- rainbow/SDLGLDraw/main.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/rainbow/SDLGLDraw/main.cpp b/rainbow/SDLGLDraw/main.cpp index 789d6ba60..c34a7b264 100644 --- a/rainbow/SDLGLDraw/main.cpp +++ b/rainbow/SDLGLDraw/main.cpp @@ -126,7 +126,7 @@ void initializeGL() "void main() \n" "{ \n" " gl_Position = u_projection * a_position; \n" - " v_color = a_color; \n" + " v_color = a_color * vec4((1.0 / 255.0), (1.0 / 255.0), (1.0 / 255.0), 1); \n" "}", "#ifdef GL_ES\n" @@ -179,10 +179,17 @@ void GLRect(Size sz, const Rect& rect, const Color& color) rect.right, rect.bottom, rect.right, rect.top, }; - float r = color.GetR() / 255.0; - float g = color.GetG() / 255.0; - float b = color.GetB() / 255.0; - float colors[] = { + +// float h = 128.0; +// GLfloat r = color.GetR() / h; +// GLfloat g = color.GetG() / h; +// GLfloat b = color.GetB() / h; + + GLint r = color.GetR(); + GLint g = color.GetG(); + GLint b = color.GetB(); + + GLfloat colors[] = { r, g, b, r, g, b, r, g, b, @@ -191,7 +198,7 @@ void GLRect(Size sz, const Rect& rect, const Color& color) GLushort indices[] = { 0, 1, 2, 0, 2, 3 }; glVertexAttribPointer(m_posLoc2, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), vertexCoords ); - glVertexAttribPointer(m_colorLoc, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), colors ); + glVertexAttribPointer(m_colorLoc, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLint), colors); glEnableVertexAttribArray(m_posLoc2); glEnableVertexAttribArray(m_colorLoc); @@ -252,7 +259,7 @@ void paintGL(Size sz) for(int i = 0; i < 10; i++) for(int j = 0; j < 10; j++) - GLRect(sz, RectC(i * 16, j * 16, 12, 12), LtRed()); + GLRect(sz, RectC(i * 16, j * 16, 12, 12), decode(i, 0, LtBlue(), 1, White(), LtRed())); // CheckError(); }