From: Ondřej Hošek Date: Sat, 29 Oct 2005 20:26:20 +0000 (+0000) Subject: * Fixed gradient background bug X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=df5f7a082ae943e7b326d4e28dc6e0efdabdf96f;p=supertux.git * Fixed gradient background bug * Users are warned if a component of the background colour is higher than 1.0 * In Color::Color(std::vector), alpha is now set to 1.0 by default. * Fixed a mistake in Background::write * Fixed all converted levels to color range 0.0-1.0 from 0-255 SVN-Revision: 2927 --- diff --git a/data/levels/bonus1/bonus-level4.stl b/data/levels/bonus1/bonus-level4.stl index 883a7e7b3..5d6bde112 100644 --- a/data/levels/bonus1/bonus-level4.stl +++ b/data/levels/bonus1/bonus-level4.stl @@ -80,8 +80,8 @@ ) ) (background - (top_color 50 50 50) - (bottom_color 50 50 50) + (top_color 0.2 0.2 0.2) + (bottom_color 0.2 0.2 0.2) ) (leveltime (time 300) diff --git a/data/levels/bonus1/bonus-level5.stl b/data/levels/bonus1/bonus-level5.stl index 613d8f464..3dc7f5ecc 100644 --- a/data/levels/bonus1/bonus-level5.stl +++ b/data/levels/bonus1/bonus-level5.stl @@ -80,8 +80,8 @@ ) ) (background - (top_color 0 0 0) - (bottom_color 0 0 0) + (top_color 0.0 0.0 0.0) + (bottom_color 0.0 0.0 0.0) ) (leveltime (time 500) diff --git a/data/levels/bonus1/matr1x-level1.stl b/data/levels/bonus1/matr1x-level1.stl index d344cb42d..5d8af1de4 100644 --- a/data/levels/bonus1/matr1x-level1.stl +++ b/data/levels/bonus1/matr1x-level1.stl @@ -80,8 +80,8 @@ ) ) (background - (top_color 0 0 255) - (bottom_color 255 255 255) + (top_color 0.0 0.0 1.0) + (bottom_color 1.0 1.0 1.0) ) (leveltime (time 180) diff --git a/data/levels/bonus1/matr1x-level2.stl b/data/levels/bonus1/matr1x-level2.stl index 31e0c5c44..fe0f9db98 100644 --- a/data/levels/bonus1/matr1x-level2.stl +++ b/data/levels/bonus1/matr1x-level2.stl @@ -80,8 +80,8 @@ ) ) (background - (top_color 255 255 255) - (bottom_color 0 0 255) + (top_color 1.0 1.0 1.0) + (bottom_color 0.0 0.0 1.0) ) (leveltime (time 250) diff --git a/data/levels/bonus1/matr1x-level3.stl b/data/levels/bonus1/matr1x-level3.stl index 24ff42937..38684b977 100644 --- a/data/levels/bonus1/matr1x-level3.stl +++ b/data/levels/bonus1/matr1x-level3.stl @@ -80,8 +80,8 @@ ) ) (background - (top_color 88 88 100) - (bottom_color 88 88 100) + (top_color 0.35 0.35 0.4) + (bottom_color 0.35 0.35 0.4) ) (leveltime (time 250) diff --git a/data/levels/bonus1/wansti-level3.stl b/data/levels/bonus1/wansti-level3.stl index f943b5b30..a6f627014 100644 --- a/data/levels/bonus1/wansti-level3.stl +++ b/data/levels/bonus1/wansti-level3.stl @@ -81,8 +81,8 @@ ) ) (background - (top_color 150 200 255) - (bottom_color 150 200 255) + (top_color 0.6 0.8 1.0) + (bottom_color 0.6 0.8 1.0) ) (leveltime (time 300) diff --git a/data/levels/bonus1/wansti-level5.stl b/data/levels/bonus1/wansti-level5.stl index 66445586e..67e754487 100644 --- a/data/levels/bonus1/wansti-level5.stl +++ b/data/levels/bonus1/wansti-level5.stl @@ -81,8 +81,8 @@ ) ) (background - (top_color 60 70 110) - (bottom_color 0 10 120) + (top_color 0.2 0.25 0.4) + (bottom_color 0.0 0.05 0.5) ) (leveltime (time 300) diff --git a/data/levels/bonus2/level16.stl b/data/levels/bonus2/level16.stl index 756cfdc9f..b3d4d2bc7 100644 --- a/data/levels/bonus2/level16.stl +++ b/data/levels/bonus2/level16.stl @@ -80,8 +80,8 @@ ) ) (background - (top_color 200 150 50) - (bottom_color 0 150 150) + (top_color 0.8 0.6 0.2) + (bottom_color 0.0 0.6 0.6) ) (leveltime (time 300) diff --git a/data/levels/bonus2/level17.stl b/data/levels/bonus2/level17.stl index 888927a9a..7c8e06dff 100644 --- a/data/levels/bonus2/level17.stl +++ b/data/levels/bonus2/level17.stl @@ -1,4 +1,5 @@ ;; Converted by Ondra Hosek +;; FIXME: Doesn't seem to have a normal exit (supertux-level (version 2) (name (_ "...Where Everything Is Possible")) @@ -80,8 +81,8 @@ ) ) (background - (top_color 150 200 255) - (bottom_color 150 200 255) + (top_color 0.6 0.8 1.0) + (bottom_color 0.6 0.8 1.0) ) (leveltime (time 300) diff --git a/data/levels/bonus2/level21.stl b/data/levels/bonus2/level21.stl index 201c9a3fd..d397bd7b0 100644 --- a/data/levels/bonus2/level21.stl +++ b/data/levels/bonus2/level21.stl @@ -38,8 +38,8 @@ ) ) (background - (top_color 0 0 0) - (bottom_color 204 0 0) + (top_color 0.0 0.0 0.0) + (bottom_color 0.8 0.0 0.0) ) (leveltime (time 300) diff --git a/data/levels/bonus2/level24.stl b/data/levels/bonus2/level24.stl index d4a9a3d5f..e0a3ea793 100644 --- a/data/levels/bonus2/level24.stl +++ b/data/levels/bonus2/level24.stl @@ -81,8 +81,8 @@ ) ) (background - (top_color 100 150 255) - (bottom_color 255 255 255) + (top_color 0.4 0.6 1.0) + (bottom_color 1.0 1.0 1.0) ) (leveltime (time 300) diff --git a/data/levels/bonus2/level27.stl b/data/levels/bonus2/level27.stl index fb26f86ba..b3f968ab0 100644 --- a/data/levels/bonus2/level27.stl +++ b/data/levels/bonus2/level27.stl @@ -80,8 +80,8 @@ ) ) (background - (top_color 100 150 255) - (bottom_color 255 255 255) + (top_color 0.4 0.6 1.0) + (bottom_color 1.0 1.0 1.0) ) (leveltime (time 400) diff --git a/data/levels/bonus2/level6.stl b/data/levels/bonus2/level6.stl index b12d6ac80..f184a362b 100644 --- a/data/levels/bonus2/level6.stl +++ b/data/levels/bonus2/level6.stl @@ -38,8 +38,8 @@ ) ) (background - (top_color 100 100 255) - (bottom_color 255 255 255) + (top_color 0.4 0.4 1.0) + (bottom_color 1.0 1.0 1.0) ) (leveltime (time 200) diff --git a/data/levels/world1/level11.stl b/data/levels/world1/level11.stl index aabe1ed76..8b20bb9f7 100644 --- a/data/levels/world1/level11.stl +++ b/data/levels/world1/level11.stl @@ -93,8 +93,8 @@ ) ) (background - (top_color 0 0 0) - (bottom_color 0 0 100) + (top_color 0.0 0.0 0.0) + (bottom_color 0.0 0.0 0.4) ) (leveltime (time 300) diff --git a/data/levels/world1/level12.stl b/data/levels/world1/level12.stl index b0c48031f..041121fa2 100644 --- a/data/levels/world1/level12.stl +++ b/data/levels/world1/level12.stl @@ -93,8 +93,8 @@ ) ) (background - (top_color 0 0 0) - (bottom_color 0 0 100) + (top_color 0.0 0.0 0.0) + (bottom_color 0.0 0.0 0.4) ) (leveltime (time 300) diff --git a/data/levels/world1/level13.stl b/data/levels/world1/level13.stl index f3add9216..10dfae3a9 100644 --- a/data/levels/world1/level13.stl +++ b/data/levels/world1/level13.stl @@ -94,8 +94,8 @@ ) ) (background - (top_color 100 150 255) - (bottom_color 255 255 255) + (top_color 0.4 0.6 1.0) + (bottom_color 1.0 1.0 1.0) ) (leveltime (time 200) diff --git a/data/levels/world1/level26.stl b/data/levels/world1/level26.stl index fbe1cdccb..8e010aa9f 100644 --- a/data/levels/world1/level26.stl +++ b/data/levels/world1/level26.stl @@ -92,8 +92,8 @@ ) ) (background - (top_color 0 0 0) - (bottom_color 150 0 0) + (top_color 0.0 0.0 0.0) + (bottom_color 0.6 0.0 0.0) ) (leveltime (time 300) diff --git a/src/object/background.cpp b/src/object/background.cpp index 7c43cfad9..025adbc4c 100644 --- a/src/object/background.cpp +++ b/src/object/background.cpp @@ -69,9 +69,9 @@ Background::write(lisp::Writer& writer) bkgd_top_color.push_back(gradient_top.red); bkgd_top_color.push_back(gradient_top.green); bkgd_top_color.push_back(gradient_top.blue); - bkgd_bottom_color.push_back(gradient_top.red); - bkgd_bottom_color.push_back(gradient_top.green); - bkgd_bottom_color.push_back(gradient_top.blue); + bkgd_bottom_color.push_back(gradient_bottom.red); + bkgd_bottom_color.push_back(gradient_bottom.green); + bkgd_bottom_color.push_back(gradient_bottom.blue); writer.write_float_vector("top_color", bkgd_top_color); writer.write_float_vector("bottom_color", bkgd_bottom_color); } @@ -102,6 +102,13 @@ Background::set_gradient(Color top, Color bottom) type = GRADIENT; gradient_top = top; gradient_bottom = bottom; + + if (gradient_top.red > 1.0 || gradient_top.green > 1.0 + || gradient_top.blue > 1.0 || gradient_top.alpha > 1.0) + std::cerr << "Warning: top gradient color has values above 1.0." << std::endl; + if (gradient_bottom.red > 1.0 || gradient_bottom.green > 1.0 + || gradient_bottom.blue > 1.0 || gradient_bottom.alpha > 1.0) + std::cerr << "Warning: bottom gradient color has values above 1.0." << std::endl; delete image; image = NULL; diff --git a/src/video/color.hpp b/src/video/color.hpp index 18f8849db..7cbbd7206 100644 --- a/src/video/color.hpp +++ b/src/video/color.hpp @@ -19,6 +19,8 @@ public: blue = vals[2]; if(vals.size() > 3) alpha = vals[3]; + else + alpha = 1.0; } float red, green, blue, alpha; diff --git a/src/video/drawing_context.cpp b/src/video/drawing_context.cpp index 6f1aee1fd..c231e4bb8 100644 --- a/src/video/drawing_context.cpp +++ b/src/video/drawing_context.cpp @@ -225,6 +225,7 @@ DrawingContext::draw_gradient(DrawingRequest& request) const Color& top = gradientrequest->top; const Color& bottom = gradientrequest->bottom; + glDisable(GL_TEXTURE_2D); glBegin(GL_QUADS); glColor4f(top.red, top.green, top.blue, top.alpha); glVertex2f(0, 0); @@ -233,6 +234,7 @@ DrawingContext::draw_gradient(DrawingRequest& request) glVertex2f(SCREEN_WIDTH, SCREEN_HEIGHT); glVertex2f(0, SCREEN_HEIGHT); glEnd(); + glEnable(GL_TEXTURE_2D); delete gradientrequest; }