diff --git a/examples/C99/HelloTriangle/HelloTriangle.c b/examples/C99/HelloTriangle/HelloTriangle.c index 3b116d921c..b868e5ed92 100644 --- a/examples/C99/HelloTriangle/HelloTriangle.c +++ b/examples/C99/HelloTriangle/HelloTriangle.c @@ -53,7 +53,6 @@ int main(int argc, char* argv[]) LLGLWindow window = LLGL_GET_AS(LLGLWindow, surface); llglSetWindowTitle(window, L"LLGL C99 Example: Hello Triangle"); - llglShowWindow(window, true); // Vertex data structure typedef struct Vertex diff --git a/include/LLGL/SwapChain.h b/include/LLGL/SwapChain.h index d2fdae6498..2100197478 100644 --- a/include/LLGL/SwapChain.h +++ b/include/LLGL/SwapChain.h @@ -210,6 +210,9 @@ class LLGL_EXPORT SwapChain : public RenderTarget std::size_t windowContextSize = 0 ); + //! Shows the swap-chain surface if it's not the same as the input surface. + void ShowSurface(); + /** \brief Shares the surface and resolution with another swap-chain. \note This is only used by the renderer debug layer. diff --git a/sources/Renderer/Direct3D11/D3D11SwapChain.cpp b/sources/Renderer/Direct3D11/D3D11SwapChain.cpp index 2107c6d9a3..28f4fef172 100644 --- a/sources/Renderer/Direct3D11/D3D11SwapChain.cpp +++ b/sources/Renderer/Direct3D11/D3D11SwapChain.cpp @@ -43,6 +43,10 @@ D3D11SwapChain::D3D11SwapChain( if (desc.debugName != nullptr) SetDebugName(desc.debugName); + + /* Show default surface */ + if (!surface) + ShowSurface(); } void D3D11SwapChain::SetDebugName(const char* name) diff --git a/sources/Renderer/Direct3D12/D3D12SwapChain.cpp b/sources/Renderer/Direct3D12/D3D12SwapChain.cpp index 8b9934654c..3a1d387ce8 100644 --- a/sources/Renderer/Direct3D12/D3D12SwapChain.cpp +++ b/sources/Renderer/Direct3D12/D3D12SwapChain.cpp @@ -55,6 +55,10 @@ D3D12SwapChain::D3D12SwapChain( if (desc.debugName != nullptr) SetDebugName(desc.debugName); + + /* Show default surface */ + if (!surface) + ShowSurface(); } D3D12SwapChain::~D3D12SwapChain() diff --git a/sources/Renderer/Metal/MTSwapChain.mm b/sources/Renderer/Metal/MTSwapChain.mm index a71075d921..5980ba1840 100644 --- a/sources/Renderer/Metal/MTSwapChain.mm +++ b/sources/Renderer/Metal/MTSwapChain.mm @@ -69,6 +69,10 @@ - (void)mtkView:(nonnull MTKView *)view drawableSizeWillChange:(CGSize)size view_.colorPixelFormat = renderPass_.GetColorAttachments()[0].pixelFormat; view_.depthStencilPixelFormat = renderPass_.GetDepthStencilFormat(); view_.sampleCount = renderPass_.GetSampleCount(); + + /* Show default surface */ + if (!surface) + ShowSurface(); } void MTSwapChain::Present() diff --git a/sources/Renderer/Null/NullSwapChain.cpp b/sources/Renderer/Null/NullSwapChain.cpp index baadf4062d..a8a82d694b 100644 --- a/sources/Renderer/Null/NullSwapChain.cpp +++ b/sources/Renderer/Null/NullSwapChain.cpp @@ -46,8 +46,13 @@ NullSwapChain::NullSwapChain( depthStencilFormat_ { ChooseDepthStencilFormat(desc.depthBits, desc.stencilBits) } { SetOrCreateSurface(surface, SwapChain::BuildDefaultSurfaceTitle(rendererInfo), desc.resolution, desc.fullscreen); + if (desc.debugName != nullptr) SetDebugName(desc.debugName); + + /* Show default surface */ + if (!surface) + ShowSurface(); } void NullSwapChain::SetDebugName(const char* name) diff --git a/sources/Renderer/OpenGL/GLSwapChain.cpp b/sources/Renderer/OpenGL/GLSwapChain.cpp index db9e75f3a2..81ca4fb265 100644 --- a/sources/Renderer/OpenGL/GLSwapChain.cpp +++ b/sources/Renderer/OpenGL/GLSwapChain.cpp @@ -67,6 +67,10 @@ GLSwapChain::GLSwapChain( /* Get state manager and reset current framebuffer height */ GetStateManager().ResetFramebufferHeight(framebufferHeight_); + + /* Show default surface */ + if (!surface) + ShowSurface(); } void GLSwapChain::Present() diff --git a/sources/Renderer/SwapChain.cpp b/sources/Renderer/SwapChain.cpp index 6db73e7147..b254a7ad3f 100644 --- a/sources/Renderer/SwapChain.cpp +++ b/sources/Renderer/SwapChain.cpp @@ -176,7 +176,7 @@ void SwapChain::SetOrCreateSurface( { windowDesc.title = title; windowDesc.size = size; - windowDesc.flags = WindowFlags::Visible | WindowFlags::DisableSizeScaling | (fullscreen ? WindowFlags::Borderless : WindowFlags::Centered); + windowDesc.flags = WindowFlags::DisableSizeScaling | (fullscreen ? WindowFlags::Borderless : WindowFlags::Centered); windowDesc.windowContext = windowContext; windowDesc.windowContextSize = windowContextSize; } @@ -193,6 +193,13 @@ void SwapChain::SetOrCreateSurface( SetDisplayFullscreenMode(pimpl_->resolution); } +void SwapChain::ShowSurface() +{ + #ifndef LLGL_MOBILE_PLATFORM + static_cast(GetSurface()).Show(); + #endif +} + void SwapChain::ShareSurfaceAndConfig(SwapChain& other) { pimpl_->surface = other.pimpl_->surface; diff --git a/sources/Renderer/Vulkan/VKSwapChain.cpp b/sources/Renderer/Vulkan/VKSwapChain.cpp index 4d98c5d7c7..3fa5aef9bb 100644 --- a/sources/Renderer/Vulkan/VKSwapChain.cpp +++ b/sources/Renderer/Vulkan/VKSwapChain.cpp @@ -97,6 +97,10 @@ VKSwapChain::VKSwapChain( /* Create Vulkan render passes, swap-chain, depth-stencil buffer, and multisampling color buffers */ CreateDefaultAndSecondaryRenderPass(); CreateResolutionDependentResources(GetResolution()); + + /* Show default surface */ + if (!surface) + ShowSurface(); } void VKSwapChain::Present()