mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-24 17:49:52 +01:00
fix for non working vsync
This commit is contained in:
parent
9d9ced47f4
commit
d98cf4f6ea
@ -4,11 +4,12 @@
|
|||||||
#include "glext.h"
|
#include "glext.h"
|
||||||
|
|
||||||
void OpenGL_Init();
|
void OpenGL_Init();
|
||||||
BOOL OpenGL_ExtExists(char *ext);
|
BOOL OpenGL_ExtExists(char *ext, HDC hdc);
|
||||||
GLuint OpenGL_BuildProgram(const GLchar *vertSource, const GLchar *fragSource);
|
GLuint OpenGL_BuildProgram(const GLchar *vertSource, const GLchar *fragSource);
|
||||||
GLuint OpenGL_BuildProgramFromFile(const char *filePath);
|
GLuint OpenGL_BuildProgramFromFile(const char *filePath);
|
||||||
|
|
||||||
typedef void (APIENTRYP PFNWGLSWAPINTERVALEXT) (int interval);
|
typedef void (APIENTRYP PFNWGLSWAPINTERVALEXT) (int interval);
|
||||||
|
typedef const char* (WINAPI *PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC hdc);
|
||||||
|
|
||||||
extern PFNGLCREATEPROGRAMPROC glCreateProgram;
|
extern PFNGLCREATEPROGRAMPROC glCreateProgram;
|
||||||
extern PFNGLDELETEPROGRAMPROC glDeleteProgram;
|
extern PFNGLDELETEPROGRAMPROC glDeleteProgram;
|
||||||
@ -70,5 +71,6 @@ extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
|
|||||||
extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
|
extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
|
||||||
|
|
||||||
extern PFNWGLSWAPINTERVALEXT wglSwapIntervalEXT;
|
extern PFNWGLSWAPINTERVALEXT wglSwapIntervalEXT;
|
||||||
|
extern PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB;
|
||||||
|
|
||||||
extern PFNGLTEXBUFFERPROC glTexBuffer;
|
extern PFNGLTEXBUFFERPROC glTexBuffer;
|
||||||
|
@ -662,6 +662,15 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBPNG
|
||||||
|
case WM_KEYUP:
|
||||||
|
if (wParam == VK_SNAPSHOT)
|
||||||
|
screenshot(ddraw->primary);
|
||||||
|
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* button up messages reactivate cursor lock */
|
/* button up messages reactivate cursor lock */
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
case WM_RBUTTONUP:
|
case WM_RBUTTONUP:
|
||||||
|
15
src/opengl.c
15
src/opengl.c
@ -64,6 +64,7 @@ PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus = NULL;
|
|||||||
PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers = NULL;
|
PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers = NULL;
|
||||||
|
|
||||||
PFNWGLSWAPINTERVALEXT wglSwapIntervalEXT = NULL;
|
PFNWGLSWAPINTERVALEXT wglSwapIntervalEXT = NULL;
|
||||||
|
PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = NULL;
|
||||||
|
|
||||||
PFNGLTEXBUFFERPROC glTexBuffer = NULL;
|
PFNGLTEXBUFFERPROC glTexBuffer = NULL;
|
||||||
|
|
||||||
@ -128,11 +129,12 @@ void OpenGL_Init()
|
|||||||
glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)wglGetProcAddress("glDeleteFramebuffers");
|
glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)wglGetProcAddress("glDeleteFramebuffers");
|
||||||
|
|
||||||
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXT)wglGetProcAddress("wglSwapIntervalEXT");
|
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXT)wglGetProcAddress("wglSwapIntervalEXT");
|
||||||
|
wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
|
||||||
|
|
||||||
glTexBuffer = (PFNGLTEXBUFFERPROC)wglGetProcAddress("glTexBuffer");
|
glTexBuffer = (PFNGLTEXBUFFERPROC)wglGetProcAddress("glTexBuffer");
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL OpenGL_ExtExists(char *ext)
|
BOOL OpenGL_ExtExists(char *ext, HDC hdc)
|
||||||
{
|
{
|
||||||
char *glext = (char *)glGetString(GL_EXTENSIONS);
|
char *glext = (char *)glGetString(GL_EXTENSIONS);
|
||||||
if (glext)
|
if (glext)
|
||||||
@ -140,6 +142,17 @@ BOOL OpenGL_ExtExists(char *ext)
|
|||||||
if (strstr(glext, ext))
|
if (strstr(glext, ext))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wglGetExtensionsStringARB)
|
||||||
|
{
|
||||||
|
char *wglext = (char *)wglGetExtensionsStringARB(hdc);
|
||||||
|
if (wglext)
|
||||||
|
{
|
||||||
|
if (strstr(wglext, ext))
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
21
src/render.c
21
src/render.c
@ -56,12 +56,30 @@ DWORD WINAPI render_main(void)
|
|||||||
|
|
||||||
OpenGL_Init();
|
OpenGL_Init();
|
||||||
|
|
||||||
if (OpenGL_ExtExists("WGL_EXT_swap_control"))
|
int maxfps = ddraw->render.maxfps;
|
||||||
|
|
||||||
|
if (OpenGL_ExtExists("WGL_EXT_swap_control_tear", ddraw->render.hDC))
|
||||||
|
{
|
||||||
|
if (wglSwapIntervalEXT)
|
||||||
|
{
|
||||||
|
if (ddraw->vsync)
|
||||||
|
{
|
||||||
|
wglSwapIntervalEXT(-1);
|
||||||
|
maxfps = 1000;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
wglSwapIntervalEXT(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (OpenGL_ExtExists("WGL_EXT_swap_control", ddraw->render.hDC))
|
||||||
{
|
{
|
||||||
if (wglSwapIntervalEXT)
|
if (wglSwapIntervalEXT)
|
||||||
{
|
{
|
||||||
if (ddraw->vsync)
|
if (ddraw->vsync)
|
||||||
|
{
|
||||||
wglSwapIntervalEXT(1);
|
wglSwapIntervalEXT(1);
|
||||||
|
maxfps = 1000;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
wglSwapIntervalEXT(0);
|
wglSwapIntervalEXT(0);
|
||||||
}
|
}
|
||||||
@ -70,7 +88,6 @@ DWORD WINAPI render_main(void)
|
|||||||
DWORD tick_start = 0;
|
DWORD tick_start = 0;
|
||||||
DWORD tick_end = 0;
|
DWORD tick_end = 0;
|
||||||
DWORD frame_len = 0;
|
DWORD frame_len = 0;
|
||||||
int maxfps = ddraw->render.maxfps;
|
|
||||||
|
|
||||||
if (maxfps < 0)
|
if (maxfps < 0)
|
||||||
maxfps = ddraw->mode.dmDisplayFrequency;
|
maxfps = ddraw->mode.dmDisplayFrequency;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user