diff --git a/CMakeLists.txt b/CMakeLists.txt index c443eea5a2a..ef549552bda 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,12 +66,12 @@ FIND_PACKAGE(Boost REQUIRED) INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIR}) LINK_DIRECTORIES(${Boost_LIBRARY_DIRS}) -FIND_PACKAGE(SDL REQUIRED) -INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR}) +#FIND_PACKAGE(SDL REQUIRED) +INCLUDE_DIRECTORIES("src/SDL2/") SET(HAVE_SDL TRUE) -FIND_PACKAGE(SDL_image REQUIRED) -INCLUDE_DIRECTORIES(${SDLIMAGE_INCLUDE_DIR}) +#FIND_PACKAGE(SDL_image REQUIRED) +#INCLUDE_DIRECTORIES(${SDLIMAGE_INCLUDE_DIR}) OPTION(ENABLE_OPENGL "Enable OpenGL support" ON) IF(ENABLE_OPENGL) diff --git a/external/squirrel/squirrel/sqdebug.cpp b/external/squirrel/squirrel/sqdebug.cpp index 14f7f64065f..68cad62bddb 100644 --- a/external/squirrel/squirrel/sqdebug.cpp +++ b/external/squirrel/squirrel/sqdebug.cpp @@ -74,7 +74,7 @@ SQString *SQVM::PrintObjVal(const SQObject &o) switch(type(o)) { case OT_STRING: return _string(o); case OT_INTEGER: - scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)), _SC("%d"), _integer(o)); + scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)), _SC("%ld"), _integer(o)); return SQString::Create(_ss(this), _spval); break; case OT_FLOAT: diff --git a/src/control/joystickkeyboardcontroller.cpp b/src/control/joystickkeyboardcontroller.cpp index 6c9e9c06dff..f225745da02 100644 --- a/src/control/joystickkeyboardcontroller.cpp +++ b/src/control/joystickkeyboardcontroller.cpp @@ -28,6 +28,7 @@ #include "supertux/menu/keyboard_menu.hpp" #include "util/gettext.hpp" #include "util/writer.hpp" +//#include // add by giby JoystickKeyboardController::JoystickKeyboardController() : controller(), @@ -138,12 +139,12 @@ JoystickKeyboardController::updateAvailableJoysticks() SDL_Joystick* joystick = SDL_JoystickOpen(i); bool good = true; if(SDL_JoystickNumButtons(joystick) < 2) { - log_info << "Joystick " << i << ": " << SDL_JoystickName(i) << " has less than 2 buttons" << std::endl; + log_info << _("Joystick ") << i << ": " << SDL_JoystickID(i) << _(" has less than 2 buttons") << std::endl; good = false; } if(SDL_JoystickNumAxes(joystick) < 2 && SDL_JoystickNumHats(joystick) == 0) { - log_info << "Joystick " << i << ": " << SDL_JoystickName(i) << " has less than 2 axes and no hat" << std::endl; + log_info << _("Joystick ") << i << ": " << SDL_JoystickID(i) << _(" has less than 2 axes and no hat") << std::endl; good = false; } if(!good) { @@ -196,10 +197,10 @@ JoystickKeyboardController::read(const Reader& lisp) const lisp::Lisp* map = iter.lisp(); map->get("key", key); map->get("control", control); - if(key < SDLK_FIRST || key >= SDLK_LAST) { - log_info << "Invalid key '" << key << "' in keymap" << std::endl; - continue; - } +// if(key < SDLK_FIRST || key >= SDLK_LAST) { +// log_info << "Invalid key '" << key << "' in keymap" << std::endl; +// continue; +// } int i = 0; for(i = 0; Controller::controlNames[i] != 0; ++i) { @@ -210,18 +211,18 @@ JoystickKeyboardController::read(const Reader& lisp) log_info << "Invalid control '" << control << "' in keymap" << std::endl; continue; } - keymap[SDLKey(key)] = Control(i); + keymap[SDL_Keycode(key)] = Control(i); } } } - const lisp::Lisp* joystick_lisp = lisp.get_lisp("joystick"); + const lisp::Lisp* joystick_lisp = lisp.get_lisp(_("joystick")); if(joystick_lisp) { joystick_lisp->get("dead-zone", dead_zone); joystick_lisp->get("jump-with-up", jump_with_up_joy); lisp::ListIterator iter(joystick_lisp); while(iter.next()) { - if(iter.item() == "map") { + if(iter.item() == _("map")) { int button = -1; int axis = 0; int hat = -1; @@ -510,7 +511,7 @@ JoystickKeyboardController::process_key_event(const SDL_KeyboardEvent& event) process_menu_key_event(event); } else if(key_mapping == keymap.end()) { // default action: update controls - //log_debug << "Key " << event.key.keysym.sym << " is unbound" << std::endl; + //log_debug << "Key " << event.key.SDL_Keycode.sym << " is unbound" << std::endl; } else { Control control = key_mapping->second; bool value = (event.type == SDL_KEYDOWN); @@ -562,10 +563,10 @@ JoystickKeyboardController::process_console_key_event(const SDL_KeyboardEvent& e Console::instance->move_cursor(+1); break; default: - int c = event.keysym.unicode; - if ((c >= 32) && (c <= 126)) { - Console::instance->input((char)c); - } + // int c = SDL_GetScancodeName(event.keysym); + // if ((c >= 32) && (c <= 126)) { you need to move that "unicode" source we were originaly talkinga bout into a new function that gets called from the SDL_TextInput event..... you'll be adding that event. + // Console::instance->input((char)c); + // } break; } } @@ -689,7 +690,7 @@ JoystickKeyboardController::bind_joybutton(JoyId joy_id, int button, Control con } void -JoystickKeyboardController::bind_key(SDLKey key, Control control) +JoystickKeyboardController::bind_key(SDL_Keycode key, Control control) { // remove all previous mappings for that control and for that key for(KeyMap::iterator i = keymap.begin(); @@ -714,7 +715,7 @@ JoystickKeyboardController::bind_key(SDLKey key, Control control) void JoystickKeyboardController::print_joystick_mappings() { - std::cout << "Joystick Mappings" << std::endl; + std::cout << _("Joystick Mappings") << std::endl; std::cout << "-----------------" << std::endl; for(AxisMap::iterator i = joy_axis_map.begin(); i != joy_axis_map.end(); ++i) { std::cout << "Axis: " << i->first.second << " -> " << i->second << std::endl; @@ -730,7 +731,7 @@ JoystickKeyboardController::print_joystick_mappings() std::cout << std::endl; } -SDLKey +SDL_Keycode JoystickKeyboardController::reversemap_key(Control c) { for(KeyMap::iterator i = keymap.begin(); i != keymap.end(); ++i) { diff --git a/src/control/joystickkeyboardcontroller.hpp b/src/control/joystickkeyboardcontroller.hpp index 00c4c2f40cd..1c193600438 100644 --- a/src/control/joystickkeyboardcontroller.hpp +++ b/src/control/joystickkeyboardcontroller.hpp @@ -20,7 +20,7 @@ #include "control/controller.hpp" #include - +#include // add by giby #include #include #include @@ -33,7 +33,9 @@ class KeyboardMenu; class JoystickMenu; class Controller; -class JoystickKeyboardController + //SDL_JoystickID myID = SDL_JoystickInstanceID(myOpenedStick); + +class JoystickKeyboardController // http://wiki.libsdl.org/moin.fcg/SDL_Joystick for info { private: friend class KeyboardMenu; @@ -42,7 +44,7 @@ class JoystickKeyboardController typedef Controller::Control Control; typedef Uint8 JoyId; - typedef std::map KeyMap; + typedef std::map KeyMap; typedef std::map, Control> ButtonMap; typedef std::map, Control> AxisMap; typedef std::map, Control> HatMap; @@ -74,7 +76,7 @@ class JoystickKeyboardController void print_joystick_mappings(); - SDLKey reversemap_key(Control c); + SDL_Keycode reversemap_key(Control c); int reversemap_joybutton(Control c); int reversemap_joyaxis(Control c); int reversemap_joyhat(Control c); @@ -84,9 +86,9 @@ class JoystickKeyboardController void bind_joybutton(JoyId joy_id, int button, Control c); void bind_joyaxis(JoyId joy_id, int axis, Control c); void bind_joyhat(JoyId joy_id, int dir, Control c); - void bind_key(SDLKey key, Control c); + void bind_key(SDL_Keycode key, Control c); - void set_joy_controls(Control id, bool value); + void set_joy_controls(Control id, bool value); private: Controller *controller; diff --git a/src/gui/button.cpp b/src/gui/button.cpp index 587b1e315ec..8561dd4edb0 100644 --- a/src/gui/button.cpp +++ b/src/gui/button.cpp @@ -21,7 +21,7 @@ FontPtr Button::info_font; -Button::Button(SurfacePtr image_, std::string info_, SDLKey binding_) : +Button::Button(SurfacePtr image_, std::string info_, SDL_Keycode binding_) : pos(), size(), image(), diff --git a/src/gui/button.hpp b/src/gui/button.hpp index aeeb71c3bd0..e0229b4c1ef 100644 --- a/src/gui/button.hpp +++ b/src/gui/button.hpp @@ -38,7 +38,7 @@ enum { class Button { public: - Button(SurfacePtr image_, std::string info_, SDLKey binding_); + Button(SurfacePtr image_, std::string info_, SDL_Keycode binding_); Button(const Button& rhs); ~Button(); @@ -57,7 +57,7 @@ class Button Vector size; SurfacePtr image; - SDLKey binding; + SDL_Keycode binding; int id; int state; diff --git a/src/gui/button_group.cpp b/src/gui/button_group.cpp index 0a2c7edd17e..23364894707 100644 --- a/src/gui/button_group.cpp +++ b/src/gui/button_group.cpp @@ -119,13 +119,13 @@ ButtonGroup::event(SDL_Event &event) caught_event = true; - if(event.button.button == SDL_BUTTON_WHEELUP) + if(event.button.button == SDL_MOUSEBUTTONUP) { row--; if(row < 0) row = 0; } - else if(event.button.button == SDL_BUTTON_WHEELDOWN) + else if(event.button.button == SDL_MOUSEBUTTONDOWN) { row++; if(row > (int)((buttons.size()-buttons_pair_nb)/buttons_box.x) - (int)buttons_box.y + diff --git a/src/main.cpp b/src/main.cpp index 2b4bd2160a8..6acebfd5adc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#include +#include "SDL2/SDL.h" #include "supertux/main.hpp" diff --git a/src/physfs/physfs_sdl.cpp b/src/physfs/physfs_sdl.cpp index 82c78699787..b751a8e8fcb 100644 --- a/src/physfs/physfs_sdl.cpp +++ b/src/physfs/physfs_sdl.cpp @@ -23,7 +23,7 @@ #include "util/log.hpp" -static int funcSeek(struct SDL_RWops* context, int offset, int whence) +static Sint64 funcSeek(struct SDL_RWops* context, Sint64 offset, int whence) { PHYSFS_file* file = (PHYSFS_file*) context->hidden.unknown.data1; int res; @@ -50,7 +50,7 @@ static int funcSeek(struct SDL_RWops* context, int offset, int whence) return (int) PHYSFS_tell(file); } -static int funcRead(struct SDL_RWops* context, void* ptr, int size, int maxnum) +static size_t funcRead(struct SDL_RWops* context, void* ptr, size_t size, size_t maxnum) { PHYSFS_file* file = (PHYSFS_file*) context->hidden.unknown.data1; diff --git a/src/scripting/functions.cpp b/src/scripting/functions.cpp index 5a03f37ed07..cb4260e051e 100644 --- a/src/scripting/functions.cpp +++ b/src/scripting/functions.cpp @@ -271,8 +271,10 @@ void camera() log_info << "Camera is at " << Sector::current()->camera->get_translation().x << "," << Sector::current()->camera->get_translation().y << std::endl; } -void set_gamma(float gamma) { - SDL_SetGamma(gamma, gamma, gamma); + SDL_Window *screen; + +void set_gamma(const Uint16 * gamma) { + SDL_SetWindowGammaRamp(screen,gamma, gamma, gamma); } void quit() diff --git a/src/supertux/console.cpp b/src/supertux/console.cpp index 883ec09d68e..000a978932d 100644 --- a/src/supertux/console.cpp +++ b/src/supertux/console.cpp @@ -431,7 +431,7 @@ Console::show() focused = true; height = 256; alpha = 1.0; - SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); +// SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); // Useless in SDL2 : if you want to disable repeat, then you need to check if the key was repeated and ignore it. } void @@ -451,7 +451,7 @@ Console::hide() // clear input buffer inputBuffer = ""; inputBufferPosition = 0; - SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL); + // SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL); } void diff --git a/src/supertux/main.cpp b/src/supertux/main.cpp index d89420fb9c5..9f0d8f20846 100644 --- a/src/supertux/main.cpp +++ b/src/supertux/main.cpp @@ -433,7 +433,9 @@ Main::init_sdl() // just to be sure atexit(SDL_Quit); - SDL_EnableUNICODE(1); + // SDL_EnableUNICODE(1); //old code, mofif by giby + // SDL_JoystickID myID = SDL_JoystickInstanceID(myOpenedStick); + // wait 100ms and clear SDL event queue because sometimes we have random // joystick events in the queue on startup... @@ -460,13 +462,14 @@ Main::init_video() // FIXME: Add something here SCREEN_WIDTH = 800; SCREEN_HEIGHT = 600; - + +/* SDL_Window *window; // Declare a pointer to an SDL_Window context_pointer->init_renderer(); - g_screen = SDL_GetVideoSurface(); + g_screen = SDL_GetWindowSurface(*window);*/ - SDL_WM_SetCaption(PACKAGE_NAME " " PACKAGE_VERSION, 0); + // SDL_WM_SetCaption(PACKAGE_NAME " " PACKAGE_VERSION, 0); - // set icon + /* // set icon -- Original part B4 SDL2 #ifdef MACOSX const char* icon_fname = "images/engine/icons/supertux-256x256.png"; #else @@ -480,12 +483,51 @@ Main::init_video() log_warning << "Couldn't load icon '" << icon_fname << "': " << err.what() << std::endl; } if(icon != 0) { - SDL_WM_SetIcon(icon, 0); + SDL_WM_SetIcon(icon, 0); //now SDL_SetWindowIcon(window, surface); if needed SDL_FreeSurface(icon); } else { log_warning << "Couldn't load icon '" << icon_fname << "'" << std::endl; } + */ + + // SDL_WM_SetCaption(PACKAGE_NAME " " PACKAGE_VERSION, 0); + + // set icon +#ifdef MACOSX + const char* icon_fname = "images/engine/icons/supertux-256x256.png"; +#else + const char* icon_fname = "images/engine/icons/supertux.xpm"; +#endif + SDL_Window* icon; + try { + //icon = IMG_Load_RW(get_physfs_SDLRWops(icon_fname), true); + } catch (const std::runtime_error& err) { + icon = 0; + log_warning << "Couldn't load icon '" << icon_fname << "': " << err.what() << std::endl; + } + if(icon != 0) { + // SDL_SetWindowIcon(icon, 0); //now SDL_SetWindowIcon(window, surface); if needed + // SDL_FreeSurface(icon); + } + else { + log_warning << "Couldn't load icon '" << icon_fname << "'" << std::endl; + } + + + /* // set icon +#ifdef MACOSX + const char* icon_fname = "images/engine/icons/supertux-256x256.png"; +#else + const char* icon_fname = "images/engine/icons/supertux.xpm"; +#endif + + SDL_Window icon = SDL_CreateWindow(PACKAGE_NAME " " PACKAGE_VERSION, + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + 640, 480, + SDL_WINDOW_FULLSCREEN | SDL_WINDOW_OPENGL); + // not sure of that */ SDL_ShowCursor(0); diff --git a/src/supertux/menu/joystick_menu.cpp b/src/supertux/menu/joystick_menu.cpp index c6bacb3162d..38733ffcbaf 100644 --- a/src/supertux/menu/joystick_menu.cpp +++ b/src/supertux/menu/joystick_menu.cpp @@ -59,12 +59,13 @@ JoystickMenu::recreateMenu() } add_inactive(-1,""); add_entry(SCAN_JOYSTICKS, _("Scan for Joysticks")); - - //Show Joysticks currently activated: + //Show Joysticks currently activated: //edit by giby + joy = SDL_JoystickOpen(0) + if (SDL_NumJoysticks() > 0) {joy = SDL_JoystickOpen(0); for(std::vector::iterator i = controller->joysticks.begin(); i != controller->joysticks.end(); ++i) { if(*i != 0) - add_inactive(-1, SDL_JoystickName(SDL_JoystickIndex(*i)) ); + add_inactive(-1, SDL_JoystickName(joy) ); } add_hl(); @@ -73,7 +74,7 @@ JoystickMenu::recreateMenu() } std::string -JoystickMenu::get_button_name(int button) +/*JoystickMenu::get_button_name(int button) { if(button < 0) return _("None"); @@ -81,7 +82,7 @@ JoystickMenu::get_button_name(int button) std::ostringstream name; name << "Button " << button; return name.str(); -} +}*/ void JoystickMenu::menu_action(MenuItem* item) diff --git a/src/supertux/menu/keyboard_menu.cpp b/src/supertux/menu/keyboard_menu.cpp index 883adef0bca..bbdd1cfc91a 100644 --- a/src/supertux/menu/keyboard_menu.cpp +++ b/src/supertux/menu/keyboard_menu.cpp @@ -49,7 +49,7 @@ KeyboardMenu::~KeyboardMenu() {} std::string -KeyboardMenu::get_key_name(SDLKey key) +KeyboardMenu::get_key_name(SDL_Keycode key) { switch(key) { case SDLK_UNKNOWN: @@ -79,7 +79,7 @@ KeyboardMenu::get_key_name(SDLKey key) case SDLK_LALT: return _("Left Alt"); default: - return SDL_GetKeyName((SDLKey) key); + return SDL_GetKeyName((SDL_Keycode) key); } } diff --git a/src/supertux/menu/keyboard_menu.hpp b/src/supertux/menu/keyboard_menu.hpp index f4435d17a84..c83cb4bc010 100644 --- a/src/supertux/menu/keyboard_menu.hpp +++ b/src/supertux/menu/keyboard_menu.hpp @@ -28,7 +28,7 @@ class KeyboardMenu : public Menu ~KeyboardMenu(); void update(); - std::string get_key_name(SDLKey key); + std::string SDL_GetKeyName(SDL_Keycode* key); virtual void menu_action(MenuItem* item); JoystickKeyboardController* controller; void check_menu() {} diff --git a/src/supertux/screen_manager.cpp b/src/supertux/screen_manager.cpp index ffd95992c6d..98e8740c608 100644 --- a/src/supertux/screen_manager.cpp +++ b/src/supertux/screen_manager.cpp @@ -190,7 +190,7 @@ void ScreenManager::process_events() { g_jk_controller->update(); - Uint8* keystate = SDL_GetKeyState(NULL); +const Uint8 *keystate = SDL_GetKeyboardState(NULL); //edited by giby SDL_Event event; while(SDL_PollEvent(&event)) { @@ -205,10 +205,10 @@ ScreenManager::process_events() quit(); break; - case SDL_VIDEORESIZE: - Renderer::instance()->resize(event.resize.w, event.resize.h); - MenuManager::recalc_pos(); - break; + // case SDL_ResizeEvent: //edit by giby + // Renderer::instance()->resize(event.resize.w, event.resize.h); + // MenuManager::recalc_pos(); + // break; case SDL_KEYDOWN: if (event.key.keysym.sym == SDLK_F10) @@ -221,7 +221,7 @@ ScreenManager::process_events() Renderer::instance()->apply_config(); MenuManager::recalc_pos(); } - else if (event.key.keysym.sym == SDLK_PRINT || + else if (event.key.keysym.sym == SDLK_PRINTSCREEN || event.key.keysym.sym == SDLK_F12) { take_screenshot(); diff --git a/src/video/gl/gl_renderer.cpp b/src/video/gl/gl_renderer.cpp index 0e66433c4cb..18e3874b6a8 100644 --- a/src/video/gl/gl_renderer.cpp +++ b/src/video/gl/gl_renderer.cpp @@ -1,5 +1,6 @@ // SuperTux // Copyright (C) 2006 Matthias Braun +// Updated by GiBy 2013 for SDL2 // // 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 @@ -19,6 +20,9 @@ #include #include #include +#include "SDL2/SDL.h" +//#include "SDL/SDL.h" +//#include "SDL/SDL_opengl.h" #include "supertux/gameconfig.hpp" #include "supertux/globals.hpp" @@ -56,16 +60,16 @@ GLRenderer::GLRenderer() : #ifdef SDL_GL_SWAP_CONTROL if(config->try_vsync) { /* we want vsync for smooth scrolling */ - SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); + SDL_GL_SetSwapInterval(1); } #endif - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + SDL_GL_SetSwapInterval(SDL_GL_DOUBLEBUFFER, 1); // FIXME: Hu? 16bit rendering? - SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); + SDL_GL_SetSwapInterval(5); + SDL_GL_SetSwapInterval(5); + SDL_GL_SetSwapInterval(5); if(g_config->use_fullscreen) { @@ -442,7 +446,7 @@ void GLRenderer::flip() { assert_gl("drawing"); - SDL_GL_SwapBuffers(); + SDL_GL_SwapWindow(screen)(); } void @@ -450,7 +454,7 @@ GLRenderer::resize(int w, int h) { // This causes the screen to go black, which is annoying, but seems // unavoidable with SDL at the moment - SDL_SetVideoMode(w, h, 0, SDL_OPENGL | SDL_RESIZABLE); + SDL_CreateWindow(SDL_GL_CreateContext(w, h, 0, SDL_OPENGL | SDL_RESIZABLE)); g_config->window_size = Size(w, h); @@ -559,9 +563,9 @@ GLRenderer::apply_config() // Clear both buffers so that we get a clean black border without junk glClear(GL_COLOR_BUFFER_BIT); - SDL_GL_SwapBuffers(); + SDL_GL_SwapWindow(screen); glClear(GL_COLOR_BUFFER_BIT); - SDL_GL_SwapBuffers(); + SDL_GL_SwapWindow(screen); glViewport(std::max(0, (screen_size.width - new_size.width) / 2), std::max(0, (screen_size.height - new_size.height) / 2), @@ -597,7 +601,7 @@ GLRenderer::apply_video_mode(const Size& size, bool fullscreen) flags |= SDL_RESIZABLE; } - if (SDL_Surface *screen = SDL_SetVideoMode(size.width, size.height, 0, flags)) + if (SDL_Surface *screen = SDL_CreateWindow(SDL_GL_CreateContext( size.width, size.height, 0, flags))) { screen_size = Size(screen->w, screen->h); fullscreen_active = fullscreen; diff --git a/src/video/sdl/sdl_renderer.cpp b/src/video/sdl/sdl_renderer.cpp index 39e8860f89c..ff95516a6e8 100644 --- a/src/video/sdl/sdl_renderer.cpp +++ b/src/video/sdl/sdl_renderer.cpp @@ -1,5 +1,6 @@ // SuperTux // Copyright (C) 2006 Matthias Braun +// Updated by GiBy 2013 for SDL2 // // 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 @@ -25,6 +26,10 @@ #include #include #include +#include "SDL2/SDL_video.h" +//#include "SDL/SDL.h" +//#include "SDL/SDL_opengl.h" + namespace { @@ -127,15 +132,21 @@ SDLRenderer::SDLRenderer() : log_info << "Software to hardware blits with alpha are " << (info->blit_sw_A ? "" : "not ") << "accelerated." << std::endl; log_info << "Color fills are " << (info->blit_fill ? "" : "not ") << "accelerated." << std::endl; - int flags = SDL_SWSURFACE | SDL_ANYFORMAT; - if(g_config->use_fullscreen) - flags |= SDL_FULLSCREEN; + // int flags = SDL_SWSURFACE | SDL_ANYFORMAT; + // if(g_config->use_fullscreen) + // flags |= SDL_FULLSCREEN; int width = 800; //FIXME: config->screenwidth; int height = 600; //FIXME: config->screenheight; - - screen = SDL_SetVideoMode(width, height, 0, flags); - if(screen == 0) { + + SDL_Window *window; // Declare a pointer to an SDL_Window + + SDL_Init(SDL_INIT_VIDEO); // Initialize SDL2 + + window = SDL_CreateWindow("SuperTux",SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED,width, height, 0, SDL_WINDOW_OPENGL ); + SDL_GLContext glcontext = SDL_GL_CreateContext(window); + + if(window == 0) { std::stringstream msg; msg << "Couldn't set video mode (" << width << "x" << height << "): " << SDL_GetError(); diff --git a/src/video/texture_manager.cpp b/src/video/texture_manager.cpp index 0c77a5add43..b64fcee3ac6 100644 --- a/src/video/texture_manager.cpp +++ b/src/video/texture_manager.cpp @@ -158,10 +158,10 @@ TextureManager::create_image_texture_raw(const std::string& filename, const Rect throw std::runtime_error("SDL_CreateRGBSurfaceFrom() call failed"); } - if (image->format->palette) + /* if (image->format->palette) { // copy the image palette to subimage if present - SDL_SetColors(subimage.get(), image->format->palette->colors, 0, image->format->palette->ncolors); - } + SDL_SetSurfacePalette(subimage.get(), image->format->palette->colors); //edited by giby + } */ return VideoSystem::new_texture(subimage.get()); }