[NTOS]: Implement MmDeleteTeb, VADs are now deleted/freed on thread exit as well...
[reactos.git] / base / applications / dxdiag / d3dtest.c
1 /*
2 * PROJECT: ReactX Diagnosis Application
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/applications/dxdiag/d3dtest.c
5 * PURPOSE: ReactX Direct3D 7, 8 and 9 tests
6 * PROGRAMMERS: Gregor Gullwi <gbrunmar (dot) ros (at) gmail (dot) com>
7 */
8
9 #include "precomp.h"
10
11 #define WIDTH 800
12 #define HEIGHT 600
13
14 BOOL D3D7Test(HWND hWnd);
15 BOOL D3D8Test(HWND hWnd);
16 BOOL D3D9Test(HWND hWnd);
17
18 BOOL StartD3DTest(HWND hWnd, HINSTANCE hInstance, WCHAR* pszCaption, INT TestNr)
19 {
20 WCHAR szTestDescriptionRaw[256];
21 WCHAR szTestDescription[256];
22 WCHAR szCaption[256];
23 WCHAR szResult[256];
24 WCHAR szError[256];
25 BOOL Result;
26
27 LoadStringW(hInstance, IDS_MAIN_DIALOG, szCaption, sizeof(szCaption) / sizeof(WCHAR));
28 LoadStringW(hInstance, IDS_DDTEST_ERROR, szError, sizeof(szError) / sizeof(WCHAR));
29 LoadStringW(hInstance, IDS_D3DTEST_D3Dx, szTestDescriptionRaw, sizeof(szTestDescriptionRaw) / sizeof(WCHAR));
30 //LoadStringW(hInstance, resResult, szResult, sizeof(szResult) / sizeof(WCHAR));
31
32 swprintf(szTestDescription, szTestDescriptionRaw, TestNr);
33 if (MessageBox(NULL, szTestDescription, szCaption, MB_YESNO | MB_ICONQUESTION) == IDNO)
34 return FALSE;
35
36 ShowWindow(hWnd, SW_SHOW);
37
38 switch(TestNr){
39 case 7:
40 Result = D3D7Test(hWnd);
41 break;
42 case 8:
43 Result = D3D8Test(hWnd);
44 break;
45 case 9:
46 Result = D3D9Test(hWnd);
47 break;
48 default:
49 Result = FALSE;
50 }
51
52 ShowWindow(hWnd, SW_HIDE);
53
54 if(!Result)
55 {
56 MessageBox(NULL, szError, szCaption, MB_OK | MB_ICONERROR);
57 return FALSE;
58 }
59
60 if(MessageBox(NULL, szResult, szCaption, MB_YESNO | MB_ICONQUESTION) == IDYES)
61 return TRUE;
62
63 return FALSE;
64 }
65
66 static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
67 {
68 return DefWindowProc(hWnd, msg, wParam, lParam);
69 }
70
71 VOID D3DTests()
72 {
73 WNDCLASSEX winClass;
74 HWND hWnd;
75 HINSTANCE hInstance = GetModuleHandle(NULL);
76 WCHAR szDescription[256];
77 WCHAR szCaption[256];
78
79 winClass.cbSize = sizeof(WNDCLASSEX);
80 winClass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
81 winClass.lpfnWndProc = WindowProc;
82 winClass.cbClsExtra = 0;
83 winClass.cbWndExtra = 0;
84 winClass.hInstance = hInstance;
85 winClass.hIcon = 0;
86 winClass.hCursor = 0;
87 winClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
88 winClass.lpszMenuName = NULL;
89 winClass.lpszClassName = L"d3dtest";
90 winClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
91
92 if (!RegisterClassEx(&winClass))
93 return;
94
95 hWnd = CreateWindowEx(
96 0,
97 winClass.lpszClassName,
98 NULL,
99 WS_POPUP,
100 (GetSystemMetrics(SM_CXSCREEN) - WIDTH)/2,
101 (GetSystemMetrics(SM_CYSCREEN) - HEIGHT)/2,
102 WIDTH,
103 HEIGHT,
104 NULL,
105 NULL,
106 hInstance,
107 NULL);
108
109 if (!hWnd)
110 goto cleanup;
111
112 LoadStringW(hInstance, IDS_D3DTEST_DESCRIPTION, szDescription, sizeof(szDescription) / sizeof(WCHAR));
113 LoadStringW(hInstance, IDS_MAIN_DIALOG, szCaption, sizeof(szCaption) / sizeof(WCHAR));
114 if(MessageBox(NULL, szDescription, szCaption, MB_YESNO | MB_ICONQUESTION) == IDNO)
115 goto cleanup;
116
117 StartD3DTest(hWnd, hInstance, szCaption, 7);
118 StartD3DTest(hWnd, hInstance, szCaption, 8);
119 StartD3DTest(hWnd, hInstance, szCaption, 9);
120
121 cleanup:
122 DestroyWindow(hWnd);
123 UnregisterClass(winClass.lpszClassName, hInstance);
124 }