Index: ddraw/ddraw.cpp |
— | — | @@ -33,6 +33,7 @@ |
34 | 34 |
|
35 | 35 | DWORD timer;
|
36 | 36 | int vsyncstatus;
|
| 37 | +bool ddenabled = false;
|
37 | 38 |
|
38 | 39 | DDRAW_API void WINAPI AcquireDDThreadLock()
|
39 | 40 | {
|
— | — | @@ -103,6 +104,7 @@ |
104 | 105 | }
|
105 | 106 | return sysddrawcreate(lpGUID,lplpDD,pUnkOuter);
|
106 | 107 | }
|
| 108 | + if(ddenabled) return DDERR_DIRECTDRAWALREADYCREATED;
|
107 | 109 | GetCurrentConfig(&dxglcfg);
|
108 | 110 | glDirectDraw7 *myddraw7;
|
109 | 111 | glDirectDraw1 *myddraw;
|
— | — | @@ -114,6 +116,7 @@ |
115 | 117 | delete myddraw7;
|
116 | 118 | return error;
|
117 | 119 | }
|
| 120 | + ddenabled = true;
|
118 | 121 | myddraw7->QueryInterface(IID_IDirectDraw,(VOID**)&myddraw);
|
119 | 122 | myddraw7->Release();
|
120 | 123 | *lplpDD = (LPDIRECTDRAW)myddraw;
|
— | — | @@ -126,6 +129,7 @@ |
127 | 130 | }
|
128 | 131 | HRESULT WINAPI DirectDrawCreateEx(GUID FAR *lpGUID, LPVOID *lplpDD, REFIID iid, IUnknown FAR *pUnkOuter)
|
129 | 132 | {
|
| 133 | + if(ddenabled) return DDERR_DIRECTDRAWALREADYCREATED;
|
130 | 134 | GetCurrentConfig(&dxglcfg);
|
131 | 135 | glDirectDraw7 *myddraw;
|
132 | 136 | HRESULT error;
|
— | — | @@ -137,6 +141,7 @@ |
138 | 142 | delete myddraw;
|
139 | 143 | return error;
|
140 | 144 | }
|
| 145 | + ddenabled = true;
|
141 | 146 | *lplpDD = (LPDIRECTDRAW7)myddraw;
|
142 | 147 | return error;
|
143 | 148 | }
|
Index: ddraw/ddraw.h |
— | — | @@ -60,6 +60,6 @@ |
61 | 61 | extern bool gllock;
|
62 | 62 | extern DWORD timer;
|
63 | 63 | extern int vsyncstatus;
|
| 64 | +extern bool ddenabled;
|
64 | 65 |
|
65 | | -
|
66 | 66 | #endif //_DDRAW_H |
\ No newline at end of file |
Index: ddraw/glDirectDraw.cpp |
— | — | @@ -582,6 +582,7 @@ |
583 | 583 | free(surfaces);
|
584 | 584 | }
|
585 | 585 | DeleteGL();
|
| 586 | + ddenabled = false;
|
586 | 587 | }
|
587 | 588 |
|
588 | 589 | HRESULT WINAPI glDirectDraw7::QueryInterface(REFIID riid, void** ppvObj)
|
— | — | @@ -777,6 +778,44 @@ |
778 | 779 | ZeroMemory(&ddsdMode, sizeof(DDSURFACEDESC2));
|
779 | 780 | ddsdMode.dwSize = sizeof(DDSURFACEDESC2);
|
780 | 781 | DEVMODE currmode;
|
| 782 | + if(fullscreen)
|
| 783 | + {
|
| 784 | + if(primarybpp == 8)
|
| 785 | + {
|
| 786 | + ddsdMode.ddpfPixelFormat.dwRBitMask = 0;
|
| 787 | + ddsdMode.ddpfPixelFormat.dwGBitMask = 0;
|
| 788 | + ddsdMode.ddpfPixelFormat.dwBBitMask = 0;
|
| 789 | + }
|
| 790 | + else if(primarybpp == 15)
|
| 791 | + {
|
| 792 | + ddsdMode.ddpfPixelFormat.dwRBitMask = 0x7C00;
|
| 793 | + ddsdMode.ddpfPixelFormat.dwGBitMask = 0x3E0;
|
| 794 | + ddsdMode.ddpfPixelFormat.dwRBitMask = 0x1F;
|
| 795 | + }
|
| 796 | + else if(primarybpp == 16)
|
| 797 | + {
|
| 798 | + ddsdMode.ddpfPixelFormat.dwRBitMask = 0xF800;
|
| 799 | + ddsdMode.ddpfPixelFormat.dwGBitMask = 0x7E0;
|
| 800 | + ddsdMode.ddpfPixelFormat.dwBBitMask = 0x1F;
|
| 801 | + }
|
| 802 | + else
|
| 803 | + {
|
| 804 | + ddsdMode.ddpfPixelFormat.dwRBitMask = 0xFF0000;
|
| 805 | + ddsdMode.ddpfPixelFormat.dwRBitMask = 0xFF00;
|
| 806 | + ddsdMode.ddpfPixelFormat.dwRBitMask = 0xFF;
|
| 807 | + }
|
| 808 | + ddsdMode.ddpfPixelFormat.dwRGBBitCount = GetBPPMultipleOf8();
|
| 809 | + ddsdMode.dwWidth = primaryx;
|
| 810 | + ddsdMode.dwHeight = primaryy;
|
| 811 | + if(primarybpp == 15) ddsdMode.lPitch = primaryx * 2;
|
| 812 | + else if(primarybpp == 4) ddsdMode.lPitch = primaryx / 2;
|
| 813 | + else ddsdMode.lPitch = primaryx * (primarybpp / 8);
|
| 814 | + if(lpDDSurfaceDesc2->dwSize < sizeof(DDSURFACEDESC)) ERR(DDERR_INVALIDPARAMS);
|
| 815 | + if(lpDDSurfaceDesc2->dwSize > sizeof(DDSURFACEDESC2))
|
| 816 | + lpDDSurfaceDesc2->dwSize = sizeof(DDSURFACEDESC2);
|
| 817 | + memcpy(lpDDSurfaceDesc2,&ddsdMode,lpDDSurfaceDesc2->dwSize);
|
| 818 | + return DD_OK;
|
| 819 | + }
|
781 | 820 | EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&currmode);
|
782 | 821 | if(currmode.dmBitsPerPel == 8) ddsdMode.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED8;
|
783 | 822 | else if(currmode.dmBitsPerPel == 4) ddsdMode.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED4;
|
— | — | @@ -829,7 +868,7 @@ |
830 | 869 | }
|
831 | 870 | HRESULT WINAPI glDirectDraw7::GetMonitorFrequency(LPDWORD lpdwFrequency)
|
832 | 871 | {
|
833 | | - FIXME("IDirectDraw::GetMonitorFrequency: support multi-monitor\n");
|
| 872 | + DEBUG("IDirectDraw::GetMonitorFrequency: support multi-monitor\n");
|
834 | 873 | DEVMODE devmode;
|
835 | 874 | devmode.dmSize = sizeof(DEVMODE);
|
836 | 875 | EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&devmode);
|
— | — | @@ -904,6 +943,7 @@ |
905 | 944 | HRESULT WINAPI glDirectDraw7::SetCooperativeLevel(HWND hWnd, DWORD dwFlags)
|
906 | 945 | {
|
907 | 946 | this->hWnd = hWnd;
|
| 947 | + if(hRC) DeleteGL();
|
908 | 948 | winstyle = GetWindowLongPtrA(hWnd,GWL_STYLE);
|
909 | 949 | winstyleex = GetWindowLongPtrA(hWnd,GWL_EXSTYLE);
|
910 | 950 | bool exclusive = false;
|
— | — | @@ -1267,10 +1307,17 @@ |
1268 | 1308 | {
|
1269 | 1309 | if(hRC)
|
1270 | 1310 | {
|
| 1311 | + if(dib.enabled)
|
| 1312 | + {
|
| 1313 | + if(dib.hbitmap) DeleteObject(dib.hbitmap);
|
| 1314 | + if(dib.hdc) DeleteDC(dib.hdc);
|
| 1315 | + ZeroMemory(&dib,sizeof(DIB));
|
| 1316 | + }
|
1271 | 1317 | DeleteShaders();
|
1272 | 1318 | DeleteFBO();
|
1273 | 1319 | if(PBO)
|
1274 | 1320 | {
|
| 1321 | + glBindBuffer(GL_PIXEL_PACK_BUFFER,0);
|
1275 | 1322 | glDeleteBuffers(1,&PBO);
|
1276 | 1323 | PBO = 0;
|
1277 | 1324 | }
|
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -130,6 +130,7 @@ |
131 | 131 | flipcount = 0;
|
132 | 132 | ZeroMemory(colorkey,4*sizeof(CKEY));
|
133 | 133 | bitmapinfo = (BITMAPINFO *)malloc(sizeof(BITMAPINFO)+(255*sizeof(RGBQUAD)));
|
| 134 | + ZeroMemory(bitmapinfo,sizeof(BITMAPINFO)+(255*sizeof(RGBQUAD)));
|
134 | 135 | palette = NULL;
|
135 | 136 | paltex = NULL;
|
136 | 137 | texture = NULL;
|
— | — | @@ -226,12 +227,11 @@ |
227 | 228 | if(ddsd.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY)
|
228 | 229 | {
|
229 | 230 | BITMAPINFO info;
|
| 231 | + ZeroMemory(&info,sizeof(BITMAPINFO));
|
230 | 232 | if(ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
231 | 233 | {
|
232 | | - info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
233 | 234 | info.bmiHeader.biWidth = fakex;
|
234 | 235 | info.bmiHeader.biHeight = -(signed)fakey;
|
235 | | - info.bmiHeader.biPlanes = 1;
|
236 | 236 | info.bmiHeader.biCompression = BI_RGB;
|
237 | 237 | info.bmiHeader.biSizeImage = 0;
|
238 | 238 | info.bmiHeader.biXPelsPerMeter = 0;
|
— | — | @@ -246,10 +246,8 @@ |
247 | 247 | if(ddsd.dwFlags & DDSD_PIXELFORMAT) surfacetype=2;
|
248 | 248 | else
|
249 | 249 | {
|
250 | | - info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
251 | 250 | info.bmiHeader.biWidth = fakex;
|
252 | 251 | info.bmiHeader.biHeight = -(signed)fakey;
|
253 | | - info.bmiHeader.biPlanes = 1;
|
254 | 252 | info.bmiHeader.biCompression = BI_RGB;
|
255 | 253 | info.bmiHeader.biSizeImage = 0;
|
256 | 254 | info.bmiHeader.biXPelsPerMeter = 0;
|
— | — | @@ -263,8 +261,6 @@ |
264 | 262 | }
|
265 | 263 | else
|
266 | 264 | {
|
267 | | - bitmapinfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
268 | | - bitmapinfo->bmiHeader.biPlanes = 1;
|
269 | 265 | bitmapinfo->bmiHeader.biSizeImage = 0;
|
270 | 266 | bitmapinfo->bmiHeader.biXPelsPerMeter = 0;
|
271 | 267 | bitmapinfo->bmiHeader.biYPelsPerMeter = 0;
|
— | — | @@ -274,8 +270,10 @@ |
275 | 271 | bitmapinfo->bmiHeader.biBitCount = (WORD)ddInterface->GetBPPMultipleOf8();
|
276 | 272 | }
|
277 | 273 | surfacetype=2;
|
| 274 | + bitmapinfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
278 | 275 | bitmapinfo->bmiHeader.biWidth = ddsd.dwWidth;
|
279 | 276 | bitmapinfo->bmiHeader.biHeight = -(signed)ddsd.dwHeight;
|
| 277 | + bitmapinfo->bmiHeader.biPlanes = 1;
|
280 | 278 | switch(surfacetype)
|
281 | 279 | {
|
282 | 280 | case 0:
|
— | — | @@ -308,8 +306,43 @@ |
309 | 307 | glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
|
310 | 308 | if(ddsd.dwFlags & DDSD_PIXELFORMAT)
|
311 | 309 | {
|
312 | | - if(ddsd.ddpfPixelFormat.dwFlags & DDPF_ZBUFFER)
|
| 310 | + if(ddsd.ddpfPixelFormat.dwFlags & DDPF_RGB)
|
313 | 311 | {
|
| 312 | + switch(ddsd.ddpfPixelFormat.dwRGBBitCount)
|
| 313 | + {
|
| 314 | + case 8:
|
| 315 | + if(ddsd.ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8)
|
| 316 | + {
|
| 317 | + texformat = GL_LUMINANCE;
|
| 318 | + texformat2 = GL_UNSIGNED_BYTE;
|
| 319 | + if(dxglcfg.texformat) texformat3 = GL_LUMINANCE8;
|
| 320 | + else texformat3 = GL_RGBA8;
|
| 321 | + if(!palettein) palette = new glDirectDrawPalette(DDPCAPS_8BIT|DDPCAPS_ALLOW256|DDPCAPS_PRIMARYSURFACE,NULL,NULL);
|
| 322 | + bitmapinfo->bmiHeader.biBitCount = 8;
|
| 323 | + }
|
| 324 | + else
|
| 325 | + {
|
| 326 | + texformat = GL_RGB;
|
| 327 | + texformat2 = GL_UNSIGNED_BYTE_3_3_2;
|
| 328 | + if(dxglcfg.texformat) texformat3 = GL_R3_G3_B2;
|
| 329 | + else texformat3 = GL_RGBA8;
|
| 330 | + }
|
| 331 | + ddsd.ddpfPixelFormat.dwRBitMask = 0;
|
| 332 | + ddsd.ddpfPixelFormat.dwGBitMask = 0;
|
| 333 | + ddsd.ddpfPixelFormat.dwBBitMask = 0;
|
| 334 | + ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth);
|
| 335 | + break;
|
| 336 | + case 16:
|
| 337 | + FIXME("Support 16 bit pixelformat");
|
| 338 | + case 24:
|
| 339 | + FIXME("Support 24 bit pixelformat");
|
| 340 | + case 32:
|
| 341 | + default:
|
| 342 | + FIXME("Support 32 bit pixelformat");
|
| 343 | + }
|
| 344 | + }
|
| 345 | + else if(ddsd.ddpfPixelFormat.dwFlags & DDPF_ZBUFFER)
|
| 346 | + {
|
314 | 347 | switch(ddsd.ddpfPixelFormat.dwZBufferBitDepth)
|
315 | 348 | {
|
316 | 349 | case 16:
|
— | — | @@ -447,7 +480,7 @@ |
448 | 481 | else *error = DDERR_INVALIDPARAMS;
|
449 | 482 | }
|
450 | 483 | }
|
451 | | - ddInterface->AddRef();
|
| 484 | + //ddInterface->AddRef();
|
452 | 485 | }
|
453 | 486 | glDirectDrawSurface7::~glDirectDrawSurface7()
|
454 | 487 | {
|
— | — | @@ -935,14 +968,14 @@ |
936 | 969 | if(error != DD_OK) return error;
|
937 | 970 | hdc = CreateCompatibleDC(NULL);
|
938 | 971 | bitmapinfo->bmiHeader.biWidth = ddsd.lPitch / (bitmapinfo->bmiHeader.biBitCount / 8);
|
939 | | - if(ddInterface->GetBPP() == 8)
|
| 972 | + if(ddsd.ddpfPixelFormat.dwRGBBitCount == 8)
|
940 | 973 | {
|
941 | | - memcpy(colors,ddInterface->primary->palette->GetPalette(NULL),1024);
|
| 974 | + memcpy(colors,palette->GetPalette(NULL),1024);
|
942 | 975 | for(int i = 0; i < 256; i++)
|
943 | 976 | colors[i] = ((colors[i]&0x0000FF)<<16) | (colors[i]&0x00FF00) | ((colors[i]&0xFF0000)>>16);
|
944 | 977 | memcpy(bitmapinfo->bmiColors,colors,1024);
|
945 | 978 | }
|
946 | | - else if(ddInterface->GetBPPMultipleOf8() == 16)bitmapinfo->bmiHeader.biCompression = BI_BITFIELDS;
|
| 979 | + else if(ddsd.ddpfPixelFormat.dwRGBBitCount == 16)bitmapinfo->bmiHeader.biCompression = BI_BITFIELDS;
|
947 | 980 | hbitmap = CreateDIBSection(hdc,bitmapinfo,DIB_RGB_COLORS,&surface,NULL,0);
|
948 | 981 | memcpy(surface,ddsd.lpSurface,ddsd.lPitch*ddsd.dwHeight);
|
949 | 982 | HGDIOBJ temp = SelectObject(hdc,hbitmap);
|