]> git.lizzy.rs Git - irrlicht.git/blobdiff - source/Irrlicht/CIrrDeviceWin32.cpp
Add OpenGL3 renderer
[irrlicht.git] / source / Irrlicht / CIrrDeviceWin32.cpp
index 0ea188b1f2418761542f5b1aed1a589f68e6b588..1033f9edccbed22795d60f7edddb91af81887d2c 100644 (file)
@@ -2,7 +2,6 @@
 // This file is part of the "Irrlicht Engine".\r
 // For conditions of distribution and use, see copyright notice in irrlicht.h\r
 \r
-#include "IrrCompileConfig.h"\r
 \r
 #ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_\r
 \r
@@ -720,7 +719,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
                                dev->postEventFromUser(event);\r
 \r
                        if (message == WM_SYSKEYDOWN || message == WM_SYSKEYUP)\r
-                               return DefWindowProc(hWnd, message, wParam, lParam);\r
+                               return DefWindowProcW(hWnd, message, wParam, lParam);\r
                        else\r
                                return 0;\r
                }\r
@@ -774,7 +773,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
                KEYBOARD_INPUT_HKL = GetKeyboardLayout(0);\r
                return 0;\r
        }\r
-       return DefWindowProc(hWnd, message, wParam, lParam);\r
+       return DefWindowProcW(hWnd, message, wParam, lParam);\r
 }\r
 \r
 \r
@@ -784,7 +783,8 @@ namespace irr
 //! constructor\r
 CIrrDeviceWin32::CIrrDeviceWin32(const SIrrlichtCreationParameters& params)\r
 : CIrrDeviceStub(params), HWnd(0), Resized(false),\r
-       ExternalWindow(false), Win32CursorControl(0), JoyControl(0)\r
+       ExternalWindow(false), Win32CursorControl(0), JoyControl(0),\r
+       WindowMaximized(params.WindowMaximized)\r
 {\r
        #ifdef _DEBUG\r
        setDebugName("CIrrDeviceWin32");\r
@@ -802,11 +802,11 @@ CIrrDeviceWin32::CIrrDeviceWin32(const SIrrlichtCreationParameters& params)
        // create the window if we need to and we do not use the null device\r
        if (!CreationParams.WindowId && CreationParams.DriverType != video::EDT_NULL)\r
        {\r
-               const fschar_t* ClassName = __TEXT("CIrrDeviceWin32");\r
+               const wchar_t* ClassName = L"CIrrDeviceWin32";\r
 \r
                // Register Class\r
-               WNDCLASSEX wcex;\r
-               wcex.cbSize                     = sizeof(WNDCLASSEX);\r
+               WNDCLASSEXW wcex;\r
+               wcex.cbSize                     = sizeof(WNDCLASSEXW);\r
                wcex.style                      = CS_HREDRAW | CS_VREDRAW;\r
                wcex.lpfnWndProc        = WndProc;\r
                wcex.cbClsExtra         = 0;\r
@@ -820,9 +820,9 @@ CIrrDeviceWin32::CIrrDeviceWin32(const SIrrlichtCreationParameters& params)
                wcex.hIconSm            = 0;\r
 \r
                // if there is an icon, load it\r
-               wcex.hIcon = (HICON)LoadImage(hInstance, __TEXT("irrlicht.ico"), IMAGE_ICON, 0,0, LR_LOADFROMFILE | LR_DEFAULTSIZE);\r
+               wcex.hIcon = (HICON)LoadImageW(hInstance, L"irrlicht.ico", IMAGE_ICON, 0,0, LR_LOADFROMFILE | LR_DEFAULTSIZE);\r
 \r
-               RegisterClassEx(&wcex);\r
+               RegisterClassExW(&wcex);\r
 \r
                // calculate client size\r
 \r
@@ -857,7 +857,7 @@ CIrrDeviceWin32::CIrrDeviceWin32(const SIrrlichtCreationParameters& params)
                }\r
 \r
                // create window\r
-               HWnd = CreateWindow( ClassName, __TEXT(""), style, windowLeft, windowTop,\r
+               HWnd = CreateWindowW( ClassName, L"", style, windowLeft, windowTop,\r
                                        realWidth, realHeight, NULL, NULL, hInstance, NULL);\r
                if (!HWnd)\r
                {\r
@@ -923,6 +923,9 @@ CIrrDeviceWin32::CIrrDeviceWin32(const SIrrlichtCreationParameters& params)
 \r
        // inform driver about the window size etc.\r
        resizeIfNecessary();\r
+\r
+       if (params.WindowMaximized)\r
+               maximizeWindow();\r
 }\r
 \r
 \r
@@ -1009,24 +1012,6 @@ void CIrrDeviceWin32::createDriver()
        case video::EDT_WEBGL1:\r
                os::Printer::log("WebGL1 driver not supported on Win32 device.", ELL_ERROR);\r
                break;\r
-       case video::EDT_SOFTWARE:\r
-#ifdef _IRR_COMPILE_WITH_SOFTWARE_\r
-               switchToFullScreen();\r
-\r
-               VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this);\r
-#else\r
-               os::Printer::log("Software driver was not compiled in.", ELL_ERROR);\r
-#endif\r
-               break;\r
-       case video::EDT_BURNINGSVIDEO:\r
-#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_\r
-               switchToFullScreen();\r
-\r
-               VideoDriver = video::createBurningVideoDriver(CreationParams, FileSystem, this);\r
-#else\r
-               os::Printer::log("Burning's Video driver was not compiled in.", ELL_ERROR);\r
-#endif\r
-               break;\r
        case video::EDT_NULL:\r
                VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);\r
                break;\r
