+++ /dev/null
-// $Id$
-//
-// SuperTux
-// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#ifndef __AMBIENT_LIGHT_HPP__
-#define __AMBIENT_LIGHT_HPP__
-
-#include "game_object.hpp"
-#include "lisp/lisp.hpp"
-
-class Sprite;
-
-class AmbientLight : public GameObject
-{
-public:
- AmbientLight(const lisp::Lisp& reader);
- virtual ~AmbientLight();
-
- void update(float elapsed_time);
- void draw(DrawingContext& context);
-};
-
-#endif
bool Sector::draw_solids_only = false;
Sector::Sector(Level* parent)
- : level(parent), currentmusic(LEVEL_MUSIC), gravity(10),
- player(0), camera(0)
+ : level(parent), currentmusic(LEVEL_MUSIC),
+ ambient_light( 1.0f, 1.0f, 1.0f, 1.0f ), gravity(10), player(0), camera(0)
{
add_object(new Player(player_status, "Tux"));
add_object(new DisplayEffect("Effect"));
spawnpoints.push_back(sp);
} else if(token == "init-script") {
iter.value()->get(init_script);
+ } else if(token == "ambient-light") {
+ std::vector<float> vColor;
+ sector.get_vector( "ambient-light", vColor );
+ ambient_light = Color( vColor );
} else {
GameObject* object = parse_object(token, *(iter.lisp()));
if(object) {
void
Sector::draw(DrawingContext& context)
{
+ context.set_ambient_color( ambient_light );
context.push_transform();
context.set_translation(camera->get_translation());
typedef std::vector<HSQOBJECT> ScriptList;
ScriptList scripts;
+ Color ambient_light;
+
public: // TODO make this private again
/// show collision rectangles of moving objects (for debugging)
static bool show_collrects;
return result;
}
-DrawingContext::DrawingContext()
+DrawingContext::DrawingContext():
+ ambient_color( 1.0f, 1.0f, 1.0f, 1.0f )
{
screen = SDL_GetVideoSurface();
transformstack.clear();
target_stack.clear();
- bool use_lightmap = lightmap_requests.size() != 0;
+ //Use Lightmap if ambient color is not white.
+ bool use_lightmap = ( ambient_color.red != 1.0f || ambient_color.green != 1.0f ||
+ ambient_color.blue != 1.0f );
// PART1: create lightmap
if(use_lightmap) {
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- // FIXME: Add ambient light support here
- glClearColor(0.3, 0.3, 0.4, 1);
+ glClearColor( ambient_color.red, ambient_color.green, ambient_color.blue, 1 );
glClear(GL_COLOR_BUFFER_BIT);
handle_drawing_requests(lightmap_requests);
lightmap_requests.clear();
else
requests = &drawing_requests;
}
+
+void
+DrawingContext::set_ambient_color( Color new_color )
+{
+ ambient_color = new_color;
+}
void push_target();
void pop_target();
void set_target(Target target);
+
+ void set_ambient_color( Color new_color );
private:
class Transform
DrawingRequests lightmap_requests;
DrawingRequests* requests;
+ Color ambient_color;
SDL_Surface* screen;
Target target;