DXGL r93 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r92‎ | r93 | r94 >
Date:22:48, 28 January 2012
Author:admin
Status:new
Tags:
Comment:
Release 0.1.5
Fix a few crashes
Modified paths:
  • /common/version.h (modified) (history)
  • /common/version.nsh (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)
  • /dxgltest/Tests2D.cpp (modified) (history)
  • /dxgltest/timer.h (modified) (history)

Diff [purge]

Index: common/version.h
@@ -4,12 +4,12 @@
55
66 #define DXGLMAJOR 0
77 #define DXGLMINOR 1
8 -#define DXGLPOINT 4
 8+#define DXGLPOINT 5
99 #define DXGLBUILD 0
1010
1111 #define DXGLVERNUMBER DXGLMAJOR,DXGLMINOR,DXGLPOINT,DXGLBUILD
1212 #define DXGLVERQWORD (((unsigned __int64)DXGLMAJOR<<48)+((unsigned __int64)DXGLMINOR<<32)+((unsigned __int64)DXGLPOINT<<16)+(unsigned __int64)DXGLBUILD)
13 -#define DXGLVERSTRING "0.1.4.0"
 13+#define DXGLVERSTRING "0.1.5.0"
1414
1515
1616 #endif //__VERSION_H
Index: common/version.nsh
@@ -1 +1 @@
2 -!define PRODUCT_VERSION "0.1.4"
\ No newline at end of file
 2+!define PRODUCT_VERSION "0.1.5"
\ No newline at end of file
Index: ddraw/glDirectDraw.cpp
@@ -58,7 +58,7 @@
5959 }
6060 if(!match) newcount++;
6161 }
62 - realloc(newarray,sizeof(DEVMODE)*newcount);
 62+ newarray = (DEVMODE*)realloc(newarray,sizeof(DEVMODE)*newcount);
6363 free(*array);
6464 *array = newarray;
6565 *count = newcount;
@@ -587,6 +587,7 @@
588588 }
589589 DeleteGL();
590590 ddenabled = false;
 591+ directdraw_created = false;
591592 }
592593
593594 HRESULT WINAPI glDirectDraw7::QueryInterface(REFIID riid, void** ppvObj)
@@ -941,6 +942,7 @@
942943 useguid = true;
943944 FIXME("Display GUIDs not yet supported, using primary.\n");
944945 }
 946+ directdraw_created = true;
945947 initialized = true;
946948 return DD_OK;
947949 }
@@ -1347,6 +1349,7 @@
13481350 {
13491351 for(int i = 0; i < surfacecount; i++)
13501352 if(surfaces[i] == surface) surfaces[i] = NULL;
 1353+ if(surface == primary) primary = NULL;
13511354 }
13521355
13531356 // DDRAW1 wrapper
Index: ddraw/glDirectDrawSurface.cpp
@@ -901,6 +901,7 @@
902902 HRESULT WINAPI glDirectDrawSurface7::Restore()
903903 {
904904 LONG sizes[6];
 905+ if(!ddInterface->renderer) return DDERR_INVALIDOBJECT;
905906 if(hRC != ddInterface->renderer->hRC)
906907 {
907908 if(ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
Index: ddraw/glRenderer.cpp
@@ -136,6 +136,7 @@
137137 dib.enabled = false;
138138 hWnd = hwnd;
139139 hRenderWnd = NULL;
 140+ InitializeCriticalSection(&cs);
140141 if(fullscreen)
141142 {
142143 SetWindowLongPtrA(hWnd,GWL_EXSTYLE,WS_EX_APPWINDOW);
@@ -146,8 +147,7 @@
147148 {
148149 // TODO: Adjust window rect
149150 }
150 - SetWindowPos(hWnd,NULL,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
151 - InitializeCriticalSection(&cs);
 151+ SetWindowPos(hWnd,HWND_TOP,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
152152 inputs[0] = (void*)width;
153153 inputs[1] = (void*)height;
154154 inputs[2] = (void*)bpp;
@@ -344,10 +344,6 @@
345345 TranslateMessage(&Msg);
346346 DispatchMessage(&Msg);
347347 }
348 - if(hRenderWnd) DestroyWindow(hRenderWnd);
349 - hRenderWnd = NULL;
350 - wndbusy = false;
351 - hRC = NULL;
352348 return 0;
353349 }
354350
@@ -899,12 +895,20 @@
900896 glDeleteBuffers(1,&PBO);
901897 PBO = 0;
902898 }
903 - if(backbuffer) glDeleteTextures(1,&backbuffer);
 899+ if(backbuffer)
 900+ {
 901+ glDeleteTextures(1,&backbuffer);
 902+ backbuffer = 0;
 903+ backx = 0;
 904+ backy = 0;
 905+ }
904906 wglMakeCurrent(NULL,NULL);
905907 wglDeleteContext(hRC);
906908 };
907909 if(hDC) ReleaseDC(hRenderWnd,hDC);
908910 hDC = NULL;
 911+ wndbusy = false;
 912+ PostQuitMessage(0);
909913 return 0;
910914 case WM_SETCURSOR:
911915 hParent = GetParent(hwnd);
@@ -950,7 +954,6 @@
951955 else return SendMessage(hParent,msg,wParam,lParam);
952956 case GLEVENT_DELETE:
953957 DestroyWindow(hRenderWnd);
954 - wndbusy = false;
955958 return 0;
956959 case GLEVENT_CREATE:
957960 outputs[0] = (void*)_MakeTexture((GLint)inputs[0],(GLint)inputs[1],(GLint)inputs[2],(GLint)inputs[3],
Index: dxgltest/Tests2D.cpp
@@ -160,6 +160,7 @@
161161
162162 void RunTestMouse2D(int test, UINT Msg, WPARAM wParam, LPARAM lParam)
163163 {
 164+ if(!ddsrender) return;
164165 DDSURFACEDESC2 ddsd;
165166 ddsd.dwSize = sizeof(DDSURFACEDESC2);
166167 DDBLTFX bltfx;
@@ -635,6 +636,7 @@
636637
637638 void RunTestTimed2D(int test)
638639 {
 640+ if(stoptimer) return;
639641 DDSCAPS2 ddscaps;
640642 ZeroMemory(&ddscaps,sizeof(DDSCAPS2));
641643 ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
@@ -665,7 +667,7 @@
666668 if(backbuffers) temp1->Release();
667669 }
668670 }
669 - if(backbuffers) ddsrender->Flip(NULL,DDFLIP_WAIT);
 671+ if(backbuffers && ddsrender) ddsrender->Flip(NULL,DDFLIP_WAIT);
670672 break;
671673 }
672674 }
Index: dxgltest/timer.h
@@ -20,6 +20,7 @@
2121 #define _TIMER_H
2222
2323
 24+extern bool stoptimer;
2425 void StartTimer(HWND hWnd, UINT message, double framerate);
2526 void StopTimer();
2627