From 288361b5c1481d10336e2fbc4a25bf95f59ec03d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Mon, 6 Apr 2015 21:31:26 -0700 Subject: [PATCH] Pass all reset flags to glcontext. --- src/glcontext_eagl.h | 2 +- src/glcontext_eagl.mm | 6 +++--- src/glcontext_egl.cpp | 5 +++-- src/glcontext_egl.h | 2 +- src/glcontext_glx.cpp | 5 +++-- src/glcontext_glx.h | 2 +- src/glcontext_nsgl.h | 2 +- src/glcontext_nsgl.mm | 6 ++++-- src/glcontext_ppapi.cpp | 6 +++--- src/glcontext_ppapi.h | 2 +- src/glcontext_wgl.cpp | 5 +++-- src/glcontext_wgl.h | 2 +- src/renderer_gl.cpp | 17 ++++++++++------- 13 files changed, 35 insertions(+), 27 deletions(-) diff --git a/src/glcontext_eagl.h b/src/glcontext_eagl.h index 5c26a71f2..45ba0fbf3 100644 --- a/src/glcontext_eagl.h +++ b/src/glcontext_eagl.h @@ -21,7 +21,7 @@ namespace bgfx { namespace gl void create(uint32_t _width, uint32_t _height); void destroy(); - void resize(uint32_t _width, uint32_t _height, bool _vsync); + void resize(uint32_t _width, uint32_t _height, uint32_t _flags); static bool isSwapChainSupported(); SwapChainGL* createSwapChain(void* _nwh); diff --git a/src/glcontext_eagl.mm b/src/glcontext_eagl.mm index 4348eb651..73eedd2b5 100644 --- a/src/glcontext_eagl.mm +++ b/src/glcontext_eagl.mm @@ -54,7 +54,7 @@ namespace bgfx { namespace gl GL_CHECK(glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, width, height) ); // from OES_packed_depth_stencil GL_CHECK(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilRbo) ); GL_CHECK(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilRbo) ); - + BX_CHECK(GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_FRAMEBUFFER) , "glCheckFramebufferStatus failed 0x%08x" , glCheckFramebufferStatus(GL_FRAMEBUFFER) @@ -85,9 +85,9 @@ namespace bgfx { namespace gl [context release]; } - void GlContext::resize(uint32_t _width, uint32_t _height, bool _vsync) + void GlContext::resize(uint32_t _width, uint32_t _height, uint32_t _flags) { - BX_UNUSED(_width, _height, _vsync); + BX_UNUSED(_width, _height, _flags); BX_TRACE("resize context"); } diff --git a/src/glcontext_egl.cpp b/src/glcontext_egl.cpp index a3fe4e77c..93990746c 100644 --- a/src/glcontext_egl.cpp +++ b/src/glcontext_egl.cpp @@ -280,7 +280,7 @@ EGL_IMPORT # endif // BX_PLATFORM_RPI } - void GlContext::resize(uint32_t _width, uint32_t _height, bool _vsync) + void GlContext::resize(uint32_t _width, uint32_t _height, uint32_t _flags) { BX_UNUSED(_width, _height); # if BX_PLATFORM_ANDROID @@ -289,7 +289,8 @@ EGL_IMPORT ANativeWindow_setBuffersGeometry(g_bgfxAndroidWindow, _width, _height, format); # endif // BX_PLATFORM_ANDROID - eglSwapInterval(m_display, _vsync ? 1 : 0); + bool vsync = !!(_flags&BGFX_RESET_VSYNC); + eglSwapInterval(m_display, vsync ? 1 : 0); } bool GlContext::isSwapChainSupported() diff --git a/src/glcontext_egl.h b/src/glcontext_egl.h index 122591ca8..35a30c63f 100644 --- a/src/glcontext_egl.h +++ b/src/glcontext_egl.h @@ -26,7 +26,7 @@ namespace bgfx { namespace gl void create(uint32_t _width, uint32_t _height); void destroy(); - void resize(uint32_t _width, uint32_t _height, bool _vsync); + void resize(uint32_t _width, uint32_t _height, uint32_t _flags); static bool isSwapChainSupported(); SwapChainGL* createSwapChain(void* _nwh); diff --git a/src/glcontext_glx.cpp b/src/glcontext_glx.cpp index 13a91de7d..17ee8e825 100644 --- a/src/glcontext_glx.cpp +++ b/src/glcontext_glx.cpp @@ -225,9 +225,10 @@ namespace bgfx { namespace gl m_visualInfo = NULL; } - void GlContext::resize(uint32_t /*_width*/, uint32_t /*_height*/, bool _vsync) + void GlContext::resize(uint32_t /*_width*/, uint32_t /*_height*/, uint32_t _flags) { - int32_t interval = _vsync ? 1 : 0; + bool vsync = !!(_flags&BGFX_RESET_VSYNC); + int32_t interval = vsync ? 1 : 0; if (NULL != glXSwapIntervalEXT) { diff --git a/src/glcontext_glx.h b/src/glcontext_glx.h index cff6faa16..a931356cb 100644 --- a/src/glcontext_glx.h +++ b/src/glcontext_glx.h @@ -26,7 +26,7 @@ namespace bgfx { namespace gl void create(uint32_t _width, uint32_t _height); void destroy(); - void resize(uint32_t _width, uint32_t _height, bool _vsync); + void resize(uint32_t _width, uint32_t _height, uint32_t _flags); static bool isSwapChainSupported(); SwapChainGL* createSwapChain(void* _nwh); diff --git a/src/glcontext_nsgl.h b/src/glcontext_nsgl.h index c88673d8f..666926db9 100644 --- a/src/glcontext_nsgl.h +++ b/src/glcontext_nsgl.h @@ -21,7 +21,7 @@ namespace bgfx { namespace gl void create(uint32_t _width, uint32_t _height); void destroy(); - void resize(uint32_t _width, uint32_t _height, bool _vsync); + void resize(uint32_t _width, uint32_t _height, uint32_t _flags); static bool isSwapChainSupported(); SwapChainGL* createSwapChain(void* _nwh); diff --git a/src/glcontext_nsgl.mm b/src/glcontext_nsgl.mm index 6e4912bb5..236809223 100644 --- a/src/glcontext_nsgl.mm +++ b/src/glcontext_nsgl.mm @@ -101,6 +101,7 @@ namespace bgfx { namespace gl NSOpenGLView* glView = [[NSOpenGLView alloc] initWithFrame:glViewRect pixelFormat:pixelFormat]; [pixelFormat release]; +// [glView setWantsBestResolutionOpenGLSurface:YES]; [nsWindow setContentView:glView]; NSOpenGLContext* glContext = [glView openGLContext]; @@ -130,11 +131,12 @@ namespace bgfx { namespace gl bx::dlclose(s_opengl); } - void GlContext::resize(uint32_t _width, uint32_t _height, bool _vsync) + void GlContext::resize(uint32_t _width, uint32_t _height, uint32_t _flags) { BX_UNUSED(_width, _height); - GLint interval = _vsync ? 1 : 0; + bool vsync = !!(_flags&BGFX_RESET_VSYNC); + GLint interval = vsync ? 1 : 0; NSOpenGLContext* glContext = (NSOpenGLContext*)m_context; [glContext setValues:&interval forParameter:NSOpenGLCPSwapInterval]; [glContext update]; diff --git a/src/glcontext_ppapi.cpp b/src/glcontext_ppapi.cpp index 3910e7a13..f61244dbd 100644 --- a/src/glcontext_ppapi.cpp +++ b/src/glcontext_ppapi.cpp @@ -38,7 +38,7 @@ namespace bgfx { namespace gl bool setInterfaces(PP_Instance _instance, const PPB_Instance* _instInterface, const PPB_Graphics3D* _graphicsInterface, PostSwapBuffersFn _postSwapBuffers); - void resize(uint32_t _width, uint32_t _height, bool /*_vsync*/) + void resize(uint32_t _width, uint32_t _height, uint32_t /*_flags*/) { m_graphicsInterface->ResizeBuffers(m_context, _width, _height); } @@ -147,10 +147,10 @@ namespace bgfx { namespace gl { } - void GlContext::resize(uint32_t _width, uint32_t _height, bool _vsync) + void GlContext::resize(uint32_t _width, uint32_t _height, uint32_t _flags) { s_ppapi.m_forceSwap = false; - s_ppapi.resize(_width, _height, _vsync); + s_ppapi.resize(_width, _height, _flags); } bool GlContext::isSwapChainSupported() diff --git a/src/glcontext_ppapi.h b/src/glcontext_ppapi.h index 3142b6acd..f54ea2bb5 100644 --- a/src/glcontext_ppapi.h +++ b/src/glcontext_ppapi.h @@ -25,7 +25,7 @@ namespace bgfx { namespace gl void create(uint32_t _width, uint32_t _height); void destroy(); - void resize(uint32_t _width, uint32_t _height, bool _vsync); + void resize(uint32_t _width, uint32_t _height, uint32_t _flags); static bool isSwapChainSupported(); SwapChainGL* createSwapChain(void* _nwh); diff --git a/src/glcontext_wgl.cpp b/src/glcontext_wgl.cpp index 84c32a066..19ca6d99f 100644 --- a/src/glcontext_wgl.cpp +++ b/src/glcontext_wgl.cpp @@ -287,11 +287,12 @@ namespace bgfx { namespace gl m_opengl32dll = NULL; } - void GlContext::resize(uint32_t /*_width*/, uint32_t /*_height*/, bool _vsync) + void GlContext::resize(uint32_t /*_width*/, uint32_t /*_height*/, uint32_t _flags) { if (NULL != wglSwapIntervalEXT) { - wglSwapIntervalEXT(_vsync ? 1 : 0); + bool vsync = !!(_flags&BGFX_RESET_VSYNC); + wglSwapIntervalEXT(vsync ? 1 : 0); } } diff --git a/src/glcontext_wgl.h b/src/glcontext_wgl.h index 98338f094..1948622b8 100644 --- a/src/glcontext_wgl.h +++ b/src/glcontext_wgl.h @@ -70,7 +70,7 @@ typedef void (APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum z void create(uint32_t _width, uint32_t _height); void destroy(); - void resize(uint32_t _width, uint32_t _height, bool _vsync); + void resize(uint32_t _width, uint32_t _height, uint32_t _flags); static bool isSwapChainSupported(); SwapChainGL* createSwapChain(void* _nwh); diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index 84bd844e9..c4f6ec6de 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -1902,10 +1902,10 @@ namespace bgfx { namespace gl m_resolution = _resolution; m_resolution.m_flags = flags; - uint32_t msaa = (m_resolution.m_flags&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT; - msaa = bx::uint32_min(m_maxMsaa, msaa == 0 ? 0 : 1<>BGFX_RESET_MSAA_SHIFT; + msaa = bx::uint32_min(m_maxMsaa, msaa == 0 ? 0 : 1<