DXGL r97 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r96‎ | r97 | r98 >
Date:21:38, 4 February 2012
Author:admin
Status:new
Tags:
Comment:
fix GetDisplayMode
Modified paths:
  • /ddraw/common.h (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDrawPalette.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)

Diff [purge]

Index: ddraw/common.h
@@ -75,7 +75,17 @@
7676 DEBUGBREAK\
7777 return error;\
7878 }
 79+
 80+static inline int NextMultipleOf8(int number){return ((number+7) & (~7));}
 81+static inline int NextMultipleOf4(int number){return ((number+3) & (~3));}
 82+static inline int NextMultipleOf2(int number){return ((number+1) & (~1));}
 83+#ifdef _M_X64
 84+#define NextMultipleOfWord NextMultipleOf8
7985 #else
 86+#define NextMultipleOfWord NextMultipleOf4
 87+#endif
 88+
 89+#else
8090 #define ERR(error) return error;
8191 #endif
8292 #include "../cfgmgr/cfgmgr.h"
Index: ddraw/glDirectDraw.cpp
@@ -823,6 +823,8 @@
824824 DDSURFACEDESC2 ddsdMode;
825825 ZeroMemory(&ddsdMode, sizeof(DDSURFACEDESC2));
826826 ddsdMode.dwSize = sizeof(DDSURFACEDESC2);
 827+ ddsdMode.dwFlags = DDSD_REFRESHRATE | DDSD_PIXELFORMAT | DDSD_PITCH | DDSD_WIDTH | DDSD_HEIGHT;
 828+ ddsdMode.ddpfPixelFormat.dwFlags = DDPF_RGB;
827829 DEVMODE currmode;
828830 if(fullscreen)
829831 {
@@ -831,6 +833,7 @@
832834 ddsdMode.ddpfPixelFormat.dwRBitMask = 0;
833835 ddsdMode.ddpfPixelFormat.dwGBitMask = 0;
834836 ddsdMode.ddpfPixelFormat.dwBBitMask = 0;
 837+ ddsdMode.ddpfPixelFormat.dwFlags |= DDPF_PALETTEINDEXED8;
835838 }
836839 else if(primarybpp == 15)
837840 {
@@ -853,9 +856,10 @@
854857 ddsdMode.ddpfPixelFormat.dwRGBBitCount = GetBPPMultipleOf8();
855858 ddsdMode.dwWidth = primaryx;
856859 ddsdMode.dwHeight = primaryy;
857 - if(primarybpp == 15) ddsdMode.lPitch = primaryx * 2;
858 - else if(primarybpp == 4) ddsdMode.lPitch = primaryx / 2;
859 - else ddsdMode.lPitch = primaryx * (primarybpp / 8);
 860+ ddsdMode.dwRefreshRate = primaryrefresh;
 861+ if(primarybpp == 15) ddsdMode.lPitch = NextMultipleOfWord(primaryx * 2);
 862+ else if(primarybpp == 4) ddsdMode.lPitch = NextMultipleOfWord(primaryx / 2);
 863+ else ddsdMode.lPitch = NextMultipleOfWord(primaryx * (primarybpp / 8));
860864 if(lpDDSurfaceDesc2->dwSize < sizeof(DDSURFACEDESC)) ERR(DDERR_INVALIDPARAMS);
861865 if(lpDDSurfaceDesc2->dwSize > sizeof(DDSURFACEDESC2))
862866 lpDDSurfaceDesc2->dwSize = sizeof(DDSURFACEDESC2);
Index: ddraw/glDirectDrawPalette.cpp
@@ -161,7 +161,7 @@
162162 HRESULT WINAPI glDirectDrawPalette::Initialize(LPDIRECTDRAW lpDD, DWORD dwFlags, LPPALETTEENTRY lpDDColorTable)
163163 {
164164 if(!this) return DDERR_INVALIDPARAMS;
165 - ERR(DDERR_ALREADYINITIALIZED);
 165+ return DDERR_ALREADYINITIALIZED;
166166 }
167167 HRESULT WINAPI glDirectDrawPalette::SetEntries(DWORD dwFlags, DWORD dwStartingEntry, DWORD dwCount, LPPALETTEENTRY lpEntries)
168168 {
Index: ddraw/glDirectDrawSurface.cpp
@@ -28,17 +28,6 @@
2929 #include "glutil.h"
3030
3131
32 -static inline int NextMultipleOf8(int number){return ((number+7) & (~7));}
33 -static inline int NextMultipleOf4(int number){return ((number+3) & (~3));}
34 -static inline int NextMultipleOf2(int number){return ((number+1) & (~1));}
35 -#ifdef _M_X64
36 -#define NextMultipleOfWord NextMultipleOf8
37 -#else
38 -#define NextMultipleOfWord NextMultipleOf4
39 -#endif
40 -
41 -
42 -
4332 // DDRAW7 routines
4433 glDirectDrawSurface7::glDirectDrawSurface7(LPDIRECTDRAW7 lpDD7, LPDDSURFACEDESC2 lpDDSurfaceDesc2, LPDIRECTDRAWSURFACE7 *lplpDDSurface7, HRESULT *error, bool copysurface, glDirectDrawPalette *palettein)
4534 {
Index: ddraw/glRenderer.cpp
@@ -25,15 +25,6 @@
2626 #include "scalers.h"
2727 #include "shadergen.h"
2828
29 -static inline int NextMultipleOf8(int number){return ((number+7) & (~7));}
30 -static inline int NextMultipleOf4(int number){return ((number+3) & (~3));}
31 -static inline int NextMultipleOf2(int number){return ((number+1) & (~1));}
32 -#ifdef _M_X64
33 -#define NextMultipleOfWord NextMultipleOf8
34 -#else
35 -#define NextMultipleOfWord NextMultipleOf4
36 -#endif
37 -
3829 WNDCLASSEXA wndclass;
3930 bool wndclasscreated = false;
4031 GLuint backbuffer = 0;