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