@@ -1127,54 +1112,6 @@ void CIrrDeviceWin32::setWindowCaption(const wchar_t* text)
 }\r
 \r
 \r
-//! presents a surface in the client area\r
-bool CIrrDeviceWin32::present(video::IImage* image, void* windowId, core::rect<s32>* src)\r
-{\r
-       HWND hwnd = HWnd;\r
-       if ( windowId )\r
-               hwnd = static_cast<HWND>(windowId);\r
-\r
-       HDC dc = GetDC(hwnd);\r
-\r
-       if ( dc )\r
-       {\r
-               RECT rect;\r
-               GetClientRect(hwnd, &rect);\r
-               const void* memory = (const void *)image->getData();\r
-\r
-               BITMAPV4HEADER bi;\r
-               ZeroMemory (&bi, sizeof(bi));\r
-               bi.bV4Size = sizeof(BITMAPINFOHEADER);\r
-               bi.bV4BitCount = (WORD)image->getBitsPerPixel();\r
-               bi.bV4Planes = 1;\r
-               bi.bV4Width = image->getDimension().Width;\r
-               bi.bV4Height = -((s32)image->getDimension().Height);\r
-               bi.bV4V4Compression = BI_BITFIELDS;\r
-               bi.bV4AlphaMask = image->getAlphaMask();\r
-               bi.bV4RedMask = image->getRedMask();\r
-               bi.bV4GreenMask = image->getGreenMask();\r
-               bi.bV4BlueMask = image->getBlueMask();\r
-\r
-               if ( src )\r
-               {\r
-                       StretchDIBits(dc, 0,0, rect.right, rect.bottom,\r
-                                       src->UpperLeftCorner.X, src->UpperLeftCorner.Y,\r
-                                       src->getWidth(), src->getHeight(),\r
-                                       memory, (const BITMAPINFO*)(&bi), DIB_RGB_COLORS, SRCCOPY);\r
-               }\r
-               else\r
-               {\r
-                       StretchDIBits(dc, 0,0, rect.right, rect.bottom,\r
-                                       0, 0, image->getDimension().Width, image->getDimension().Height,\r
-                                       memory, (const BITMAPINFO*)(&bi), DIB_RGB_COLORS, SRCCOPY);\r
-               }\r
-\r
-               ReleaseDC(hwnd, dc);\r
-       }\r
-       return true;\r
-}\r
-\r
-\r
 //! notifies the device that it should close itself\r
 void CIrrDeviceWin32::closeDevice()\r
 {\r
@@ -1185,9 +1122,9 @@ void CIrrDeviceWin32::closeDevice()
                PostQuitMessage(0);\r
                PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE);\r
                DestroyWindow(HWnd);\r
