#include <stdio.h>\r
#include <stdlib.h>\r
#include "SIrrCreationParameters.h"\r
-#include <SDL/SDL_syswm.h>\r
-#include <SDL/SDL_video.h>\r
+#include <SDL2/SDL_video.h>\r
\r
#ifdef _IRR_EMSCRIPTEN_PLATFORM_\r
#ifdef _IRR_COMPILE_WITH_OGLES2_\r
#include <emscripten.h>\r
#endif\r
\r
-#ifdef _MSC_VER\r
-#pragma comment(lib, "SDL.lib")\r
-#endif // _MSC_VER\r
-\r
static int SDLDeviceInstances = 0;\r
\r
namespace irr\r
\r
return EM_FALSE;\r
}\r
+#endif\r
\r
bool CIrrDeviceSDL::isNoUnicodeKey(EKEY_CODE key) const\r
{\r
return false;\r
}\r
}\r
-#endif\r
\r
//! constructor\r
CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)\r
: CIrrDeviceStub(param),\r
- Screen((SDL_Surface*)param.WindowId), SDL_Flags(SDL_ANYFORMAT),\r
+ Window((SDL_Window*)param.WindowId), SDL_Flags(0),\r
MouseX(0), MouseY(0), MouseXRel(0), MouseYRel(0), MouseButtonStates(0),\r
Width(param.WindowSize.Width), Height(param.WindowSize.Height),\r
Resizable(param.WindowResizable == 1 ? true : false), WindowMinimized(false)\r
{\r
os::Printer::log("SDL initialized", ELL_INFORMATION);\r
}\r
+ }\r
\r
-#if defined(_IRR_WINDOWS_)\r
- SDL_putenv("SDL_VIDEODRIVER=directx");\r
-#elif defined(_IRR_OSX_PLATFORM_)\r
- SDL_putenv("SDL_VIDEODRIVER=Quartz");\r
-#elif !defined(_IRR_EMSCRIPTEN_PLATFORM_)\r
- SDL_putenv("SDL_VIDEODRIVER=x11");\r
-#endif\r
+ // create keymap\r
+ createKeyMap();\r
+\r
+ if ( CreationParams.Fullscreen )\r
+ SDL_Flags |= SDL_WINDOW_FULLSCREEN;\r
+ else if ( Resizable )\r
+ SDL_Flags |= SDL_WINDOW_RESIZABLE;\r
+ if (CreationParams.DriverType == video::EDT_OPENGL)\r
+ {\r
+ SDL_Flags |= SDL_WINDOW_OPENGL;\r
+ if (!CreationParams.Doublebuffer)\r
+ SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0);\r
}\r
+#ifdef _IRR_EMSCRIPTEN_PLATFORM_\r
+ SDL_Flags |= SDL_WINDOW_OPENGL;\r
+#endif //_IRR_EMSCRIPTEN_PLATFORM_\r
\r
-// SDL_putenv("SDL_WINDOWID=");\r
+ // create window\r
+ if (CreationParams.DriverType != video::EDT_NULL)\r
+ {\r
+ // create the window, only if we do not use the null device\r
+ createWindow();\r
+ }\r
\r
SDL_VERSION(&Info.version);\r
\r
#ifndef _IRR_EMSCRIPTEN_PLATFORM_\r
- SDL_GetWMInfo(&Info);\r
+ SDL_GetWindowWMInfo(Window,&Info);\r
#endif //_IRR_EMSCRIPTEN_PLATFORM_\r
core::stringc sdlversion = "SDL Version ";\r
sdlversion += Info.version.major;\r
sdlversion += Info.version.patch;\r
\r
Operator = new COSOperator(sdlversion);\r
- if ( SDLDeviceInstances == 1 )\r
- {\r
+ if (SDLDeviceInstances == 1) {\r
os::Printer::log(sdlversion.c_str(), ELL_INFORMATION);\r
}\r
\r
- // create keymap\r
- createKeyMap();\r
- // enable key to character translation\r
- SDL_EnableUNICODE(1);\r
-\r
- (void)SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);\r
-\r
- if ( CreationParams.Fullscreen )\r
- SDL_Flags |= SDL_FULLSCREEN;\r
- else if ( Resizable )\r
- SDL_Flags |= SDL_RESIZABLE;\r
- if (CreationParams.DriverType == video::EDT_OPENGL)\r
- SDL_Flags |= SDL_OPENGL;\r
- else if (CreationParams.Doublebuffer)\r
- SDL_Flags |= SDL_DOUBLEBUF;\r
-#ifdef _IRR_EMSCRIPTEN_PLATFORM_\r
- SDL_Flags |= SDL_OPENGL;\r
-#endif //_IRR_EMSCRIPTEN_PLATFORM_\r
-\r
- // create window\r
- if (CreationParams.DriverType != video::EDT_NULL)\r
- {\r
- // create the window, only if we do not use the null device\r
- createWindow();\r
- }\r
-\r
// create cursor control\r
CursorControl = new CCursorControl(this);\r
\r
// create driver\r
createDriver();\r
\r
- if (VideoDriver)\r
+ if (VideoDriver) {\r
createGUIAndScene();\r
+ VideoDriver->OnResize(core::dimension2d<u32>(Width, Height));\r
+ }\r
}\r
\r
\r
for (u32 i=0; i<numJoysticks; ++i)\r
SDL_JoystickClose(Joysticks[i]);\r
#endif\r
+ if (Window)\r
+ {\r
+ SDL_GL_MakeCurrent(Window, NULL);\r
+ SDL_GL_DeleteContext(Context);\r
+ SDL_DestroyWindow(Window);\r
+ }\r
SDL_Quit();\r
\r
os::Printer::log("Quit SDL", ELL_INFORMATION);\r
{\r
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);\r
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);\r
- }\r
+ } \r
\r
- Screen = SDL_SetVideoMode( 0, 0, 32, SDL_Flags); // 0,0 will use the canvas size\r
+ SDL_CreateWindowAndRenderer(0, 0, SDL_Flags, &Window, &Renderer); // 0,0 will use the canvas size\r
\r
logAttributes();\r
\r
if ( Close )\r
return false;\r
\r
- if (CreationParams.DriverType == video::EDT_OPENGL)\r
- {\r
- if (CreationParams.Bits==16)\r
- {\r
- SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 4 );\r
- SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 4 );\r
- SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 4 );\r
- SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel?1:0 );\r
- }\r
- else\r
- {\r
- SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );\r
- SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );\r
- SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );\r
- SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel?8:0 );\r
+ if (CreationParams.DriverType == video::EDT_OPENGL) {\r
+ if (CreationParams.Bits == 16) {\r
+ SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 4);\r
+ SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 4);\r
+ SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 4);\r
+ SDL_GL_SetAttribute(\r
+ SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel ? 1 : 0);\r
+ } else {\r
+ SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);\r
+ SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);\r
+ SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);\r
+ SDL_GL_SetAttribute(\r
+ SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel ? 8 : 0);\r
}\r
- SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, CreationParams.ZBufferBits);\r
+ SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, CreationParams.ZBufferBits);\r
if (CreationParams.Doublebuffer)\r
- SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );\r
- SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, CreationParams.Stencilbuffer ? 8 : 0);\r
+ SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);\r
+ SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, CreationParams.Stencilbuffer ? 8 : 0);\r
if (CreationParams.Stereobuffer)\r
- SDL_GL_SetAttribute( SDL_GL_STEREO, 1 );\r
- if (CreationParams.AntiAlias>1)\r
- {\r
- SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );\r
- SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias );\r
+ SDL_GL_SetAttribute(SDL_GL_STEREO, 1);\r
+ if (CreationParams.AntiAlias > 1) {\r
+ SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);\r
+ SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias);\r
}\r
- if ( !Screen )\r
- Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags );\r
- if ( !Screen && CreationParams.AntiAlias>1)\r
- {\r
- while (--CreationParams.AntiAlias>1)\r
- {\r
- SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias );\r
- Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags );\r
- if (Screen)\r
+ if (!Window)\r
+ Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);\r
+ if (!Window && CreationParams.AntiAlias > 1) {\r
+ while (--CreationParams.AntiAlias > 1) {\r
+ SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias);\r
+ Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);\r
+ if (Window)\r
break;\r
}\r
- if ( !Screen )\r
- {\r
- SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 0 );\r
- SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 0 );\r
- Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags );\r
- if (Screen)\r
- os::Printer::log("AntiAliasing disabled due to lack of support!" );\r
+ if (!Window) {\r
+ SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);\r
+ SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);\r
+ Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);\r
+ if (Window)\r
+ os::Printer::log("AntiAliasing disabled due to lack of support!");\r
}\r
}\r
- }\r
- else if ( !Screen )\r
- Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags );\r
\r
- if ( !Screen && CreationParams.Doublebuffer)\r
+ if (Window)\r
+ {\r
+ Context = SDL_GL_CreateContext(Window);\r
+ }\r
+ } else if (!Window)\r
+ Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);\r
+\r
+ if ( !Window && CreationParams.Doublebuffer)\r
{\r
// Try single buffer\r
if (CreationParams.DriverType == video::EDT_OPENGL)\r
- SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );\r
- SDL_Flags &= ~SDL_DOUBLEBUF;\r
- Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags );\r
+ SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);\r
+ Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);\r
}\r
- if ( !Screen )\r
+ if ( !Window )\r
{\r
os::Printer::log( "Could not initialize display!" );\r
return false;\r
if ( VideoDriver && CreationParams.WindowSize.Width == 0 && CreationParams.WindowSize.Height == 0 && Width > 0 && Height > 0 )\r
{\r
#ifdef _IRR_EMSCRIPTEN_PLATFORM_\r
- Screen = SDL_SetVideoMode( Width, Height, 32, SDL_Flags );\r
+ SDL_CreateWindowAndRenderer(Width, Height, SDL_Flags, &Window, &Renderer);\r
#else //_IRR_EMSCRIPTEN_PLATFORM_\r
- Screen = SDL_SetVideoMode( Width, Height, 0, SDL_Flags );\r
+ Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags);\r
#endif //_IRR_EMSCRIPTEN_PLATFOR\r
VideoDriver->OnResize(core::dimension2d<u32>(Width, Height));\r
}\r
\r
postEventFromUser(irrevent);\r
break;\r
-\r
+ case SDL_MOUSEWHEEL:\r
+ irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;\r
+ irrevent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL;\r
+ irrevent.MouseInput.Wheel = static_cast<float>(SDL_event.wheel.y);\r
+ postEventFromUser(irrevent);\r
+ break;\r
case SDL_MOUSEBUTTONDOWN:\r
case SDL_MOUSEBUTTONUP:\r
-\r
irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;\r
irrevent.MouseInput.X = SDL_event.button.x;\r
irrevent.MouseInput.Y = SDL_event.button.y;\r
else\r
{\r
irrevent.MouseInput.Event = irr::EMIE_LMOUSE_LEFT_UP;\r
- MouseButtonStates &= !irr::EMBSM_LEFT;\r
+ MouseButtonStates &= ~irr::EMBSM_LEFT;\r
}\r
break;\r
\r
else\r
{\r
irrevent.MouseInput.Event = irr::EMIE_RMOUSE_LEFT_UP;\r
- MouseButtonStates &= !irr::EMBSM_RIGHT;\r
+ MouseButtonStates &= ~irr::EMBSM_RIGHT;\r
}\r
break;\r
\r
else\r
{\r
irrevent.MouseInput.Event = irr::EMIE_MMOUSE_LEFT_UP;\r
- MouseButtonStates &= !irr::EMBSM_MIDDLE;\r
+ MouseButtonStates &= ~irr::EMBSM_MIDDLE;\r
}\r
break;\r
-\r
- case SDL_BUTTON_WHEELUP:\r
- irrevent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL;\r
- irrevent.MouseInput.Wheel = 1.0f;\r
- break;\r
-\r
- case SDL_BUTTON_WHEELDOWN:\r
- irrevent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL;\r
- irrevent.MouseInput.Wheel = -1.0f;\r
- break;\r
}\r
\r
irrevent.MouseInput.ButtonStates = MouseButtonStates;\r
}\r
#endif\r
irrevent.EventType = irr::EET_KEY_INPUT_EVENT;\r
- irrevent.KeyInput.Char = SDL_event.key.keysym.unicode;\r
- irrevent.KeyInput.Key = key;\r
-#ifdef _IRR_EMSCRIPTEN_PLATFORM_\r
- // On emscripten SDL does not (yet?) return 0 for invalid keysym.unicode's.\r
- // Instead it sets keysym.unicode to keysym.sym.\r
- // But we need to distinguish control keys from characters here as that info\r
- // is necessary in other places like the editbox.\r
- if ( isNoUnicodeKey(key) )\r
+\r
+ if (isNoUnicodeKey(key))\r
irrevent.KeyInput.Char = 0;\r
-#endif\r
+ else\r
+ irrevent.KeyInput.Char = SDL_event.key.keysym.sym;\r
+\r
+ irrevent.KeyInput.Key = key;\r
irrevent.KeyInput.PressedDown = (SDL_event.type == SDL_KEYDOWN);\r
irrevent.KeyInput.Shift = (SDL_event.key.keysym.mod & KMOD_SHIFT) != 0;\r
irrevent.KeyInput.Control = (SDL_event.key.keysym.mod & KMOD_CTRL ) != 0;\r
+\r
+ // SDL2 no longer provides unicode character in the key event so we ensure the character is in the correct case\r
+ // TODO: Unicode input doesn't work like this, should probably use SDL_TextInputEvent\r
+ bool convertCharToUppercase =\r
+ irrevent.KeyInput.Shift != !!(SDL_event.key.keysym.mod & KMOD_CAPS);\r
+\r
+ if (convertCharToUppercase)\r
+ irrevent.KeyInput.Char = irr::core::locale_upper(irrevent.KeyInput.Char);\r
+\r
postEventFromUser(irrevent);\r
}\r
break;\r
Close = true;\r
break;\r
\r
- case SDL_ACTIVEEVENT:\r
- if (SDL_event.active.state == SDL_APPACTIVE)\r
- WindowMinimized = (SDL_event.active.gain!=1);\r
- break;\r
-\r
- case SDL_VIDEORESIZE:\r
- if ((SDL_event.resize.w != (int)Width) || (SDL_event.resize.h != (int)Height))\r
+ case SDL_WINDOWEVENT:\r
+ switch (SDL_event.window.event)\r
{\r
- Width = SDL_event.resize.w;\r
- Height = SDL_event.resize.h;\r
-#ifdef _IRR_EMSCRIPTEN_PLATFORM_\r
- Screen = SDL_SetVideoMode( 0, 0, 32, SDL_Flags ); // 0,0 will use the canvas size\r
-#else //_IRR_EMSCRIPTEN_PLATFORM_\r
- Screen = SDL_SetVideoMode( Width, Height, 0, SDL_Flags );\r
-#endif //_IRR_EMSCRIPTEN_PLATFOR\r
- if (VideoDriver)\r
- VideoDriver->OnResize(core::dimension2d<u32>(Width, Height));\r
+ case SDL_WINDOWEVENT_MAXIMIZED:\r
+ WindowMinimized = true;\r
+ break;\r
+ case SDL_WINDOWEVENT_RESTORED:\r
+ WindowMinimized = false;\r
+ break;\r
+ case SDL_WINDOWEVENT_RESIZED:\r
+ if ((SDL_event.window.data1 != (int)Width) || (SDL_event.window.data2 != (int)Height))\r
+ {\r
+ Width = SDL_event.window.data1;\r
+ Height = SDL_event.window.data2;\r
+ if (VideoDriver)\r
+ VideoDriver->OnResize(core::dimension2d<u32>(Width, Height));\r
+ }\r
+ break;\r
}\r
- break;\r
\r
case SDL_USEREVENT:\r
irrevent.EventType = irr::EET_USER_EVENT;\r
int joystick = 0;\r
for (; joystick<numJoysticks; ++joystick)\r
{\r
- Joysticks.push_back(SDL_JoystickOpen(joystick));\r
+ Joysticks.push_back( SDL_JoystickOpen(joystick));\r
SJoystickInfo info;\r
\r
info.Joystick = joystick;\r
info.Axes = SDL_JoystickNumAxes(Joysticks[joystick]);\r
info.Buttons = SDL_JoystickNumButtons(Joysticks[joystick]);\r
- info.Name = SDL_JoystickName(joystick);\r
+ info.Name = SDL_JoystickName(Joysticks[joystick]);\r
info.PovHat = (SDL_JoystickNumHats(Joysticks[joystick]) > 0)\r
? SJoystickInfo::POV_HAT_PRESENT : SJoystickInfo::POV_HAT_ABSENT;\r
\r
return false;\r
}\r
\r
+void CIrrDeviceSDL::SwapWindow()\r
+{\r
+ SDL_GL_SwapWindow(Window);\r
+}\r
+\r
\r
\r
//! pause execution temporarily\r
//! sets the caption of the window\r
void CIrrDeviceSDL::setWindowCaption(const wchar_t* text)\r
{\r
- core::stringc textc = text;\r
- SDL_WM_SetCaption( textc.c_str( ), textc.c_str( ) );\r
+ core::stringc textc;\r
+ core::wStringToMultibyte(textc, text);\r
+ SDL_SetWindowTitle(Window, textc.c_str());\r
}\r
\r
\r
surface->getRedMask(), surface->getGreenMask(), surface->getBlueMask(), surface->getAlphaMask());\r
if (!sdlSurface)\r
return false;\r
- SDL_SetAlpha(sdlSurface, 0, 0);\r
+ SDL_SetSurfaceAlphaMod(sdlSurface, 0);\r
SDL_SetColorKey(sdlSurface, 0, 0);\r
sdlSurface->format->BitsPerPixel=surface->getBitsPerPixel();\r
sdlSurface->format->BytesPerPixel=surface->getBytesPerPixel();\r
\r
SDL_Surface* scr = (SDL_Surface* )windowId;\r
if (!scr)\r
- scr = Screen;\r
+ scr = SDL_GetWindowSurface(Window);\r
if (scr)\r
{\r
if (srcClip)\r
}\r
else\r
SDL_BlitSurface(sdlSurface, NULL, scr, NULL);\r
- SDL_Flip(scr);\r
+ SDL_RenderPresent(SDL_GetRenderer(Window));\r
}\r
\r
SDL_FreeSurface(sdlSurface);\r
}\r
\r
\r
-//! \return Pointer to a list with all video modes supported\r
-video::IVideoModeList* CIrrDeviceSDL::getVideoModeList()\r
-{\r
-#ifdef _IRR_EMSCRIPTEN_PLATFORM_\r
- os::Printer::log("VideoModeList not available on the web." , ELL_WARNING);\r
- return VideoModeList;\r
-#else // !_IRR_EMSCRIPTEN_PLATFORM_\r
- if (!VideoModeList->getVideoModeCount())\r
- {\r
- // enumerate video modes.\r
- const SDL_VideoInfo *vi = SDL_GetVideoInfo();\r
-\r
- SDL_PixelFormat pixelFormat = *(vi->vfmt);\r
-\r
- core::array<Uint8> checkBitsPerPixel;\r
- checkBitsPerPixel.push_back(8);\r
- checkBitsPerPixel.push_back(16);\r
- checkBitsPerPixel.push_back(24);\r
- checkBitsPerPixel.push_back(32);\r
- if ( pixelFormat.BitsPerPixel > 32 )\r
- checkBitsPerPixel.push_back(pixelFormat.BitsPerPixel);\r
-\r
- for ( u32 i=0; i<checkBitsPerPixel.size(); ++i)\r
- {\r
- pixelFormat.BitsPerPixel = checkBitsPerPixel[i];\r
- SDL_Rect **modes = SDL_ListModes(&pixelFormat, SDL_Flags|SDL_FULLSCREEN);\r
- if (modes != 0)\r
- {\r
- if (modes == (SDL_Rect **)-1)\r
- {\r
- core::stringc strLog("All modes available for bit-depth ");\r
- strLog += core::stringc(pixelFormat.BitsPerPixel);\r
- os::Printer::log(strLog.c_str());\r
- }\r
- else\r
- {\r
- for (u32 i=0; modes[i]; ++i)\r
- VideoModeList->addMode(core::dimension2d<u32>(modes[i]->w, modes[i]->h), vi->vfmt->BitsPerPixel);\r
- }\r
- }\r
- }\r
- }\r
-\r
- return VideoModeList;\r
-#endif // !_IRR_EMSCRIPTEN_PLATFORM_\r
-}\r
-\r
//! Sets if the window should be resizable in windowed mode.\r
void CIrrDeviceSDL::setResizable(bool resize)\r
{\r
os::Printer::log("Resizable not available on the web." , ELL_WARNING);\r
return;\r
#else // !_IRR_EMSCRIPTEN_PLATFORM_\r
- if (resize != Resizable)\r
- {\r
-#if defined(_IRR_COMPILE_WITH_OPENGL_) && defined(_IRR_WINDOWS_)\r
- if ( SDL_Flags & SDL_OPENGL )\r
- {\r
- // For unknown reasons the hack with sharing resources which was added in Irrlicht 1.8.5 for this no longer works in 1.9\r
- // But at least we got a new WindowResizable flag since Irrlicht 1.9.\r
- os::Printer::log("setResizable not supported with this device/driver combination. Use SIrrCreationParameters.WindowResizable instead.", ELL_WARNING);\r
- return;\r
- }\r
-#endif\r
-\r
+ if (resize != Resizable) { \r
if (resize)\r
- SDL_Flags |= SDL_RESIZABLE;\r
+ SDL_Flags |= SDL_WINDOW_RESIZABLE;\r
else\r
- SDL_Flags &= ~SDL_RESIZABLE;\r
+ SDL_Flags &= ~SDL_WINDOW_RESIZABLE;\r
\r
- Screen = SDL_SetVideoMode( 0, 0, 0, SDL_Flags );\r
+ if (Window) {\r
+ SDL_SetWindowResizable(Window, (SDL_bool)resize);\r
+ }\r
Resizable = resize;\r
}\r
#endif // !_IRR_EMSCRIPTEN_PLATFORM_\r
//! Minimizes window if possible\r
void CIrrDeviceSDL::minimizeWindow()\r
{\r
- SDL_WM_IconifyWindow();\r
+ if (Window) {\r
+ SDL_MinimizeWindow(Window);\r
+ }\r
}\r
\r
\r
return false;\r
}\r
#endif\r
- const Uint8 appState = SDL_GetAppState();\r
- return (appState&SDL_APPACTIVE && appState&SDL_APPINPUTFOCUS) ? true : false;\r
+ const u32 windowFlags = SDL_GetWindowFlags(Window);\r
+ return windowFlags & SDL_WINDOW_SHOWN && windowFlags & SDL_WINDOW_INPUT_FOCUS;\r
}\r
\r
\r
//! returns if window has focus.\r
bool CIrrDeviceSDL::isWindowFocused() const\r
{\r
- return (SDL_GetAppState()&SDL_APPINPUTFOCUS) ? true : false;\r
+ return SDL_GetWindowFlags(Window) & SDL_WINDOW_INPUT_FOCUS;\r
}\r
\r
\r
//! returns color format of the window.\r
video::ECOLOR_FORMAT CIrrDeviceSDL::getColorFormat() const\r
{\r
- if (Screen)\r
+ if (Window)\r
{\r
- if (Screen->format->BitsPerPixel==16)\r
+ SDL_Surface *surface = SDL_GetWindowSurface(Window);\r
+ if (surface->format->BitsPerPixel == 16)\r
{\r
- if (Screen->format->Amask != 0)\r
+ if (surface->format->Amask != 0)\r
return video::ECF_A1R5G5B5;\r
else\r
return video::ECF_R5G6B5;\r
}\r
else\r
{\r
- if (Screen->format->Amask != 0)\r
+ if (surface->format->Amask != 0)\r
return video::ECF_A8R8G8B8;\r
else\r
return video::ECF_R8G8B8;\r
KeyMap.push_back(SKeyMap(SDLK_DOWN, KEY_DOWN));\r
\r
// select missing\r
- KeyMap.push_back(SKeyMap(SDLK_PRINT, KEY_PRINT));\r
+ KeyMap.push_back(SKeyMap(SDLK_PRINTSCREEN, KEY_PRINT));\r
// execute missing\r
- KeyMap.push_back(SKeyMap(SDLK_PRINT, KEY_SNAPSHOT));\r
+ KeyMap.push_back(SKeyMap(SDLK_PRINTSCREEN, KEY_SNAPSHOT));\r
\r
KeyMap.push_back(SKeyMap(SDLK_INSERT, KEY_INSERT));\r
KeyMap.push_back(SKeyMap(SDLK_DELETE, KEY_DELETE));\r
KeyMap.push_back(SKeyMap(SDLK_y, KEY_KEY_Y));\r
KeyMap.push_back(SKeyMap(SDLK_z, KEY_KEY_Z));\r
\r
- KeyMap.push_back(SKeyMap(SDLK_LSUPER, KEY_LWIN));\r
- KeyMap.push_back(SKeyMap(SDLK_RSUPER, KEY_RWIN));\r
+ KeyMap.push_back(SKeyMap(SDLK_LGUI, KEY_LWIN));\r
+ KeyMap.push_back(SKeyMap(SDLK_RGUI, KEY_RWIN));\r
// apps missing\r
KeyMap.push_back(SKeyMap(SDLK_POWER, KEY_SLEEP)); //??\r
\r
- KeyMap.push_back(SKeyMap(SDLK_KP0, KEY_NUMPAD0));\r
- KeyMap.push_back(SKeyMap(SDLK_KP1, KEY_NUMPAD1));\r
- KeyMap.push_back(SKeyMap(SDLK_KP2, KEY_NUMPAD2));\r
- KeyMap.push_back(SKeyMap(SDLK_KP3, KEY_NUMPAD3));\r
- KeyMap.push_back(SKeyMap(SDLK_KP4, KEY_NUMPAD4));\r
- KeyMap.push_back(SKeyMap(SDLK_KP5, KEY_NUMPAD5));\r
- KeyMap.push_back(SKeyMap(SDLK_KP6, KEY_NUMPAD6));\r
- KeyMap.push_back(SKeyMap(SDLK_KP7, KEY_NUMPAD7));\r
- KeyMap.push_back(SKeyMap(SDLK_KP8, KEY_NUMPAD8));\r
- KeyMap.push_back(SKeyMap(SDLK_KP9, KEY_NUMPAD9));\r
+ KeyMap.push_back(SKeyMap(SDLK_KP_0, KEY_NUMPAD0));\r
+ KeyMap.push_back(SKeyMap(SDLK_KP_1, KEY_NUMPAD1));\r
+ KeyMap.push_back(SKeyMap(SDLK_KP_2, KEY_NUMPAD2));\r
+ KeyMap.push_back(SKeyMap(SDLK_KP_3, KEY_NUMPAD3));\r
+ KeyMap.push_back(SKeyMap(SDLK_KP_4, KEY_NUMPAD4));\r
+ KeyMap.push_back(SKeyMap(SDLK_KP_5, KEY_NUMPAD5));\r
+ KeyMap.push_back(SKeyMap(SDLK_KP_6, KEY_NUMPAD6));\r
+ KeyMap.push_back(SKeyMap(SDLK_KP_7, KEY_NUMPAD7));\r
+ KeyMap.push_back(SKeyMap(SDLK_KP_8, KEY_NUMPAD8));\r
+ KeyMap.push_back(SKeyMap(SDLK_KP_9, KEY_NUMPAD9));\r
KeyMap.push_back(SKeyMap(SDLK_KP_MULTIPLY, KEY_MULTIPLY));\r
KeyMap.push_back(SKeyMap(SDLK_KP_PLUS, KEY_ADD));\r
// KeyMap.push_back(SKeyMap(SDLK_KP_, KEY_SEPARATOR));\r
KeyMap.push_back(SKeyMap(SDLK_F15, KEY_F15));\r
// no higher F-keys\r
\r
- KeyMap.push_back(SKeyMap(SDLK_NUMLOCK, KEY_NUMLOCK));\r
- KeyMap.push_back(SKeyMap(SDLK_SCROLLOCK, KEY_SCROLL));\r
+ KeyMap.push_back(SKeyMap(SDLK_NUMLOCKCLEAR, KEY_NUMLOCK));\r
+ KeyMap.push_back(SKeyMap(SDLK_SCROLLLOCK, KEY_SCROLL));\r
KeyMap.push_back(SKeyMap(SDLK_LSHIFT, KEY_LSHIFT));\r
KeyMap.push_back(SKeyMap(SDLK_RSHIFT, KEY_RSHIFT));\r
KeyMap.push_back(SKeyMap(SDLK_LCTRL, KEY_LCONTROL));\r