Index: ddraw/glDirectDraw.cpp |
— | — | @@ -1088,6 +1088,7 @@ |
1089 | 1089 | glDD4 = NULL;
|
1090 | 1090 | renderer = NULL;
|
1091 | 1091 | primary = NULL;
|
| 1092 | + lastsync = false;
|
1092 | 1093 | fullscreen = false;
|
1093 | 1094 | fpupreserve = false;
|
1094 | 1095 | fpusetup = false;
|
— | — | @@ -1479,9 +1480,8 @@ |
1480 | 1481 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
1481 | 1482 | if(dwFlags & DDWAITVB_BLOCKBEGINEVENT)
|
1482 | 1483 | TRACE_RET(HRESULT,23,DDERR_UNSUPPORTED);
|
1483 | | - swapinterval=1;
|
1484 | | - primary->RenderScreen(primary->texture,primary);
|
1485 | | - swapinterval=0;
|
| 1484 | + if(!lastsync) lastsync = true;
|
| 1485 | + else primary->RenderScreen(primary->texture,primary,1);
|
1486 | 1486 | TRACE_EXIT(23,DD_OK);
|
1487 | 1487 | return DD_OK;
|
1488 | 1488 | }
|
Index: ddraw/glDirectDraw.h |
— | — | @@ -84,6 +84,7 @@ |
85 | 85 | void DeleteClipper(glDirectDrawClipper *clipper);
|
86 | 86 | glDirectDrawSurface7 *primary;
|
87 | 87 | bool primarylost;
|
| 88 | + bool lastsync;
|
88 | 89 | glDirectDraw1 *glDD1;
|
89 | 90 | glDirectDraw2 *glDD2;
|
90 | 91 | glDirectDraw4 *glDD4;
|
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -687,7 +687,15 @@ |
688 | 688 | TRACE_ENTER(3,14,this,14,lpDDSurfaceTargetOverride,9,dwFlags);
|
689 | 689 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
690 | 690 | HRESULT ret = Flip2(lpDDSurfaceTargetOverride,dwFlags);
|
691 | | - if(ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) RenderScreen(texture,this);
|
| 691 | + if(ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
| 692 | + {
|
| 693 | + if(ddInterface->lastsync)
|
| 694 | + {
|
| 695 | + swapinterval++;
|
| 696 | + ddInterface->lastsync = false;
|
| 697 | + }
|
| 698 | + RenderScreen(texture,this,swapinterval);
|
| 699 | + }
|
692 | 700 | TRACE_EXIT(23,ret);
|
693 | 701 | return ret;
|
694 | 702 | }
|
— | — | @@ -1213,8 +1221,12 @@ |
1214 | 1222 | ((ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) &&
|
1215 | 1223 | !(ddsd.ddsCaps.dwCaps & DDSCAPS_FLIP)))
|
1216 | 1224 | {
|
1217 | | - swapinterval = 0;
|
1218 | | - RenderScreen(texture,this);
|
| 1225 | + if(ddInterface->lastsync)
|
| 1226 | + {
|
| 1227 | + RenderScreen(texture,this,1);
|
| 1228 | + ddInterface->lastsync = false;
|
| 1229 | + }
|
| 1230 | + else RenderScreen(texture,this,0);
|
1219 | 1231 | }
|
1220 | 1232 | TRACE_EXIT(23,DD_OK);
|
1221 | 1233 | return DD_OK;
|
— | — | @@ -1244,10 +1256,10 @@ |
1245 | 1257 | ERR(DDERR_GENERIC);
|
1246 | 1258 | }
|
1247 | 1259 |
|
1248 | | -void glDirectDrawSurface7::RenderScreen(TEXTURE *texture, glDirectDrawSurface7 *surface)
|
| 1260 | +void glDirectDrawSurface7::RenderScreen(TEXTURE *texture, glDirectDrawSurface7 *surface, int vsync)
|
1249 | 1261 | {
|
1250 | 1262 | TRACE_ENTER(3,14,this,14,texture,14,surface);
|
1251 | | - renderer->DrawScreen(texture,paltex,this,surface);
|
| 1263 | + renderer->DrawScreen(texture,paltex,this,surface,vsync);
|
1252 | 1264 | TRACE_EXIT(0,0);
|
1253 | 1265 | }
|
1254 | 1266 | // ddraw 2+ api
|
Index: ddraw/glDirectDrawSurface.h |
— | — | @@ -105,7 +105,7 @@ |
106 | 106 | void SetTexture(TEXTURE *newtexture){texture = newtexture;};
|
107 | 107 | glDirectDrawSurface7 *GetBackbuffer(){return backbuffer;};
|
108 | 108 | glDirectDrawSurface7 *GetZBuffer(){return zbuffer;};
|
109 | | - void RenderScreen(TEXTURE *texture, glDirectDrawSurface7 *surface);
|
| 109 | + void RenderScreen(TEXTURE *texture, glDirectDrawSurface7 *surface, int vsync);
|
110 | 110 | // Special ddraw2->ddraw7 api
|
111 | 111 | HRESULT WINAPI Unlock2(LPVOID lpSurfaceData);
|
112 | 112 | HRESULT GetHandle(glDirect3DDevice7 *glD3DDev7, LPD3DTEXTUREHANDLE lpHandle);
|
— | — | @@ -136,6 +136,7 @@ |
137 | 137 | D3DMATERIALHANDLE handle;
|
138 | 138 | FBO fbo;
|
139 | 139 | private:
|
| 140 | + int swapinterval;
|
140 | 141 | ULONG refcount;
|
141 | 142 | int locked;
|
142 | 143 | HDC hdc;
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -64,7 +64,6 @@ |
65 | 65 | }
|
66 | 66 |
|
67 | 67 | int oldswap = 0;
|
68 | | -int swapinterval = 0;
|
69 | 68 |
|
70 | 69 | /**
|
71 | 70 | * Sets the Windows OpenGL swap interval
|
— | — | @@ -439,8 +438,10 @@ |
440 | 439 | * Destination surface to be updated
|
441 | 440 | * @param src
|
442 | 441 | * Source surface to be updated
|
| 442 | + * @param vsync
|
| 443 | + * Vertical sync count
|
443 | 444 | */
|
444 | | -void glRenderer::DrawScreen(TEXTURE *texture, TEXTURE *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src)
|
| 445 | +void glRenderer::DrawScreen(TEXTURE *texture, TEXTURE *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, GLint vsync)
|
445 | 446 | {
|
446 | 447 | EnterCriticalSection(&cs);
|
447 | 448 | inputs[0] = texture;
|
— | — | @@ -447,6 +448,7 @@ |
448 | 449 | inputs[1] = paltex;
|
449 | 450 | inputs[2] = dest;
|
450 | 451 | inputs[3] = src;
|
| 452 | + inputs[4] = (void*)vsync;
|
451 | 453 | opcode = OP_DRAWSCREEN;
|
452 | 454 | SetEvent(start);
|
453 | 455 | WaitForSingleObject(busy,INFINITE);
|
— | — | @@ -681,7 +683,7 @@ |
682 | 684 | (LPRECT)inputs[3],(DWORD)inputs[4],(LPDDBLTFX)inputs[5]);
|
683 | 685 | break;
|
684 | 686 | case OP_DRAWSCREEN:
|
685 | | - _DrawScreen((TEXTURE*)inputs[0],(TEXTURE*)inputs[1],(glDirectDrawSurface7*)inputs[2],(glDirectDrawSurface7*)inputs[3],true);
|
| 687 | + _DrawScreen((TEXTURE*)inputs[0],(TEXTURE*)inputs[1],(glDirectDrawSurface7*)inputs[2],(glDirectDrawSurface7*)inputs[3],(GLint)inputs[4],true);
|
686 | 688 | break;
|
687 | 689 | case OP_INITD3D:
|
688 | 690 | _InitD3D((int)inputs[0]);
|
— | — | @@ -983,7 +985,7 @@ |
984 | 986 | if(((ddsd.ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER)) &&
|
985 | 987 | (ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)) ||
|
986 | 988 | ((ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) &&
|
987 | | - !(ddsd.ddsCaps.dwCaps & DDSCAPS_FLIP)))_DrawScreen(dest->texture,dest->paltex,dest,dest,false);
|
| 989 | + !(ddsd.ddsCaps.dwCaps & DDSCAPS_FLIP)))_DrawScreen(dest->texture,dest->paltex,dest,dest,0,false);
|
988 | 990 | outputs[0] = DD_OK;
|
989 | 991 | SetEvent(busy);
|
990 | 992 | }
|
— | — | @@ -1042,7 +1044,7 @@ |
1043 | 1045 | SetFBO((FBO*)NULL);
|
1044 | 1046 | }
|
1045 | 1047 |
|
1046 | | -void glRenderer::_DrawScreen(TEXTURE *texture, TEXTURE *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, bool setsync)
|
| 1048 | +void glRenderer::_DrawScreen(TEXTURE *texture, TEXTURE *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, GLint vsync, bool setsync)
|
1047 | 1049 | {
|
1048 | 1050 | int progtype;
|
1049 | 1051 | RECT r,r2;
|
— | — | @@ -1056,7 +1058,7 @@ |
1057 | 1059 | }
|
1058 | 1060 | DepthTest(false);
|
1059 | 1061 | RECT *viewrect = &r2;
|
1060 | | - SetSwap(swapinterval);
|
| 1062 | + SetSwap(vsync);
|
1061 | 1063 | LONG sizes[6];
|
1062 | 1064 | GLfloat view[4];
|
1063 | 1065 | GLint viewport[4];
|
Index: ddraw/glRenderer.h |
— | — | @@ -77,7 +77,6 @@ |
78 | 78 | #define OP_DELETEFBO 13
|
79 | 79 |
|
80 | 80 |
|
81 | | -extern int swapinterval;
|
82 | 81 | extern inline void SetSwap(int swap);
|
83 | 82 |
|
84 | 83 | class glDirectDraw7;
|
— | — | @@ -99,7 +98,7 @@ |
100 | 99 | HRESULT Blt(LPRECT lpDestRect, glDirectDrawSurface7 *src,
|
101 | 100 | glDirectDrawSurface7 *dest, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx);
|
102 | 101 | void MakeTexture(TEXTURE *texture, DWORD width, DWORD height);
|
103 | | - void DrawScreen(TEXTURE *texture, TEXTURE *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src);
|
| 102 | + void DrawScreen(TEXTURE *texture, TEXTURE *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, GLint vsync);
|
104 | 103 | void DeleteTexture(TEXTURE *texture);
|
105 | 104 | void InitD3D(int zbuffer);
|
106 | 105 | void Flush();
|
— | — | @@ -119,7 +118,7 @@ |
120 | 119 | void _Blt(LPRECT lpDestRect, glDirectDrawSurface7 *src,
|
121 | 120 | glDirectDrawSurface7 *dest, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx);
|
122 | 121 | void _MakeTexture(TEXTURE *texture, DWORD width, DWORD height);
|
123 | | - void _DrawScreen(TEXTURE *texture, TEXTURE *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, bool setsync);
|
| 122 | + void _DrawScreen(TEXTURE *texture, TEXTURE *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, GLint vsync, bool setsync);
|
124 | 123 | void _DeleteTexture(TEXTURE *texture);
|
125 | 124 | void _DrawBackbuffer(TEXTURE **texture, int x, int y, int progtype);
|
126 | 125 | void _InitD3D(int zbuffer);
|