DXGL r45 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r44‎ | r45 | r46 >
Date:17:40, 25 December 2011
Author:admin
Status:new
Tags:
Comment:
Implement glDirectDraw7::Initialize
Modified paths:
  • /ddraw/ddraw.cpp (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDraw.h (modified) (history)

Diff [purge]

Index: ddraw/ddraw.cpp
@@ -107,7 +107,7 @@
108108 glDirectDraw7 *myddraw7;
109109 glDirectDraw1 *myddraw;
110110 HRESULT error;
111 - myddraw7 = new glDirectDraw7(lpGUID,lplpDD,pUnkOuter);
 111+ myddraw7 = new glDirectDraw7(lpGUID,pUnkOuter);
112112 error = myddraw7->err();
113113 if(error != DD_OK)
114114 {
@@ -130,7 +130,7 @@
131131 glDirectDraw7 *myddraw;
132132 HRESULT error;
133133 if(iid != IID_IDirectDraw7) ERR(DDERR_UNSUPPORTED);
134 - myddraw = new glDirectDraw7(lpGUID,(LPDIRECTDRAW FAR *)lplpDD,pUnkOuter);
 134+ myddraw = new glDirectDraw7(lpGUID,pUnkOuter);
135135 error = myddraw->err();
136136 if(error != DD_OK)
137137 {
Index: ddraw/glDirectDraw.cpp
@@ -542,56 +542,23 @@
543543 }
544544
545545 // DDRAW7/common routines
546 -glDirectDraw7::glDirectDraw7(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnknown FAR* pUnkOuter)
 546+
 547+glDirectDraw7::glDirectDraw7()
547548 {
548 - hDC = NULL;
549 - hRC = NULL;
550 - hRenderWnd = NULL;
551 - primary = NULL;
552 - fullscreen = false;
553 - fpupreserve = false;
554 - fpusetup = false;
555 - threadsafe = false;
556 - nowindowchanges = false;
557 - timer = timeGetTime();
558 - ZeroMemory(&oldmode,sizeof(DEVMODE));
559 - surfaces = (glDirectDrawSurface7 **)malloc(1024*sizeof(glDirectDrawSurface7 *));
560 - if(!surfaces)
 549+ initialized = false;
 550+ refcount = 1;
 551+}
 552+
 553+glDirectDraw7::glDirectDraw7(GUID FAR* lpGUID, IUnknown FAR* pUnkOuter)
 554+{
 555+ initialized = false;
 556+ if(pUnkOuter)
561557 {
562 - error = DDERR_OUTOFMEMORY;
 558+ error = DDERR_INVALIDPARAMS ;
563559 return;
564560 }
565 - ZeroMemory(surfaces,1024*sizeof(glDirectDrawSurface7 *));
566 - surfacecount = 0;
567 - surfacecountmax = 1024;
568 - clippers = (glDirectDrawClipper **)malloc(1024*sizeof(glDirectDrawClipper *));
569 - if(!clippers)
570 - {
571 - error = DDERR_OUTOFMEMORY;
572 - return;
573 - }
574 - ZeroMemory(clippers,1024*sizeof(glDirectDrawClipper *));
575 - clippercount = 0;
576 - clippercountmax = 1024;
577 - if(directdraw_created) error = DDERR_DIRECTDRAWALREADYCREATED;
578 - bool useguid = false;
579 - if(pUnkOuter) error = DDERR_INVALIDPARAMS ;
580 - switch((INT_PTR)lpGUID)
581 - {
582 - case NULL:
583 - break;
584 - case DDCREATE_EMULATIONONLY:
585 - DEBUG("DDRAW software emulation not supported, using OpenGL.\n");
586 - break;
587 - case DDCREATE_HARDWAREONLY:
588 - DEBUG("DDCREATE_HARDWAREONLY unnecessarily called.\n");
589 - break;
590 - default:
591 - useguid = true;
592 - FIXME("Display GUIDs not yet supported, using primary.\n");
593 - }
 561+ error = glDirectDraw7::Initialize(lpGUID);
594562 refcount = 1;
595 - error = 0;
596563 }
597564
598565 glDirectDraw7::~glDirectDraw7()
@@ -869,8 +836,45 @@
870837 }
871838 HRESULT WINAPI glDirectDraw7::Initialize(GUID FAR *lpGUID)
872839 {
873 - FIXME("IDirectDraw::Initialize: stub\n");
874 - ERR(DDERR_DIRECTDRAWALREADYCREATED);
 840+ if(initialized) return DDERR_ALREADYINITIALIZED;
 841+ hDC = NULL;
 842+ hRC = NULL;
 843+ hRenderWnd = NULL;
 844+ primary = NULL;
 845+ fullscreen = false;
 846+ fpupreserve = false;
 847+ fpusetup = false;
 848+ threadsafe = false;
 849+ nowindowchanges = false;
 850+ timer = timeGetTime();
 851+ ZeroMemory(&oldmode,sizeof(DEVMODE));
 852+ surfaces = (glDirectDrawSurface7 **)malloc(1024*sizeof(glDirectDrawSurface7 *));
 853+ if(!surfaces) return DDERR_OUTOFMEMORY;
 854+ ZeroMemory(surfaces,1024*sizeof(glDirectDrawSurface7 *));
 855+ surfacecount = 0;
 856+ surfacecountmax = 1024;
 857+ clippers = (glDirectDrawClipper **)malloc(1024*sizeof(glDirectDrawClipper *));
 858+ if(!clippers) return DDERR_OUTOFMEMORY;
 859+ ZeroMemory(clippers,1024*sizeof(glDirectDrawClipper *));
 860+ clippercount = 0;
 861+ clippercountmax = 1024;
 862+ if(directdraw_created) error = DDERR_DIRECTDRAWALREADYCREATED;
 863+ bool useguid = false;
 864+ switch((INT_PTR)lpGUID)
 865+ {
 866+ case NULL:
 867+ break;
 868+ case DDCREATE_EMULATIONONLY:
 869+ DEBUG("DDRAW software emulation not supported, using OpenGL.\n");
 870+ break;
 871+ case DDCREATE_HARDWAREONLY:
 872+ DEBUG("DDCREATE_HARDWAREONLY unnecessarily called.\n");
 873+ break;
 874+ default:
 875+ useguid = true;
 876+ FIXME("Display GUIDs not yet supported, using primary.\n");
 877+ }
 878+ return 0;
875879 }
876880 HRESULT WINAPI glDirectDraw7::RestoreDisplayMode()
877881 {
Index: ddraw/glDirectDraw.h
@@ -39,7 +39,8 @@
4040 class glDirectDraw7 : public IDirectDraw7
4141 {
4242 public:
43 - glDirectDraw7(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnknown FAR* pUnkOuter);
 43+ glDirectDraw7();
 44+ glDirectDraw7(GUID FAR* lpGUID, IUnknown FAR* pUnkOuter);
4445 virtual ~glDirectDraw7();
4546
4647 // ddraw 1+ api
@@ -115,6 +116,7 @@
116117 int clippercount, clippercountmax;
117118 GLCAPS gl_caps;
118119 DEVMODE oldmode;
 120+ bool initialized;
119121 };
120122
121123 class glDirectDraw1 : public IDirectDraw