Pass all reset flags to glcontext.

This commit is contained in:
Branimir Karadžić 2015-04-06 21:31:26 -07:00
parent c5a03233c0
commit 288361b5c1
13 changed files with 35 additions and 27 deletions

View file

@ -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);

View file

@ -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");
}

View file

@ -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()

View file

@ -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);

View file

@ -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)
{

View file

@ -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);

View file

@ -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);

View file

@ -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];

View file

@ -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()

View file

@ -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);

View file

@ -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);
}
}

View file

@ -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);

View file

@ -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<<msaa);
bool vsync = !!(m_resolution.m_flags&BGFX_RESET_VSYNC);
setRenderContextSize(_resolution.m_width, _resolution.m_height, msaa, vsync);
setRenderContextSize(m_resolution.m_width
, m_resolution.m_height
, m_resolution.m_flags
);
updateCapture();
ovrPreReset();
@ -2071,7 +2071,7 @@ namespace bgfx { namespace gl
}
}
void setRenderContextSize(uint32_t _width, uint32_t _height, uint32_t _msaa = 0, bool _vsync = false)
void setRenderContextSize(uint32_t _width, uint32_t _height, uint32_t _flags = 0)
{
if (_width != 0
|| _height != 0)
@ -2089,9 +2089,12 @@ namespace bgfx { namespace gl
{
destroyMsaaFbo();
m_glctx.resize(_width, _height, _vsync);
m_glctx.resize(_width, _height, _flags);
createMsaaFbo(_width, _height, _msaa);
uint32_t msaa = (_flags&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT;
msaa = bx::uint32_min(m_maxMsaa, msaa == 0 ? 0 : 1<<msaa);
createMsaaFbo(_width, _height, msaa);
}
}