DXGL r494 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r493‎ | r494 | r495 >
Date:23:43, 19 August 2014
Author:admin
Status:new
Tags:
Comment:
Add GetClipList.
Add partial, broken device window support.
Modified paths:
  • /ddraw/ddraw.cpp (modified) (history)
  • /ddraw/ddraw.h (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDraw.h (modified) (history)
  • /ddraw/glDirectDrawClipper.cpp (modified) (history)
  • /ddraw/glDirectDrawClipper.h (modified) (history)
  • /ddraw/glRenderWindow.cpp (modified) (history)
  • /ddraw/glRenderWindow.h (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/glRenderer.h (modified) (history)

Diff [purge]

Index: ddraw/ddraw.cpp
@@ -37,15 +37,15 @@
3838 { 0x9ff8900, 0x8c4a, 0x4ba4, { 0xbf, 0x29, 0x56, 0x50, 0x4a, 0xf, 0x3b, 0xb3 } };
3939
4040
41 -void InitGL(int width, int height, int bpp, bool fullscreen, unsigned int frequency, HWND hWnd, glDirectDraw7 *glDD7)
 41+void InitGL(int width, int height, int bpp, bool fullscreen, unsigned int frequency, HWND hWnd, glDirectDraw7 *glDD7, bool devwnd)
4242 {
4343 TRACE_ENTER(6,11,width,11,height,11,bpp,21,fullscreen,13,hWnd,14,glDD7);
4444 if (!glDD7->renderer)
4545 {
4646 glDD7->renderer = (glRenderer*)malloc(sizeof(glRenderer));
47 - glRenderer_Init(glDD7->renderer,width,height,bpp,fullscreen,frequency,hWnd,glDD7);
 47+ glRenderer_Init(glDD7->renderer,width,height,bpp,fullscreen,frequency,hWnd,glDD7,devwnd);
4848 }
49 - else glRenderer_SetWnd(glDD7->renderer,width,height,bpp,fullscreen,frequency,hWnd);
 49+ else glRenderer_SetWnd(glDD7->renderer,width,height,bpp,fullscreen,frequency,hWnd,devwnd);
5050 TRACE_EXIT(0,0);
5151 }
5252
Index: ddraw/ddraw.h
@@ -61,6 +61,6 @@
6262 extern const GUID device_template;
6363 struct glRenderer;
6464 class glDirectDraw7;
65 -void InitGL(int width, int height, int bpp, bool fullscreen, unsigned int frequency, HWND hWnd, glDirectDraw7 *glDD7);
 65+void InitGL(int width, int height, int bpp, bool fullscreen, unsigned int frequency, HWND hWnd, glDirectDraw7 *glDD7, bool devwnd);
6666
6767 #endif //_DDRAW_PRIVATE_H
\ No newline at end of file
Index: ddraw/glDirectDraw.cpp
@@ -1061,7 +1061,7 @@
10621062 DEVMODE mode;
10631063 mode.dmSize = sizeof(DEVMODE);
10641064 EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &mode);
1065 - glRenderer_Init(tmprenderer, 16, 16, mode.dmBitsPerPel, false, mode.dmDisplayFrequency, hGLWnd, NULL);
 1065+ glRenderer_Init(tmprenderer, 16, 16, mode.dmBitsPerPel, false, mode.dmDisplayFrequency, hGLWnd, NULL, FALSE);
10661066 if (tmprenderer->ext->glver_major >= 3) fullrop = TRUE;
10671067 if (tmprenderer->ext->GLEXT_EXT_gpu_shader4) fullrop = TRUE;
10681068 glRenderer_Delete(tmprenderer);
@@ -1329,6 +1329,7 @@
13301330 winstyle = GetWindowLongPtrA(hWnd,GWL_STYLE);
13311331 winstyleex = GetWindowLongPtrA(hWnd,GWL_EXSTYLE);
13321332 bool exclusive = false;
 1333+ devwnd = false;
13331334 if(dwFlags & DDSCL_ALLOWMODEX)
13341335 {
13351336 // Validate flags
@@ -1340,8 +1341,6 @@
13411342 }
13421343 if(dwFlags & DDSCL_ALLOWREBOOT)
13431344 DEBUG("IDirectDraw::SetCooperativeLevel: DDSCL_ALLOWREBOOT unnecessary\n");
1344 - if(dwFlags & DDSCL_CREATEDEVICEWINDOW)
1345 - FIXME("IDirectDraw::SetCooperativeLevel: DDSCL_CREATEDEVICEWINDOW unsupported\n");
13461345 if(dwFlags & DDSCL_EXCLUSIVE)
13471346 exclusive = true;
13481347 else exclusive = false;
@@ -1350,7 +1349,12 @@
13511350 else fullscreen = false;
13521351 if(exclusive)
13531352 if(!fullscreen) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
1354 - if(dwFlags & DDSCL_FPUPRESERVE)
 1353+ if (dwFlags & DDSCL_CREATEDEVICEWINDOW)
 1354+ {
 1355+ if (!exclusive) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 1356+ devwnd = true;
 1357+ }
 1358+ if (dwFlags & DDSCL_FPUPRESERVE)
13551359 fpupreserve = true;
13561360 else fpupreserve = false;
13571361 if(dwFlags & DDSCL_FPUSETUP)
@@ -1392,7 +1396,7 @@
13931397 bpp = devmode.dmBitsPerPel;
13941398 internalrefresh = primaryrefresh = screenrefresh = devmode.dmDisplayFrequency;
13951399 primarybpp = bpp;
1396 - InitGL(x,y,bpp,fullscreen,internalrefresh,hWnd,this);
 1400+ InitGL(x,y,bpp,fullscreen,internalrefresh,hWnd,this,devwnd);
13971401 TRACE_EXIT(23,DD_OK);
13981402 return DD_OK;
13991403 }
@@ -1467,6 +1471,7 @@
14681472 if (dwFlags & 0xFFFFFFFE) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
14691473 if ((dwBPP != 4) && (dwBPP != 8) && (dwBPP != 15) && (dwBPP != 16) && (dwBPP != 24) && (dwBPP != 32))
14701474 TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 1475+ if (!fullscreen) TRACE_RET(HRESULT, 23, DDERR_NOEXCLUSIVEMODE);
14711476 DEBUG("IDirectDraw::SetDisplayMode: implement multiple monitors\n");
14721477 DEVMODE newmode,newmode2;
14731478 DEVMODE currmode;
@@ -1506,7 +1511,7 @@
15071512 primarybpp = dwBPP;
15081513 if(dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
15091514 else internalrefresh = primaryrefresh = screenrefresh = currmode.dmDisplayFrequency;
1510 - InitGL(screenx,screeny,screenbpp,true,internalrefresh,hWnd,this);
 1515+ InitGL(screenx,screeny,screenbpp,true,internalrefresh,hWnd,this,devwnd);
15111516 primarylost = true;
15121517 TRACE_EXIT(23,DD_OK);
15131518 return DD_OK;
@@ -1539,7 +1544,7 @@
15401545 if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
15411546 else internalrefresh = primaryrefresh = screenrefresh = currmode.dmDisplayFrequency;
15421547 primarybpp = dwBPP;
1543 - InitGL(screenx,screeny,screenbpp,true,internalrefresh,hWnd,this);
 1548+ InitGL(screenx,screeny,screenbpp,true,internalrefresh,hWnd,this,devwnd);
15441549 primarylost = true;
15451550 TRACE_EXIT(23,DD_OK);
15461551 return DD_OK;
@@ -1584,7 +1589,7 @@
15851590 if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
15861591 else internalrefresh = primaryrefresh = screenrefresh = currmode.dmDisplayFrequency;
15871592 primarybpp = dwBPP;
1588 - InitGL(screenx,screeny,screenbpp,true,internalrefresh,hWnd,this);
 1593+ InitGL(screenx,screeny,screenbpp,true,internalrefresh,hWnd,this,devwnd);
15891594 primarylost = true;
15901595 TRACE_EXIT(23,DD_OK);
15911596 return DD_OK;
@@ -1599,7 +1604,7 @@
16001605 else internalbpp = screenbpp = currmode.dmBitsPerPel;
16011606 if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
16021607 else internalrefresh = primaryrefresh = screenrefresh = currmode.dmDisplayFrequency;
1603 - InitGL(screenx, screeny, screenbpp, true, internalrefresh, hWnd, this);
 1608+ InitGL(screenx, screeny, screenbpp, true, internalrefresh, hWnd, this, devwnd);
16041609 TRACE_EXIT(23,DD_OK);
16051610 return DD_OK;
16061611 break;
@@ -1637,7 +1642,7 @@
16381643 if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
16391644 else internalrefresh = primaryrefresh = screenrefresh = newmode2.dmDisplayFrequency;
16401645 primarybpp = dwBPP;
1641 - InitGL(screenx,screeny,screenbpp,true,internalrefresh,hWnd,this);
 1646+ InitGL(screenx,screeny,screenbpp,true,internalrefresh,hWnd,this,devwnd);
16421647 primarylost = true;
16431648 TRACE_EXIT(23,DD_OK);
16441649 return DD_OK;
@@ -1682,7 +1687,7 @@
16831688 if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
16841689 else internalrefresh = primaryrefresh = screenrefresh = newmode2.dmDisplayFrequency;
16851690 primarybpp = dwBPP;
1686 - InitGL(screenx,screeny,screenbpp,true,internalrefresh,hWnd,this);
 1691+ InitGL(screenx,screeny,screenbpp,true,internalrefresh,hWnd,this,devwnd);
16871692 primarylost = true;
16881693 TRACE_EXIT(23,DD_OK);
16891694 return DD_OK;
@@ -1698,7 +1703,7 @@
16991704 else internalbpp = screenbpp = newmode2.dmBitsPerPel;
17001705 if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
17011706 else internalrefresh = primaryrefresh = screenrefresh = newmode2.dmDisplayFrequency;
1702 - InitGL(screenx,screeny,screenbpp,true,internalrefresh,hWnd,this);
 1707+ InitGL(screenx,screeny,screenbpp,true,internalrefresh,hWnd,this,devwnd);
17031708 primarylost = true;
17041709 TRACE_EXIT(23,DD_OK);
17051710 return DD_OK;
Index: ddraw/glDirectDraw.h
@@ -113,6 +113,7 @@
114114 bool initialized;
115115 glDirect3D7 *glD3D7;
116116 DWORD timer;
 117+ bool devwnd;
117118 };
118119
119120 class glDirectDraw1 : public IDirectDraw
Index: ddraw/glDirectDrawClipper.cpp
@@ -117,10 +117,125 @@
118118 TRACE_EXIT(8,ret);
119119 return ret;
120120 }
 121+
