DXGL r99 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r98‎ | r99 | r100 >
Date:19:00, 11 February 2012
Author:admin
Status:new
Tags:
Comment:
GetDC() fixes
Modified paths:
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirectDraw.cpp
@@ -1054,6 +1054,8 @@
10551055 {
10561056 x = devmode.dmPelsWidth;
10571057 y = devmode.dmPelsHeight;
 1058+ internalx = screenx = primaryx = devmode.dmPelsWidth;
 1059+ internaly = screeny = primaryy = devmode.dmPelsHeight;
10581060 }
10591061 else
10601062 {
Index: ddraw/glDirectDrawSurface.cpp
@@ -383,17 +383,19 @@
384384 *error = DDERR_INVALIDPIXELFORMAT;
385385 return;
386386 }
387 - if(ddInterface->GetBPP() > 8)
388 - {
389 - colormasks[0] = ddsd.ddpfPixelFormat.dwRBitMask;
390 - colormasks[1] = ddsd.ddpfPixelFormat.dwGBitMask;
391 - colormasks[2] = ddsd.ddpfPixelFormat.dwBBitMask;
392 - memcpy(bitmapinfo->bmiColors,colormasks,3*sizeof(DWORD));
393 - }
394387 }
395388 texture = renderer->MakeTexture(filter,filter,GL_CLAMP,GL_CLAMP,fakex,fakey,texformat,texformat2,texformat3);
396389 }
397390
 391+ if(ddsd.ddpfPixelFormat.dwRGBBitCount > 8)
 392+ {
 393+ colormasks[0] = ddsd.ddpfPixelFormat.dwRBitMask;
 394+ colormasks[1] = ddsd.ddpfPixelFormat.dwGBitMask;
 395+ colormasks[2] = ddsd.ddpfPixelFormat.dwBBitMask;
 396+ memcpy(bitmapinfo->bmiColors,colormasks,3*sizeof(DWORD));
 397+ }
 398+ if(!bitmapinfo->bmiHeader.biBitCount)
 399+ bitmapinfo->bmiHeader.biBitCount = (WORD)ddsd.ddpfPixelFormat.dwRGBBitCount;
398400 refcount = 1;
399401 *error = DD_OK;
400402 backbuffer = NULL;
@@ -801,6 +803,7 @@
802804 {
803805 if(!this) return DDERR_INVALIDPARAMS;
804806 if(hdc) ERR(DDERR_DCALREADYCREATED);
 807+ glDirectDrawPalette *pal;
805808 DWORD colors[256];
806809 HRESULT error;
807810 LPVOID surface;
@@ -810,12 +813,15 @@
811814 bitmapinfo->bmiHeader.biWidth = ddsd.lPitch / (bitmapinfo->bmiHeader.biBitCount / 8);
812815 if(ddsd.ddpfPixelFormat.dwRGBBitCount == 8)
813816 {
814 - memcpy(colors,palette->GetPalette(NULL),1024);
 817+ if(palette) pal = palette;
 818+ else pal = ddInterface->primary->palette;
 819+ memcpy(colors,pal->GetPalette(NULL),1024);
815820 for(int i = 0; i < 256; i++)
816821 colors[i] = ((colors[i]&0x0000FF)<<16) | (colors[i]&0x00FF00) | ((colors[i]&0xFF0000)>>16);
817822 memcpy(bitmapinfo->bmiColors,colors,1024);
818823 }
819 - else if(ddsd.ddpfPixelFormat.dwRGBBitCount == 16)bitmapinfo->bmiHeader.biCompression = BI_BITFIELDS;
 824+ if(ddsd.ddpfPixelFormat.dwRGBBitCount == 16) bitmapinfo->bmiHeader.biCompression = BI_BITFIELDS;
 825+ else bitmapinfo->bmiHeader.biCompression = BI_RGB;
820826 hbitmap = CreateDIBSection(hdc,bitmapinfo,DIB_RGB_COLORS,&surface,NULL,0);
821827 memcpy(surface,ddsd.lpSurface,ddsd.lPitch*ddsd.dwHeight);
822828 HGDIOBJ temp = SelectObject(hdc,hbitmap);