From 044b06a7d3f1e7873d2021540da18693d889e695 Mon Sep 17 00:00:00 2001 From: Laura Hermanns Date: Sat, 27 Jul 2024 11:35:25 -0400 Subject: [PATCH] [GL] Deprecated Surface::ResetPixelFormat() by selecting multi-sample pixel format via proxy window for Win32 platform. Surface::ResetPixelFormat() was solely used to re-create the internal window of a Win32 LLGL::Window object when a multi-sample pixel format is selected for an OpenGL context. In order to load the necessary GL extension procedure wglChoosePixelFormatARB(), a valid GL context must be active. After selecting a format, the multi-sampled GL context can be created. A Win32 window, however, cannot change its pixel format once its selected, so previously ResetPixelFormat() would re-create the native window on Win32 platform, while all other platforms only had dummy implementations. This change uses a proxy window that is invisible to select a multi-sample pixel format when a WGL context is created before the format is selected for the actual window provided for the swap-chain. --- include/LLGL-C/Surface.h | 4 +- include/LLGL/Surface.h | 13 +- sources/Platform/Android/AndroidCanvas.cpp | 5 - sources/Platform/Android/AndroidCanvas.h | 2 - sources/Platform/IOS/IOSCanvas.h | 2 - sources/Platform/IOS/IOSCanvas.mm | 10 - sources/Platform/Linux/LinuxWindow.cpp | 5 - sources/Platform/Linux/LinuxWindow.h | 2 - sources/Platform/MacOS/MacOSSubviewWindow.h | 2 - sources/Platform/MacOS/MacOSSubviewWindow.mm | 5 - sources/Platform/MacOS/MacOSWindow.h | 2 - sources/Platform/MacOS/MacOSWindow.mm | 5 - sources/Platform/UWP/UWPWindow.cpp | 5 - sources/Platform/UWP/UWPWindow.h | 2 - sources/Platform/Win32/Win32Window.cpp | 15 +- sources/Platform/Win32/Win32Window.h | 2 - .../OpenGL/Platform/Win32/Win32GLContext.cpp | 187 ++++++++++++------ .../OpenGL/Platform/Win32/Win32GLContext.h | 8 +- wrapper/C99/C99Surface.cpp | 2 +- wrapper/CSharp/Surface.cs | 3 +- 20 files changed, 147 insertions(+), 134 deletions(-) diff --git a/include/LLGL-C/Surface.h b/include/LLGL-C/Surface.h index c95038e2e2..67b1d2cf76 100644 --- a/include/LLGL-C/Surface.h +++ b/include/LLGL-C/Surface.h @@ -18,10 +18,12 @@ LLGL_C_EXPORT bool llglGetSurfaceNativeHandle(LLGLSurface surface, void* nativeHandle, size_t nativeHandleSize); LLGL_C_EXPORT void llglGetSurfaceContentSize(LLGLSurface surface, LLGLExtent2D* outSize); LLGL_C_EXPORT bool llglAdaptSurfaceForVideoMode(LLGLSurface surface, LLGLExtent2D* outResolution, bool* outFullscreen); -LLGL_C_EXPORT void llglResetSurfacePixelFormat(LLGLSurface surface); LLGL_C_EXPORT bool llglProcessSurfaceEvents(); LLGL_C_EXPORT LLGLDisplay llglFindSurfaceResidentDisplay(LLGLSurface surface); +//! \deprecated Since 0.04b; No need to reset pixel format anymore. +LLGL_C_EXPORT void llglResetSurfacePixelFormat(LLGLSurface surface); + #endif diff --git a/include/LLGL/Surface.h b/include/LLGL/Surface.h index b1ffb932b6..265a29e40a 100644 --- a/include/LLGL/Surface.h +++ b/include/LLGL/Surface.h @@ -13,6 +13,7 @@ #include #include #include +#include namespace LLGL @@ -76,14 +77,6 @@ class LLGL_EXPORT Surface : public Interface */ virtual bool AdaptForVideoMode(Extent2D* resolution, bool* fullscreen) = 0; - /** - \brief Resets the internal pixel format of the surface. - \remarks This function is mainly used by the OpenGL renderer on Win32 when a multi-sampled framebuffer is created. - \note This may invalidate the native handle previously returned by \c GetNativeHandle. - \see GetNativeHandle - */ - virtual void ResetPixelFormat() = 0; - /** \brief Returns the Display interface where this surface is resident in. \remarks A surface is considered resident in a display if more than the half of its client area is visible in that display. @@ -91,6 +84,10 @@ class LLGL_EXPORT Surface : public Interface */ virtual Display* FindResidentDisplay() const = 0; + //! \deprecated Since 0.04b; No need to reset pixel format anymore! + LLGL_DEPRECATED("Surface::ResetPixelFormat is deprecated since 0.04b; No need to reset pixel format anymore!") + virtual void ResetPixelFormat(); + public: /** diff --git a/sources/Platform/Android/AndroidCanvas.cpp b/sources/Platform/Android/AndroidCanvas.cpp index e5f04fba2d..cdabb203f8 100644 --- a/sources/Platform/Android/AndroidCanvas.cpp +++ b/sources/Platform/Android/AndroidCanvas.cpp @@ -112,11 +112,6 @@ UTF8String AndroidCanvas::GetTitle() const return {}; //todo... } -void AndroidCanvas::ResetPixelFormat() -{ - // dummy -} - } // /namespace LLGL diff --git a/sources/Platform/Android/AndroidCanvas.h b/sources/Platform/Android/AndroidCanvas.h index 8acefe46e8..6f9607251d 100644 --- a/sources/Platform/Android/AndroidCanvas.h +++ b/sources/Platform/Android/AndroidCanvas.h @@ -32,8 +32,6 @@ class AndroidCanvas : public Canvas void SetTitle(const UTF8String& title) override; UTF8String GetTitle() const override; - void ResetPixelFormat() override; - private: CanvasDescriptor desc_; diff --git a/sources/Platform/IOS/IOSCanvas.h b/sources/Platform/IOS/IOSCanvas.h index 7d6490cf06..a0da47507a 100644 --- a/sources/Platform/IOS/IOSCanvas.h +++ b/sources/Platform/IOS/IOSCanvas.h @@ -32,8 +32,6 @@ class IOSCanvas : public Canvas void SetTitle(const UTF8String& title) override; UTF8String GetTitle() const override; - void ResetPixelFormat() override; - public: // Returns the native UIWindow. diff --git a/sources/Platform/IOS/IOSCanvas.mm b/sources/Platform/IOS/IOSCanvas.mm index 6943ec7088..ba7671a9c3 100644 --- a/sources/Platform/IOS/IOSCanvas.mm +++ b/sources/Platform/IOS/IOSCanvas.mm @@ -195,16 +195,6 @@ - (void)handlePanGesture:(UIPanGestureRecognizer*)recognizer } -/* - * ======= Private: ======= - */ - -void IOSCanvas::ResetPixelFormat() -{ - // dummy -} - - } // /namespace LLGL diff --git a/sources/Platform/Linux/LinuxWindow.cpp b/sources/Platform/Linux/LinuxWindow.cpp index 794b8d6937..ce631b4712 100644 --- a/sources/Platform/Linux/LinuxWindow.cpp +++ b/sources/Platform/Linux/LinuxWindow.cpp @@ -155,11 +155,6 @@ bool LinuxWindow::GetNativeHandle(void* nativeHandle, std::size_t nativeHandleSi return false; } -void LinuxWindow::ResetPixelFormat() -{ - // dummy -} - Extent2D LinuxWindow::GetContentSize() const { /* Return the size of the client area */ diff --git a/sources/Platform/Linux/LinuxWindow.h b/sources/Platform/Linux/LinuxWindow.h index 3a20767cd2..29229e9c6d 100644 --- a/sources/Platform/Linux/LinuxWindow.h +++ b/sources/Platform/Linux/LinuxWindow.h @@ -28,8 +28,6 @@ class LinuxWindow : public Window bool GetNativeHandle(void* nativeHandle, std::size_t nativeHandleSize) override; - void ResetPixelFormat() override; - Extent2D GetContentSize() const override; void SetPosition(const Offset2D& position) override; diff --git a/sources/Platform/MacOS/MacOSSubviewWindow.h b/sources/Platform/MacOS/MacOSSubviewWindow.h index 67a712c3ee..c351396e9c 100644 --- a/sources/Platform/MacOS/MacOSSubviewWindow.h +++ b/sources/Platform/MacOS/MacOSSubviewWindow.h @@ -28,8 +28,6 @@ class MacOSSubviewWindow : public Window bool GetNativeHandle(void* nativeHandle, std::size_t nativeHandleSize) override; - void ResetPixelFormat() override; - Extent2D GetContentSize() const override; void SetPosition(const Offset2D& position) override; diff --git a/sources/Platform/MacOS/MacOSSubviewWindow.mm b/sources/Platform/MacOS/MacOSSubviewWindow.mm index a4ae728000..612a6801c2 100644 --- a/sources/Platform/MacOS/MacOSSubviewWindow.mm +++ b/sources/Platform/MacOS/MacOSSubviewWindow.mm @@ -41,11 +41,6 @@ return false; } -void MacOSSubviewWindow::ResetPixelFormat() -{ - // dummy -} - Extent2D MacOSSubviewWindow::GetContentSize() const { NSSize size = [view_ frame].size; diff --git a/sources/Platform/MacOS/MacOSWindow.h b/sources/Platform/MacOS/MacOSWindow.h index 2928c2561d..3d3379f450 100644 --- a/sources/Platform/MacOS/MacOSWindow.h +++ b/sources/Platform/MacOS/MacOSWindow.h @@ -29,8 +29,6 @@ class MacOSWindow : public Window bool GetNativeHandle(void* nativeHandle, std::size_t nativeHandleSize) override; - void ResetPixelFormat() override; - Extent2D GetContentSize() const override; void SetPosition(const Offset2D& position) override; diff --git a/sources/Platform/MacOS/MacOSWindow.mm b/sources/Platform/MacOS/MacOSWindow.mm index 05291abc9f..f66c0bbe13 100644 --- a/sources/Platform/MacOS/MacOSWindow.mm +++ b/sources/Platform/MacOS/MacOSWindow.mm @@ -179,11 +179,6 @@ static NSUInteger GetNSWindowStyleMask(const WindowDescriptor& desc) return false; } -void MacOSWindow::ResetPixelFormat() -{ - // dummy -} - Extent2D MacOSWindow::GetContentSize() const { NSSize size = [[wnd_ contentView] frame].size; diff --git a/sources/Platform/UWP/UWPWindow.cpp b/sources/Platform/UWP/UWPWindow.cpp index 2fb9d9e359..4f2e278349 100644 --- a/sources/Platform/UWP/UWPWindow.cpp +++ b/sources/Platform/UWP/UWPWindow.cpp @@ -64,11 +64,6 @@ bool UWPWindow::GetNativeHandle(void* nativeHandle, std::size_t nativeHandleSize return false; } -void UWPWindow::ResetPixelFormat() -{ - //todo -} - Extent2D UWPWindow::GetContentSize() const { return Extent2D diff --git a/sources/Platform/UWP/UWPWindow.h b/sources/Platform/UWP/UWPWindow.h index ac91e9089d..0f7d55ccde 100644 --- a/sources/Platform/UWP/UWPWindow.h +++ b/sources/Platform/UWP/UWPWindow.h @@ -29,8 +29,6 @@ class UWPWindow final : public Window bool GetNativeHandle(void* nativeHandle, std::size_t nativeHandleSize) override; - void ResetPixelFormat() override; - Extent2D GetContentSize() const override; void SetPosition(const Offset2D& position) override; diff --git a/sources/Platform/Win32/Win32Window.cpp b/sources/Platform/Win32/Win32Window.cpp index 6927d25a36..29ff19de52 100644 --- a/sources/Platform/Win32/Win32Window.cpp +++ b/sources/Platform/Win32/Win32Window.cpp @@ -21,6 +21,11 @@ namespace LLGL * Surface class */ +void Surface::ResetPixelFormat() +{ + // dummy +} + bool Surface::ProcessEvents() { /* Peek all queued messages */ @@ -68,7 +73,7 @@ static RECT GetClientArea(LONG width, LONG height, DWORD style) // Determines the Win32 window style for the specified descriptor. static DWORD GetWindowStyle(const WindowDescriptor& desc) { - DWORD style = (WS_CLIPCHILDREN | WS_CLIPSIBLINGS); + DWORD style = (WS_CLIPCHILDREN | WS_CLIPSIBLINGS); // Both required for OpenGL const bool hasWindowContext = ( @@ -168,14 +173,6 @@ bool Win32Window::GetNativeHandle(void* nativeHandle, std::size_t nativeHandleSi return false; } -void Win32Window::ResetPixelFormat() -{ - /* Destroy previous window handle and create a new one with current descriptor settings */ - auto desc = GetDesc(); - DestroyWindow(wnd_); - wnd_ = CreateWindowHandle(desc); -} - Extent2D Win32Window::GetContentSize() const { /* Return the size of the client area */ diff --git a/sources/Platform/Win32/Win32Window.h b/sources/Platform/Win32/Win32Window.h index 65d0c4fb34..b7f4713349 100644 --- a/sources/Platform/Win32/Win32Window.h +++ b/sources/Platform/Win32/Win32Window.h @@ -27,8 +27,6 @@ class Win32Window final : public Window bool GetNativeHandle(void* nativeHandle, std::size_t nativeHandleSize) override; - void ResetPixelFormat() override; - Extent2D GetContentSize() const override; void SetPosition(const Offset2D& position) override; diff --git a/sources/Renderer/OpenGL/Platform/Win32/Win32GLContext.cpp b/sources/Renderer/OpenGL/Platform/Win32/Win32GLContext.cpp index 179e1526e1..b7223a1eb3 100644 --- a/sources/Renderer/OpenGL/Platform/Win32/Win32GLContext.cpp +++ b/sources/Renderer/OpenGL/Platform/Win32/Win32GLContext.cpp @@ -5,6 +5,8 @@ * Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt). */ +#include + #include "Win32GLContext.h" #include "../../Ext/GLExtensions.h" #include "../../Ext/GLExtensionLoader.h" @@ -24,6 +26,55 @@ namespace LLGL { +/* + * WGLProxyWindowClass struct + */ + +struct WGLProxyWindowClass +{ + static const TCHAR* GetName() + { + return TEXT("LLGL.WGLProxyWindowClass"); + } + + WGLProxyWindowClass() + { + /* Setup window class information */ + WNDCLASS wc = {}; + + wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; + wc.hInstance = GetModuleHandle(nullptr); + wc.lpfnWndProc = DefWindowProc; + wc.hIcon = nullptr; + wc.hCursor = nullptr; + wc.hbrBackground = nullptr; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.lpszMenuName = nullptr; + wc.lpszClassName = GetName(); + + /* Register window class */ + if (!RegisterClass(&wc)) + LLGL_TRAP("failed to register window class"); + } + + ~WGLProxyWindowClass() + { + UnregisterClass(GetName(), GetModuleHandle(nullptr)); + } +}; + +static std::unique_ptr g_wglProxyWindowClass; + +static const TCHAR* GetProxyWindowClassName() +{ + /* Register Win32 window class if not already done */ + if (!g_wglProxyWindowClass) + g_wglProxyWindowClass = MakeUnique(); + return WGLProxyWindowClass::GetName(); +} + + /* * GLContext class */ @@ -76,26 +127,31 @@ Win32GLContext::Win32GLContext( Win32GLContext* sharedContext, const OpenGL::RenderSystemNativeHandle* customNativeHandle) : - profile_ { profile }, - formatDesc_ { pixelFormat } + profile_ { profile }, + formatDesc_ { pixelFormat }, + isProxyGLRC_ { customNativeHandle != nullptr } { - /* Create WGL context */ - if (customNativeHandle != nullptr) + if (isProxyGLRC_) { - isProxyGLRC_ = true; + /* Create a proxy context which only caches the provided WGL context and its pixel format */ CreateProxyContext(surface, *customNativeHandle); } else if (sharedContext) { + /* Create WGL context with a shared GL context */ Win32GLContext* sharedContextWGL = LLGL_CAST(Win32GLContext*, sharedContext); CreateWGLContext(surface, sharedContextWGL); } else + { + /* Create default WGL context */ CreateWGLContext(surface); + } } Win32GLContext::~Win32GLContext() { + /* Only delete this WGL context if we own it. A proxy context does not own the WGL context as it was provided externally. */ if (!isProxyGLRC_) DeleteWGLContext(hGLRC_); } @@ -131,11 +187,6 @@ bool Win32GLContext::SetSwapInterval(int interval) return (wglSwapIntervalEXT(interval) == TRUE); } -static void ErrMultisampledGLContextNotSupported() -{ - Log::Errorf("multi-sampled OpenGL context is not supported"); -} - static HDC GetWin32DeviceContext(Surface& surface) { /* Get device context from native window */ @@ -160,15 +211,48 @@ void Win32GLContext::CreateProxyContext(Surface& surface, const OpenGL::RenderSy LLGL_TRAP("failed to make initial GL context current"); } -/* -TODO: -- When anti-aliasing and extended-profile-selection is enabled, - maximal 2 contexts should be created (and not 3). -*/ +static HWND CreateProxyWindow() +{ + return CreateWindow( + GetProxyWindowClassName(), + TEXT("LLGL.Win32GLContext.ProxyWindow"), + WS_CLIPCHILDREN | WS_CLIPSIBLINGS, + CW_USEDEFAULT, + CW_USEDEFAULT, + CW_USEDEFAULT, + CW_USEDEFAULT, + nullptr, + nullptr, + GetModuleHandle(nullptr), + nullptr + ); +} + void Win32GLContext::CreateWGLContext(Surface& surface, Win32GLContext* sharedContext) { const bool hasMultiSampling = (formatDesc_.samples > 1); + if (hasMultiSampling) + { + /* + A multi-sampling render context is created in these steps: + 1. Create a proxy Win32 window to get a valid device context (HDC). + 2. Create a default WGL context to get a valid OpenGL render context (HGLRC). + 3. Load the OpenGL extension procedure to select a multi-sample pixel format (wglChoosePixelFormatARB). + 4. Cache available multi-sample pixel formats. + 5. Delete proxy window. + */ + HWND proxyWnd = CreateProxyWindow(); + LLGL_ASSERT(proxyWnd != nullptr); + HDC proxyDC = GetDC(proxyWnd); + SelectPixelFormat(proxyDC); + HGLRC proxyGLRC = CreateStandardWGLContext(proxyDC); + if (!SelectMultisampledPixelFormat(proxyDC)) + ErrorMultisampleContextFailed(); + DeleteWGLContext(proxyGLRC); + ::DestroyWindow(proxyWnd); + } + /* Get the surface's Win32 device context */ hDC_ = GetWin32DeviceContext(surface); @@ -180,35 +264,7 @@ void Win32GLContext::CreateWGLContext(Surface& surface, Win32GLContext* sharedCo SelectPixelFormat(hDC_); /* Create standard render context first */ - HGLRC stdRenderContext = CreateStandardWGLContext(hDC_); - - /* Check for multi-sample anti-aliasing */ - if (hasMultiSampling) - { - /* Setup anti-aliasing after creating a standard render context. */ - if (SelectMultisampledPixelFormat(hDC_)) - { - /* Delete old standard render context */ - DeleteWGLContext(stdRenderContext); - - /* - Update pixel format for the device context after a new pixel format has been selected. - see https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-setpixelformat#remarks - */ - hDC_ = UpdateSurfacePixelFormat(surface); - - /* Create a new render context -> now with anti-aliasing pixel format */ - stdRenderContext = CreateStandardWGLContext(hDC_); - } - else - { - /* Print warning and disable anti-aliasing */ - ErrMultisampledGLContextNotSupported(); - formatDesc_.samples = 1; - } - } - - hGLRC_ = stdRenderContext; + hGLRC_ = CreateStandardWGLContext(hDC_); /* Check for extended render context */ if (profile_.contextProfile != OpenGLContextProfile::CompatibilityProfile) @@ -222,8 +278,8 @@ void Win32GLContext::CreateWGLContext(Surface& surface, Win32GLContext* sharedCo if (HGLRC extRenderContext = CreateExplicitWGLContext(hDC_, sharedContext)) { /* Use the extended profile and delete the old standard render context */ + DeleteWGLContext(hGLRC_); hGLRC_ = extRenderContext; - DeleteWGLContext(stdRenderContext); } else { @@ -383,7 +439,7 @@ static void GetWGLPixelFormatDesc(const GLPixelFormat& inDesc, PIXELFORMATDESCRI outDesc.dwDamageMask = 0; } -void Win32GLContext::SelectPixelFormat(HDC hDC) +bool Win32GLContext::SelectPixelFormat(HDC hDC) { /* Setup pixel format attributes */ PIXELFORMATDESCRIPTOR formatDesc; @@ -396,7 +452,7 @@ void Win32GLContext::SelectPixelFormat(HDC hDC) for (UINT pixelFormatMSIndex = 0;;) { - if (isMultisampleFormatRequested && pixelFormatMSIndex < Win32GLContext::maxPixelFormatsMS) + if (isMultisampleFormatRequested && pixelFormatMSIndex < pixelFormatsMSCount_) { /* Choose multi-sample pixel format */ pixelFormat_ = pixelFormatsMS_[pixelFormatMSIndex++]; @@ -408,7 +464,10 @@ void Win32GLContext::SelectPixelFormat(HDC hDC) pixelFormat_ = ::ChoosePixelFormat(hDC, &formatDesc); if (isMultisampleFormatRequested) - ErrMultisampledGLContextNotSupported(); + { + ErrorMultisampleContextFailed(); + return false; + } wasStandardFormatUsed = true; @@ -440,7 +499,12 @@ void Win32GLContext::SelectPixelFormat(HDC hDC) if (!wasFormatSelected) { if (wasStandardFormatUsed) - LLGL_TRAP("failed to set pixel format"); + LLGL_TRAP("failed to set default pixel format"); + if (pixelFormatMSIndex == pixelFormatsMSCount_) + { + ErrorMultisampleContextFailed(); + return false; + } } else { @@ -448,22 +512,25 @@ void Win32GLContext::SelectPixelFormat(HDC hDC) break; } } + + return true; } bool Win32GLContext::SelectMultisampledPixelFormat(HDC hDC) { /* - Load GL extension "wglChoosePixelFormatARB" to choose anti-aliasing pixel formats + Load GL extension "wglChoosePixelFormatARB" to choose multi-sample pixel formats A valid (standard) GL context must be created at this time, before an extension can be loaded! */ if (wglChoosePixelFormatARB == nullptr) - LoadPixelFormatProcs(); - if (wglChoosePixelFormatARB == nullptr) - return false; + { + if (!LoadPixelFormatProcs() || wglChoosePixelFormatARB == nullptr) + return false; + } const float attribsFlt[] = { 0.0f, 0.0f }; - /* Setup pixel format for anti-aliasing */ + /* Reduce sample count successively if we fail to select a pixel format with the current sample count */ for (; formatDesc_.samples > 0; formatDesc_.samples--) { const int attribsInt[] = @@ -481,7 +548,7 @@ bool Win32GLContext::SelectMultisampledPixelFormat(HDC hDC) 0, 0 }; - /* Choose new pixel format with anti-aliasing */ + /* Choose new pixel format with current number of samples */ const BOOL result = wglChoosePixelFormatARB( hDC, attribsInt, @@ -510,13 +577,11 @@ void Win32GLContext::CopyPixelFormat(Win32GLContext& sourceContext) ::memcpy(pixelFormatsMS_, sourceContext.pixelFormatsMS_, sizeof(pixelFormatsMS_)); } -HDC Win32GLContext::UpdateSurfacePixelFormat(Surface& surface) +void Win32GLContext::ErrorMultisampleContextFailed() { - /* Recreate window with current descriptor, then update device context and pixel format */ - surface.ResetPixelFormat(); - HDC hDC = GetWin32DeviceContext(surface); - SelectPixelFormat(hDC); - return GetWin32DeviceContext(surface); + /* Print error and disable multi-sampled context */ + Log::Errorf("multi-sampled OpenGL context is not supported"); + formatDesc_.samples = 1; } diff --git a/sources/Renderer/OpenGL/Platform/Win32/Win32GLContext.h b/sources/Renderer/OpenGL/Platform/Win32/Win32GLContext.h index 8d1b2908a2..a0006b4375 100644 --- a/sources/Renderer/OpenGL/Platform/Win32/Win32GLContext.h +++ b/sources/Renderer/OpenGL/Platform/Win32/Win32GLContext.h @@ -42,7 +42,7 @@ class Win32GLContext final : public GLContext public: // Select the pixel format for the specified surface to make it compatible with this GL context. - void SelectPixelFormat(HDC hDC); + bool SelectPixelFormat(HDC hDC); // Returns the OpenGL render context handle. inline HGLRC GetGLRCHandle() const @@ -72,11 +72,11 @@ class Win32GLContext final : public GLContext bool SelectMultisampledPixelFormat(HDC hDC); void CopyPixelFormat(Win32GLContext& sourceContext); - HDC UpdateSurfacePixelFormat(Surface& surface); + void ErrorMultisampleContextFailed(); private: - static const UINT maxPixelFormatsMS = 8; + static constexpr UINT maxPixelFormatsMS = 8; RendererConfigurationOpenGL profile_; GLPixelFormat formatDesc_; @@ -88,7 +88,7 @@ class Win32GLContext final : public GLContext HDC hDC_ = nullptr; HGLRC hGLRC_ = nullptr; - bool isProxyGLRC_ = false; // true if a custom native handle was provided + const bool isProxyGLRC_ = false; // true if a custom native handle was provided }; diff --git a/wrapper/C99/C99Surface.cpp b/wrapper/C99/C99Surface.cpp index b51f3e1ad0..893d591b50 100644 --- a/wrapper/C99/C99Surface.cpp +++ b/wrapper/C99/C99Surface.cpp @@ -34,7 +34,7 @@ LLGL_C_EXPORT bool llglAdaptSurfaceForVideoMode(LLGLSurface surface, LLGLExtent2 LLGL_C_EXPORT void llglResetSurfacePixelFormat(LLGLSurface surface) { - LLGL_PTR(Surface, surface)->ResetPixelFormat(); + // dummy } LLGL_C_EXPORT bool llglProcessSurfaceEvents() diff --git a/wrapper/CSharp/Surface.cs b/wrapper/CSharp/Surface.cs index 81cd6d57ed..903ea45eba 100644 --- a/wrapper/CSharp/Surface.cs +++ b/wrapper/CSharp/Surface.cs @@ -44,9 +44,10 @@ public bool AdaptForVideoMode(ref Extent2D resolution, ref bool fullscreen) } } + [Obsolete("LLGL.Surface.ResetPixelFormat() is deprecated since 0.04b; No need to reset pixel format anymore!")] public void ResetPixelFormat() { - NativeLLGL.ResetSurfacePixelFormat(NativeBase); + // dummy } public Window AsWindow()