diff --git a/drivers/rtaudio/audio_driver_rtaudio.cpp b/drivers/rtaudio/audio_driver_rtaudio.cpp index 93531283336..bc6ceb1e7e8 100644 --- a/drivers/rtaudio/audio_driver_rtaudio.cpp +++ b/drivers/rtaudio/audio_driver_rtaudio.cpp @@ -114,11 +114,12 @@ Error AudioDriverRtAudio::init() { unsigned int buffer_frames = closest_power_of_2(latency * mix_rate / 1000); print_verbose("Audio buffer frames: " + itos(buffer_frames) + " calculated latency: " + itos(buffer_frames * 1000 / mix_rate) + "ms"); - short int tries = 2; + short int tries = 4; - while (tries >= 0) { + while (tries > 0) { switch (speaker_mode) { case SPEAKER_MODE_STEREO: parameters.nChannels = 2; break; + case SPEAKER_SURROUND_31: parameters.nChannels = 4; break; case SPEAKER_SURROUND_51: parameters.nChannels = 6; break; case SPEAKER_SURROUND_71: parameters.nChannels = 8; break; }; @@ -133,7 +134,9 @@ Error AudioDriverRtAudio::init() { ERR_PRINT("Unable to open audio, retrying with fewer channels..."); switch (speaker_mode) { - case SPEAKER_SURROUND_51: speaker_mode = SPEAKER_MODE_STEREO; break; + case SPEAKER_MODE_STEREO: break; // Required to silence unhandled enum value warning. + case SPEAKER_SURROUND_31: speaker_mode = SPEAKER_MODE_STEREO; break; + case SPEAKER_SURROUND_51: speaker_mode = SPEAKER_SURROUND_31; break; case SPEAKER_SURROUND_71: speaker_mode = SPEAKER_SURROUND_51; break; } diff --git a/platform/windows/context_gl_win.cpp b/platform/windows/context_gl_win.cpp index fd7cd69c37a..2d70b00ddac 100644 --- a/platform/windows/context_gl_win.cpp +++ b/platform/windows/context_gl_win.cpp @@ -92,9 +92,9 @@ Error ContextGL_Win::initialize() { PFD_SUPPORT_OPENGL | // Format Must Support OpenGL PFD_DOUBLEBUFFER, (BYTE)PFD_TYPE_RGBA, - OS::get_singleton()->is_layered_allowed() ? (BYTE)32 : (BYTE)24, + (BYTE)(OS::get_singleton()->is_layered_allowed() ? 32 : 24), (BYTE)0, (BYTE)0, (BYTE)0, (BYTE)0, (BYTE)0, (BYTE)0, // Color Bits Ignored - OS::get_singleton()->is_layered_allowed() ? (BYTE)8 : (BYTE)0, // Alpha Buffer + (BYTE)(OS::get_singleton()->is_layered_allowed() ? 8 : 0), // Alpha Buffer (BYTE)0, // Shift Bit Ignored (BYTE)0, // No Accumulation Buffer (BYTE)0, (BYTE)0, (BYTE)0, (BYTE)0, // Accumulation Bits Ignored diff --git a/platform/windows/joypad.cpp b/platform/windows/joypad.cpp index 99ac0214e0c..7201714fb83 100644 --- a/platform/windows/joypad.cpp +++ b/platform/windows/joypad.cpp @@ -172,7 +172,7 @@ bool JoypadWindows::setup_dinput_joypad(const DIDEVICEINSTANCE *instance) { joy->di_joy->SetDataFormat(&c_dfDIJoystick2); joy->di_joy->SetCooperativeLevel(*hWnd, DISCL_FOREGROUND); - joy->di_joy->EnumObjects(objectsCallback, this, NULL); + joy->di_joy->EnumObjects(objectsCallback, this, 0); joy->joy_axis.sort(); joy->guid = instance->guidInstance; diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index ac130ac4f23..3bbffd8fb7d 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -763,7 +763,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) RECT r; GetWindowRect(hWnd, &r); - dib_size = Size2(r.right - r.left, r.bottom - r.top); + dib_size = Size2i(r.right - r.left, r.bottom - r.top); BITMAPINFO bmi; ZeroMemory(&bmi, sizeof(BITMAPINFO)); @@ -773,7 +773,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biBitCount = 32; bmi.bmiHeader.biCompression = BI_RGB; - bmi.bmiHeader.biSizeImage = dib_size.x, dib_size.y * 4; + bmi.bmiHeader.biSizeImage = dib_size.x * dib_size.y * 4; hBitmap = CreateDIBSection(hDC_dib, &bmi, DIB_RGB_COLORS, (void **)&dib_data, NULL, 0x0); SelectObject(hDC_dib, hBitmap); @@ -1050,7 +1050,6 @@ static int QueryDpiForMonitor(HMONITOR hmon, _MonitorDpiType dpiType = MDT_Defau UINT x = 0, y = 0; HRESULT hr = E_FAIL; - bool bSet = false; if (hmon && (Shcore != (HMODULE)INVALID_HANDLE_VALUE)) { hr = getDPIForMonitor(hmon, dpiType /*MDT_Effective_DPI*/, &x, &y); if (SUCCEEDED(hr) && (x > 0) && (y > 0)) { @@ -1229,7 +1228,7 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int printf("Error setting WNDPROC: %li\n", le); }; - LONG_PTR proc = GetWindowLongPtr(hWnd, GWLP_WNDPROC); + GetWindowLongPtr(hWnd, GWLP_WNDPROC); RECT rect; if (!GetClientRect(hWnd, &rect)) { @@ -1728,14 +1727,18 @@ void OS_Windows::set_window_position(const Point2 &p_position) { Size2 OS_Windows::get_window_size() const { RECT r; - GetClientRect(hWnd, &r); - return Vector2(r.right - r.left, r.bottom - r.top); + if (GetClientRect(hWnd, &r)) { // Only area inside of window border + return Size2(r.right - r.left, r.bottom - r.top); + } + return Size2(); } Size2 OS_Windows::get_real_window_size() const { RECT r; - GetWindowRect(hWnd, &r); - return Vector2(r.right - r.left, r.bottom - r.top); + if (GetWindowRect(hWnd, &r)) { // Includes area of the window border + return Size2(r.right - r.left, r.bottom - r.top); + } + return Size2(); } void OS_Windows::set_window_size(const Size2 p_size) { @@ -2274,7 +2277,6 @@ void OS_Windows::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shap ERR_FAIL_COND(!image.is_valid()); UINT image_size = texture_size.width * texture_size.height; - UINT size = sizeof(UINT) * image_size; // Create the BITMAP with alpha channel COLORREF *buffer = (COLORREF *)memalloc(sizeof(COLORREF) * image_size); @@ -2746,11 +2748,6 @@ void OS_Windows::run() { main_loop->init(); - uint64_t last_ticks = get_ticks_usec(); - - int frames = 0; - uint64_t frame = 0; - while (!force_quit) { process_events(); // get rid of pending events diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 97e746907dd..6bf1d12086a 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -629,10 +629,8 @@ Rect2 Viewport::get_visible_rect() const { Rect2 r; if (size == Size2()) { - - r = Rect2(Point2(), Size2(OS::get_singleton()->get_window_size().width, OS::get_singleton()->get_window_size().height)); + r = Rect2(Point2(), OS::get_singleton()->get_window_size()); } else { - r = Rect2(Point2(), size); }