121122 HRESULT WINAPI glDirectDrawClipper_GetClipList(glDirectDrawClipper *This, LPRECT lpRect, LPRGNDATA lpClipList, LPDWORD lpdwSize)
122123 {
 124+ HRGN rgnrect;
 125+ HRGN rgncliplist;
 126+ RGNDATA *rgn;
 127+ DWORD rgnsize;
123128 TRACE_ENTER(4,14,This,26,lpRect,14,lpClipList,14,lpdwSize);
124129 if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 130+ if (!lpdwSize) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 131+ if (!This->clipsize) TRACE_RET(HRESULT, 23, DDERR_NOCLIPLIST);
 132+ if (!lpClipList)
 133+ {
 134+ if (lpRect)
 135+ {
 136+ rgnrect = CreateRectRgnIndirect(lpRect);
 137+ rgncliplist = ExtCreateRegion(NULL, (sizeof(RGNDATAHEADER) + (This->cliplist->rdh.nCount*sizeof(RECT))),
 138+ This->cliplist);
 139+ if (CombineRgn(rgncliplist, rgnrect, rgncliplist, RGN_AND) == ERROR)
 140+ {
 141+ DeleteObject(rgnrect);
 142+ DeleteObject(rgncliplist);
 143+ TRACE_RET(HRESULT, 23, DDERR_GENERIC);
 144+ }
 145+ rgnsize = GetRegionData(rgncliplist, 0, NULL);
 146+ rgn = (RGNDATA*)malloc(rgnsize);
 147+ if (!rgn)
 148+ {
 149+ DeleteObject(rgnrect);
 150+ DeleteObject(rgncliplist);
 151+ TRACE_RET(HRESULT, 23, DDERR_OUTOFMEMORY);
 152+ }
 153+ GetRegionData(rgncliplist, rgnsize, rgn);
 154+ *lpdwSize = sizeof(RGNDATAHEADER) + (rgn->rdh.nCount*sizeof(RECT));
 155+ free(rgn);
 156+ DeleteObject(rgnrect);
 157+ DeleteObject(rgncliplist);
 158+ TRACE_EXIT(23, DD_OK);
 159+ return DD_OK;
 160+ }
 161+ else
 162+ {
 163+ *lpdwSize = sizeof(RGNDATAHEADER) + (This->clipsize*sizeof(RECT));
 164+ TRACE_EXIT(23, DD_OK);
 165+ return DD_OK;
 166+ }
 167+ }
 168+ else
 169+ {
 170+ if (lpRect)
 171+ {
 172+ rgnrect = CreateRectRgnIndirect(lpRect);
 173+ rgncliplist = ExtCreateRegion(NULL, (sizeof(RGNDATAHEADER) + (This->cliplist->rdh.nCount*sizeof(RECT))),
 174+ This->cliplist);
 175+ if (CombineRgn(rgncliplist, rgnrect, rgncliplist, RGN_AND) == ERROR)
 176+ {
 177+ DeleteObject(rgnrect);
 178+ DeleteObject(rgncliplist);
 179+ TRACE_RET(HRESULT, 23, DDERR_GENERIC);
 180+ }
 181+ rgnsize = GetRegionData(rgncliplist, 0, NULL);
 182+ rgn = (RGNDATA*)malloc(rgnsize);
 183+ if (!rgn)
 184+ {
 185+ DeleteObject(rgnrect);
 186+ DeleteObject(rgncliplist);
 187+ TRACE_RET(HRESULT, 23, DDERR_OUTOFMEMORY);
 188+ }
 189+ GetRegionData(rgncliplist, rgnsize, rgn);
 190+ if (*lpdwSize < (sizeof(RGNDATAHEADER) + (rgn->rdh.nCount*sizeof(RECT))))
 191+ {
 192+ free(rgn);
 193+ DeleteObject(rgnrect);
 194+ DeleteObject(rgncliplist);
 195+ TRACE_RET(HRESULT, 23, DDERR_REGIONTOOSMALL);
 196+ }
 197+ *lpdwSize = sizeof(RGNDATAHEADER) + (rgn->rdh.nCount*sizeof(RECT));
 198+#ifdef _MSC_VER
 199+ __try
 200+ {
 201+#endif
 202+ memcpy(lpClipList, rgn, sizeof(RGNDATAHEADER) + (rgn->rdh.nCount*sizeof(RECT)));
 203+#ifdef _MSC_VER
 204+ }
 205+ __except (GetExceptionCode() == STATUS_ACCESS_VIOLATION)
 206+ {
 207+ free(rgn);
 208+ DeleteObject(rgnrect);
 209+ DeleteObject(rgncliplist);
 210+ TRACE_RET(HRESULT, 23, DDERR_INVALIDCLIPLIST);
 211+ }
 212+#endif
 213+ free(rgn);
 214+ DeleteObject(rgnrect);
 215+ DeleteObject(rgncliplist);
 216+ TRACE_EXIT(23, DD_OK);
 217+ return DD_OK;
 218+ }
 219+ else
 220+ {
 221+ if(*lpdwSize < (sizeof(RGNDATAHEADER) + (This->clipsize*sizeof(RECT))))
 222+ TRACE_RET(HRESULT,23,DDERR_REGIONTOOSMALL);
 223+ *lpdwSize = sizeof(RGNDATAHEADER) + (This->clipsize*sizeof(RECT));
 224+#ifdef _MSC_VER
 225+ __try
 226+ {
 227+#endif
 228+ memcpy(lpClipList, This->cliplist, sizeof(RGNDATAHEADER) + (This->clipsize*sizeof(RECT)));
 229+#ifdef _MSC_VER
 230+ }
 231+ __except (GetExceptionCode() == STATUS_ACCESS_VIOLATION)
 232+ {
 233+ TRACE_RET(HRESULT, 23, DDERR_INVALIDCLIPLIST);
 234+ }
 235+#endif
 236+ TRACE_EXIT(23, DD_OK);
 237+ return DD_OK;
 238+ }
 239+ }
125240 FIXME("IDirectDrawClipper::GetClipList: stub");
126241 TRACE_EXIT(23,DDERR_GENERIC);
127242 ERR(DDERR_GENERIC);
@@ -179,7 +294,7 @@
180295 {
181296 memfail = false;
182297 This->maxsize = lpClipList->rdh.nCount;
183 - This->cliplist = (RECT*)malloc(This->maxsize*sizeof(RECT));
 298+ This->cliplist = (RGNDATA*)malloc(sizeof(RGNDATAHEADER)+(This->maxsize*sizeof(RECT)));
184299 if(!This->cliplist) memfail = true;
185300 if(!memfail) This->vertices = (BltVertex*)malloc(This->maxsize*4*sizeof(BltVertex));
186301 if(!This->vertices) memfail = true;
@@ -204,10 +319,10 @@
205320 if(lpClipList->rdh.nCount > This->maxsize)
206321 {
207322 memfail = false;
208 - RECT *newcliplist = NULL;
 323+ RGNDATA *newcliplist = NULL;
209324 BltVertex *newvertices = NULL;
210325 WORD *newindices = NULL;
211 - newcliplist = (RECT*)realloc(This->cliplist,lpClipList->rdh.nCount*sizeof(RECT));
 326+ newcliplist = (RGNDATA*)realloc(This->cliplist,sizeof(RGNDATAHEADER)+(lpClipList->rdh.nCount*sizeof(RECT)));
212327 if(!newcliplist) memfail = true;
213328 else This->cliplist = newcliplist;
214329 if(!memfail) newvertices = (BltVertex*)realloc(This->vertices,lpClipList->rdh.nCount*4*sizeof(BltVertex));
@@ -220,13 +335,14 @@
221336 This->maxsize = lpClipList->rdh.nCount;
222337 }
223338 This->clipsize = lpClipList->rdh.nCount;
224 - memcpy(This->cliplist,lpClipList->Buffer,lpClipList->rdh.nCount*sizeof(RECT));
 339+ memcpy(This->cliplist,lpClipList,sizeof(RGNDATAHEADER)+(lpClipList->rdh.nCount*sizeof(RECT)));
 340+ RECT *buffer = (RECT*)This->cliplist->Buffer;
225341 for(int i = 0; i < lpClipList->rdh.nCount; i++)
226342 {
227 - This->vertices[(i*4)+1].x = This->vertices[(i*4)+3].x = This->cliplist[i].left;
228 - This->vertices[i*4].x = This->vertices[(i*4)+2].x = This->cliplist[i].right;
229 - This->vertices[i*4].y = This->vertices[(i*4)+1].y = This->cliplist[i].top;
230 - This->vertices[(i*4)+2].y = This->vertices[(i*4)+3].y = This->cliplist[i].bottom;
 343+ This->vertices[(i*4)+1].x = This->vertices[(i*4)+3].x = buffer[i].left;
 344+ This->vertices[i*4].x = This->vertices[(i*4)+2].x = buffer[i].right;
 345+ This->vertices[i*4].y = This->vertices[(i*4)+1].y = buffer[i].top;
 346+ This->vertices[(i*4)+2].y = This->vertices[(i*4)+3].y = buffer[i].bottom;
231347 // 0 1 2 2 1 3
232348 This->indices[i*6] = i*4;
233349 This->indices[(i*6)+1] = This->indices[(i*6)+4] = (i*4)+1;
Index: ddraw/glDirectDrawClipper.h
@@ -31,7 +31,7 @@
3232 bool hasparent;
3333 bool initialized;
3434 HWND hWnd;
35 - RECT *cliplist;
 35+ RGNDATA *cliplist;
3636 BltVertex *vertices;
3737 WORD *indices;
3838 int clipsize;
Index: ddraw/glRenderWindow.cpp
@@ -47,12 +47,13 @@
4848
4949 }
5050
51 -glRenderWindow::glRenderWindow(int width, int height, bool fullscreen, HWND parent, glDirectDraw7 *glDD7)
 51+glRenderWindow::glRenderWindow(int width, int height, bool fullscreen, HWND parent, glDirectDraw7 *glDD7, bool devwnd)
5252 {
5353 ddInterface = glDD7;
5454 this->width = width;
5555 this->height = height;
5656 this->fullscreen = fullscreen;
 57+ this->device = devwnd;
5758 hParentWnd = parent;
5859 ReadyEvent = CreateEvent(NULL,false,false,NULL);
5960 hThread = CreateThread(NULL,0,ThreadEntry,this,0,NULL);
@@ -68,6 +69,9 @@
6970
7071 DWORD glRenderWindow::_Entry()
7172 {
 73+ char *windowname;
 74+ if (device) windowname = "DirectDrawDeviceWnd";
 75+ else windowname = "Renderer";
7276 MSG Msg;
7377 if(!wndclasscreated)
7478 {
@@ -81,7 +85,7 @@
8286 wndclass.hCursor = NULL;
8387 wndclass.hbrBackground = NULL;
8488 wndclass.lpszMenuName = NULL;
85 - wndclass.lpszClassName = "DXGLRenderWindow";
 89+ wndclass.lpszClassName = "DirectDrawDeviceWnd";
8690 wndclass.hIconSm = NULL;
8791 RegisterClassExA(&wndclass);
8892 wndclasscreated = true;
@@ -91,7 +95,7 @@
9296 dead = false;
9397 if(hParentWnd)
9498 {
95 - hWnd = CreateWindowA("DXGLRenderWindow","Renderer",WS_CHILD|WS_VISIBLE,0,0,rectRender.right - rectRender.left,
 99+ hWnd = CreateWindowA("DirectDrawDeviceWnd",windowname,WS_CHILD|WS_VISIBLE,0,0,rectRender.right - rectRender.left,
96100 rectRender.bottom - rectRender.top,hParentWnd,NULL,wndclass.hInstance,this);
97101 SetWindowPos(hWnd,HWND_TOP,0,0,rectRender.right,rectRender.bottom,SWP_SHOWWINDOW);
98102 }
@@ -100,7 +104,7 @@
101105 width = GetSystemMetrics(SM_CXSCREEN);
102106 height = GetSystemMetrics(SM_CYSCREEN);
103107 hWnd = CreateWindowExA(WS_EX_TOOLWINDOW|WS_EX_LAYERED|WS_EX_TRANSPARENT|WS_EX_TOPMOST,
104 - "DXGLRenderWindow","Renderer",WS_POPUP,0,0,width,height,0,0,NULL,this);
 108+ "DirectDrawDeviceWnd",windowname,WS_POPUP,0,0,width,height,0,0,NULL,this);
105109 SetWindowPos(hWnd,HWND_TOP,0,0,width,height,SWP_SHOWWINDOW|SWP_NOACTIVATE);
106110 }
107111 #ifdef _DEBUG
Index: ddraw/glRenderWindow.h
@@ -26,7 +26,7 @@
2727 class glRenderWindow
2828 {
2929 public:
30 - glRenderWindow(int width, int height, bool fullscreen, HWND parent, glDirectDraw7 *glDD7);
 30+ glRenderWindow(int width, int height, bool fullscreen, HWND parent, glDirectDraw7 *glDD7, bool devwnd);
3131 ~glRenderWindow();
3232 void resize(int width, int height);
3333 HWND GetHWnd(){return hWnd;};
@@ -42,6 +42,7 @@
4343 int height;
4444 bool fullscreen;
4545 bool dead;
 46+ bool device;
4647 glDirectDraw7 *ddInterface;
4748 };
4849
Index: ddraw/glRenderer.cpp
@@ -194,8 +194,10 @@
195195 * layered window will be created for the renderer.
196196 * @param glDD7
197197 * Pointer to the glDirectDraw7 object that is managing the glRenderer object
 198+ * @param devwnd
 199+ * True if creating window with name "DirectDrawDeviceWnd"
198200 */
199 -void glRenderer_Init(glRenderer *This, int width, int height, int bpp, bool fullscreen, unsigned int frequency, HWND hwnd, glDirectDraw7 *glDD7)
 201+void glRenderer_Init(glRenderer *This, int width, int height, int bpp, bool fullscreen, unsigned int frequency, HWND hwnd, glDirectDraw7 *glDD7, BOOL devwnd)
200202 {
201203 This->oldswap = 0;
202204 This->fogcolor = 0;
@@ -222,7 +224,7 @@
223225 // TODO: Adjust window rect
224226 }
225227 SetWindowPos(This->hWnd,HWND_TOP,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
226 - This->RenderWnd = new glRenderWindow(width,height,fullscreen,This->hWnd,glDD7);
 228+ This->RenderWnd = new glRenderWindow(width,height,fullscreen,This->hWnd,glDD7,devwnd);
227229 This->inputs[0] = (void*)width;
228230 This->inputs[1] = (void*)height;
229231 This->inputs[2] = (void*)bpp;
@@ -231,6 +233,7 @@
232234 This->inputs[5] = (void*)This->hWnd;
233235 This->inputs[6] = glDD7;
234236 This->inputs[7] = This;
 237+ This->inputs[8] = (void*)devwnd;
235238 This->hThread = CreateThread(NULL, 0, glRenderer_ThreadEntry, This->inputs, 0, NULL);
236239 WaitForSingleObject(This->busy,INFINITE);
237240 }
@@ -557,8 +560,10 @@
558561 * True if fullscreen
559562 * @param newwnd
560563 * HWND of the new window
 564+ * @param devwnd
 565+ * True if creating window with name "DirectDrawDeviceWnd"
561566 */
562 -void glRenderer_SetWnd(glRenderer *This, int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND newwnd)
 567+void glRenderer_SetWnd(glRenderer *This, int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND newwnd, BOOL devwnd)
563568 {
564569 EnterCriticalSection(&This->cs);
565570 if(fullscreen && newwnd)
@@ -573,6 +578,7 @@
574579 This->inputs[3] = (void*)fullscreen;
575580 This->inputs[4] = (void*)frequency;
576581 This->inputs[5] = (void*)newwnd;
 582+ This->inputs[6] = (void*)devwnd;
577583 This->opcode = OP_SETWND;
578584 SetEvent(This->start);
579585 WaitForObjectAndMessages(This->busy);
@@ -734,7 +740,7 @@
735741 break;
736742 case OP_SETWND:
737743 glRenderer__SetWnd(This,(int)This->inputs[0],(int)This->inputs[1],(int)This->inputs[2],
738 - (int)This->inputs[3],(unsigned int)This->inputs[4],(HWND)This->inputs[5]);
 744+ (int)This->inputs[3],(unsigned int)This->inputs[4],(HWND)This->inputs[5],(BOOL)This->inputs[6]);
739745 break;
740746 case OP_CREATE:
741747 glRenderer__MakeTexture(This,(TEXTURE*)This->inputs[0],(DWORD)This->inputs[1],(DWORD)This->inputs[2]);
@@ -1649,7 +1655,7 @@
16501656 SetEvent(This->busy);
16511657 }
16521658
1653 -void glRenderer__SetWnd(glRenderer *This, int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND newwnd)
 1659+void glRenderer__SetWnd(glRenderer *This, int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND newwnd, BOOL devwnd)
16541660 {
16551661 if(newwnd != This->hWnd)
16561662 {
@@ -1657,7 +1663,7 @@
16581664 wglMakeCurrent(NULL, NULL);
16591665 ReleaseDC(This->hWnd,This->hDC);
16601666 delete This->RenderWnd;
1661 - This->RenderWnd = new glRenderWindow(width,height,fullscreen,newwnd,This->ddInterface);
 1667+ This->RenderWnd = new glRenderWindow(width,height,fullscreen,newwnd,This->ddInterface, devwnd);
16621668 PIXELFORMATDESCRIPTOR pfd;
16631669 GLuint pf;
16641670 InterlockedIncrement(&gllock);
Index: ddraw/glRenderer.h
@@ -118,7 +118,7 @@
119119 ShaderManager *shaders;
120120 } glRenderer;
121121
122 -void glRenderer_Init(glRenderer *This, int width, int height, int bpp, bool fullscreen, unsigned int frequency, HWND hwnd, glDirectDraw7 *glDD7);
 122+void glRenderer_Init(glRenderer *This, int width, int height, int bpp, bool fullscreen, unsigned int frequency, HWND hwnd, glDirectDraw7 *glDD7, BOOL devwnd);
123123 void glRenderer_Delete(glRenderer *This);
124124 static DWORD WINAPI glRenderer_ThreadEntry(void *entry);
125125 void glRenderer_UploadTexture(glRenderer *This, char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y, int bigx, int bigy, int pitch, int bigpitch, int bpp);
@@ -130,7 +130,7 @@
131131 void glRenderer_DeleteTexture(glRenderer *This, TEXTURE *texture);
132132 void glRenderer_InitD3D(glRenderer *This, int zbuffer);
133133 void glRenderer_Flush(glRenderer *This);
134 -void glRenderer_SetWnd(glRenderer *This, int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND newwnd);
 134+void glRenderer_SetWnd(glRenderer *This, int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND newwnd, BOOL devwnd);
135135 HRESULT glRenderer_Clear(glRenderer *This, glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil);
136136 HRESULT glRenderer_DrawPrimitives(glRenderer *This, glDirect3DDevice7 *device, GLenum mode, GLVERTEX *vertices, int *texformats, DWORD count, LPWORD indices,
137137 DWORD indexcount, DWORD flags);
@@ -154,7 +154,7 @@
155155 void glRenderer__DrawPrimitives(glRenderer *This, glDirect3DDevice7 *device, GLenum mode, GLVERTEX *vertices, int *texcormats, DWORD count, LPWORD indices,
156156 DWORD indexcount, DWORD flags);
157157 void glRenderer__Flush(glRenderer *This);
158 -void glRenderer__SetWnd(glRenderer *This, int width, int height, int fullscreen, int bpp, unsigned int frequency, HWND newwnd);
 158+void glRenderer__SetWnd(glRenderer *This, int width, int height, int fullscreen, int bpp, unsigned int frequency, HWND newwnd, BOOL devwnd);
159159 void glRenderer__DeleteFBO(glRenderer *This, FBO *fbo);
160160 void glRenderer__UpdateClipper(glRenderer *This, glDirectDrawSurface7 *surface);
161161 void glRenderer__SetFogColor(glRenderer *This, DWORD color);