-               const fschar_t* ClassName = __TEXT("CIrrDeviceWin32");\r
+               const wchar_t* ClassName = L"CIrrDeviceWin32";\r
                HINSTANCE hInstance = GetModuleHandle(0);\r
-               UnregisterClass(ClassName, hInstance);\r
+               UnregisterClassW(ClassName, hInstance);\r
        }\r
        Close=true;\r
 }\r
@@ -1220,6 +1157,13 @@ bool CIrrDeviceWin32::isWindowMinimized() const
 }\r
 \r
 \r
+//! returns last state from maximizeWindow() and restoreWindow()\r
+bool CIrrDeviceWin32::isWindowMaximized() const\r
+{\r
+       return WindowMaximized;\r
+}\r
+\r
+\r
 //! switches to fullscreen\r
 bool CIrrDeviceWin32::switchToFullScreen()\r
 {\r
@@ -1344,6 +1288,8 @@ void CIrrDeviceWin32::maximizeWindow()
        GetWindowPlacement(HWnd, &wndpl);\r
        wndpl.showCmd = SW_SHOWMAXIMIZED;\r
        SetWindowPlacement(HWnd, &wndpl);\r
+\r
+       WindowMaximized = true;\r
 }\r
 \r
 \r
@@ -1355,6 +1301,8 @@ void CIrrDeviceWin32::restoreWindow()
        GetWindowPlacement(HWnd, &wndpl);\r
        wndpl.showCmd = SW_SHOWNORMAL;\r
        SetWindowPlacement(HWnd, &wndpl);\r
+\r
+       WindowMaximized = false;\r
 }\r
 \r
 core::position2di CIrrDeviceWin32::getWindowPosition()\r
@@ -1383,46 +1331,6 @@ bool CIrrDeviceWin32::activateJoysticks(core::array<SJoystickInfo> & joystickInf
 }\r
 \r
 \r
-//! Set the current Gamma Value for the Display\r
-bool CIrrDeviceWin32::setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast )\r
-{\r
-       bool r;\r
-       u16 ramp[3][256];\r
-\r
-       calculateGammaRamp( ramp[0], red, brightness, contrast );\r
-       calculateGammaRamp( ramp[1], green, brightness, contrast );\r
-       calculateGammaRamp( ramp[2], blue, brightness, contrast );\r
-\r
-       HDC dc = GetDC(0);\r
-       r = SetDeviceGammaRamp ( dc, ramp ) == TRUE;\r
-       ReleaseDC(HWnd, dc);\r
-       return r;\r
-}\r
-\r
-//! Get the current Gamma Value for the Display\r
-bool CIrrDeviceWin32::getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast )\r
-{\r
-       bool r;\r
-       u16 ramp[3][256];\r
-\r
-       HDC dc = GetDC(0);\r
-       r = GetDeviceGammaRamp ( dc, ramp ) == TRUE;\r
-       ReleaseDC(HWnd, dc);\r
-\r
-       if (r)\r
-       {\r
-               calculateGammaFromRamp(red, ramp[0]);\r
-               calculateGammaFromRamp(green, ramp[1]);\r
-               calculateGammaFromRamp(blue, ramp[2]);\r
-       }\r
-\r
-       brightness = 0.f;\r
-       contrast = 0.f;\r
-\r
-       return r;\r
-}\r
-\r
-\r
 //! Process system events\r
 void CIrrDeviceWin32::handleSystemMessages()\r
 {\r