From b2bf9e6594d4a99dedb04b3761d12f183cb3853f Mon Sep 17 00:00:00 2001 From: mathnerd314 Date: Mon, 28 Dec 2009 05:19:55 +0000 Subject: [PATCH] include fixes from ohnobinki, video_systems.cpp should fall back to SDL now if GL fails. git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6229 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- data/levels/world2/airkey.stl | 30 ++++++++---------------------- src/badguy/badguy.cpp | 5 +++-- src/badguy/dispenser.cpp | 2 ++ src/gui/button.cpp | 2 +- src/gui/button_group.cpp | 4 ++-- src/gui/menu.cpp | 12 +++++------- src/gui/menu.hpp | 9 ++++----- src/math/size.hpp | 8 +++++++- src/math/sizef.hpp | 20 ++++++++++++++++++++ src/object/background.cpp | 2 ++ src/object/bonus_block.cpp | 2 ++ src/object/gradient.cpp | 2 ++ src/object/ispy.cpp | 2 ++ src/object/moving_sprite.cpp | 2 ++ src/object/powerup.cpp | 2 ++ src/object/pushbutton.cpp | 3 +++ src/object/sprite_particle.cpp | 2 ++ src/object/tilemap.cpp | 32 ++++++++++++++++---------------- src/sprite/sprite_manager.cpp | 4 ++++ src/supertux/globals.hpp | 10 +++------- src/supertux/level.cpp | 3 +++ src/supertux/levelintro.cpp | 2 ++ src/supertux/menu/options_menu.cpp | 5 +++-- src/supertux/player_status.cpp | 1 + src/supertux/textscroller.cpp | 3 +++ src/supertux/title_screen.cpp | 1 + src/trigger/switch.cpp | 2 ++ src/video/font.cpp | 1 + src/video/sdl/sdl_renderer.cpp | 10 ++++++---- src/video/texture_manager.cpp | 8 +++++++- src/video/video_systems.cpp | 26 ++++++++++++++++---------- 31 files changed, 137 insertions(+), 80 deletions(-) diff --git a/data/levels/world2/airkey.stl b/data/levels/world2/airkey.stl index cdf78eed0..7ec1a4658 100644 --- a/data/levels/world2/airkey.stl +++ b/data/levels/world2/airkey.stl @@ -30,9 +30,9 @@ (initial-delay 0) (fire-delay 2) (ammo -1) + (direction "left") (x 2484) (y 2554.679) - (direction "left") ) (door (sector "main") @@ -63,8 +63,6 @@ (platform (name "final_lift") (running #f) - (x 6464) - (y 384) (sprite "images/objects/platforms/small.sprite") (path (node @@ -82,8 +80,6 @@ (platform (name "blocker1") (running #f) - (x 2912) - (y 2144) (sprite "images/objects/platforms/vertical-wood.sprite") (path (node @@ -99,8 +95,6 @@ (platform (name "blocker2") (running #f) - (x 2944) - (y 2144) (sprite "images/objects/platforms/vertical-wood.sprite") (path (node @@ -116,8 +110,6 @@ (platform (name "blocker4") (running #f) - (x 3008) - (y 2144) (sprite "images/objects/platforms/vertical-wood.sprite") (path (node @@ -133,8 +125,6 @@ (platform (name "blocker5") (running #f) - (x 3040) - (y 2144) (sprite "images/objects/platforms/vertical-wood.sprite") (path (node @@ -150,8 +140,6 @@ (platform (name "blocker6") (running #f) - (x 3072) - (y 2144) (sprite "images/objects/platforms/vertical-wood.sprite") (path (node @@ -167,8 +155,6 @@ (platform (name "blocker3") (running #f) - (x 2976) - (y 2144) (sprite "images/objects/platforms/vertical-wood.sprite") (path (node @@ -202,9 +188,9 @@ (y 800) ) (mrbomb + (direction "left") (x 1184) (y 2464) - (direction "left") ) (mrbomb (x 4128) @@ -231,9 +217,9 @@ (y 2144) ) (poisonivy + (direction "right") (x 4512) (y 2368) - (direction "right") ) (poisonivy (x 4706) @@ -246,14 +232,14 @@ wait(0.5); Tux.do_cheer(); end_level(); ") + (sprite "images/objects/keys/key_air.sprite") (x 6608) (y 80) - (sprite "images/objects/keys/key_air.sprite") ) (powerup + (sprite "images/powerups/fireflower/fireflower.sprite") (x 3008) (y 544) - (sprite "images/powerups/fireflower/fireflower.sprite") ) (scripttrigger (script "final_lift.goto_node(0);") @@ -300,9 +286,9 @@ end_level(); (y 480) ) (sspiky + (direction "left") (x 4576) (y 704) - (direction "left") ) (snail (x 3456) @@ -338,9 +324,9 @@ end_level(); Tux.activate(); this.door_opened <- true; }") + (sprite "images/objects/switch/right.sprite") (x 2688) (y 2464) - (sprite "images/objects/switch/right.sprite") ) (tilemap (solid #f) @@ -949,9 +935,9 @@ end_level(); (y 2270) ) (walkingleaf + (direction "right") (x 4706) (y 2400) - (direction "right") ) (walkingleaf (x 5090) diff --git a/src/badguy/badguy.cpp b/src/badguy/badguy.cpp index 09fba678f..b30e1d3c1 100644 --- a/src/badguy/badguy.cpp +++ b/src/badguy/badguy.cpp @@ -16,8 +16,6 @@ #include "badguy/badguy.hpp" -#include - #include "audio/sound_manager.hpp" #include "object/bullet.hpp" #include "object/player.hpp" @@ -26,6 +24,9 @@ #include "supertux/tile.hpp" #include "util/reader.hpp" +#include +#include + static const float SQUISH_TIME = 2; static const float X_OFFSCREEN_DISTANCE = 1600; diff --git a/src/badguy/dispenser.cpp b/src/badguy/dispenser.cpp index d19815f26..732e732fc 100644 --- a/src/badguy/dispenser.cpp +++ b/src/badguy/dispenser.cpp @@ -24,6 +24,8 @@ #include "supertux/sector.hpp" #include "util/reader.hpp" +#include + Dispenser::Dispenser(const Reader& reader) : BadGuy(reader, "images/creatures/dispenser/dispenser.sprite"), cycle(), diff --git a/src/gui/button.cpp b/src/gui/button.cpp index 587b1e315..1a89d34d6 100644 --- a/src/gui/button.cpp +++ b/src/gui/button.cpp @@ -78,7 +78,7 @@ void Button::draw(DrawingContext &context, bool selected) if(state == BT_SHOW_INFO) { Vector offset; - if(pos.x + tanslation.x < 100 && pos.y + tanslation.y > SCREEN_HEIGHT - 20) + if(pos.x + tanslation.x < 100 && pos.y + tanslation.y > SCREEN_SIZE.height - 20) offset = Vector(size.x, - 10); else if(pos.x + tanslation.x < 100) offset = Vector(size.x, 0); diff --git a/src/gui/button_group.cpp b/src/gui/button_group.cpp index 0a2c7edd1..9727fb8cd 100644 --- a/src/gui/button_group.cpp +++ b/src/gui/button_group.cpp @@ -103,8 +103,8 @@ ButtonGroup::event(SDL_Event &event) if(mouse_left_button) { - pos.x += int(event.motion.xrel * float(SCREEN_WIDTH)/g_screen->w); - pos.y += int(event.motion.yrel * float(SCREEN_HEIGHT)/g_screen->h); + pos.x += int(event.motion.xrel * float(SCREEN_SIZE.width)/g_screen->w); + pos.y += int(event.motion.yrel * float(SCREEN_SIZE.height)/g_screen->h); caught_event = true; } if(event.button.x > pos.x-12 && event.button.x < pos.x+16 + buttons_box.x*buttons_size.x && diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp index e086afc1c..01be2c79b 100644 --- a/src/gui/menu.cpp +++ b/src/gui/menu.cpp @@ -17,6 +17,7 @@ #include "gui/menu.hpp" #include +#include #include "control/joystickkeyboardcontroller.hpp" #include "gui/menu_item.hpp" @@ -35,8 +36,7 @@ static const float MENU_REPEAT_RATE = 0.1f; Menu::Menu() : hit_item(), - pos_x(), - pos_y(), + pos(), menuaction(), delete_character(), mn_input_char(), @@ -60,8 +60,7 @@ Menu::Menu() : delete_character = 0; mn_input_char = '\0'; - pos_x = SCREEN_WIDTH/2; - pos_y = SCREEN_HEIGHT/2; + pos = SCREEN_SIZE/2.0f; arrange_left = 0; active_item = -1; @@ -93,10 +92,9 @@ Menu::~Menu() } void -Menu::set_pos(float x, float y, float rw, float rh) +Menu::set_pos(Vector loc, Vector r) { - pos_x = x + get_width() * rw; - pos_y = y + get_height() * rh; + pos = loc + get_size() * r; } /* Add an item to a menu */ diff --git a/src/gui/menu.hpp b/src/gui/menu.hpp index 5c97fa1fb..0ab66c6cc 100644 --- a/src/gui/menu.hpp +++ b/src/gui/menu.hpp @@ -21,6 +21,7 @@ #include #include +#include "math/sizef.hpp" #include "video/color.hpp" #include "video/surface_ptr.hpp" @@ -90,7 +91,7 @@ public: void set_active_item(int id); void draw(DrawingContext& context); - void set_pos(float x, float y, float rw = 0, float rh = 0); + void set_pos(Vector loc, Vector r = Vector(0,0)); void event(const SDL_Event& event); @@ -101,8 +102,7 @@ public: protected: void additem(MenuItem* pmenu_item); - float get_width() const; - float get_height() const; + Sizef get_size() const; private: void check_controlfield_change_event(const SDL_Event& event); @@ -114,8 +114,7 @@ private: int hit_item; // position of the menu (ie. center of the menu, not top/left) - float pos_x; - float pos_y; + Vector pos; /** input event for the menu (up, down, left, right, etc.) */ MenuAction menuaction; diff --git a/src/math/size.hpp b/src/math/size.hpp index 81983d6f5..91a7868e1 100644 --- a/src/math/size.hpp +++ b/src/math/size.hpp @@ -19,7 +19,7 @@ #include -class Sizef; +#include "math/vector.hpp" class Size { @@ -92,6 +92,12 @@ inline Size operator/(const Size& lhs, int divisor) lhs.height / divisor); } +inline Vector operator/(const Size& lhs, float divisor) +{ + return Vector(lhs.width / divisor, + lhs.height / divisor); +} + inline Size operator+(const Size& lhs, const Size& rhs) { return Size(lhs.width + rhs.width, diff --git a/src/math/sizef.hpp b/src/math/sizef.hpp index e03aeb03c..e9580f6eb 100644 --- a/src/math/sizef.hpp +++ b/src/math/sizef.hpp @@ -19,6 +19,8 @@ #include +#include "math/vector.hpp" + class Size; class Sizef @@ -98,6 +100,24 @@ inline Sizef operator+(const Sizef& lhs, const Sizef& rhs) lhs.height + rhs.height); } +inline Vector operator+(const Vector& lhs, const Sizef& rhs) const +{ + return Vector(lhs.x + rhs.width, + lhs.y + rhs.height); +} + +inline Vector operator*(const Vector& lhs, const Sizef& rhs) const +{ + return Vector(lhs.x * rhs.width, + lhs.y * rhs.height); +} + +inline Vector operator*(const Sizefr& lhs, const Vector& rhs) const +{ + return Vector(lhs.width * rhs.x, + lhs.height * rhs.y); +} + inline Sizef operator-(const Sizef& lhs, const Sizef& rhs) { return Sizef(lhs.width - rhs.width, diff --git a/src/object/background.cpp b/src/object/background.cpp index 597aa9d8d..67cf854e6 100644 --- a/src/object/background.cpp +++ b/src/object/background.cpp @@ -24,6 +24,8 @@ #include "util/log.hpp" #include "util/reader.hpp" +#include + Background::Background() : alignment(NO_ALIGNMENT), layer(LAYER_BACKGROUND0), diff --git a/src/object/bonus_block.cpp b/src/object/bonus_block.cpp index d612c7093..9a4117516 100644 --- a/src/object/bonus_block.cpp +++ b/src/object/bonus_block.cpp @@ -34,6 +34,8 @@ #include "supertux/object_factory.hpp" #include "supertux/sector.hpp" +#include + BonusBlock::BonusBlock(const Vector& pos, int data) : Block(sprite_manager->create("images/objects/bonus_block/bonusblock.sprite")), contents(), diff --git a/src/object/gradient.cpp b/src/object/gradient.cpp index 7e325b1ee..f259c08ad 100644 --- a/src/object/gradient.cpp +++ b/src/object/gradient.cpp @@ -18,6 +18,8 @@ #include "supertux/object_factory.hpp" #include "util/reader.hpp" +#include + Gradient::Gradient() : layer(LAYER_BACKGROUND0), gradient_top(), diff --git a/src/object/ispy.cpp b/src/object/ispy.cpp index b4461de7b..dbdce6541 100644 --- a/src/object/ispy.cpp +++ b/src/object/ispy.cpp @@ -24,6 +24,8 @@ #include "supertux/tile.hpp" #include "util/reader.hpp" +#include + Ispy::Ispy(const Reader& reader) : MovingSprite(reader, "images/objects/ispy/ispy.sprite", LAYER_TILES+5, COLGROUP_DISABLED), state(ISPYSTATE_IDLE), diff --git a/src/object/moving_sprite.cpp b/src/object/moving_sprite.cpp index 4f06e07fb..b98972f35 100644 --- a/src/object/moving_sprite.cpp +++ b/src/object/moving_sprite.cpp @@ -19,6 +19,8 @@ #include "sprite/sprite_manager.hpp" #include "util/reader.hpp" +#include + MovingSprite::MovingSprite(const Vector& pos, const std::string& sprite_name, int layer, CollisionGroup collision_group) : sprite_name(sprite_name), diff --git a/src/object/powerup.cpp b/src/object/powerup.cpp index a5e384acc..eb9cd5c7f 100644 --- a/src/object/powerup.cpp +++ b/src/object/powerup.cpp @@ -21,6 +21,8 @@ #include "supertux/sector.hpp" #include "util/reader.hpp" +#include + PowerUp::PowerUp(const Reader& lisp) : MovingSprite(lisp, LAYER_OBJECTS, COLGROUP_MOVING), physic(), diff --git a/src/object/pushbutton.cpp b/src/object/pushbutton.cpp index 07190c280..454966cb8 100644 --- a/src/object/pushbutton.cpp +++ b/src/object/pushbutton.cpp @@ -22,6 +22,9 @@ #include "supertux/sector.hpp" #include "util/reader.hpp" +#include +#include + namespace { const std::string BUTTON_SOUND = "sounds/switch.ogg"; //14 -> 8 diff --git a/src/object/sprite_particle.cpp b/src/object/sprite_particle.cpp index 21725d8eb..514527ebf 100644 --- a/src/object/sprite_particle.cpp +++ b/src/object/sprite_particle.cpp @@ -20,6 +20,8 @@ #include "supertux/globals.hpp" #include "supertux/sector.hpp" +#include + SpriteParticle::SpriteParticle(std::string sprite_name, std::string action, Vector position, AnchorPoint anchor, Vector velocity, Vector acceleration, int drawing_layer) : diff --git a/src/object/tilemap.cpp b/src/object/tilemap.cpp index 0adbb86ab..b43ee331c 100644 --- a/src/object/tilemap.cpp +++ b/src/object/tilemap.cpp @@ -188,7 +188,7 @@ TileMap::update(float elapsed_time) void TileMap::draw(DrawingContext& context) { - // skip draw if current opacity is set to 0.0 + // skip draw if current opacity is 0.0 if (current_alpha == 0.0) return; context.push_transform(); @@ -200,25 +200,25 @@ TileMap::draw(DrawingContext& context) if(drawing_effect != 0) context.set_drawing_effect(drawing_effect); if(current_alpha != 1.0) context.set_alpha(current_alpha); - float trans_x = roundf(context.get_translation().x); - float trans_y = roundf(context.get_translation().y); - context.set_translation(Vector(int(trans_x * speed_x), - int(trans_y * speed_y))); + if(!solid) { + float trans_x = roundf(context.get_translation().x); + float trans_y = roundf(context.get_translation().y); + context.set_translation(Vector(int(trans_x * speed_x), + int(trans_y * speed_y))); + } - /** if we don't round here, we'll have a 1 pixel gap on screen sometimes. - * I have no idea why */ - float start_x = int((roundf(context.get_translation().x) - roundf(x_offset)) / 32) * 32 + roundf(x_offset); - float start_y = int((roundf(context.get_translation().y) - roundf(y_offset)) / 32) * 32 + roundf(y_offset); - float end_x = std::min(start_x + SCREEN_WIDTH + 32, float(width * 32 + roundf(x_offset))); - float end_y = std::min(start_y + SCREEN_HEIGHT + 32, float(height * 32 + roundf(y_offset))); - int tsx = int((start_x - roundf(x_offset)) / 32); // tilestartindex x - int tsy = int((start_y - roundf(y_offset)) / 32); // tilestartindex y + float start_x = context.get_translation().x; + float start_y = context.get_translation().y; + float end_x = start_x + SCREEN_WIDTH + 32; + float end_y = start_y + SCREEN_HEIGHT + 32; + int tsx = std::max(int((start_x - x_offset) / 32), 0); // tilestartindex x + int tsy = std::max(int((start_y - y_offset) / 32), 0); // tilestartindex y Vector pos; int tx, ty; - for(pos.x = start_x, tx = tsx; pos.x < end_x; pos.x += 32, ++tx) { - for(pos.y = start_y, ty = tsy; pos.y < end_y; pos.y += 32, ++ty) { - if ((tx < 0) || (ty < 0) || (tiles[ty*width + tx] == 0)) continue; + for(pos.x = start_x, tx = tsx; (pos.x < end_x) && (tx < width); pos.x += 32, ++tx) { + for(pos.y = start_y, ty = tsy; (pos.y < end_y) && (ty < height); pos.y += 32, ++ty) { + if (tiles[ty*width + tx] == 0) continue; const Tile* tile = tileset->get(tiles[ty*width + tx]); assert(tile != 0); tile->draw(context, pos, z_pos); diff --git a/src/sprite/sprite_manager.cpp b/src/sprite/sprite_manager.cpp index fd100b1b9..72d282ce7 100644 --- a/src/sprite/sprite_manager.cpp +++ b/src/sprite/sprite_manager.cpp @@ -21,6 +21,10 @@ #include "util/file_system.hpp" #include "util/reader.hpp" +#include +#include + + SpriteManager::SpriteManager() : sprites() { diff --git a/src/supertux/globals.hpp b/src/supertux/globals.hpp index 08a48304e..0fe3f794c 100644 --- a/src/supertux/globals.hpp +++ b/src/supertux/globals.hpp @@ -23,21 +23,17 @@ class Config; class JoystickKeyboardController; class PlayerStatus; class ScreenManager; +class Size; class SoundManager; class SpriteManager; class TextureManager; class TileManager; class TileSet; -/** The width of the display (this is a logical value, not the +/** The width/height of the display (this is a logical value, not the physical value, since aspect_ration and projection_area might shrink or scale things) */ -extern int SCREEN_WIDTH; - -/** The width of the display (this is a logical value, not the - physical value, since aspect_ration and projection_area might - shrink or scale things) */ -extern int SCREEN_HEIGHT; +extern Size SCREEN_SIZE; // global variables extern JoystickKeyboardController* g_main_controller; diff --git a/src/supertux/level.cpp b/src/supertux/level.cpp index 3b69137c2..e9d6e085b 100644 --- a/src/supertux/level.cpp +++ b/src/supertux/level.cpp @@ -25,6 +25,9 @@ #include "supertux/tile_set.hpp" #include "trigger/secretarea_trigger.hpp" +#include +#include + using namespace std; Level::Level() : diff --git a/src/supertux/levelintro.cpp b/src/supertux/levelintro.cpp index f7cb7d8da..257446ac8 100644 --- a/src/supertux/levelintro.cpp +++ b/src/supertux/levelintro.cpp @@ -25,6 +25,8 @@ #include "supertux/resources.hpp" #include "util/gettext.hpp" +#include + LevelIntro::LevelIntro(const Level* level, const Statistics* best_level_statistics) : level(level), best_level_statistics(best_level_statistics), diff --git a/src/supertux/menu/options_menu.cpp b/src/supertux/menu/options_menu.cpp index 66893cc70..c2cc42ca8 100644 --- a/src/supertux/menu/options_menu.cpp +++ b/src/supertux/menu/options_menu.cpp @@ -17,8 +17,6 @@ #include "supertux/menu/options_menu.hpp" -#include - #include "audio/sound_manager.hpp" #include "gui/menu_manager.hpp" #include "supertux/gameconfig.hpp" @@ -30,6 +28,9 @@ #include "util/string_util.hpp" #include "video/renderer.hpp" +#include +#include + enum OptionsMenuIDs { MNID_FULLSCREEN, MNID_FULLSCREEN_RESOLUTION, diff --git a/src/supertux/player_status.cpp b/src/supertux/player_status.cpp index 0f322cad9..eef573cd7 100644 --- a/src/supertux/player_status.cpp +++ b/src/supertux/player_status.cpp @@ -16,6 +16,7 @@ // along with this program. If not, see . #include +#include #include "audio/sound_manager.hpp" #include "util/writer.hpp" diff --git a/src/supertux/textscroller.cpp b/src/supertux/textscroller.cpp index 33002c3e9..f828bf0b0 100644 --- a/src/supertux/textscroller.cpp +++ b/src/supertux/textscroller.cpp @@ -27,6 +27,9 @@ #include "util/reader.hpp" #include "video/drawing_context.hpp" +#include +#include + static const float DEFAULT_SPEED = 20; static const float LEFT_BORDER = 50; static const float SCROLL = 60; diff --git a/src/supertux/title_screen.cpp b/src/supertux/title_screen.cpp index e5ea2915c..31dc2267d 100644 --- a/src/supertux/title_screen.cpp +++ b/src/supertux/title_screen.cpp @@ -39,6 +39,7 @@ #include "util/reader.hpp" #include "video/drawing_context.hpp" +#include #include TitleScreen::TitleScreen(PlayerStatus* player_status) : diff --git a/src/trigger/switch.cpp b/src/trigger/switch.cpp index a1cd864ca..53662c72b 100644 --- a/src/trigger/switch.cpp +++ b/src/trigger/switch.cpp @@ -24,6 +24,8 @@ #include "supertux/sector.hpp" #include "trigger/switch.hpp" +#include + namespace { const std::string SWITCH_SOUND = "sounds/switch.ogg"; } diff --git a/src/video/font.cpp b/src/video/font.cpp index 429b0a199..d9ccd08df 100644 --- a/src/video/font.cpp +++ b/src/video/font.cpp @@ -17,6 +17,7 @@ #include +#include #include #include #include diff --git a/src/video/sdl/sdl_renderer.cpp b/src/video/sdl/sdl_renderer.cpp index d769dc5f6..6d6a357a5 100644 --- a/src/video/sdl/sdl_renderer.cpp +++ b/src/video/sdl/sdl_renderer.cpp @@ -16,14 +16,16 @@ #include "video/sdl/sdl_renderer.hpp" -#include -#include -#include - #include "video/drawing_request.hpp" #include "video/sdl/sdl_surface_data.hpp" #include "video/sdl/sdl_texture.hpp" +#include +#include +#include +#include +#include + namespace { SDL_Surface *apply_alpha(SDL_Surface *src, float alpha_factor) diff --git a/src/video/texture_manager.cpp b/src/video/texture_manager.cpp index a7c32e4e9..e49423bf2 100644 --- a/src/video/texture_manager.cpp +++ b/src/video/texture_manager.cpp @@ -19,15 +19,21 @@ #include #include #include +#include +#include #include "math/rect.hpp" #include "physfs/physfs_sdl.hpp" #include "util/file_system.hpp" #include "util/log.hpp" -#include "video/gl/gl_texture.hpp" #include "video/sdl_surface_ptr.hpp" +#include "video/texture.hpp" #include "video/video_systems.hpp" +#ifdef HAVE_OPENGL +#include "video/gl/gl_texture.hpp" +#endif + TextureManager::TextureManager() : image_textures() #ifdef HAVE_OPENGL diff --git a/src/video/video_systems.cpp b/src/video/video_systems.cpp index b73996c3b..27fd41760 100644 --- a/src/video/video_systems.cpp +++ b/src/video/video_systems.cpp @@ -17,10 +17,6 @@ #include #include "supertux/gameconfig.hpp" -#include "video/gl/gl_lightmap.hpp" -#include "video/gl/gl_renderer.hpp" -#include "video/gl/gl_surface_data.hpp" -#include "video/gl/gl_texture.hpp" #include "video/lightmap.hpp" #include "video/renderer.hpp" #include "video/sdl/sdl_lightmap.hpp" @@ -30,6 +26,13 @@ #include "video/texture.hpp" #include "video/video_systems.hpp" +#ifdef HAVE_OPENGL +#include "video/gl/gl_lightmap.hpp" +#include "video/gl/gl_renderer.hpp" +#include "video/gl/gl_surface_data.hpp" +#include "video/gl/gl_texture.hpp" +#endif + Renderer* VideoSystem::new_renderer() { @@ -37,19 +40,22 @@ VideoSystem::new_renderer() { case AUTO_VIDEO: #ifdef HAVE_OPENGL - log_info << "new GL renderer\n"; - return new GLRenderer(); -#else - log_warning << "new SDL renderer\n"; - return new SDLRenderer(); + try { + log_info << "new GL renderer\n"; + return new GLRenderer(); + } catch(std::runtime_error& e) { + log_warning << "Error creating GL renderer: " << e.what() << std::endl; #endif + log_warning << "new SDL renderer\n"; + return new SDLRenderer(); #ifdef HAVE_OPENGL + } case OPENGL: log_info << "new GL renderer\n"; return new GLRenderer(); #endif case PURE_SDL: - log_warning << "new SDL renderer\n"; + log_info << "new SDL renderer\n"; return new SDLRenderer(); default: assert(0 && "invalid video system in config"); -- 2.11.0