This commit is contained in:
raa-eruanna 2016-09-25 19:43:52 -04:00
commit c8d0a478d8
4 changed files with 34 additions and 9 deletions

View file

@ -176,12 +176,12 @@ void GLPortal::DrawPortalStencil()
bool GLPortal::Start(bool usestencil, bool doquery) bool GLPortal::Start(bool usestencil, bool doquery)
{ {
rendered_portals++; rendered_portals++;
PortalAll.Clock(); // PortalAll.Clock();
if (usestencil) if (usestencil)
{ {
if (!gl_portals) if (!gl_portals)
{ {
PortalAll.Unclock(); // PortalAll.Unclock();
return false; return false;
} }
@ -297,7 +297,7 @@ bool GLPortal::Start(bool usestencil, bool doquery)
GLRenderer->mCurrentPortal = this; GLRenderer->mCurrentPortal = this;
if (PrevPortal != NULL) PrevPortal->PushState(); if (PrevPortal != NULL) PrevPortal->PushState();
PortalAll.Unclock(); // PortalAll.Unclock();
return true; return true;
} }

View file

@ -209,13 +209,13 @@ void OpenGLFrameBuffer::Swap()
{ {
Finish.Reset(); Finish.Reset();
Finish.Clock(); Finish.Clock();
glFinish();
if (needsetgamma) if (needsetgamma)
{ {
//DoSetGamma(); //DoSetGamma();
needsetgamma = false; needsetgamma = false;
} }
SwapBuffers(); SwapBuffers();
glFinish();
Finish.Unclock(); Finish.Unclock();
swapped = true; swapped = true;
FHardwareTexture::UnbindAll(); FHardwareTexture::UnbindAll();

View file

@ -37,7 +37,9 @@ extern int NewWidth, NewHeight, NewBits, DisplayBits;
// these get used before GLEW is initialized so we have to use separate pointers with different names // these get used before GLEW is initialized so we have to use separate pointers with different names
PFNWGLCHOOSEPIXELFORMATARBPROC myWglChoosePixelFormatARB; // = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); PFNWGLCHOOSEPIXELFORMATARBPROC myWglChoosePixelFormatARB; // = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
PFNWGLCREATECONTEXTATTRIBSARBPROC myWglCreateContextAttribsARB; PFNWGLCREATECONTEXTATTRIBSARBPROC myWglCreateContextAttribsARB;
PFNWGLSWAPINTERVALEXTPROC vsyncfunc; PFNWGLSWAPINTERVALEXTPROC myWglSwapIntervalExtProc;
CUSTOM_CVAR(Bool, gl_debug, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) CUSTOM_CVAR(Bool, gl_debug, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
@ -934,10 +936,32 @@ Win32GLFrameBuffer::Win32GLFrameBuffer(void *hMonitor, int width, int height, in
vid_renderer = 0; vid_renderer = 0;
return; return;
} }
vsyncfunc = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
HDC hDC = GetDC(Window); HDC hDC = GetDC(Window);
const char *wglext = nullptr;
myWglSwapIntervalExtProc = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
auto myWglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
if (myWglGetExtensionsStringARB)
{
wglext = myWglGetExtensionsStringARB(hDC);
}
else
{
auto myWglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)wglGetProcAddress("wglGetExtensionsStringEXT");
if (myWglGetExtensionsStringEXT)
{
wglext = myWglGetExtensionsStringEXT();
}
}
SwapInterval = 1;
if (wglext != nullptr)
{
if (strstr(wglext, "WGL_EXT_swap_control_tear"))
{
SwapInterval = -1;
}
}
m_supportsGamma = !!GetDeviceGammaRamp(hDC, (void *)m_origGamma); m_supportsGamma = !!GetDeviceGammaRamp(hDC, (void *)m_origGamma);
ReleaseDC(Window, hDC); ReleaseDC(Window, hDC);
} }
@ -1092,7 +1116,7 @@ void Win32GLFrameBuffer::ReleaseResources ()
void Win32GLFrameBuffer::SetVSync (bool vsync) void Win32GLFrameBuffer::SetVSync (bool vsync)
{ {
if (vsyncfunc != NULL) vsyncfunc(vsync ? 1 : 0); if (myWglSwapIntervalExtProc != NULL) myWglSwapIntervalExtProc(vsync ? SwapInterval : 0);
} }
void Win32GLFrameBuffer::SwapBuffers() void Win32GLFrameBuffer::SwapBuffers()

View file

@ -148,6 +148,7 @@ protected:
int m_Lock; int m_Lock;
char m_displayDeviceNameBuffer[CCHDEVICENAME]; char m_displayDeviceNameBuffer[CCHDEVICENAME];
char *m_displayDeviceName; char *m_displayDeviceName;
int SwapInterval;
friend class Win32GLVideo; friend class Win32GLVideo;