Index: dxgltest/Tests3D.cpp |
— | — | @@ -1,2242 +0,0 @@ |
2 | Â | -// DXGL
|
3 | Â | -// Copyright (C) 2012-2013 William Feely
|
4 | Â | -
|
5 | Â | -// This library is free software; you can redistribute it and/or
|
6 | Â | -// modify it under the terms of the GNU Lesser General Public
|
7 | Â | -// License as published by the Free Software Foundation; either
|
8 | Â | -// version 2.1 of the License, or (at your option) any later version.
|
9 | Â | -
|
10 | Â | -// This library is distributed in the hope that it will be useful,
|
11 | Â | -// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 | Â | -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13 | Â | -// Lesser General Public License for more details.
|
14 | Â | -
|
15 | Â | -// You should have received a copy of the GNU Lesser General Public
|
16 | Â | -// License along with this library; if not, write to the Free Software
|
17 | Â | -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18 | Â | -
|
19 | Â | -#include "common.h"
|
20 | Â | -#include "MultiDD.h"
|
21 | Â | -#include "tests.h"
|
22 | Â | -#include "surfacegen.h"
|
23 | Â | -#include "timer.h"
|
24 | Â | -#include "misc.h"
|
25 | Â | -#define D3D_OVERLOADS
|
26 | Â | -#include "../ddraw/include/d3d.h"
|
27 | Â | -
|
28 | Â | -void InitTest3D(int test);
|
29 | Â | -void RunTestTimed3D(int test);
|
30 | Â | -void RunTestLooped3D(int test);
|
31 | Â | -bool RunTestMouse3D(int test, UINT Msg, WPARAM wParam, LPARAM lParam);
|
32 | Â | -
|
33 | Â | -
|
34 | Â | -static MultiDirectDraw *ddinterface;
|
35 | Â | -static MultiDirectDrawSurface *ddsurface;
|
36 | Â | -static MultiDirectDrawSurface *ddsrender;
|
37 | Â | -static MultiDirectDrawSurface *zbuffer;
|
38 | Â | -static MultiDirectDrawSurface *textures[8];
|
39 | Â | -static IDirect3D7 *d3d7;
|
40 | Â | -static IDirect3DDevice7 *d3d7dev;
|
41 | Â | -D3DMATERIAL7 material;
|
42 | Â | -static LPDIRECTDRAWCLIPPER ddclipper;
|
43 | Â | -static int width,height,bpp,refresh,backbuffers;
|
44 | Â | -static double fps;
|
45 | Â | -static bool fullscreen,resizable;
|
46 | Â | -static HWND hWnd;
|
47 | Â | -static int testnum;
|
48 | Â | -static unsigned int randnum;
|
49 | Â | -static int testtypes[] = {0,0,0};
|
50 | Â | -
|
51 | Â | -#define FVF_COLORVERTEX (D3DFVF_VERTEX | D3DFVF_DIFFUSE | D3DFVF_SPECULAR)
|
52 | Â | -struct COLORVERTEX
|
53 | Â | -{
|
54 | Â | - D3DVALUE x;
|
55 | Â | - D3DVALUE y;
|
56 | Â | - D3DVALUE z;
|
57 | Â | - D3DVALUE nx;
|
58 | Â | - D3DVALUE ny;
|
59 | Â | - D3DVALUE nz;
|
60 | Â | - D3DCOLOR color;
|
61 | Â | - D3DCOLOR specular;
|
62 | Â | - D3DVALUE tu;
|
63 | Â | - D3DVALUE tv;
|
64 | Â | -public:
|
65 | Â | - COLORVERTEX() {};
|
66 | Â | - COLORVERTEX(const D3DVECTOR& v, const D3DVECTOR& n, D3DCOLOR _color,
|
67 | Â | - D3DCOLOR _specular, D3DVALUE _tu, D3DVALUE _tv)
|
68 | Â | - {
|
69 | Â | - x = v.x; y = v.y; z = v.z;
|
70 | Â | - nx = n.x; ny = n.y; nz = n.z;
|
71 | Â | - color = _color; specular = _specular;
|
72 | Â | - tu = _tu; tv = _tv;
|
73 | Â | - }
|
74 | Â | -
|
75 | Â | -};
|
76 | Â | -
|
77 | Â | -static int numpoints = 0;
|
78 | Â | -static int numindices = 0;
|
79 | Â | -static D3DVERTEX *vertices = NULL;
|
80 | Â | -static D3DLVERTEX *litvertices = NULL;
|
81 | Â | -static COLORVERTEX *colorvertices = NULL;
|
82 | Â | -static WORD *mesh = NULL;
|
83 | Â | -static D3DLIGHT7 lights[8];
|
84 | Â | -static BOOL lightenable[8];
|
85 | Â | -static DWORD bgcolor = 0;
|
86 | Â | -
|
87 | Â | -typedef struct
|
88 | Â | -{
|
89 | Â | - DWORD ambient;
|
90 | Â | - DWORD diffuse;
|
91 | Â | - DWORD specular;
|
92 | Â | -} HEXLIGHTCOLOR;
|
93 | Â | -HEXLIGHTCOLOR hexlightcolor[8];
|
94 | Â | -
|
95 | Â | -typedef struct
|
96 | Â | -{
|
97 | Â | - D3DTEXTUREOP colorop;
|
98 | Â | - DWORD colorarg1;
|
99 | Â | - DWORD colorarg2;
|
100 | Â | - D3DTEXTUREOP alphaop;
|
101 | Â | - DWORD alphaarg1;
|
102 | Â | - DWORD alphaarg2;
|
103 | Â | - DWORD texturetype;
|
104 | Â | - TCHAR texturefile[MAX_PATH+1];
|
105 | Â | - MultiDirectDrawSurface* texture;
|
106 | Â | - BOOL colorkey;
|
107 | Â | - DWORD keycolor;
|
108 | Â | -} TEXSTAGE;
|
109 | Â | -
|
110 | Â | -typedef struct
|
111 | Â | -{
|
112 | Â | - int currentstage;
|
113 | Â | - TEXSTAGE texstages[8];
|
114 | Â | - DWORD diffuse;
|
115 | Â | - DWORD specular;
|
116 | Â | - DWORD factor;
|
117 | Â | - D3DFOGMODE vertexfog;
|
118 | Â | - D3DFOGMODE pixelfog;
|
119 | Â | - FLOAT fogstart;
|
120 | Â | - FLOAT fogend;
|
121 | Â | - FLOAT fogdensity;
|
122 | Â | - BOOL rangefog;
|
123 | Â | - DWORD fogcolor;
|
124 | Â | - BOOL alphatest;
|
125 | Â | - BOOL alphastipple;
|
126 | Â | - BOOL colorkey;
|
127 | Â | - BOOL colorkeyblend;
|
128 | Â | - D3DBLEND srcblend;
|
129 | Â | - D3DBLEND destblend;
|
130 | Â | - BYTE refalpha;
|
131 | Â | - D3DCMPFUNC alphafunc;
|
132 | Â | - D3DLINEPATTERN linepattern;
|
133 | Â | - DWORD fillstippletype;
|
134 | Â | - TCHAR fillstipplefile[MAX_PATH+1];
|
135 | Â | - DWORD fillstipple[32];
|
136 | Â | -} TEXSHADERSTATE;
|
137 | Â | -
|
138 | Â | -static TEXSHADERSTATE texshaderstate;
|
139 | Â | -const TEXSHADERSTATE defaulttexshaderstate =
|
140 | Â | -{
|
141 | Â | - 0,
|
142 | Â | - {
|
143 | Â | - {D3DTOP_MODULATE,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_SELECTARG1,D3DTA_TEXTURE,D3DTA_CURRENT,0,_T(""),NULL,FALSE,0},
|
144 | Â | - {D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,0,_T(""),NULL,FALSE,0},
|
145 | Â | - {D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,0,_T(""),NULL,FALSE,0},
|
146 | Â | - {D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,0,_T(""),NULL,FALSE,0},
|
147 | Â | - {D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,0,_T(""),NULL,FALSE,0},
|
148 | Â | - {D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,0,_T(""),NULL,FALSE,0},
|
149 | Â | - {D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,0,_T(""),NULL,FALSE,0},
|
150 | Â | - {D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,0,_T(""),NULL,FALSE,0},
|
151 | Â | - },
|
152 | Â | - 0xFFFFFFFF,
|
153 | Â | - 0,
|
154 | Â | - 0xFFFFFFFF,
|
155 | Â | - D3DFOG_NONE,
|
156 | Â | - D3DFOG_NONE,
|
157 | Â | - 0.0,
|
158 | Â | - 1.0,
|
159 | Â | - 1.0,
|
160 | Â | - FALSE,
|
161 | Â | - 0,
|
162 | Â | - FALSE,
|
163 | Â | - FALSE,
|
164 | Â | - FALSE,
|
165 | Â | - FALSE,
|
166 | Â | - D3DBLEND_ONE,
|
167 | Â | - D3DBLEND_ZERO,
|
168 | Â | - 0,
|
169 | Â | - D3DCMP_ALWAYS,
|
170 | Â | - {0,0}
|
171 | Â | -};
|
172 | Â | -
|
173 | Â | -typedef struct
|
174 | Â | -{
|
175 | Â | - DWORD texturetype;
|
176 | Â | - TCHAR texturefile[MAX_PATH+1];
|
177 | Â | - MultiDirectDrawSurface* texture;
|
178 | Â | - int currentlight;
|
179 | Â | -} VERTEXSHADERSTATE;
|
180 | Â | -static VERTEXSHADERSTATE vertexshaderstate;
|
181 | Â | -
|
182 | Â | -
|
183 | Â | -LRESULT CALLBACK D3DWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
184 | Â | -{
|
185 | Â | - bool paintwnd = true;
|
186 | Â | - POINT p;
|
187 | Â | - RECT srcrect,destrect;
|
188 | Â | - HRESULT error;
|
189 | Â | - PAINTSTRUCT paintstruct;
|
190 | Â | - switch(Msg)
|
191 | Â | - {
|
192 | Â | - case WM_CLOSE:
|
193 | Â | - DestroyWindow(hWnd);
|
194 | Â | - break;
|
195 | Â | - case WM_DESTROY:
|
196 | Â | - StopTimer();
|
197 | Â | - Sleep(100);
|
198 | Â | - for(int i = 0; i < 8; i++)
|
199 | Â | - {
|
200 | Â | - if(textures[i])
|
201 | Â | - {
|
202 | Â | - textures[i]->Release();
|
203 | Â | - textures[i] = NULL;
|
204 | Â | - }
|
205 | Â | - }
|
206 | Â | - if(d3d7dev)
|
207 | Â | - {
|
208 | Â | - d3d7dev->Release();
|
209 | Â | - d3d7dev = NULL;
|
210 | Â | - }
|
211 | Â | - if(d3d7)
|
212 | Â | - {
|
213 | Â | - d3d7->Release();
|
214 | Â | - d3d7dev = NULL;
|
215 | Â | - }
|
216 | Â | - if(ddsrender)
|
217 | Â | - {
|
218 | Â | - ddsrender->Release();
|
219 | Â | - ddsrender = NULL;
|
220 | Â | - }
|
221 | Â | - if(ddsurface)
|
222 | Â | - {
|
223 | Â | - ddsurface->Release();
|
224 | Â | - ddsurface = NULL;
|
225 | Â | - }
|
226 | Â | - if(zbuffer)
|
227 | Â | - {
|
228 | Â | - zbuffer->Release();
|
229 | Â | - zbuffer = NULL;
|
230 | Â | - }
|
231 | Â | - if(ddclipper)
|
232 | Â | - {
|
233 | Â | - ddclipper->Release();
|
234 | Â | - ddclipper = NULL;
|
235 | Â | - }
|
236 | Â | - if(ddinterface)
|
237 | Â | - {
|
238 | Â | - ddinterface->Release();
|
239 | Â | - ddinterface = NULL;
|
240 | Â | - }
|
241 | Â | - if(mesh)
|
242 | Â | - {
|
243 | Â | - free(mesh);
|
244 | Â | - mesh = NULL;
|
245 | Â | - }
|
246 | Â | - if(vertices)
|
247 | Â | - {
|
248 | Â | - free(vertices);
|
249 | Â | - vertices = NULL;
|
250 | Â | - }
|
251 | Â | - if(litvertices)
|
252 | Â | - {
|
253 | Â | - free(litvertices);
|
254 | Â | - litvertices = NULL;
|
255 | Â | - }
|
256 | Â | - if(colorvertices)
|
257 | Â | - {
|
258 | Â | - free(colorvertices);
|
259 | Â | - colorvertices = NULL;
|
260 | Â | - }
|
261 | Â | - PostQuitMessage(0);
|
262 | Â | - break;
|
263 | Â | - case WM_KEYDOWN:
|
264 | Â | - if(wParam == VK_ESCAPE) DestroyWindow(hWnd);
|
265 | Â | - break;
|
266 | Â | - case WM_APP:
|
267 | Â | - RunTestTimed3D(testnum);
|
268 | Â | - break;
|
269 | Â | - case WM_SIZE:
|
270 | Â | - paintwnd = false;
|
271 | Â | - case WM_PAINT:
|
272 | Â | - if(paintwnd) BeginPaint(hWnd,&paintstruct);
|
273 | Â | - if(!fullscreen)
|
274 | Â | - {
|
275 | Â | - p.x = 0;
|
276 | Â | - p.y = 0;
|
277 | Â | - ClientToScreen(hWnd,&p);
|
278 | Â | - GetClientRect(hWnd,&destrect);
|
279 | Â | - OffsetRect(&destrect,p.x,p.y);
|
280 | Â | - SetRect(&srcrect,0,0,width,height);
|
281 | Â | - if(ddsurface && ddsrender)error = ddsurface->Blt(&destrect,ddsrender,&srcrect,DDBLT_WAIT,NULL);
|
282 | Â | - }
|
283 | Â | - if(paintwnd) EndPaint(hWnd,&paintstruct);
|
284 | Â | - return 0;
|
285 | Â | - case WM_MOUSEMOVE:
|
286 | Â | - case WM_LBUTTONDOWN:
|
287 | Â | - case WM_LBUTTONUP:
|
288 | Â | - case WM_LBUTTONDBLCLK:
|
289 | Â | - case WM_RBUTTONDOWN:
|
290 | Â | - case WM_RBUTTONUP:
|
291 | Â | - case WM_RBUTTONDBLCLK:
|
292 | Â | - case WM_MBUTTONDOWN:
|
293 | Â | - case WM_MBUTTONUP:
|
294 | Â | - case WM_MBUTTONDBLCLK:
|
295 | Â | - case WM_MOUSEWHEEL:
|
296 | Â | - case WM_XBUTTONDOWN:
|
297 | Â | - case WM_XBUTTONUP:
|
298 | Â | - case WM_XBUTTONDBLCLK:
|
299 | Â | - case WM_MOUSEHWHEEL:
|
300 | Â | - if(RunTestMouse3D(testnum,Msg,wParam,lParam))
|
301 | Â | - {
|
302 | Â | - if(!fullscreen)
|
303 | Â | - {
|
304 | Â | - p.x = 0;
|
305 | Â | - p.y = 0;
|
306 | Â | - ClientToScreen(hWnd,&p);
|
307 | Â | - GetClientRect(hWnd,&destrect);
|
308 | Â | - OffsetRect(&destrect,p.x,p.y);
|
309 | Â | - SetRect(&srcrect,0,0,width,height);
|
310 | Â | - if(ddsurface && ddsrender)error = ddsurface->Blt(&destrect,ddsrender,&srcrect,DDBLT_WAIT,NULL);
|
311 | Â | - }
|
312 | Â | - }
|
313 | Â | - break;
|
314 | Â | - default:
|
315 | Â | - return DefWindowProc(hWnd,Msg,wParam,lParam);
|
316 | Â | - }
|
317 | Â | - return FALSE;
|
318 | Â | -}
|
319 | Â | -
|
320 | Â | -static int d3dtestnum;
|
321 | Â | -static int d3dver;
|
322 | Â | -static int ddver;
|
323 | Â | -
|
324 | Â | -bool RunTestMouse3D(int test, UINT Msg, WPARAM wParam, LPARAM lParam)
|
325 | Â | -{
|
326 | Â | - return false;
|
327 | Â | -}
|
328 | Â | -
|
329 | Â | -const TCHAR wndclassname3d[] = _T("D3DTestWndClass");
|
330 | Â | -
|
331 | Â | -static HRESULT WINAPI zcallback(DDPIXELFORMAT *ddpf, VOID *context)
|
332 | Â | -{
|
333 | Â | - if(ddpf->dwFlags == DDPF_ZBUFFER)
|
334 | Â | - {
|
335 | Â | - memcpy(context,ddpf,sizeof(DDPIXELFORMAT));
|
336 | Â | - return D3DENUMRET_CANCEL;
|
337 | Â | - }
|
338 | Â | - return D3DENUMRET_OK;
|
339 | Â | -}
|
340 | Â | -
|
341 | Â | -INT_PTR CALLBACK TexShader7Proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
342 | Â | -INT_PTR CALLBACK VertexShader7Proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
343 | Â | -
|
344 | Â | -void RunTest3D(int testnum, int width, int height, int bpp, int refresh, int backbuffers, int apiver,
|
345 | Â | - int filter, int msaa, double fps, bool fullscreen, bool resizable)
|
346 | Â | -{
|
347 | Â | - if(testnum == 2)
|
348 | Â | - {
|
349 | Â | - DialogBox(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_TEXSHADER),NULL,TexShader7Proc);
|
350 | Â | - return;
|
351 | Â | - }
|
352 | Â | - if(testnum == 3)
|
353 | Â | - {
|
354 | Â | - DialogBox(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_VERTEXSHADER),NULL,VertexShader7Proc);
|
355 | Â | - return;
|
356 | Â | - }
|
357 | Â | - DDSCAPS2 caps;
|
358 | Â | - DDSURFACEDESC2 ddsd;
|
359 | Â | - DDPIXELFORMAT ddpfz;
|
360 | Â | - BOOL done = false;
|
361 | Â | - ::testnum = testnum;
|
362 | Â | - randnum = (unsigned int)time(NULL);
|
363 | Â | - ZeroMemory(&ddsd,sizeof(DDSURFACEDESC2));
|
364 | Â | - ZeroMemory(textures,8*sizeof(MultiDirectDrawSurface*));
|
365 | Â | - if(apiver >= 3) ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
366 | Â | - else ddsd.dwSize = sizeof(DDSURFACEDESC);
|
367 | Â | - ::fullscreen = fullscreen;
|
368 | Â | - ::resizable = resizable;
|
369 | Â | - ::width = width;
|
370 | Â | - ::height = height;
|
371 | Â | - ::bpp = bpp;
|
372 | Â | - ::refresh = refresh;
|
373 | Â | - if(fullscreen)::backbuffers = backbuffers;
|
374 | Â | - else ::backbuffers = backbuffers = 0;
|
375 | Â | - ::fps = fps;
|
376 | Â | - d3dtestnum = testnum;
|
377 | Â | - d3dver = apiver;
|
378 | Â | - if(apiver == 3) ddver = 4;
|
379 | Â | - else ddver = apiver;
|
380 | Â | - HINSTANCE hinstance = (HINSTANCE)GetModuleHandle(NULL);
|
381 | Â | - WNDCLASSEX wc;
|
382 | Â | - MSG Msg;
|
383 | Â | - ZeroMemory(&wc,sizeof(WNDCLASS));
|
384 | Â | - wc.cbSize = sizeof(WNDCLASSEX);
|
385 | Â | - wc.style = CS_HREDRAW | CS_VREDRAW;
|
386 | Â | - wc.lpfnWndProc = D3DWndProc;
|
387 | Â | - wc.hInstance = hinstance;
|
388 | Â | - wc.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(IDI_DXGL));
|
389 | Â | - wc.hIconSm = LoadIcon(hinstance,MAKEINTRESOURCE(IDI_DXGLSM));
|
390 | Â | - if(testnum == 6) wc.hCursor = LoadCursor(NULL,IDC_CROSS);
|
391 | Â | - else wc.hCursor = LoadCursor(NULL,IDC_ARROW);
|
392 | Â | - wc.hbrBackground = NULL;
|
393 | Â | - wc.lpszClassName = wndclassname3d;
|
394 | Â | - if(!RegisterClassEx(&wc))
|
395 | Â | - {
|
396 | Â | - MessageBox(NULL,_T("Can not register window class"),_T("Error"),MB_ICONEXCLAMATION|MB_OK);
|
397 | Â | - return;
|
398 | Â | - }
|
399 | Â | - if(resizable)
|
400 | Â | - hWnd = CreateWindowEx(WS_EX_APPWINDOW,wndclassname3d,_T("D3D Test Window"),WS_OVERLAPPEDWINDOW,
|
401 | Â | - CW_USEDEFAULT,CW_USEDEFAULT,width,height,NULL,NULL,hinstance,NULL);
|
402 | Â | - else if(!fullscreen)
|
403 | Â | - hWnd = CreateWindowEx(WS_EX_APPWINDOW,wndclassname3d,_T("D3D Test Window"),WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX,
|
404 | Â | - CW_USEDEFAULT,CW_USEDEFAULT,width,height,NULL,NULL,hinstance,NULL);
|
405 | Â | - else hWnd = CreateWindowEx(0,wndclassname3d,_T("DDraw Test Window"),WS_POPUP,0,0,
|
406 | Â | - GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN),NULL,NULL,hinstance,NULL);
|
407 | Â | - DWORD err = GetLastError();
|
408 | Â | - ShowWindow(hWnd,SW_SHOWNORMAL);
|
409 | Â | - UpdateWindow(hWnd);
|
410 | Â | - RECT r1,r2;
|
411 | Â | - POINT p1;
|
412 | Â | - HRESULT error;
|
413 | Â | - ddinterface = new MultiDirectDraw(ddver,&error,NULL);
|
414 | Â | - if(fullscreen) error = ddinterface->SetCooperativeLevel(hWnd,DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN);
|
415 | Â | - else error = ddinterface->SetCooperativeLevel(hWnd,DDSCL_NORMAL);
|
416 | Â | - if(fullscreen) error = ddinterface->SetDisplayMode(width,height,bpp,refresh,0);
|
417 | Â | - else
|
418 | Â | - {
|
419 | Â | - GetClientRect(hWnd,&r1);
|
420 | Â | - GetWindowRect(hWnd,&r2);
|
421 | Â | - p1.x = (r2.right - r2.left) - r1.right;
|
422 | Â | - p1.y = (r2.bottom - r2.top) - r1.bottom;
|
423 | Â | - MoveWindow(hWnd,r2.left,r2.top,width+p1.x,height+p1.y,TRUE);
|
424 | Â | - }
|
425 | Â | - ddsd.dwFlags = DDSD_CAPS;
|
426 | Â | - ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
427 | Â | - if(fullscreen)
|
428 | Â | - {
|
429 | Â | - if(backbuffers)ddsd.dwFlags |= DDSD_BACKBUFFERCOUNT;
|
430 | Â | - ddsd.dwBackBufferCount = backbuffers;
|
431 | Â | - if(backbuffers) ddsd.ddsCaps.dwCaps |= DDSCAPS_FLIP | DDSCAPS_COMPLEX;
|
432 | Â | - ddsd.ddsCaps.dwCaps |= DDSCAPS_3DDEVICE;
|
433 | Â | - }
|
434 | Â | - error = ddinterface->CreateSurface(&ddsd,&ddsurface,NULL);
|
435 | Â | - if(!fullscreen)
|
436 | Â | - {
|
437 | Â | - error = ddinterface->CreateClipper(0,&ddclipper,NULL);
|
438 | Â | - error = ddclipper->SetHWnd(0,hWnd);
|
439 | Â | - error = ddsurface->SetClipper(ddclipper);
|
440 | Â | - ZeroMemory(&ddsd,sizeof(ddsd));
|
441 | Â | - if(apiver > 3) ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
442 | Â | - else ddsd.dwSize = sizeof(DDSURFACEDESC);
|
443 | Â | - ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
444 | Â | - ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN|DDSCAPS_3DDEVICE;
|
445 | Â | - ddsd.dwWidth = width;
|
446 | Â | - ddsd.dwHeight = height;
|
447 | Â | - error = ddinterface->CreateSurface(&ddsd,&ddsrender,NULL);
|
448 | Â | - }
|
449 | Â | - else
|
450 | Â | - {
|
451 | Â | - if(backbuffers)
|
452 | Â | - {
|
453 | Â | - ZeroMemory(&caps,sizeof(DDSCAPS2));
|
454 | Â | - caps.dwCaps = DDSCAPS_BACKBUFFER;
|
455 | Â | - error = ddsurface->GetAttachedSurface(&caps,&ddsrender);
|
456 | Â | - }
|
457 | Â | - else
|
458 | Â | - {
|
459 | Â | - ddsrender = ddsurface;
|
460 | Â | - ddsrender->AddRef();
|
461 | Â | - }
|
462 | Â | - }
|
463 | Â | - error = ddinterface->QueryInterface(IID_IDirect3D7,(VOID**)&d3d7);
|
464 | Â | - error = d3d7->EnumZBufferFormats(IID_IDirect3DRGBDevice,zcallback,&ddpfz);
|
465 | Â | - error = ddsrender->GetSurfaceDesc(&ddsd);
|
466 | Â | - ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT;
|
467 | Â | - ddsd.ddsCaps.dwCaps = DDSCAPS_ZBUFFER|DDSCAPS_VIDEOMEMORY;
|
468 | Â | - memcpy(&ddsd.ddpfPixelFormat,&ddpfz,sizeof(DDPIXELFORMAT));
|
469 | Â | - error = ddinterface->CreateSurface(&ddsd,&zbuffer,NULL);
|
470 | Â | - error = ddsrender->AddAttachedSurface(zbuffer);
|
471 | Â | - error = d3d7->CreateDevice(IID_IDirect3DHALDevice,(LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(),&d3d7dev);
|
472 | Â | - if(error != D3D_OK)
|
473 | Â | - error = d3d7->CreateDevice(IID_IDirect3DRGBDevice,(LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(),&d3d7dev);
|
474 | Â | - ddsrender->GetSurfaceDesc(&ddsd);
|
475 | Â | - D3DVIEWPORT7 vp = {0,0,ddsd.dwWidth,ddsd.dwHeight,0.0f,1.0f};
|
476 | Â | - error = d3d7dev->SetViewport(&vp);
|
477 | Â | - error = d3d7dev->SetRenderState(D3DRENDERSTATE_ZENABLE,TRUE);
|
478 | Â | - InitTest3D(testnum);
|
479 | Â | - if(!fullscreen) SendMessage(hWnd,WM_PAINT,0,0);
|
480 | Â | - if(testtypes[testnum] == 1)
|
481 | Â | - {
|
482 | Â | - while(!done)
|
483 | Â | - {
|
484 | Â | - if(PeekMessage(&Msg,NULL,0,0,PM_REMOVE))
|
485 | Â | - {
|
486 | Â | - if(Msg.message == WM_PAINT) RunTestLooped3D(testnum);
|
487 | Â | - else if(Msg.message == WM_QUIT) done = TRUE;
|
488 | Â | - else
|
489 | Â | - {
|
490 | Â | - TranslateMessage(&Msg);
|
491 | Â | - DispatchMessage(&Msg);
|
492 | Â | - }
|
493 | Â | - }
|
494 | Â | - else
|
495 | Â | - {
|
496 | Â | - RunTestLooped3D(testnum);
|
497 | Â | - }
|
498 | Â | - }
|
499 | Â | - }
|
500 | Â | - else if(testtypes[testnum] == 0)
|
501 | Â | - {
|
502 | Â | - StartTimer(hWnd,WM_APP,fps);
|
503 | Â | - while(GetMessage(&Msg, NULL, 0, 0) > 0)
|
504 | Â | - {
|
505 | Â | - TranslateMessage(&Msg);
|
506 | Â | - DispatchMessage(&Msg);
|
507 | Â | - }
|
508 | Â | - }
|
509 | Â | - else
|
510 | Â | - {
|
511 | Â | - while(GetMessage(&Msg, NULL, 0, 0) > 0)
|
512 | Â | - {
|
513 | Â | - TranslateMessage(&Msg);
|
514 | Â | - DispatchMessage(&Msg);
|
515 | Â | - }
|
516 | Â | - }
|
517 | Â | - UnregisterClass(wndclassname3d,hinstance);
|
518 | Â | - StopTimer();
|
519 | Â | -}
|
520 | Â | -
|
521 | Â | -void MakeCube3D(float size, int detail)
|
522 | Â | -{
|
523 | Â | - if(detail < 2) return;
|
524 | Â | - D3DVECTOR normals[6];
|
525 | Â | - normals[0] = D3DVECTOR(0.0f,0.0f,-1.0f);
|
526 | Â | - normals[1] = D3DVECTOR(1.0f,0.0f,0.0f);
|
527 | Â | - normals[2] = D3DVECTOR(0.0f,0.0f,1.0f);
|
528 | Â | - normals[3] = D3DVECTOR(-1.0f,0.0f,0.0f);
|
529 | Â | - normals[4] = D3DVECTOR(0.0f,1.0f,0.0f);
|
530 | Â | - normals[5] = D3DVECTOR(0.0f,-1.0f,0.0f);
|
531 | Â | - int numfacevertices = detail*detail;
|
532 | Â | - D3DVECTOR *face = (D3DVECTOR*)malloc(numfacevertices*sizeof(D3DVECTOR));
|
533 | Â | - int numfaceindices = ((detail-1)*(detail-1))*6;
|
534 | Â | - WORD *faceindex = (WORD*)malloc(numfaceindices*sizeof(WORD));
|
535 | Â | - int ptr = 0;
|
536 | Â | - float fx,fy;
|
537 | Â | - // Generate points
|
538 | Â | - for(int y = 0; y < detail; y++)
|
539 | Â | - {
|
540 | Â | - fy = (((float)(y / (float)(detail-1)))-.5f)*size;
|
541 | Â | - for(int x = 0; x < detail; x++)
|
542 | Â | - {
|
543 | Â | - fx = (((float)(x / (float)(detail-1)))-.5f)*size;
|
544 | Â | - face[ptr] = D3DVECTOR(fx,fy,0);
|
545 | Â | - ptr++;
|
546 | Â | - }
|
547 | Â | - }
|
548 | Â | - // Generate triangle indices
|
549 | Â | - ptr = 0;
|
550 | Â | - for(int y = 0; y < (detail-1); y++)
|
551 | Â | - {
|
552 | Â | - for(int x = 0; x < (detail-1); x++)
|
553 | Â | - {
|
554 | Â | - faceindex[ptr++] = x + (detail*y);
|
555 | Â | - faceindex[ptr++] = x + (detail*(y+1));
|
556 | Â | - faceindex[ptr++] = (x+1) + (detail*y);
|
557 | Â | - faceindex[ptr++] = (x+1) + (detail*y);
|
558 | Â | - faceindex[ptr++] = x + (detail*(y+1));
|
559 | Â | - faceindex[ptr++] = (x+1) + (detail*(y+1));
|
560 | Â | - }
|
561 | Â | - }
|
562 | Â | - numpoints = (detail*detail)*6;
|
563 | Â | - numindices = ((detail-1)*(detail-1))*36;
|
564 | Â | - if(vertices) free(vertices);
|
565 | Â | - if(litvertices) free(litvertices);
|
566 | Â | - if(colorvertices) free(colorvertices);
|
567 | Â | - if(mesh) free(mesh);
|
568 | Â | - vertices = (D3DVERTEX*)malloc(numpoints*sizeof(D3DVERTEX));
|
569 | Â | - litvertices = (D3DLVERTEX*)malloc(numpoints*sizeof(D3DLVERTEX));
|
570 | Â | - colorvertices = (COLORVERTEX*)malloc(numpoints*sizeof(COLORVERTEX));
|
571 | Â | - mesh = (WORD*)malloc(numindices*sizeof(WORD));
|
572 | Â | - // Generate vertex list
|
573 | Â | - float u,v;
|
574 | Â | - D3DVECTOR pos;
|
575 | Â | - D3DVECTOR normal;
|
576 | Â | - // Front face
|
577 | Â | - ptr = 0;
|
578 | Â | - for(int y = 0; y < detail; y++)
|
579 | Â | - {
|
580 | Â | - for(int x = 0; x < detail; x++)
|
581 | Â | - {
|
582 | Â | - u = (float)x/(float)(detail-1);
|
583 | Â | - v = 1.f-((float)y/(float)(detail-1));
|
584 | Â | - ptr = x+(detail*y);
|
585 | Â | - pos = D3DVECTOR(face[ptr].x,face[ptr].y,-size/2.f);
|
586 | Â | - normal = D3DVECTOR(0,0,-1);
|
587 | Â | - vertices[ptr] = D3DVERTEX(pos,normal,u,v);
|
588 | Â | - litvertices[ptr] = D3DLVERTEX(pos,0xFFFFFFFF,0,u,v);
|
589 | Â | - colorvertices[ptr] = COLORVERTEX(pos,normal,0xFFFFFFFF,0,u,v);
|
590 | Â | - }
|
591 | Â | - }
|
592 | Â | - // Right face
|
593 | Â | - ptr = 0;
|
594 | Â | - for(int y = 0; y < detail; y++)
|
595 | Â | - {
|
596 | Â | - for(int x = 0; x < detail; x++)
|
597 | Â | - {
|
598 | Â | - u = (float)x/(float)(detail-1);
|
599 | Â | - v = 1.f-((float)y/(float)(detail-1));
|
600 | Â | - ptr = x+(detail*y);
|
601 | Â | - pos = D3DVECTOR(size/2.f,face[ptr].y,face[ptr].x);
|
602 | Â | - normal = D3DVECTOR(1,0,0);
|
603 | Â | - vertices[ptr+numfacevertices] = D3DVERTEX(pos,normal,u,v);
|
604 | Â | - litvertices[ptr+numfacevertices] = D3DLVERTEX(pos,0xFFFFFFFF,0,u,v);
|
605 | Â | - colorvertices[ptr+numfacevertices] = COLORVERTEX(pos,normal,0xFFFFFFFF,0,u,v);
|
606 | Â | - }
|
607 | Â | - }
|
608 | Â | - // Back face
|
609 | Â | - ptr = 0;
|
610 | Â | - for(int y = 0; y < detail; y++)
|
611 | Â | - {
|
612 | Â | - for(int x = 0; x < detail; x++)
|
613 | Â | - {
|
614 | Â | - u = (float)x/(float)(detail-1);
|
615 | Â | - v = 1.f-((float)y/(float)(detail-1));
|
616 | Â | - ptr = x+(detail*y);
|
617 | Â | - pos = D3DVECTOR(-face[ptr].x,face[ptr].y,size/2.f);
|
618 | Â | - normal = D3DVECTOR(0,0,1);
|
619 | Â | - vertices[ptr+(numfacevertices*2)] = D3DVERTEX(pos,normal,u,v);
|
620 | Â | - litvertices[ptr+(numfacevertices*2)] = D3DLVERTEX(pos,0xFFFFFFFF,0,u,v);
|
621 | Â | - colorvertices[ptr+(numfacevertices*2)] = COLORVERTEX(pos,normal,0xFFFFFFFF,0,u,v);
|
622 | Â | - }
|
623 | Â | - }
|
624 | Â | - // Left face
|
625 | Â | - ptr = 0;
|
626 | Â | - for(int y = 0; y < detail; y++)
|
627 | Â | - {
|
628 | Â | - for(int x = 0; x < detail; x++)
|
629 | Â | - {
|
630 | Â | - u = (float)x/(float)(detail-1);
|
631 | Â | - v = 1.f-((float)y/(float)(detail-1));
|
632 | Â | - ptr = x+(detail*y);
|
633 | Â | - pos = D3DVECTOR(-size/2.f,face[ptr].y,-face[ptr].x);
|
634 | Â | - normal = D3DVECTOR(-1,0,0);
|
635 | Â | - vertices[ptr+(numfacevertices*3)] = D3DVERTEX(pos,normal,u,v);
|
636 | Â | - litvertices[ptr+(numfacevertices*3)] = D3DLVERTEX(pos,0xFFFFFFFF,0,u,v);
|
637 | Â | - colorvertices[ptr+(numfacevertices*3)] = COLORVERTEX(pos,normal,0xFFFFFFFF,0,u,v);
|
638 | Â | - }
|
639 | Â | - }
|
640 | Â | - // Top face
|
641 | Â | - for(int y = 0; y < detail; y++)
|
642 | Â | - {
|
643 | Â | - for(int x = 0; x < detail; x++)
|
644 | Â | - {
|
645 | Â | - u = (float)x/(float)(detail-1);
|
646 | Â | - v = 1.f-((float)y/(float)(detail-1));
|
647 | Â | - ptr = x+(detail*y);
|
648 | Â | - pos = D3DVECTOR(face[ptr].x,size/2.f,face[ptr].y);
|
649 | Â | - normal = D3DVECTOR(0,1,0);
|
650 | Â | - vertices[ptr+(numfacevertices*4)] = D3DVERTEX(pos,normal,u,v);
|
651 | Â | - litvertices[ptr+(numfacevertices*4)] = D3DLVERTEX(pos,0xFFFFFFFF,0,u,v);
|
652 | Â | - colorvertices[ptr+(numfacevertices*4)] = COLORVERTEX(pos,normal,0xFFFFFFFF,0,u,v);
|
653 | Â | - }
|
654 | Â | - }
|
655 | Â | - // Bottom face
|
656 | Â | - for(int y = 0; y < detail; y++)
|
657 | Â | - {
|
658 | Â | - for(int x = 0; x < detail; x++)
|
659 | Â | - {
|
660 | Â | - u = (float)x/(float)(detail-1);
|
661 | Â | - v = 1.f-((float)y/(float)(detail-1));
|
662 | Â | - ptr = x+(detail*y);
|
663 | Â | - pos = D3DVECTOR(face[ptr].x,-size/2.f,-face[ptr].y);
|
664 | Â | - normal = D3DVECTOR(0,-1,0);
|
665 | Â | - vertices[ptr+(numfacevertices*5)] = D3DVERTEX(pos,normal,u,v);
|
666 | Â | - litvertices[ptr+(numfacevertices*5)] = D3DLVERTEX(pos,0xFFFFFFFF,0,u,v);
|
667 | Â | - colorvertices[ptr+(numfacevertices*5)] = COLORVERTEX(pos,normal,0xFFFFFFFF,0,u,v);
|
668 | Â | - }
|
669 | Â | - }
|
670 | Â | - free(face);
|
671 | Â | - // Generate index table
|
672 | Â | - ptr = 0;
|
673 | Â | - for(int i = 0; i < 6; i++)
|
674 | Â | - {
|
675 | Â | - for(int j = 0; j < numfaceindices; j++)
|
676 | Â | - mesh[ptr++] = faceindex[j]+(i*numfacevertices);
|
677 | Â | - }
|
678 | Â | - free(faceindex);
|
679 | Â | -}
|
680 | Â | -
|
681 | Â | -void SetVertexColor(D3DLVERTEX *start, COLORVERTEX *start_color, int count, DWORD color)
|
682 | Â | -{
|
683 | Â | - for(int i = 0; i < count; i++)
|
684 | Â | - {
|
685 | Â | - start[i].color = color;
|
686 | Â | - start_color[i].color = color;
|
687 | Â | - }
|
688 | Â | -}
|
689 | Â | -
|
690 | Â | -void SetVertexSpecular(D3DLVERTEX *start, COLORVERTEX *start_color, int count, DWORD color)
|
691 | Â | -{
|
692 | Â | - for(int i = 0; i < count; i++)
|
693 | Â | - {
|
694 | Â | - start[i].specular = color;
|
695 | Â | - start_color[i].specular = color;
|
696 | Â | - }
|
697 | Â | -}
|
698 | Â | -
|
699 | Â | -
|
700 | Â | -DDPIXELFORMAT texformats[256];
|
701 | Â | -int texformatindex = 0;
|
702 | Â | -
|
703 | Â | -void cleartexformats()
|
704 | Â | -{
|
705 | Â | - ZeroMemory(texformats,256*sizeof(DDPIXELFORMAT));
|
706 | Â | - texformatindex = 0;
|
707 | Â | -}
|
708 | Â | -
|
709 | Â | -HRESULT CALLBACK gettexformat(LPDDPIXELFORMAT lpDDPixFmt, LPVOID lpContext)
|
710 | Â | -{
|
711 | Â | - memcpy(&texformats[texformatindex],lpDDPixFmt,sizeof(DDPIXELFORMAT));
|
712 | Â | - texformatindex++;
|
713 | Â | - if(texformatindex >= 256) return D3DENUMRET_CANCEL;
|
714 | Â | - return D3DENUMRET_OK;
|
715 | Â | -}
|
716 | Â | -
|
717 | Â | -static bool gentexture(const DDPIXELFORMAT format, MultiDirectDrawSurface **surface, int width, int height, int pattern)
|
718 | Â | -{
|
719 | Â | - DDSURFACEDESC2 ddsd;
|
720 | Â | - ZeroMemory(&ddsd,sizeof(DDSURFACEDESC2));
|
721 | Â | - ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
722 | Â | - ddsd.dwFlags = DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT|DDSD_TEXTURESTAGE;
|
723 | Â | - ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
|
724 | Â | - ddsd.dwWidth = width;
|
725 | Â | - ddsd.dwHeight = height;
|
726 | Â | - ddsd.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE;
|
727 | Â | - ddsd.ddpfPixelFormat = format;
|
728 | Â | - HRESULT error = ddinterface->CreateSurface(&ddsd,surface,NULL);
|
729 | Â | - if(error != D3D_OK) return false;
|
730 | Â | - switch(pattern)
|
731 | Â | - {
|
732 | Â | - case 0:
|
733 | Â | - default:
|
734 | Â | - (*surface)->Lock(NULL,&ddsd,DDLOCK_WAIT,NULL);
|
735 | Â | - DrawPalette(ddsd,(unsigned char *)ddsd.lpSurface);
|
736 | Â | - (*surface)->Unlock(NULL);
|
737 | Â | - }
|
738 | Â | - return true;
|
739 | Â | -}
|
740 | Â | -
|
741 | Â | -void MakeLights()
|
742 | Â | -{
|
743 | Â | - for(int i = 0; i < 8; i++)
|
744 | Â | - {
|
745 | Â | - lightenable[i] = FALSE;
|
746 | Â | - ZeroMemory(&lights[i],sizeof(D3DLIGHT7));
|
747 | Â | - lights[i].dcvDiffuse.r = lights[i].dcvDiffuse.g = lights[i].dcvDiffuse.b = 1;
|
748 | Â | - lights[i].dltType = D3DLIGHT_DIRECTIONAL;
|
749 | Â | - hexlightcolor[i].diffuse = 0xFFFFFF;
|
750 | Â | - }
|
751 | Â | - lightenable[0] = TRUE;
|
752 | Â | - lights[0].dvPosition = D3DVECTOR(-10,-10,-10);
|
753 | Â | - lights[1].dvPosition = D3DVECTOR(10,-10,-10);
|
754 | Â | - lights[2].dvPosition = D3DVECTOR(-10,10,-10);
|
755 | Â | - lights[3].dvPosition = D3DVECTOR(10,10,-10);
|
756 | Â | - lights[4].dvPosition = D3DVECTOR(-10,-10,10);
|
757 | Â | - lights[5].dvPosition = D3DVECTOR(10,-10,10);
|
758 | Â | - lights[6].dvPosition = D3DVECTOR(-10,10,10);
|
759 | Â | - lights[7].dvPosition = D3DVECTOR(10,10,10);
|
760 | Â | - lights[0].dvDirection = D3DVECTOR(1,1,1);
|
761 | Â | - lights[1].dvDirection = D3DVECTOR(-1,1,1);
|
762 | Â | - lights[2].dvDirection = D3DVECTOR(1,-1,1);
|
763 | Â | - lights[3].dvDirection = D3DVECTOR(-1,-1,1);
|
764 | Â | - lights[4].dvDirection = D3DVECTOR(1,1,-1);
|
765 | Â | - lights[5].dvDirection = D3DVECTOR(-1,1,-1);
|
766 | Â | - lights[6].dvDirection = D3DVECTOR(1,-1,-1);
|
767 | Â | - lights[7].dvDirection = D3DVECTOR(-1,-1,-1);
|
768 | Â | -}
|
769 | Â | -
|
770 | Â | -static const DDPIXELFORMAT fmt_rgba4444 = {sizeof(DDPIXELFORMAT),DDPF_RGB|DDPF_ALPHAPIXELS,0,16,0xF00,0xF0,0xF,0xF000};
|
771 | Â | -static const DDPIXELFORMAT fmt_rgba1555 = {sizeof(DDPIXELFORMAT),DDPF_RGB|DDPF_ALPHAPIXELS,0,16,0x7C00,0x3E0,0x1F,0x8000};
|
772 | Â | -static const DDPIXELFORMAT fmt_rgb565 = {sizeof(DDPIXELFORMAT),DDPF_RGB,0,16,0xF800,0x7E0,0x1F,0};
|
773 | Â | -static const DDPIXELFORMAT fmt_rgba8888 = {sizeof(DDPIXELFORMAT),DDPF_RGB|DDPF_ALPHAPIXELS,0,32,0xFF0000,0xFF00,0xFF,0xFF000000};
|
774 | Â | -
|
775 | Â | -void InitTest3D(int test)
|
776 | Â | -{
|
777 | Â | - HRESULT error;
|
778 | Â | - D3DMATRIX matWorld;
|
779 | Â | - D3DMATRIX matView;
|
780 | Â | - D3DMATRIX matProj;
|
781 | Â | - D3DMATRIX mat;
|
782 | Â | - bgcolor = 0;
|
783 | Â | - switch(test)
|
784 | Â | - {
|
785 | Â | - case 0:
|
786 | Â | - MakeCube3D(5,2);
|
787 | Â | - ZeroMemory(&material,sizeof(D3DMATERIAL7));
|
788 | Â | - material.ambient.r = 0.5f;
|
789 | Â | - material.ambient.g = 0.5f;
|
790 | Â | - material.ambient.b = 0.0f;
|
791 | Â | - material.diffuse.r = 1.0f;
|
792 | Â | - material.diffuse.g = 1.0f;
|
793 | Â | - material.diffuse.b = 1.0f;
|
794 | Â | - error = d3d7dev->SetMaterial(&material);
|
795 | Â | - error = d3d7dev->LightEnable(0,TRUE);
|
796 | Â | - error = d3d7dev->SetRenderState(D3DRENDERSTATE_LIGHTING, TRUE);
|
797 | Â | - error = d3d7dev->SetRenderState(D3DRENDERSTATE_AMBIENT, 0x7f7f7f7f);
|
798 | Â | - mat._11 = mat._22 = mat._33 = mat._44 = 1.0f;
|
799 | Â | - mat._12 = mat._13 = mat._14 = mat._41 = 0.0f;
|
800 | Â | - mat._21 = mat._23 = mat._24 = mat._42 = 0.0f;
|
801 | Â | - mat._31 = mat._32 = mat._34 = mat._43 = 0.0f;
|
802 | Â | - matWorld = mat;
|
803 | Â | - error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_WORLD,&matWorld);
|
804 | Â | - matView = mat;
|
805 | Â | - matView._43 = 10.0f;
|
806 | Â | - error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_VIEW,&matView);
|
807 | Â | - matProj = mat;
|
808 | Â | - matProj._11 = 2.0f;
|
809 | Â | - matProj._22 = 2.0f;
|
810 | Â | - matProj._34 = 1.0f;
|
811 | Â | - matProj._43 = -1.0f;
|
812 | Â | - matProj._44 = 0.0f;
|
813 | Â | - error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_PROJECTION,&matProj);
|
814 | Â | - ZeroMemory(&lights[0],sizeof(D3DLIGHT7));
|
815 | Â | - lights[0].dltType = D3DLIGHT_DIRECTIONAL;
|
816 | Â | - lights[0].dcvDiffuse.r = 1;
|
817 | Â | - lights[0].dcvDiffuse.g = 0;
|
818 | Â | - lights[0].dcvDiffuse.b = 1;
|
819 | Â | - lights[0].dvDirection = D3DVECTOR(5,5,5);
|
820 | Â | - lights[0].dvRange = D3DLIGHT_RANGE_MAX;
|
821 | Â | - lights[0].dvAttenuation1 = 0.4f;
|
822 | Â | - error = d3d7dev->SetLight(0,&lights[0]);
|
823 | Â | - break;
|
824 | Â | - case 1:
|
825 | Â | - MakeCube3D(5,2);
|
826 | Â | - cleartexformats();
|
827 | Â | - d3d7dev->EnumTextureFormats(gettexformat,NULL);
|
828 | Â | - gentexture(fmt_rgba4444,&textures[0],256,256,0);
|
829 | Â | - gentexture(fmt_rgba1555,&textures[1],256,256,0);
|
830 | Â | - gentexture(fmt_rgb565,&textures[2],256,256,0);
|
831 | Â | - gentexture(fmt_rgba8888,&textures[3],256,256,0);
|
832 | Â | - ZeroMemory(&material,sizeof(D3DMATERIAL7));
|
833 | Â | - material.ambient.r = 1.0f;
|
834 | Â | - material.ambient.g = 1.0f;
|
835 | Â | - material.ambient.b = 1.0f;
|
836 | Â | - material.diffuse.r = 1.0f;
|
837 | Â | - material.diffuse.g = 1.0f;
|
838 | Â | - material.diffuse.b = 1.0f;
|
839 | Â | - error = d3d7dev->SetMaterial(&material);
|
840 | Â | - error = d3d7dev->LightEnable(0,TRUE);
|
841 | Â | - error = d3d7dev->SetRenderState(D3DRENDERSTATE_LIGHTING, TRUE);
|
842 | Â | - error = d3d7dev->SetRenderState(D3DRENDERSTATE_AMBIENT, 0xFFFFFFFF);
|
843 | Â | - error = d3d7dev->SetRenderState(D3DRENDERSTATE_CULLMODE,D3DCULL_CW);
|
844 | Â | - mat._11 = mat._22 = mat._33 = mat._44 = 1.0f;
|
845 | Â | - mat._12 = mat._13 = mat._14 = mat._41 = 0.0f;
|
846 | Â | - mat._21 = mat._23 = mat._24 = mat._42 = 0.0f;
|
847 | Â | - mat._31 = mat._32 = mat._34 = mat._43 = 0.0f;
|
848 | Â | - matWorld = mat;
|
849 | Â | - error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_WORLD,&matWorld);
|
850 | Â | - matView = mat;
|
851 | Â | - matView._43 = 10.0f;
|
852 | Â | - error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_VIEW,&matView);
|
853 | Â | - matProj = mat;
|
854 | Â | - matProj._11 = 2.0f;
|
855 | Â | - matProj._22 = 2.0f;
|
856 | Â | - matProj._34 = 1.0f;
|
857 | Â | - matProj._43 = -1.0f;
|
858 | Â | - matProj._44 = 0.0f;
|
859 | Â | - error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_PROJECTION,&matProj);
|
860 | Â | - ZeroMemory(&lights[0],sizeof(D3DLIGHT7));
|
861 | Â | - lights[0].dltType = D3DLIGHT_DIRECTIONAL;
|
862 | Â | - lights[0].dcvDiffuse.r = 1;
|
863 | Â | - lights[0].dcvDiffuse.g = 0;
|
864 | Â | - lights[0].dcvDiffuse.b = 1;
|
865 | Â | - lights[0].dvDirection = D3DVECTOR(5,5,5);
|
866 | Â | - lights[0].dvRange = D3DLIGHT_RANGE_MAX;
|
867 | Â | - lights[0].dvAttenuation1 = 0.4f;
|
868 | Â | - error = d3d7dev->SetLight(0,&lights[0]);
|
869 | Â | - break;
|
870 | Â | - case 3:
|
871 | Â | - ZeroMemory(lights,8*sizeof(D3DLIGHT7));
|
872 | Â | - MakeLights();
|
873 | Â | - case 2:
|
874 | Â | - MakeCube3D(5,8);
|
875 | Â | - ZeroMemory(&material,sizeof(D3DMATERIAL7));
|
876 | Â | - material.ambient.r = 1.0f;
|
877 | Â | - material.ambient.g = 1.0f;
|
878 | Â | - material.ambient.b = 1.0f;
|
879 | Â | - material.ambient.a = 1.0f;
|
880 | Â | - material.diffuse.r = 1.0f;
|
881 | Â | - material.diffuse.g = 1.0f;
|
882 | Â | - material.diffuse.b = 1.0f;
|
883 | Â | - material.diffuse.a = 1.0f;
|
884 | Â | - error = d3d7dev->SetMaterial(&material);
|
885 | Â | - error = d3d7dev->SetRenderState(D3DRENDERSTATE_LIGHTING, FALSE);
|
886 | Â | - error = d3d7dev->SetRenderState(D3DRENDERSTATE_AMBIENT, 0xffffffff);
|
887 | Â | - mat._11 = mat._22 = mat._33 = mat._44 = 1.0f;
|
888 | Â | - mat._12 = mat._13 = mat._14 = mat._41 = 0.0f;
|
889 | Â | - mat._21 = mat._23 = mat._24 = mat._42 = 0.0f;
|
890 | Â | - mat._31 = mat._32 = mat._34 = mat._43 = 0.0f;
|
891 | Â | - matWorld = mat;
|
892 | Â | - error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_WORLD,&matWorld);
|
893 | Â | - matView = mat;
|
894 | Â | - matView._43 = 10.0f;
|
895 | Â | - error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_VIEW,&matView);
|
896 | Â | - matProj = mat;
|
897 | Â | - matProj._11 = 2.0f;
|
898 | Â | - matProj._22 = 2.0f;
|
899 | Â | - matProj._34 = 1.0f;
|
900 | Â | - matProj._43 = -1.0f;
|
901 | Â | - matProj._44 = 0.0f;
|
902 | Â | - error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_PROJECTION,&matProj);
|
903 | Â | - texshaderstate = defaulttexshaderstate;
|
904 | Â | - break;
|
905 | Â | - default:
|
906 | Â | - break;
|
907 | Â | - }
|
908 | Â | -}
|
909 | Â | -
|
910 | Â | -void RunTestTimed3D(int test)
|
911 | Â | -{
|
912 | Â | - if(!d3d7dev) return;
|
913 | Â | - POINT p;
|
914 | Â | - RECT srcrect,destrect;
|
915 | Â | - HRESULT error;
|
916 | Â | - D3DMATRIX mat;
|
917 | Â | - DDSURFACEDESC2 ddsd;
|
918 | Â | - ZeroMemory(&ddsd,sizeof(DDSURFACEDESC2));
|
919 | Â | - if(d3dver >= 3) ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
920 | Â | - else ddsd.dwSize = sizeof(DDSURFACEDESC);
|
921 | Â | - error = d3d7dev->Clear(0,NULL,D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,bgcolor,1.0,0);
|
922 | Â | - float time = (float)clock() / (float)CLOCKS_PER_SEC;
|
923 | Â | - switch(test)
|
924 | Â | - {
|
925 | Â | - case 0:
|
926 | Â | - mat._11 = mat._22 = mat._33 = mat._44 = 1.0f;
|
927 | Â | - mat._12 = mat._13 = mat._14 = mat._41 = 0.0f;
|
928 | Â | - mat._21 = mat._23 = mat._24 = mat._42 = 0.0f;
|
929 | Â | - mat._31 = mat._32 = mat._34 = mat._43 = 0.0f;
|
930 | Â | - mat._11 = (FLOAT)cos( (float)time );
|
931 | Â | - mat._33 = (FLOAT)cos( (float)time );
|
932 | Â | - mat._13 = -(FLOAT)sin( (float)time );
|
933 | Â | - mat._31 = (FLOAT)sin( (float)time );
|
934 | Â | - error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_WORLD, &mat);
|
935 | Â | - error = d3d7dev->BeginScene();
|
936 | Â | - error = d3d7dev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,D3DFVF_VERTEX,vertices,numpoints,mesh,numindices,0);
|
937 | Â | - error = d3d7dev->EndScene();
|
938 | Â | - break;
|
939 | Â | - case 1:
|
940 | Â | - mat._11 = mat._22 = mat._33 = mat._44 = 1.0f;
|
941 | Â | - mat._12 = mat._13 = mat._14 = mat._41 = 0.0f;
|
942 | Â | - mat._21 = mat._23 = mat._24 = mat._42 = 0.0f;
|
943 | Â | - mat._31 = mat._32 = mat._34 = mat._43 = 0.0f;
|
944 | Â | - mat._11 = (FLOAT)cos( (float)time );
|
945 | Â | - mat._33 = (FLOAT)cos( (float)time );
|
946 | Â | - mat._13 = -(FLOAT)sin( (float)time );
|
947 | Â | - mat._31 = (FLOAT)sin( (float)time );
|
948 | Â | - error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_WORLD, &mat);
|
949 | Â | - error = d3d7dev->BeginScene();
|
950 | Â | - error = d3d7dev->SetTexture(0,(LPDIRECTDRAWSURFACE7)textures[0]->GetSurface());
|
951 | Â | - error = d3d7dev->DrawPrimitive(D3DPT_TRIANGLESTRIP,D3DFVF_VERTEX,vertices,4,0);
|
952 | Â | - error = d3d7dev->SetTexture(0,(LPDIRECTDRAWSURFACE7)textures[1]->GetSurface());
|
953 | Â | - error = d3d7dev->DrawPrimitive(D3DPT_TRIANGLESTRIP,D3DFVF_VERTEX,vertices+4,4,0);
|
954 | Â | - error = d3d7dev->SetTexture(0,(LPDIRECTDRAWSURFACE7)textures[2]->GetSurface());
|
955 | Â | - error = d3d7dev->DrawPrimitive(D3DPT_TRIANGLESTRIP,D3DFVF_VERTEX,vertices+8,4,0);
|
956 | Â | - error = d3d7dev->SetTexture(0,(LPDIRECTDRAWSURFACE7)textures[3]->GetSurface());
|
957 | Â | - error = d3d7dev->DrawPrimitive(D3DPT_TRIANGLESTRIP,D3DFVF_VERTEX,vertices+12,4,0);
|
958 | Â | - error = d3d7dev->EndScene();
|
959 | Â | - break;
|
960 | Â | - case 2:
|
961 | Â | - mat._11 = mat._22 = mat._33 = mat._44 = 1.0f;
|
962 | Â | - mat._12 = mat._13 = mat._14 = mat._41 = 0.0f;
|
963 | Â | - mat._21 = mat._23 = mat._24 = mat._42 = 0.0f;
|
964 | Â | - mat._31 = mat._32 = mat._34 = mat._43 = 0.0f;
|
965 | Â | - mat._11 = (FLOAT)cos( (float)time );
|
966 | Â | - mat._33 = (FLOAT)cos( (float)time );
|
967 | Â | - mat._13 = -(FLOAT)sin( (float)time );
|
968 | Â | - mat._31 = (FLOAT)sin( (float)time );
|
969 | Â | - error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_WORLD, &mat);
|
970 | Â | - error = d3d7dev->BeginScene();
|
971 | Â | - error = d3d7dev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,D3DFVF_LVERTEX,litvertices,numpoints,mesh,numindices,0);
|
972 | Â | - error = d3d7dev->EndScene();
|
973 | Â | - break;
|
974 | Â | - case 3:
|
975 | Â | - mat._11 = mat._22 = mat._33 = mat._44 = 1.0f;
|
976 | Â | - mat._12 = mat._13 = mat._14 = mat._41 = 0.0f;
|
977 | Â | - mat._21 = mat._23 = mat._24 = mat._42 = 0.0f;
|
978 | Â | - mat._31 = mat._32 = mat._34 = mat._43 = 0.0f;
|
979 | Â | - mat._11 = (FLOAT)cos( (float)time );
|
980 | Â | - mat._33 = (FLOAT)cos( (float)time );
|
981 | Â | - mat._13 = -(FLOAT)sin( (float)time );
|
982 | Â | - mat._31 = (FLOAT)sin( (float)time );
|
983 | Â | - error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_WORLD, &mat);
|
984 | Â | - error = d3d7dev->BeginScene();
|
985 | Â | - error = d3d7dev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,FVF_COLORVERTEX,colorvertices,numpoints,mesh,numindices,0);
|
986 | Â | - error = d3d7dev->EndScene();
|
987 | Â | - break;
|
988 | Â | - default:
|
989 | Â | - break;
|
990 | Â | - }
|
991 | Â | - if(fullscreen)
|
992 | Â | - {
|
993 | Â | - if(backbuffers) ddsurface->Flip(NULL,DDFLIP_WAIT);
|
994 | Â | - }
|
995 | Â | - else
|
996 | Â | - {
|
997 | Â | - p.x = 0;
|
998 | Â | - p.y = 0;
|
999 | Â | - ClientToScreen(hWnd,&p);
|
1000 | Â | - GetClientRect(hWnd,&destrect);
|
1001 | Â | - OffsetRect(&destrect,p.x,p.y);
|
1002 | Â | - SetRect(&srcrect,0,0,width,height);
|
1003 | Â | - if(ddsurface && ddsrender)error = ddsurface->Blt(&destrect,ddsrender,&srcrect,DDBLT_WAIT,NULL);
|
1004 | Â | - }
|
1005 | Â | -}
|
1006 | Â | -
|
1007 | Â | -void RunTestLooped3D(int test)
|
1008 | Â | -{
|
1009 | Â | -}
|
1010 | Â | -
|
1011 | Â | -void PopulateArgCombo(HWND hWnd)
|
1012 | Â | -{
|
1013 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Diffuse"));
|
1014 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Current"));
|
1015 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Texture"));
|
1016 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Factor"));
|
1017 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Specular"));
|
1018 | Â | -}
|
1019 | Â | -
|
1020 | Â | -void PopulateOpCombo(HWND hWnd, bool color)
|
1021 | Â | -{
|
1022 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Disable"));
|
1023 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Select Arg 1"));
|
1024 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Select Arg 2"));
|
1025 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Modulate"));
|
1026 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Modulate 2x"));
|
1027 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Modulate 4x"));
|
1028 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Add"));
|
1029 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Add Signed"));
|
1030 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Add Signed 2x"));
|
1031 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Subtract"));
|
1032 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Add Smooth"));
|
1033 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Blend Diffuse Alpha"));
|
1034 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Blend Texture Alpha"));
|
1035 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Blend Factor Alpha"));
|
1036 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Blend Texture Alpha PM"));
|
1037 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Blend Current Alpha"));
|
1038 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Premodulate"));
|
1039 | Â | - if(color)
|
1040 | Â | - {
|
1041 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Modulate Alpha Add Color"));
|
1042 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Modulate Color Add Alpha"));
|
1043 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Modulate Inv. Alpha Add Color"));
|
1044 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Modulate Inv. Color Add Alpha"));
|
1045 | Â | - }
|
1046 | Â | - else
|
1047 | Â | - {
|
1048 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("(invalid)"));
|
1049 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("(invalid)"));
|
1050 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("(invalid)"));
|
1051 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("(invalid)"));
|
1052 | Â | - }
|
1053 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Bump Env. Map"));
|
1054 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Bump Env. Map Luminance"));
|
1055 | Â | - if(color) SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Dot Product3"));
|
1056 | Â | -}
|
1057 | Â | -
|
1058 | Â | -void PopulateBlendCombo(HWND hWnd, bool src)
|
1059 | Â | -{
|
1060 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Zero"));
|
1061 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("One"));
|
1062 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Source Color"));
|
1063 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Inv. Src. Color"));
|
1064 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Source Alpha"));
|
1065 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Inv. Src. Alpha"));
|
1066 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Dest. Alpha"));
|
1067 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Inv. Dest. Alpha"));
|
1068 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Dest. Color"));
|
1069 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Inv. Dest. Color"));
|
1070 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Src. Alpha Sat."));
|
1071 | Â | - if(src)
|
1072 | Â | - {
|
1073 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Both Src. Alpha"));
|
1074 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Both Inv. Src. Alpha"));
|
1075 | Â | - }
|
1076 | Â | -}
|
1077 | Â | -
|
1078 | Â | -void PopulateCompareCombo(HWND hWnd)
|
1079 | Â | -{
|
1080 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Never"));
|
1081 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Less"));
|
1082 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Equal"));
|
1083 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Less or Equal"));
|
1084 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Greater"));
|
1085 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Not Equal"));
|
1086 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Greater or Equal"));
|
1087 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Always"));
|
1088 | Â | -}
|
1089 | Â | -
|
1090 | Â | -void PopulateFogCombo(HWND hWnd)
|
1091 | Â | -{
|
1092 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("None"));
|
1093 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Exponential"));
|
1094 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Exp. Squared"));
|
1095 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Linear"));
|
1096 | Â | -}
|
1097 | Â | -
|
1098 | Â | -void PopulateSourceCombo(HWND hWnd)
|
1099 | Â | -{
|
1100 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Material"));
|
1101 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Color 1"));
|
1102 | Â | - SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Color 2"));
|
1103 | Â | -}
|
1104 | Â | -
|
1105 | Â | -void strupper(TCHAR *str)
|
1106 | Â | -{
|
1107 | Â | - TCHAR *ptr = str;
|
1108 | Â | - while(*ptr != 0)
|
1109 | Â | - {
|
1110 | Â | - *ptr = _totupper(*ptr);
|
1111 | Â | - ptr++;
|
1112 | Â | - }
|
1113 | Â | -}
|
1114 | Â | -
|
1115 | Â | -void paddwordzeroes(TCHAR *str)
|
1116 | Â | -{
|
1117 | Â | - TCHAR str2[16];
|
1118 | Â | - str2[0] = 0;
|
1119 | Â | - int len = _tcslen(str);
|
1120 | Â | - if(len < 8)
|
1121 | Â | - {
|
1122 | Â | - for(int i = 0; i < 8-len; i++)
|
1123 | Â | - _tcscat(str2,_T("0"));
|
1124 | Â | - _tcscat(str2,str);
|
1125 | Â | - _tcscpy(str,str2);
|
1126 | Â | - }
|
1127 | Â | -}
|
1128 | Â | -
|
1129 | Â | -HRESULT CALLBACK SelectTextureFormatCallback(LPDDPIXELFORMAT lpDDPixFmt, LPVOID lpContext)
|
1130 | Â | -{
|
1131 | Â | - if(lpDDPixFmt->dwFlags & (DDPF_LUMINANCE|DDPF_BUMPLUMINANCE|DDPF_BUMPDUDV)) return D3DENUMRET_OK;
|
1132 | Â | - if(lpDDPixFmt->dwFourCC != 0) return D3DENUMRET_OK;
|
1133 | Â | - if(!(lpDDPixFmt->dwFlags & DDPF_ALPHAPIXELS)) return D3DENUMRET_OK;
|
1134 | Â | - if(lpDDPixFmt->dwRGBBitCount < 32) return D3DENUMRET_OK;
|
1135 | Â | - memcpy(lpContext,lpDDPixFmt,sizeof(DDPIXELFORMAT));
|
1136 | Â | - return D3DENUMRET_CANCEL;
|
1137 | Â | -}
|
1138 | Â | -
|
1139 | Â | -void CreateSurfaceFromBitmap(MultiDirectDrawSurface **surface, DDSURFACEDESC2 *ddsd, HDC hdc, int width, int height)
|
1140 | Â | -{
|
1141 | Â | - ddinterface->CreateSurface(ddsd,surface,NULL);
|
1142 | Â | - HDC surfacedc;
|
1143 | Â | - if(surface)
|
1144 | Â | - {
|
1145 | Â | - (*surface)->GetDC(&surfacedc);
|
1146 | Â | - BitBlt(surfacedc,0,0,width,height,hdc,0,0,SRCCOPY);
|
1147 | Â | - (*surface)->ReleaseDC(surfacedc);
|
1148 | Â | - }
|
1149 | Â | -}
|
1150 | Â | -
|
1151 | Â | -void SelectTexture(MultiDirectDrawSurface **surface, int type, DWORD colorkey, bool haskey, LPCTSTR file)
|
1152 | Â | -{
|
1153 | Â | - DDSURFACEDESC2 ddsd;
|
1154 | Â | - ZeroMemory(&ddsd,sizeof(DDSURFACEDESC2));
|
1155 | Â | - ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
1156 | Â | - BITMAPV4HEADER bi;
|
1157 | Â | - HBITMAP bitmap;
|
1158 | Â | - HDC hdc;
|
1159 | Â | - HDC hmemdc;
|
1160 | Â | - HBITMAP holdbmp;
|
1161 | Â | - HICON icon;
|
1162 | Â | - VOID *bmpbits;
|
1163 | Â | - ZeroMemory(&bi,sizeof(BITMAPV4HEADER));
|
1164 | Â | - bi.bV4Size = sizeof(BITMAPV4HEADER);
|
1165 | Â | - bi.bV4Planes = 1;
|
1166 | Â | - bi.bV4BitCount = 32;
|
1167 | Â | - bi.bV4V4Compression = BI_BITFIELDS;
|
1168 | Â | - bi.bV4RedMask = 0x00FF0000;
|
1169 | Â | - bi.bV4GreenMask = 0x0000FF00;
|
1170 | Â | - bi.bV4BlueMask = 0x000000FF;
|
1171 | Â | - bi.bV4AlphaMask = 0xFF000000;
|
1172 | Â | - d3d7dev->EnumTextureFormats(SelectTextureFormatCallback,&ddsd.ddpfPixelFormat);
|
1173 | Â | - ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
|
1174 | Â | - ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT|DDSD_TEXTURESTAGE;
|
1175 | Â | - DDCOLORKEY ckey;
|
1176 | Â | - ckey.dwColorSpaceHighValue = ckey.dwColorSpaceLowValue = colorkey;
|
1177 | Â | - if(haskey) ddsd.dwFlags |= DDSD_CKSRCBLT;
|
1178 | Â | - if(*surface)
|
1179 | Â | - {
|
1180 | Â | - d3d7dev->SetTexture(texshaderstate.currentstage,NULL);
|
1181 | Â | - (*surface)->Release();
|
1182 | Â | - *surface = NULL;
|
1183 | Â | - }
|
1184 | Â | - switch(type)
|
1185 | Â | - {
|
1186 | Â | - case 0:
|
1187 | Â | - default:
|
1188 | Â | - break;
|
1189 | Â | - case 1:
|
1190 | Â | - break;
|
1191 | Â | - case 2:
|
1192 | Â | - hdc = GetDC(NULL);
|
1193 | Â | - bi.bV4Width = ddsd.dwWidth = bi.bV4Height = ddsd.dwHeight = 16;
|
1194 | Â | - bitmap = CreateDIBSection(hdc,(BITMAPINFO*)&bi,DIB_RGB_COLORS,&bmpbits,NULL,0);
|
1195 | Â | - hmemdc = CreateCompatibleDC(hdc);
|
1196 | Â | - ReleaseDC(NULL,hdc);
|
1197 | Â | - holdbmp = (HBITMAP)SelectObject(hmemdc,bitmap);
|
1198 | Â | - icon = (HICON)LoadImage(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_DXGL),IMAGE_ICON,16,16,0);
|
1199 | Â | - DrawIconEx(hmemdc,0,0,icon,16,16,0,NULL,DI_NORMAL);
|
1200 | Â | - CreateSurfaceFromBitmap(surface,&ddsd,hmemdc,16,16);
|
1201 | Â | - SelectObject(hmemdc,holdbmp);
|
1202 | Â | - DeleteDC(hmemdc);
|
1203 | Â | - DeleteObject(bitmap);
|
1204 | Â | - if(*surface && haskey) (*surface)->SetColorKey(DDCKEY_SRCBLT,&ckey);
|
1205 | Â | - if(*surface) d3d7dev->SetTexture(texshaderstate.currentstage,(LPDIRECTDRAWSURFACE7)(*surface)->GetSurface());
|
1206 | Â | - break;
|
1207 | Â | - case 3:
|
1208 | Â | - hdc = GetDC(NULL);
|
1209 | Â | - bi.bV4Width = ddsd.dwWidth = bi.bV4Height = ddsd.dwHeight = 256;
|
1210 | Â | - bitmap = CreateDIBSection(hdc,(BITMAPINFO*)&bi,DIB_RGB_COLORS,&bmpbits,NULL,0);
|
1211 | Â | - hmemdc = CreateCompatibleDC(hdc);
|
1212 | Â | - ReleaseDC(NULL,hdc);
|
1213 | Â | - holdbmp = (HBITMAP)SelectObject(hmemdc,bitmap);
|
1214 | Â | - icon = (HICON)LoadImage(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_DXGL),IMAGE_ICON,256,256,0);
|
1215 | Â | - DrawIconEx(hmemdc,0,0,icon,256,256,0,NULL,DI_NORMAL);
|
1216 | Â | - CreateSurfaceFromBitmap(surface,&ddsd,hmemdc,256,256);
|
1217 | Â | - SelectObject(hmemdc,holdbmp);
|
1218 | Â | - DeleteDC(hmemdc);
|
1219 | Â | - DeleteObject(bitmap);
|
1220 | Â | - if(*surface && haskey) (*surface)->SetColorKey(DDCKEY_SRCBLT,&ckey);
|
1221 | Â | - if(*surface) d3d7dev->SetTexture(texshaderstate.currentstage,(LPDIRECTDRAWSURFACE7)(*surface)->GetSurface());
|
1222 | Â | - break;
|
1223 | Â | - case 4:
|
1224 | Â | - break;
|
1225 | Â | - }
|
1226 | Â | -}
|
1227 | Â | -
|
1228 | Â | -void SetShaderArg(HWND hWnd, UINT dropdown, UINT checkalpha, UINT checkinv, DWORD *texarg)
|
1229 | Â | -{
|
1230 | Â | - DWORD arg = SendDlgItemMessage(hWnd,dropdown,CB_GETCURSEL,0,0);
|
1231 | Â | - if(SendDlgItemMessage(hWnd,checkalpha,BM_GETCHECK,0,0) == BST_CHECKED)
|
1232 | Â | - arg |= D3DTA_ALPHAREPLICATE;
|
1233 | Â | - if(SendDlgItemMessage(hWnd,checkinv,BM_GETCHECK,0,0) == BST_CHECKED)
|
1234 | Â | - arg |= D3DTA_COMPLEMENT;
|
1235 | Â | - *texarg = arg;
|
1236 | Â | -}
|
1237 | Â | -
|
1238 | Â | -INT_PTR CALLBACK TexShader7Proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
1239 | Â | -{
|
1240 | Â | - HRESULT error;
|
1241 | Â | - D3DVIEWPORT7 vp;
|
1242 | Â | - HWND hDisplay;
|
1243 | Â | - int number;
|
1244 | Â | - float f;
|
1245 | Â | - TCHAR tmpstring[MAX_PATH+1];
|
1246 | Â | - switch(Msg)
|
1247 | Â | - {
|
1248 | Â | - case WM_INITDIALOG:
|
1249 | Â | - RECT r;
|
1250 | Â | - DDSCAPS2 caps;
|
1251 | Â | - DDSURFACEDESC2 ddsd;
|
1252 | Â | - DDPIXELFORMAT ddpfz;
|
1253 | Â | - testnum = 2;
|
1254 | Â | - ddinterface = new MultiDirectDraw(7,&error,NULL);
|
1255 | Â | - hDisplay = GetDlgItem(hWnd,IDC_DISPLAY);
|
1256 | Â | - ::hWnd = hDisplay;
|
1257 | Â | - error = ddinterface->SetCooperativeLevel(hDisplay,DDSCL_NORMAL);
|
1258 | Â | - ZeroMemory(&ddsd,sizeof(DDSURFACEDESC2));
|
1259 | Â | - ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
1260 | Â | - ddsd.dwFlags = DDSD_CAPS;
|
1261 | Â | - ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
1262 | Â | - error = ddinterface->CreateSurface(&ddsd,&ddsurface,NULL);
|
1263 | Â | - error = ddinterface->CreateClipper(0,&ddclipper,NULL);
|
1264 | Â | - error = ddclipper->SetHWnd(0,hDisplay);
|
1265 | Â | - error = ddsurface->SetClipper(ddclipper);
|
1266 | Â | - ZeroMemory(&ddsd,sizeof(DDSURFACEDESC2));
|
1267 | Â | - ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
1268 | Â | - ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
1269 | Â | - ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN|DDSCAPS_3DDEVICE;
|
1270 | Â | - GetClientRect(hDisplay,&r);
|
1271 | Â | - ddsd.dwWidth = r.right;
|
1272 | Â | - ddsd.dwHeight = r.bottom;
|
1273 | Â | - error = ddinterface->CreateSurface(&ddsd,&ddsrender,NULL);
|
1274 | Â | - error = ddinterface->QueryInterface(IID_IDirect3D7,(VOID**)&d3d7);
|
1275 | Â | - error = d3d7->EnumZBufferFormats(IID_IDirect3DRGBDevice,zcallback,&ddpfz);
|
1276 | Â | - error = ddsrender->GetSurfaceDesc(&ddsd);
|
1277 | Â | - ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT;
|
1278 | Â | - ddsd.ddsCaps.dwCaps = DDSCAPS_ZBUFFER|DDSCAPS_VIDEOMEMORY;
|
1279 | Â | - memcpy(&ddsd.ddpfPixelFormat,&ddpfz,sizeof(DDPIXELFORMAT));
|
1280 | Â | - error = ddinterface->CreateSurface(&ddsd,&zbuffer,NULL);
|
1281 | Â | - error = ddsrender->AddAttachedSurface(zbuffer);
|
1282 | Â | - error = d3d7->CreateDevice(IID_IDirect3DHALDevice,(LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(),&d3d7dev);
|
1283 | Â | - if(error != D3D_OK)
|
1284 | Â | - error = d3d7->CreateDevice(IID_IDirect3DRGBDevice,(LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(),&d3d7dev);
|
1285 | Â | - ddsrender->GetSurfaceDesc(&ddsd);
|
1286 | Â | - vp.dvMaxZ = 1.0f;
|
1287 | Â | - vp.dvMinZ = 0.0f;
|
1288 | Â | - vp.dwX = vp.dwY = 0;
|
1289 | Â | - vp.dwWidth = ddsd.dwWidth;
|
1290 | Â | - vp.dwHeight = ddsd.dwHeight;
|
1291 | Â | - error = d3d7dev->SetViewport(&vp);
|
1292 | Â | - error = d3d7dev->SetRenderState(D3DRENDERSTATE_ZENABLE,TRUE);
|
1293 | Â | - InitTest3D(2);
|
1294 | Â | - SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_ADDSTRING,0,(LPARAM)_T("None"));
|
1295 | Â | - SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_ADDSTRING,0,(LPARAM)_T("Gradients"));
|
1296 | Â | - SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_ADDSTRING,0,(LPARAM)_T("DXGL logo (small)"));
|
1297 | Â | - SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_ADDSTRING,0,(LPARAM)_T("DXGL logo (large)"));
|
1298 | Â | - SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_ADDSTRING,0,(LPARAM)_T("Texture file"));
|
1299 | Â | - SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_SETCURSEL,0,0);
|
1300 | Â | - SendDlgItemMessage(hWnd,IDC_TEXCOLORKEY,WM_SETTEXT,0,(LPARAM)_T(""));
|
1301 | Â | - PopulateArgCombo(GetDlgItem(hWnd,IDC_CARG1));
|
1302 | Â | - PopulateArgCombo(GetDlgItem(hWnd,IDC_CARG2));
|
1303 | Â | - PopulateArgCombo(GetDlgItem(hWnd,IDC_AARG1));
|
1304 | Â | - PopulateArgCombo(GetDlgItem(hWnd,IDC_AARG2));
|
1305 | Â | - SendDlgItemMessage(hWnd,IDC_CARG1,CB_SETCURSEL,D3DTA_TEXTURE,0);
|
1306 | Â | - SendDlgItemMessage(hWnd,IDC_CARG2,CB_SETCURSEL,D3DTA_CURRENT,0);
|
1307 | Â | - SendDlgItemMessage(hWnd,IDC_AARG1,CB_SETCURSEL,D3DTA_TEXTURE,0);
|
1308 | Â | - SendDlgItemMessage(hWnd,IDC_AARG2,CB_SETCURSEL,D3DTA_CURRENT,0);
|
1309 | Â | - PopulateOpCombo(GetDlgItem(hWnd,IDC_COLOROP),true);
|
1310 | Â | - PopulateOpCombo(GetDlgItem(hWnd,IDC_ALPHAOP),false);
|
1311 | Â | - SendDlgItemMessage(hWnd,IDC_COLOROP,CB_SETCURSEL,D3DTOP_MODULATE-1,0);
|
1312 | Â | - SendDlgItemMessage(hWnd,IDC_ALPHAOP,CB_SETCURSEL,D3DTOP_SELECTARG1-1,0);
|
1313 | Â | - SendDlgItemMessage(hWnd,IDC_DIFFUSE,WM_SETTEXT,0,(LPARAM)_T("FFFFFFFF"));
|
1314 | Â | - SendDlgItemMessage(hWnd,IDC_SPECULAR,WM_SETTEXT,0,(LPARAM)_T("00000000"));
|
1315 | Â | - SendDlgItemMessage(hWnd,IDC_FACTOR,WM_SETTEXT,0,(LPARAM)_T("00000000"));
|
1316 | Â | - SendDlgItemMessage(hWnd,IDC_FOGCOLOR,WM_SETTEXT,0,(LPARAM)_T("00000000"));
|
1317 | Â | - SendDlgItemMessage(hWnd,IDC_BGCOLOR,WM_SETTEXT,0,(LPARAM)_T("00000000"));
|
1318 | Â | - PopulateBlendCombo(GetDlgItem(hWnd,IDC_SRCBLEND),true);
|
1319 | Â | - PopulateBlendCombo(GetDlgItem(hWnd,IDC_DESTBLEND),true);
|
1320 | Â | - SendDlgItemMessage(hWnd,IDC_SRCBLEND,CB_SETCURSEL,D3DBLEND_ONE-1,0);
|
1321 | Â | - SendDlgItemMessage(hWnd,IDC_DESTBLEND,CB_SETCURSEL,D3DBLEND_ZERO-1,0);
|
1322 | Â | - PopulateCompareCombo(GetDlgItem(hWnd,IDC_ALPHAFUNC));
|
1323 | Â | - SendDlgItemMessage(hWnd,IDC_ALPHAFUNC,CB_SETCURSEL,D3DCMP_ALWAYS-1,0);
|
1324 | Â | - PopulateFogCombo(GetDlgItem(hWnd,IDC_VERTEXFOGMODE));
|
1325 | Â | - PopulateFogCombo(GetDlgItem(hWnd,IDC_PIXELFOGMODE));
|
1326 | Â | - SendDlgItemMessage(hWnd,IDC_VERTEXFOGMODE,CB_SETCURSEL,D3DFOG_NONE,0);
|
1327 | Â | - SendDlgItemMessage(hWnd,IDC_PIXELFOGMODE,CB_SETCURSEL,D3DFOG_NONE,0);
|
1328 | Â | - SendDlgItemMessage(hWnd,IDC_FOGSTART,WM_SETTEXT,0,(LPARAM)_T("0.0"));
|
1329 | Â | - SendDlgItemMessage(hWnd,IDC_FOGEND,WM_SETTEXT,0,(LPARAM)_T("1.0"));
|
1330 | Â | - SendDlgItemMessage(hWnd,IDC_FOGDENSITY,WM_SETTEXT,0,(LPARAM)_T("1.0"));
|
1331 | Â | - SendDlgItemMessage(hWnd,IDC_SPINSTAGE,UDM_SETRANGE32,0,7);
|
1332 | Â | - SendDlgItemMessage(hWnd,IDC_SPINALPHAREF,UDM_SETRANGE32,0,255);
|
1333 | Â | - ::width = ddsd.dwWidth;
|
1334 | Â | - ::height = ddsd.dwHeight;
|
1335 | Â | - StartTimer(hWnd,WM_APP,60);
|
1336 | Â | - break;
|
1337 | Â | - case WM_COMMAND:
|
1338 | Â | - switch(LOWORD(wParam))
|
1339 | Â | - {
|
1340 | Â | - case IDC_TEXSTAGE:
|
1341 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
1342 | Â | - {
|
1343 | Â | - SendDlgItemMessage(hWnd,IDC_TEXSTAGE,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
1344 | Â | - number = _ttoi(tmpstring);
|
1345 | Â | - if(number < 0) SendDlgItemMessage(hWnd,IDC_TEXSTAGE,WM_SETTEXT,0,(LPARAM)_T("0"));
|
1346 | Â | - if(number > 7) SendDlgItemMessage(hWnd,IDC_TEXSTAGE,WM_SETTEXT,0,(LPARAM)_T("7"));
|
1347 | Â | - if(number < 0) number = 0;
|
1348 | Â | - if(number > 7) number = 7;
|
1349 | Â | - texshaderstate.currentstage = number;
|
1350 | Â | - _itot(texshaderstate.texstages[number].keycolor,tmpstring,16);
|
1351 | Â | - strupper(tmpstring);
|
1352 | Â | - paddwordzeroes(tmpstring);
|
1353 | Â | - if(texshaderstate.texstages[number].colorkey == FALSE) tmpstring[0] = 0;
|
1354 | Â | - SendDlgItemMessage(hWnd,IDC_TEXCOLORKEY,WM_SETTEXT,0,(LPARAM)tmpstring);
|
1355 | Â | - SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_SETCURSEL,texshaderstate.texstages[number].texturetype,0);
|
1356 | Â | - SendDlgItemMessage(hWnd,IDC_TEXTUREFILE,WM_SETTEXT,0,(LPARAM)texshaderstate.texstages[number].texturefile);
|
1357 | Â | - SendDlgItemMessage(hWnd,IDC_CARG1,CB_SETCURSEL,texshaderstate.texstages[number].colorarg1 & D3DTA_SELECTMASK,0);
|
1358 | Â | - SendDlgItemMessage(hWnd,IDC_CARG2,CB_SETCURSEL,texshaderstate.texstages[number].colorarg2 & D3DTA_SELECTMASK,0);
|
1359 | Â | - SendDlgItemMessage(hWnd,IDC_AARG1,CB_SETCURSEL,texshaderstate.texstages[number].alphaarg1 & D3DTA_SELECTMASK,0);
|
1360 | Â | - SendDlgItemMessage(hWnd,IDC_AARG2,CB_SETCURSEL,texshaderstate.texstages[number].alphaarg2 & D3DTA_SELECTMASK,0);
|
1361 | Â | - if(texshaderstate.texstages[number].colorarg1 & D3DTA_ALPHAREPLICATE)
|
1362 | Â | - SendDlgItemMessage(hWnd,IDC_CARG1A,BM_SETCHECK,BST_CHECKED,0);
|
1363 | Â | - else SendDlgItemMessage(hWnd,IDC_CARG1A,BM_SETCHECK,BST_UNCHECKED,0);
|
1364 | Â | - if(texshaderstate.texstages[number].colorarg2 & D3DTA_ALPHAREPLICATE)
|
1365 | Â | - SendDlgItemMessage(hWnd,IDC_CARG2A,BM_SETCHECK,BST_CHECKED,0);
|
1366 | Â | - else SendDlgItemMessage(hWnd,IDC_CARG2A,BM_SETCHECK,BST_UNCHECKED,0);
|
1367 | Â | - if(texshaderstate.texstages[number].alphaarg1 & D3DTA_ALPHAREPLICATE)
|
1368 | Â | - SendDlgItemMessage(hWnd,IDC_AARG1A,BM_SETCHECK,BST_CHECKED,0);
|
1369 | Â | - else SendDlgItemMessage(hWnd,IDC_AARG1A,BM_SETCHECK,BST_UNCHECKED,0);
|
1370 | Â | - if(texshaderstate.texstages[number].alphaarg2 & D3DTA_ALPHAREPLICATE)
|
1371 | Â | - SendDlgItemMessage(hWnd,IDC_AARG2A,BM_SETCHECK,BST_CHECKED,0);
|
1372 | Â | - else SendDlgItemMessage(hWnd,IDC_AARG2A,BM_SETCHECK,BST_UNCHECKED,0);
|
1373 | Â | - if(texshaderstate.texstages[number].colorarg1 & D3DTA_COMPLEMENT)
|
1374 | Â | - SendDlgItemMessage(hWnd,IDC_CARG1INV,BM_SETCHECK,BST_CHECKED,0);
|
1375 | Â | - else SendDlgItemMessage(hWnd,IDC_CARG1INV,BM_SETCHECK,BST_UNCHECKED,0);
|
1376 | Â | - if(texshaderstate.texstages[number].colorarg2 & D3DTA_COMPLEMENT)
|
1377 | Â | - SendDlgItemMessage(hWnd,IDC_CARG2INV,BM_SETCHECK,BST_CHECKED,0);
|
1378 | Â | - else SendDlgItemMessage(hWnd,IDC_CARG2INV,BM_SETCHECK,BST_UNCHECKED,0);
|
1379 | Â | - if(texshaderstate.texstages[number].alphaarg1 & D3DTA_COMPLEMENT)
|
1380 | Â | - SendDlgItemMessage(hWnd,IDC_AARG1INV,BM_SETCHECK,BST_CHECKED,0);
|
1381 | Â | - else SendDlgItemMessage(hWnd,IDC_AARG1INV,BM_SETCHECK,BST_UNCHECKED,0);
|
1382 | Â | - if(texshaderstate.texstages[number].alphaarg2 & D3DTA_COMPLEMENT)
|
1383 | Â | - SendDlgItemMessage(hWnd,IDC_AARG2INV,BM_SETCHECK,BST_CHECKED,0);
|
1384 | Â | - else SendDlgItemMessage(hWnd,IDC_AARG2INV,BM_SETCHECK,BST_UNCHECKED,0);
|
1385 | Â | - SendDlgItemMessage(hWnd,IDC_COLOROP,CB_SETCURSEL,texshaderstate.texstages[number].colorop-1,0);
|
1386 | Â | - SendDlgItemMessage(hWnd,IDC_ALPHAOP,CB_SETCURSEL,texshaderstate.texstages[number].alphaop-1,0);
|
1387 | Â | - }
|
1388 | Â | - break;
|
1389 | Â | - case IDC_TEXTURE:
|
1390 | Â | - if(HIWORD(wParam) == CBN_SELCHANGE)
|
1391 | Â | - {
|
1392 | Â | - number = texshaderstate.currentstage;
|
1393 | Â | - texshaderstate.texstages[number].texturetype =
|
1394 | Â | - SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_GETCURSEL,0,0);
|
1395 | Â | - SelectTexture(&texshaderstate.texstages[number].texture,texshaderstate.texstages[number].texturetype,
|
1396 | Â | - texshaderstate.texstages[number].keycolor, texshaderstate.texstages[number].colorkey,
|
1397 | Â | - texshaderstate.texstages[number].texturefile);
|
1398 | Â | - }
|
1399 | Â | - break;
|
1400 | Â | - case IDC_TEXTUREFILE:
|
1401 | Â | - if(HIWORD(wParam) == EN_KILLFOCUS)
|
1402 | Â | - {
|
1403 | Â | - number = texshaderstate.currentstage;
|
1404 | Â | - SendDlgItemMessage(hWnd,IDC_TEXTUREFILE,WM_GETTEXT,MAX_PATH+1,
|
1405 | Â | - (LPARAM)texshaderstate.texstages[number].texturefile);
|
1406 | Â | - SelectTexture(&texshaderstate.texstages[number].texture,texshaderstate.texstages[number].texturetype,
|
1407 | Â | - texshaderstate.texstages[number].keycolor, texshaderstate.texstages[number].colorkey,
|
1408 | Â | - texshaderstate.texstages[number].texturefile);
|
1409 | Â | - }
|
1410 | Â | - break;
|
1411 | Â | - case IDC_CARG1:
|
1412 | Â | - if(HIWORD(wParam) == CBN_SELCHANGE)
|
1413 | Â | - {
|
1414 | Â | - number = texshaderstate.currentstage;
|
1415 | Â | - SetShaderArg(hWnd,IDC_CARG1,IDC_CARG1A,IDC_CARG1INV,&texshaderstate.texstages[number].colorarg1);
|
1416 | Â | - d3d7dev->SetTextureStageState(number,D3DTSS_COLORARG1,texshaderstate.texstages[number].colorarg1);
|
1417 | Â | - }
|
1418 | Â | - break;
|
1419 | Â | - case IDC_CARG1A:
|
1420 | Â | - case IDC_CARG1INV:
|
1421 | Â | - if(HIWORD(wParam) == BN_CLICKED)
|
1422 | Â | - {
|
1423 | Â | - number = texshaderstate.currentstage;
|
1424 | Â | - SetShaderArg(hWnd,IDC_CARG1,IDC_CARG1A,IDC_CARG1INV,&texshaderstate.texstages[number].colorarg2);
|
1425 | Â | - d3d7dev->SetTextureStageState(number,D3DTSS_COLORARG1,texshaderstate.texstages[number].colorarg2);
|
1426 | Â | - }
|
1427 | Â | - break;
|
1428 | Â | - case IDC_CARG2:
|
1429 | Â | - if(HIWORD(wParam) == CBN_SELCHANGE)
|
1430 | Â | - {
|
1431 | Â | - number = texshaderstate.currentstage;
|
1432 | Â | - SetShaderArg(hWnd,IDC_CARG2,IDC_CARG2A,IDC_CARG2INV,&texshaderstate.texstages[number].colorarg2);
|
1433 | Â | - d3d7dev->SetTextureStageState(number,D3DTSS_COLORARG2,texshaderstate.texstages[number].colorarg2);
|
1434 | Â | - }
|
1435 | Â | - break;
|
1436 | Â | - case IDC_CARG2A:
|
1437 | Â | - case IDC_CARG2INV:
|
1438 | Â | - if(HIWORD(wParam) == BN_CLICKED)
|
1439 | Â | - {
|
1440 | Â | - number = texshaderstate.currentstage;
|
1441 | Â | - SetShaderArg(hWnd,IDC_CARG2,IDC_CARG2A,IDC_CARG2INV,&texshaderstate.texstages[number].colorarg1);
|
1442 | Â | - d3d7dev->SetTextureStageState(number,D3DTSS_COLORARG2,texshaderstate.texstages[number].colorarg1);
|
1443 | Â | - }
|
1444 | Â | - break;
|
1445 | Â | - case IDC_AARG1:
|
1446 | Â | - if(HIWORD(wParam) == CBN_SELCHANGE)
|
1447 | Â | - {
|
1448 | Â | - number = texshaderstate.currentstage;
|
1449 | Â | - SetShaderArg(hWnd,IDC_AARG1,IDC_AARG1A,IDC_AARG1INV,&texshaderstate.texstages[number].alphaarg1);
|
1450 | Â | - d3d7dev->SetTextureStageState(number,D3DTSS_ALPHAARG1,texshaderstate.texstages[number].alphaarg1);
|
1451 | Â | - }
|
1452 | Â | - break;
|
1453 | Â | - case IDC_AARG1A:
|
1454 | Â | - case IDC_AARG1INV:
|
1455 | Â | - if(HIWORD(wParam) == BN_CLICKED)
|
1456 | Â | - {
|
1457 | Â | - number = texshaderstate.currentstage;
|
1458 | Â | - SetShaderArg(hWnd,IDC_AARG1,IDC_AARG1A,IDC_AARG1INV,&texshaderstate.texstages[number].alphaarg1);
|
1459 | Â | - d3d7dev->SetTextureStageState(number,D3DTSS_ALPHAARG1,texshaderstate.texstages[number].alphaarg1);
|
1460 | Â | - }
|
1461 | Â | - break;
|
1462 | Â | - case IDC_AARG2:
|
1463 | Â | - if(HIWORD(wParam) == CBN_SELCHANGE)
|
1464 | Â | - {
|
1465 | Â | - number = texshaderstate.currentstage;
|
1466 | Â | - SetShaderArg(hWnd,IDC_AARG2,IDC_AARG2A,IDC_AARG2INV,&texshaderstate.texstages[number].alphaarg2);
|
1467 | Â | - d3d7dev->SetTextureStageState(number,D3DTSS_ALPHAARG2,texshaderstate.texstages[number].alphaarg2);
|
1468 | Â | - }
|
1469 | Â | - break;
|
1470 | Â | - case IDC_AARG2A:
|
1471 | Â | - case IDC_AARG2INV:
|
1472 | Â | - if(HIWORD(wParam) == BN_CLICKED)
|
1473 | Â | - {
|
1474 | Â | - number = texshaderstate.currentstage;
|
1475 | Â | - SetShaderArg(hWnd,IDC_AARG2,IDC_AARG2A,IDC_AARG2INV,&texshaderstate.texstages[number].alphaarg2);
|
1476 | Â | - d3d7dev->SetTextureStageState(number,D3DTSS_ALPHAARG2,texshaderstate.texstages[number].alphaarg2);
|
1477 | Â | - }
|
1478 | Â | - break;
|
1479 | Â | - case IDC_COLOROP:
|
1480 | Â | - if(HIWORD(wParam) == CBN_SELCHANGE)
|
1481 | Â | - {
|
1482 | Â | - number = texshaderstate.currentstage;
|
1483 | Â | - texshaderstate.texstages[number].colorop = (D3DTEXTUREOP)(SendDlgItemMessage(hWnd,IDC_COLOROP,CB_GETCURSEL,0,0)+1);
|
1484 | Â | - d3d7dev->SetTextureStageState(number,D3DTSS_COLOROP,texshaderstate.texstages[number].colorop);
|
1485 | Â | - }
|
1486 | Â | - break;
|
1487 | Â | - case IDC_ALPHAOP:
|
1488 | Â | - if(HIWORD(wParam) == CBN_SELCHANGE)
|
1489 | Â | - {
|
1490 | Â | - number = texshaderstate.currentstage;
|
1491 | Â | - texshaderstate.texstages[number].alphaop = (D3DTEXTUREOP)(SendDlgItemMessage(hWnd,IDC_ALPHAOP,CB_GETCURSEL,0,0)+1);
|
1492 | Â | - d3d7dev->SetTextureStageState(number,D3DTSS_ALPHAOP,texshaderstate.texstages[number].alphaop);
|
1493 | Â | - }
|
1494 | Â | - break;
|
1495 | Â | - case IDC_BGCOLOR:
|
1496 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
1497 | Â | - {
|
1498 | Â | - SendDlgItemMessage(hWnd,IDC_BGCOLOR,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
1499 | Â | - if(!_stscanf(tmpstring,_T("%x"),&bgcolor)) bgcolor = 0;
|
1500 | Â | - }
|
1501 | Â | - break;
|
1502 | Â | - case IDC_DIFFUSE:
|
1503 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
1504 | Â | - {
|
1505 | Â | - SendDlgItemMessage(hWnd,IDC_DIFFUSE,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
1506 | Â | - if(!_stscanf(tmpstring,_T("%x"),&number)) number = 0;
|
1507 | Â | - SetVertexColor(litvertices,colorvertices,numpoints,number);
|
1508 | Â | - }
|
1509 | Â | - break;
|
1510 | Â | - case IDC_SPECULAR:
|
1511 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
1512 | Â | - {
|
1513 | Â | - SendDlgItemMessage(hWnd,IDC_SPECULAR,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
1514 | Â | - if(!_stscanf(tmpstring,_T("%x"),&number)) number = 0;
|
1515 | Â | - SetVertexSpecular(litvertices,colorvertices,numpoints,number);
|
1516 | Â | - }
|
1517 | Â | - break;
|
1518 | Â | - case IDC_FACTOR:
|
1519 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
1520 | Â | - {
|
1521 | Â | - SendDlgItemMessage(hWnd,IDC_FACTOR,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
1522 | Â | - if(!_stscanf(tmpstring,_T("%x"),&number)) number = 0;
|
1523 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_TEXTUREFACTOR,number);
|
1524 | Â | - }
|
1525 | Â | - break;
|
1526 | Â | - case IDC_FOGCOLOR:
|
1527 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
1528 | Â | - {
|
1529 | Â | - SendDlgItemMessage(hWnd,IDC_FOGCOLOR,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
1530 | Â | - if(!_stscanf(tmpstring,_T("%x"),&number)) number = 0;
|
1531 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_FOGCOLOR,number);
|
1532 | Â | - }
|
1533 | Â | - break;
|
1534 | Â | - case IDC_TEXCOLORKEY:
|
1535 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
1536 | Â | - {
|
1537 | Â | - SendDlgItemMessage(hWnd,IDC_TEXCOLORKEY,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
1538 | Â | - number = texshaderstate.currentstage;
|
1539 | Â | - if(tmpstring[0] == 0)
|
1540 | Â | - {
|
1541 | Â | - texshaderstate.texstages[number].colorkey = FALSE;
|
1542 | Â | - texshaderstate.texstages[number].keycolor = 0;
|
1543 | Â | - }
|
1544 | Â | - else
|
1545 | Â | - {
|
1546 | Â | - texshaderstate.texstages[number].colorkey = TRUE;
|
1547 | Â | - if(!_stscanf(tmpstring,_T("%x"),&texshaderstate.texstages[number].keycolor))
|
1548 | Â | - texshaderstate.texstages[number].keycolor = 0;
|
1549 | Â | - }
|
1550 | Â | - SelectTexture(&texshaderstate.texstages[number].texture,texshaderstate.texstages[number].texturetype,
|
1551 | Â | - texshaderstate.texstages[number].keycolor, texshaderstate.texstages[number].colorkey,
|
1552 | Â | - texshaderstate.texstages[number].texturefile);
|
1553 | Â | - }
|
1554 | Â | - case IDC_ALPHABLEND:
|
1555 | Â | - if(HIWORD(wParam) == BN_CLICKED)
|
1556 | Â | - {
|
1557 | Â | - if(SendDlgItemMessage(hWnd,IDC_ALPHABLEND,BM_GETCHECK,0,0) == BST_CHECKED)
|
1558 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE,TRUE);
|
1559 | Â | - else d3d7dev->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE,FALSE);
|
1560 | Â | - }
|
1561 | Â | - break;
|
1562 | Â | - case IDC_SRCBLEND:
|
1563 | Â | - if(HIWORD(wParam) == CBN_SELCHANGE)
|
1564 | Â | - {
|
1565 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_SRCBLEND,SendDlgItemMessage(hWnd,
|
1566 | Â | - IDC_SRCBLEND,CB_GETCURSEL,0,0)+1);
|
1567 | Â | - }
|
1568 | Â | - case IDC_DESTBLEND:
|
1569 | Â | - if(HIWORD(wParam) == CBN_SELCHANGE)
|
1570 | Â | - {
|
1571 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_DESTBLEND,SendDlgItemMessage(hWnd,
|
1572 | Â | - IDC_DESTBLEND,CB_GETCURSEL,0,0)+1);
|
1573 | Â | - }
|
1574 | Â | - break;
|
1575 | Â | - case IDC_ALPHATEST:
|
1576 | Â | - if(HIWORD(wParam) == BN_CLICKED)
|
1577 | Â | - {
|
1578 | Â | - if(SendDlgItemMessage(hWnd,IDC_ALPHATEST,BM_GETCHECK,0,0) == BST_CHECKED)
|
1579 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE,TRUE);
|
1580 | Â | - else d3d7dev->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE,FALSE);
|
1581 | Â | - }
|
1582 | Â | - case IDC_ALPHAFUNC:
|
1583 | Â | - if(HIWORD(wParam) == CBN_SELCHANGE)
|
1584 | Â | - {
|
1585 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_ALPHAFUNC,SendDlgItemMessage(hWnd,
|
1586 | Â | - IDC_ALPHAFUNC,CB_GETCURSEL,0,0)+1);
|
1587 | Â | - }
|
1588 | Â | - break;
|
1589 | Â | - case IDC_ALPHAREF:
|
1590 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
1591 | Â | - {
|
1592 | Â | - SendDlgItemMessage(hWnd,IDC_ALPHAREF,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
1593 | Â | - number = _ttoi(tmpstring);
|
1594 | Â | - if(number < 0) SendDlgItemMessage(hWnd,IDC_ALPHAREF,WM_SETTEXT,0,(LPARAM)_T("0"));
|
1595 | Â | - if(number > 255) SendDlgItemMessage(hWnd,IDC_ALPHAREF,WM_SETTEXT,0,(LPARAM)_T("255"));
|
1596 | Â | - if(number < 0) number = 0;
|
1597 | Â | - if(number > 255) number = 255;
|
1598 | Â | - if(d3d7dev) d3d7dev->SetRenderState(D3DRENDERSTATE_ALPHAREF,number);
|
1599 | Â | - }
|
1600 | Â | - case IDC_COLORKEY:
|
1601 | Â | - if(HIWORD(wParam) == BN_CLICKED)
|
1602 | Â | - {
|
1603 | Â | - if(SendDlgItemMessage(hWnd,IDC_COLORKEY,BM_GETCHECK,0,0) == BST_CHECKED)
|
1604 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE,TRUE);
|
1605 | Â | - else d3d7dev->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE,FALSE);
|
1606 | Â | - }
|
1607 | Â | - break;
|
1608 | Â | - case IDC_FOGENABLE:
|
1609 | Â | - if(HIWORD(wParam) == BN_CLICKED)
|
1610 | Â | - {
|
1611 | Â | - if(SendDlgItemMessage(hWnd,IDC_FOGENABLE,BM_GETCHECK,0,0) == BST_CHECKED)
|
1612 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_FOGENABLE,TRUE);
|
1613 | Â | - else d3d7dev->SetRenderState(D3DRENDERSTATE_FOGENABLE,FALSE);
|
1614 | Â | - }
|
1615 | Â | - break;
|
1616 | Â | - case IDC_VERTEXFOGMODE:
|
1617 | Â | - if(HIWORD(wParam) == CBN_SELCHANGE)
|
1618 | Â | - {
|
1619 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_FOGVERTEXMODE,SendDlgItemMessage(hWnd,
|
1620 | Â | - IDC_VERTEXFOGMODE,CB_GETCURSEL,0,0));
|
1621 | Â | - }
|
1622 | Â | - break;
|
1623 | Â | - case IDC_PIXELFOGMODE:
|
1624 | Â | - if(HIWORD(wParam) == CBN_SELCHANGE)
|
1625 | Â | - {
|
1626 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE,SendDlgItemMessage(hWnd,
|
1627 | Â | - IDC_PIXELFOGMODE,CB_GETCURSEL,0,0));
|
1628 | Â | - }
|
1629 | Â | - break;
|
1630 | Â | - case IDC_FOGSTART:
|
1631 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
1632 | Â | - {
|
1633 | Â | - SendDlgItemMessage(hWnd,IDC_FOGSTART,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
1634 | Â | - f = (float)_ttof(tmpstring);
|
1635 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_FOGSTART, *((LPDWORD)(&f)));
|
1636 | Â | - }
|
1637 | Â | - break;
|
1638 | Â | - case IDC_FOGEND:
|
1639 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
1640 | Â | - {
|
1641 | Â | - SendDlgItemMessage(hWnd,IDC_FOGEND,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
1642 | Â | - f = (float)_ttof(tmpstring);
|
1643 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_FOGEND, *((LPDWORD)(&f)));
|
1644 | Â | - }
|
1645 | Â | - break;
|
1646 | Â | - case IDC_FOGDENSITY:
|
1647 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
1648 | Â | - {
|
1649 | Â | - SendDlgItemMessage(hWnd,IDC_FOGDENSITY,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
1650 | Â | - f = (float)_ttof(tmpstring);
|
1651 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_FOGDENSITY, *((LPDWORD)(&f)));
|
1652 | Â | - }
|
1653 | Â | - break;
|
1654 | Â | - default:
|
1655 | Â | - return FALSE;
|
1656 | Â | - }
|
1657 | Â | - break;
|
1658 | Â | - case WM_CLOSE:
|
1659 | Â | - if(d3d7dev)
|
1660 | Â | - {
|
1661 | Â | - d3d7dev->Release();
|
1662 | Â | - d3d7dev = NULL;
|
1663 | Â | - }
|
1664 | Â | - if(d3d7)
|
1665 | Â | - {
|
1666 | Â | - d3d7->Release();
|
1667 | Â | - d3d7dev = NULL;
|
1668 | Â | - }
|
1669 | Â | - if(ddsrender)
|
1670 | Â | - {
|
1671 | Â | - ddsrender->Release();
|
1672 | Â | - ddsrender = NULL;
|
1673 | Â | - }
|
1674 | Â | - if(ddsurface)
|
1675 | Â | - {
|
1676 | Â | - ddsurface->Release();
|
1677 | Â | - ddsurface = NULL;
|
1678 | Â | - }
|
1679 | Â | - if(zbuffer)
|
1680 | Â | - {
|
1681 | Â | - zbuffer->Release();
|
1682 | Â | - zbuffer = NULL;
|
1683 | Â | - }
|
1684 | Â | - if(ddclipper)
|
1685 | Â | - {
|
1686 | Â | - ddclipper->Release();
|
1687 | Â | - ddclipper = NULL;
|
1688 | Â | - }
|
1689 | Â | - if(ddinterface)
|
1690 | Â | - {
|
1691 | Â | - ddinterface->Release();
|
1692 | Â | - ddinterface = NULL;
|
1693 | Â | - }
|
1694 | Â | - if(mesh)
|
1695 | Â | - {
|
1696 | Â | - free(mesh);
|
1697 | Â | - mesh = NULL;
|
1698 | Â | - }
|
1699 | Â | - if(vertices)
|
1700 | Â | - {
|
1701 | Â | - free(vertices);
|
1702 | Â | - vertices = NULL;
|
1703 | Â | - }
|
1704 | Â | - if(litvertices)
|
1705 | Â | - {
|
1706 | Â | - free(litvertices);
|
1707 | Â | - litvertices = NULL;
|
1708 | Â | - }
|
1709 | Â | - if(colorvertices)
|
1710 | Â | - {
|
1711 | Â | - free(colorvertices);
|
1712 | Â | - colorvertices = NULL;
|
1713 | Â | - }
|
1714 | Â | - EndDialog(hWnd,IDCANCEL);
|
1715 | Â | - break;
|
1716 | Â | - case WM_APP:
|
1717 | Â | - RunTestTimed3D(testnum);
|
1718 | Â | - break;
|
1719 | Â | - default:
|
1720 | Â | - return FALSE;
|
1721 | Â | - }
|
1722 | Â | - return TRUE;
|
1723 | Â | -
|
1724 | Â | -
|
1725 | Â | -}
|
1726 | Â | -
|
1727 | Â | -INT_PTR CALLBACK VertexShader7Proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
1728 | Â | -{
|
1729 | Â | - HRESULT error;
|
1730 | Â | - D3DVIEWPORT7 vp;
|
1731 | Â | - HWND hDisplay;
|
1732 | Â | - int number;
|
1733 | Â | - float f;
|
1734 | Â | - TCHAR tmpstring[MAX_PATH+1];
|
1735 | Â | - switch(Msg)
|
1736 | Â | - {
|
1737 | Â | - case WM_INITDIALOG:
|
1738 | Â | - RECT r;
|
1739 | Â | - DDSCAPS2 caps;
|
1740 | Â | - DDSURFACEDESC2 ddsd;
|
1741 | Â | - DDPIXELFORMAT ddpfz;
|
1742 | Â | - testnum = 3;
|
1743 | Â | - ddinterface = new MultiDirectDraw(7,&error,NULL);
|
1744 | Â | - hDisplay = GetDlgItem(hWnd,IDC_DISPLAY);
|
1745 | Â | - ::hWnd = hDisplay;
|
1746 | Â | - error = ddinterface->SetCooperativeLevel(hDisplay,DDSCL_NORMAL);
|
1747 | Â | - ZeroMemory(&ddsd,sizeof(DDSURFACEDESC2));
|
1748 | Â | - ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
1749 | Â | - ddsd.dwFlags = DDSD_CAPS;
|
1750 | Â | - ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
1751 | Â | - error = ddinterface->CreateSurface(&ddsd,&ddsurface,NULL);
|
1752 | Â | - error = ddinterface->CreateClipper(0,&ddclipper,NULL);
|
1753 | Â | - error = ddclipper->SetHWnd(0,hDisplay);
|
1754 | Â | - error = ddsurface->SetClipper(ddclipper);
|
1755 | Â | - ZeroMemory(&ddsd,sizeof(DDSURFACEDESC2));
|
1756 | Â | - ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
1757 | Â | - ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
1758 | Â | - ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN|DDSCAPS_3DDEVICE;
|
1759 | Â | - GetClientRect(hDisplay,&r);
|
1760 | Â | - ddsd.dwWidth = r.right;
|
1761 | Â | - ddsd.dwHeight = r.bottom;
|
1762 | Â | - error = ddinterface->CreateSurface(&ddsd,&ddsrender,NULL);
|
1763 | Â | - error = ddinterface->QueryInterface(IID_IDirect3D7,(VOID**)&d3d7);
|
1764 | Â | - error = d3d7->EnumZBufferFormats(IID_IDirect3DRGBDevice,zcallback,&ddpfz);
|
1765 | Â | - error = ddsrender->GetSurfaceDesc(&ddsd);
|
1766 | Â | - ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT;
|
1767 | Â | - ddsd.ddsCaps.dwCaps = DDSCAPS_ZBUFFER|DDSCAPS_VIDEOMEMORY;
|
1768 | Â | - memcpy(&ddsd.ddpfPixelFormat,&ddpfz,sizeof(DDPIXELFORMAT));
|
1769 | Â | - error = ddinterface->CreateSurface(&ddsd,&zbuffer,NULL);
|
1770 | Â | - error = ddsrender->AddAttachedSurface(zbuffer);
|
1771 | Â | - error = d3d7->CreateDevice(IID_IDirect3DHALDevice,(LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(),&d3d7dev);
|
1772 | Â | - if(error != D3D_OK)
|
1773 | Â | - error = d3d7->CreateDevice(IID_IDirect3DRGBDevice,(LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(),&d3d7dev);
|
1774 | Â | - ddsrender->GetSurfaceDesc(&ddsd);
|
1775 | Â | - vp.dvMaxZ = 1.0f;
|
1776 | Â | - vp.dvMinZ = 0.0f;
|
1777 | Â | - vp.dwX = vp.dwY = 0;
|
1778 | Â | - vp.dwWidth = ddsd.dwWidth;
|
1779 | Â | - vp.dwHeight = ddsd.dwHeight;
|
1780 | Â | - error = d3d7dev->SetViewport(&vp);
|
1781 | Â | - error = d3d7dev->SetRenderState(D3DRENDERSTATE_ZENABLE,TRUE);
|
1782 | Â | - InitTest3D(3);
|
1783 | Â | - SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_ADDSTRING,0,(LPARAM)_T("None"));
|
1784 | Â | - SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_ADDSTRING,0,(LPARAM)_T("Gradients"));
|
1785 | Â | - SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_ADDSTRING,0,(LPARAM)_T("DXGL logo (small)"));
|
1786 | Â | - SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_ADDSTRING,0,(LPARAM)_T("DXGL logo (large)"));
|
1787 | Â | - SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_ADDSTRING,0,(LPARAM)_T("Texture file"));
|
1788 | Â | - SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_SETCURSEL,0,0);
|
1789 | Â | - SendDlgItemMessage(hWnd,IDC_DIFFUSE,WM_SETTEXT,0,(LPARAM)_T("FFFFFFFF"));
|
1790 | Â | - SendDlgItemMessage(hWnd,IDC_SPECULAR,WM_SETTEXT,0,(LPARAM)_T("00000000"));
|
1791 | Â | - SendDlgItemMessage(hWnd,IDC_FACTOR,WM_SETTEXT,0,(LPARAM)_T("00000000"));
|
1792 | Â | - SendDlgItemMessage(hWnd,IDC_FOGCOLOR,WM_SETTEXT,0,(LPARAM)_T("00000000"));
|
1793 | Â | - SendDlgItemMessage(hWnd,IDC_BGCOLOR,WM_SETTEXT,0,(LPARAM)_T("00000000"));
|
1794 | Â | - SendDlgItemMessage(hWnd,IDC_AMBIENT,WM_SETTEXT,0,(LPARAM)_T("FFFFFFFF"));
|
1795 | Â | - SendDlgItemMessage(hWnd,IDC_EMISSIVE,WM_SETTEXT,0,(LPARAM)_T("00000000"));
|
1796 | Â | - SendDlgItemMessage(hWnd,IDC_MATAMBIENT,WM_SETTEXT,0,(LPARAM)_T("FFFFFFFF"));
|
1797 | Â | - SendDlgItemMessage(hWnd,IDC_MATDIFFUSE,WM_SETTEXT,0,(LPARAM)_T("FFFFFFFF"));
|
1798 | Â | - SendDlgItemMessage(hWnd,IDC_MATSPECULAR,WM_SETTEXT,0,(LPARAM)_T("00000000"));
|
1799 | Â | - PopulateFogCombo(GetDlgItem(hWnd,IDC_VERTEXFOGMODE));
|
1800 | Â | - PopulateFogCombo(GetDlgItem(hWnd,IDC_PIXELFOGMODE));
|
1801 | Â | - SendDlgItemMessage(hWnd,IDC_VERTEXFOGMODE,CB_SETCURSEL,D3DFOG_NONE,0);
|
1802 | Â | - SendDlgItemMessage(hWnd,IDC_PIXELFOGMODE,CB_SETCURSEL,D3DFOG_NONE,0);
|
1803 | Â | - SendDlgItemMessage(hWnd,IDC_FOGSTART,WM_SETTEXT,0,(LPARAM)_T("0.0"));
|
1804 | Â | - SendDlgItemMessage(hWnd,IDC_FOGEND,WM_SETTEXT,0,(LPARAM)_T("1.0"));
|
1805 | Â | - SendDlgItemMessage(hWnd,IDC_FOGDENSITY,WM_SETTEXT,0,(LPARAM)_T("1.0"));
|
1806 | Â | - SendDlgItemMessage(hWnd,IDC_FILLMODE,CB_ADDSTRING,0,(LPARAM)_T("Points"));
|
1807 | Â | - SendDlgItemMessage(hWnd,IDC_FILLMODE,CB_ADDSTRING,0,(LPARAM)_T("Wireframe"));
|
1808 | Â | - SendDlgItemMessage(hWnd,IDC_FILLMODE,CB_ADDSTRING,0,(LPARAM)_T("Solid"));
|
1809 | Â | - SendDlgItemMessage(hWnd,IDC_FILLMODE,CB_SETCURSEL,2,0);
|
1810 | Â | - SendDlgItemMessage(hWnd,IDC_SHADEMODE,CB_ADDSTRING,0,(LPARAM)_T("Flat"));
|
1811 | Â | - SendDlgItemMessage(hWnd,IDC_SHADEMODE,CB_ADDSTRING,0,(LPARAM)_T("Gouraud"));
|
1812 | Â | - SendDlgItemMessage(hWnd,IDC_SHADEMODE,CB_ADDSTRING,0,(LPARAM)_T("Phong"));
|
1813 | Â | - SendDlgItemMessage(hWnd,IDC_SHADEMODE,CB_SETCURSEL,1,0);
|
1814 | Â | - SendDlgItemMessage(hWnd,IDC_CULLMODE,CB_ADDSTRING,0,(LPARAM)_T("None"));
|
1815 | Â | - SendDlgItemMessage(hWnd,IDC_CULLMODE,CB_ADDSTRING,0,(LPARAM)_T("CW"));
|
1816 | Â | - SendDlgItemMessage(hWnd,IDC_CULLMODE,CB_ADDSTRING,0,(LPARAM)_T("CCW"));
|
1817 | Â | - SendDlgItemMessage(hWnd,IDC_CULLMODE,CB_SETCURSEL,2,0);
|
1818 | Â | - SendDlgItemMessage(hWnd,IDC_VERTEXCOLOR,BM_SETCHECK,BST_CHECKED,0);
|
1819 | Â | - PopulateSourceCombo(GetDlgItem(hWnd,IDC_DIFFUSESOURCE));
|
1820 | Â | - PopulateSourceCombo(GetDlgItem(hWnd,IDC_SPECULARSOURCE));
|
1821 | Â | - PopulateSourceCombo(GetDlgItem(hWnd,IDC_AMBIENTSOURCE));
|
1822 | Â | - PopulateSourceCombo(GetDlgItem(hWnd,IDC_EMISSIVESOURCE));
|
1823 | Â | - SendDlgItemMessage(hWnd,IDC_DIFFUSESOURCE,CB_SETCURSEL,D3DMCS_COLOR1,0);
|
1824 | Â | - SendDlgItemMessage(hWnd,IDC_SPECULARSOURCE,CB_SETCURSEL,D3DMCS_COLOR2,0);
|
1825 | Â | - SendDlgItemMessage(hWnd,IDC_AMBIENTSOURCE,CB_SETCURSEL,D3DMCS_MATERIAL,0);
|
1826 | Â | - SendDlgItemMessage(hWnd,IDC_EMISSIVESOURCE,CB_SETCURSEL,D3DMCS_MATERIAL,0);
|
1827 | Â | - SendDlgItemMessage(hWnd,IDC_SPINDETAIL,UDM_SETRANGE32,2,64);
|
1828 | Â | - SendDlgItemMessage(hWnd,IDC_SPINDETAIL,UDM_SETPOS32,0,8);
|
1829 | Â | - SendDlgItemMessage(hWnd,IDC_SPINLIGHT,UDM_SETRANGE32,0,7);
|
1830 | Â | - SendDlgItemMessage(hWnd,IDC_LIGHTDIFFUSE,WM_SETTEXT,0,(LPARAM)_T("00FFFFFF"));
|
1831 | Â | - SendDlgItemMessage(hWnd,IDC_LIGHTAMBIENT,WM_SETTEXT,0,(LPARAM)_T("00000000"));
|
1832 | Â | - SendDlgItemMessage(hWnd,IDC_LIGHTSPECULAR,WM_SETTEXT,0,(LPARAM)_T("00000000"));
|
1833 | Â | - SendDlgItemMessage(hWnd,IDC_LIGHTRANGE,WM_SETTEXT,0,(LPARAM)_T("0"));
|
1834 | Â | - SendDlgItemMessage(hWnd,IDC_LIGHTFALLOFF,WM_SETTEXT,0,(LPARAM)_T("0"));
|
1835 | Â | - SendDlgItemMessage(hWnd,IDC_LIGHTTHETA,WM_SETTEXT,0,(LPARAM)_T("0"));
|
1836 | Â | - SendDlgItemMessage(hWnd,IDC_LIGHTPHI,WM_SETTEXT,0,(LPARAM)_T("0"));
|
1837 | Â | - SendDlgItemMessage(hWnd,IDC_LIGHTATTEN0,WM_SETTEXT,0,(LPARAM)_T("0"));
|
1838 | Â | - SendDlgItemMessage(hWnd,IDC_LIGHTATTEN1,WM_SETTEXT,0,(LPARAM)_T("0"));
|
1839 | Â | - SendDlgItemMessage(hWnd,IDC_LIGHTATTEN2,WM_SETTEXT,0,(LPARAM)_T("0"));
|
1840 | Â | - SendDlgItemMessage(hWnd,IDC_POWER,WM_SETTEXT,0,(LPARAM)_T("0"));
|
1841 | Â | - SendDlgItemMessage(hWnd,IDC_LIGHTTYPE,CB_ADDSTRING,0,(LPARAM)_T("Point"));
|
1842 | Â | - SendDlgItemMessage(hWnd,IDC_LIGHTTYPE,CB_ADDSTRING,0,(LPARAM)_T("Spot"));
|
1843 | Â | - SendDlgItemMessage(hWnd,IDC_LIGHTTYPE,CB_ADDSTRING,0,(LPARAM)_T("Directional"));
|
1844 | Â | - SendDlgItemMessage(hWnd,IDC_LIGHTTYPE,CB_ADDSTRING,0,(LPARAM)_T("Parallel Point"));
|
1845 | Â | - SendDlgItemMessage(hWnd,IDC_LIGHTTYPE,CB_ADDSTRING,0,(LPARAM)_T("GL Spot"));
|
1846 | Â | - SendDlgItemMessage(hWnd,IDC_LIGHTTYPE,CB_SETCURSEL,D3DLIGHT_DIRECTIONAL-1,0);
|
1847 | Â | - SendDlgItemMessage(hWnd,IDC_LIGHTENABLED,BM_SETCHECK,BST_CHECKED,0);
|
1848 | Â | - ::width = ddsd.dwWidth;
|
1849 | Â | - ::height = ddsd.dwHeight;
|
1850 | Â | - vertexshaderstate.texture = NULL;
|
1851 | Â | - vertexshaderstate.texturefile[0] = 0;
|
1852 | Â | - vertexshaderstate.texturetype = 0;
|
1853 | Â | - vertexshaderstate.currentlight = 0;
|
1854 | Â | - StartTimer(hWnd,WM_APP,60);
|
1855 | Â | - break;
|
1856 | Â | - case WM_COMMAND:
|
1857 | Â | - switch(LOWORD(wParam))
|
1858 | Â | - {
|
1859 | Â | - case IDC_TEXTURE:
|
1860 | Â | - if(HIWORD(wParam) == CBN_SELCHANGE)
|
1861 | Â | - {
|
1862 | Â | - number = texshaderstate.currentstage;
|
1863 | Â | - vertexshaderstate.texturetype =
|
1864 | Â | - SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_GETCURSEL,0,0);
|
1865 | Â | - SelectTexture(&vertexshaderstate.texture,vertexshaderstate.texturetype,
|
1866 | Â | - 0, FALSE,vertexshaderstate.texturefile);
|
1867 | Â | - if((vertexshaderstate.texturetype == 2) || (vertexshaderstate.texturetype == 3))
|
1868 | Â | - d3d7dev->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_BLENDTEXTUREALPHAPM);
|
1869 | Â | - else d3d7dev->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE);
|
1870 | Â | - }
|
1871 | Â | - break;
|
1872 | Â | - case IDC_TEXTUREFILE:
|
1873 | Â | - if(HIWORD(wParam) == EN_KILLFOCUS)
|
1874 | Â | - {
|
1875 | Â | - number = texshaderstate.currentstage;
|
1876 | Â | - SendDlgItemMessage(hWnd,IDC_TEXTUREFILE,WM_GETTEXT,MAX_PATH+1,
|
1877 | Â | - (LPARAM)vertexshaderstate.texturefile);
|
1878 | Â | - SelectTexture(&vertexshaderstate.texture,vertexshaderstate.texturetype,
|
1879 | Â | - 0, FALSE,vertexshaderstate.texturefile);
|
1880 | Â | - }
|
1881 | Â | - break;
|
1882 | Â | - case IDC_FOGENABLE:
|
1883 | Â | - if(HIWORD(wParam) == BN_CLICKED)
|
1884 | Â | - {
|
1885 | Â | - if(SendDlgItemMessage(hWnd,IDC_FOGENABLE,BM_GETCHECK,0,0) == BST_CHECKED)
|
1886 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_FOGENABLE,TRUE);
|
1887 | Â | - else d3d7dev->SetRenderState(D3DRENDERSTATE_FOGENABLE,FALSE);
|
1888 | Â | - }
|
1889 | Â | - break;
|
1890 | Â | - case IDC_VERTEXFOGMODE:
|
1891 | Â | - if(HIWORD(wParam) == CBN_SELCHANGE)
|
1892 | Â | - {
|
1893 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_FOGVERTEXMODE,SendDlgItemMessage(hWnd,
|
1894 | Â | - IDC_VERTEXFOGMODE,CB_GETCURSEL,0,0));
|
1895 | Â | - }
|
1896 | Â | - break;
|
1897 | Â | - case IDC_PIXELFOGMODE:
|
1898 | Â | - if(HIWORD(wParam) == CBN_SELCHANGE)
|
1899 | Â | - {
|
1900 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE,SendDlgItemMessage(hWnd,
|
1901 | Â | - IDC_PIXELFOGMODE,CB_GETCURSEL,0,0));
|
1902 | Â | - }
|
1903 | Â | - break;
|
1904 | Â | - case IDC_FOGSTART:
|
1905 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
1906 | Â | - {
|
1907 | Â | - SendDlgItemMessage(hWnd,IDC_FOGSTART,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
1908 | Â | - f = (float)_ttof(tmpstring);
|
1909 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_FOGSTART, *((LPDWORD)(&f)));
|
1910 | Â | - }
|
1911 | Â | - break;
|
1912 | Â | - case IDC_FOGEND:
|
1913 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
1914 | Â | - {
|
1915 | Â | - SendDlgItemMessage(hWnd,IDC_FOGEND,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
1916 | Â | - f = (float)_ttof(tmpstring);
|
1917 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_FOGEND, *((LPDWORD)(&f)));
|
1918 | Â | - }
|
1919 | Â | - break;
|
1920 | Â | - case IDC_FOGDENSITY:
|
1921 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
1922 | Â | - {
|
1923 | Â | - SendDlgItemMessage(hWnd,IDC_FOGDENSITY,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
1924 | Â | - f = (float)_ttof(tmpstring);
|
1925 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_FOGDENSITY, *((LPDWORD)(&f)));
|
1926 | Â | - }
|
1927 | Â | - break;
|
1928 | Â | - case IDC_RANGEBASEDFOG:
|
1929 | Â | - if(HIWORD(wParam) == BN_CLICKED)
|
1930 | Â | - {
|
1931 | Â | - if(SendDlgItemMessage(hWnd,IDC_RANGEBASEDFOG,BM_GETCHECK,0,0) == BST_CHECKED)
|
1932 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_RANGEFOGENABLE,TRUE);
|
1933 | Â | - else d3d7dev->SetRenderState(D3DRENDERSTATE_RANGEFOGENABLE,FALSE);
|
1934 | Â | - }
|
1935 | Â | - break;
|
1936 | Â | - case IDC_FILLMODE:
|
1937 | Â | - if(HIWORD(wParam) == CBN_SELCHANGE)
|
1938 | Â | - {
|
1939 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_FILLMODE,SendDlgItemMessage(hWnd,
|
1940 | Â | - IDC_FILLMODE,CB_GETCURSEL,0,0)+1);
|
1941 | Â | - }
|
1942 | Â | - break;
|
1943 | Â | - case IDC_SHADEMODE:
|
1944 | Â | - if(HIWORD(wParam) == CBN_SELCHANGE)
|
1945 | Â | - {
|
1946 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_SHADEMODE,SendDlgItemMessage(hWnd,
|
1947 | Â | - IDC_SHADEMODE,CB_GETCURSEL,0,0)+1);
|
1948 | Â | - }
|
1949 | Â | - break;
|
1950 | Â | - case IDC_CULLMODE:
|
1951 | Â | - if(HIWORD(wParam) == CBN_SELCHANGE)
|
1952 | Â | - {
|
1953 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_CULLMODE,SendDlgItemMessage(hWnd,
|
1954 | Â | - IDC_CULLMODE,CB_GETCURSEL,0,0)+1);
|
1955 | Â | - }
|
1956 | Â | - break;
|
1957 | Â | - case IDC_DIFFUSE:
|
1958 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
1959 | Â | - {
|
1960 | Â | - SendDlgItemMessage(hWnd,IDC_DIFFUSE,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
1961 | Â | - if(!_stscanf(tmpstring,_T("%x"),&number)) number = 0;
|
1962 | Â | - SetVertexColor(litvertices,colorvertices,numpoints,number);
|
1963 | Â | - }
|
1964 | Â | - break;
|
1965 | Â | - case IDC_SPECULAR:
|
1966 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
1967 | Â | - {
|
1968 | Â | - SendDlgItemMessage(hWnd,IDC_SPECULAR,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
1969 | Â | - if(!_stscanf(tmpstring,_T("%x"),&number)) number = 0;
|
1970 | Â | - SetVertexSpecular(litvertices,colorvertices,numpoints,number);
|
1971 | Â | - }
|
1972 | Â | - break;
|
1973 | Â | - case IDC_FACTOR:
|
1974 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
1975 | Â | - {
|
1976 | Â | - SendDlgItemMessage(hWnd,IDC_FACTOR,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
1977 | Â | - if(!_stscanf(tmpstring,_T("%x"),&number)) number = 0;
|
1978 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_TEXTUREFACTOR,number);
|
1979 | Â | - }
|
1980 | Â | - break;
|
1981 | Â | - case IDC_FOGCOLOR:
|
1982 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
1983 | Â | - {
|
1984 | Â | - SendDlgItemMessage(hWnd,IDC_FOGCOLOR,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
1985 | Â | - if(!_stscanf(tmpstring,_T("%x"),&number)) number = 0;
|
1986 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_FOGCOLOR,number);
|
1987 | Â | - }
|
1988 | Â | - break;
|
1989 | Â | - case IDC_BGCOLOR:
|
1990 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
1991 | Â | - {
|
1992 | Â | - SendDlgItemMessage(hWnd,IDC_BGCOLOR,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
1993 | Â | - if(!_stscanf(tmpstring,_T("%x"),&bgcolor)) bgcolor = 0;
|
1994 | Â | - }
|
1995 | Â | - break;
|
1996 | Â | - case IDC_AMBIENT:
|
1997 | Â | - {
|
1998 | Â | - SendDlgItemMessage(hWnd,IDC_AMBIENT,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
1999 | Â | - if(!_stscanf(tmpstring,_T("%x"),&number)) number = 0;
|
2000 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_AMBIENT,number);
|
2001 | Â | - }
|
2002 | Â | - break;
|
2003 | Â | - case IDC_EMISSIVE:
|
2004 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
2005 | Â | - {
|
2006 | Â | - SendDlgItemMessage(hWnd,IDC_EMISSIVE,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
2007 | Â | - if(!_stscanf(tmpstring,_T("%x"),&number)) number = 0;
|
2008 | Â | - material.emissive.b = (float)(number & 255) / 255.0;
|
2009 | Â | - material.emissive.g = (float)((number>>8) & 255) / 255.0;
|
2010 | Â | - material.emissive.r = (float)((number>>16) & 255) / 255.0;
|
2011 | Â | - material.emissive.a = (float)((number>>24) & 255) / 255.0;
|
2012 | Â | - d3d7dev->SetMaterial(&material);
|
2013 | Â | - }
|
2014 | Â | - break;
|
2015 | Â | - case IDC_MATAMBIENT:
|
2016 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
2017 | Â | - {
|
2018 | Â | - SendDlgItemMessage(hWnd,IDC_MATAMBIENT,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
2019 | Â | - if(!_stscanf(tmpstring,_T("%x"),&number)) number = 0;
|
2020 | Â | - material.ambient.b = (float)(number & 255) / 255.0;
|
2021 | Â | - material.ambient.g = (float)((number>>8) & 255) / 255.0;
|
2022 | Â | - material.ambient.r = (float)((number>>16) & 255) / 255.0;
|
2023 | Â | - material.ambient.a = (float)((number>>24) & 255) / 255.0;
|
2024 | Â | - d3d7dev->SetMaterial(&material);
|
2025 | Â | - }
|
2026 | Â | - break;
|
2027 | Â | - case IDC_MATDIFFUSE:
|
2028 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
2029 | Â | - {
|
2030 | Â | - SendDlgItemMessage(hWnd,IDC_MATDIFFUSE,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
2031 | Â | - if(!_stscanf(tmpstring,_T("%x"),&number)) number = 0;
|
2032 | Â | - material.diffuse.b = (float)(number & 255) / 255.0;
|
2033 | Â | - material.diffuse.g = (float)((number>>8) & 255) / 255.0;
|
2034 | Â | - material.diffuse.r = (float)((number>>16) & 255) / 255.0;
|
2035 | Â | - material.diffuse.a = (float)((number>>24) & 255) / 255.0;
|
2036 | Â | - d3d7dev->SetMaterial(&material);
|
2037 | Â | - }
|
2038 | Â | - break;
|
2039 | Â | - case IDC_MATSPECULAR:
|
2040 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
2041 | Â | - {
|
2042 | Â | - SendDlgItemMessage(hWnd,IDC_MATSPECULAR,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
2043 | Â | - if(!_stscanf(tmpstring,_T("%x"),&number)) number = 0;
|
2044 | Â | - material.specular.b = (float)(number & 255) / 255.0;
|
2045 | Â | - material.specular.g = (float)((number>>8) & 255) / 255.0;
|
2046 | Â | - material.specular.r = (float)((number>>16) & 255) / 255.0;
|
2047 | Â | - material.specular.a = (float)((number>>24) & 255) / 255.0;
|
2048 | Â | - d3d7dev->SetMaterial(&material);
|
2049 | Â | - }
|
2050 | Â | - break;
|
2051 | Â | - case IDC_POWER:
|
2052 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
2053 | Â | - {
|
2054 | Â | - SendDlgItemMessage(hWnd,IDC_POWER,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
2055 | Â | - material.power = (float)_ttof(tmpstring);
|
2056 | Â | - d3d7dev->SetMaterial(&material);
|
2057 | Â | - }
|
2058 | Â | - break;
|
2059 | Â | - case IDC_ENABLELIGHT:
|
2060 | Â | - if(HIWORD(wParam) == BN_CLICKED)
|
2061 | Â | - {
|
2062 | Â | - if(SendDlgItemMessage(hWnd,IDC_ENABLELIGHT,BM_GETCHECK,0,0) == BST_CHECKED)
|
2063 | Â | - {
|
2064 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_LIGHTING,TRUE);
|
2065 | Â | - for(int i = 0; i < 8; i++)
|
2066 | Â | - {
|
2067 | Â | - d3d7dev->SetLight(i,&lights[i]);
|
2068 | Â | - d3d7dev->LightEnable(i,lightenable[i]);
|
2069 | Â | - }
|
2070 | Â | - }
|
2071 | Â | - else d3d7dev->SetRenderState(D3DRENDERSTATE_LIGHTING,FALSE);
|
2072 | Â | - }
|
2073 | Â | - break;
|
2074 | Â | - case IDC_VERTEXCOLOR:
|
2075 | Â | - if(HIWORD(wParam) == BN_CLICKED)
|
2076 | Â | - {
|
2077 | Â | - if(SendDlgItemMessage(hWnd,IDC_VERTEXCOLOR,BM_GETCHECK,0,0) == BST_CHECKED)
|
2078 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_COLORVERTEX,TRUE);
|
2079 | Â | - else d3d7dev->SetRenderState(D3DRENDERSTATE_COLORVERTEX,FALSE);
|
2080 | Â | - }
|
2081 | Â | - break;
|
2082 | Â | - case IDC_DETAIL:
|
2083 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
2084 | Â | - {
|
2085 | Â | - SendDlgItemMessage(hWnd,IDC_DETAIL,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
2086 | Â | - number = _ttoi(tmpstring);
|
2087 | Â | - if(number < 2) SendDlgItemMessage(hWnd,IDC_DETAIL,WM_SETTEXT,0,(LPARAM)_T("2"));
|
2088 | Â | - if(number > 64) SendDlgItemMessage(hWnd,IDC_DETAIL,WM_SETTEXT,0,(LPARAM)_T("64"));
|
2089 | Â | - MakeCube3D(5,number);
|
2090 | Â | - }
|
2091 | Â | - break;
|
2092 | Â | - case IDC_DIFFUSESOURCE:
|
2093 | Â | - if(HIWORD(wParam) == CBN_SELCHANGE)
|
2094 | Â | - {
|
2095 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_DIFFUSEMATERIALSOURCE,SendDlgItemMessage(hWnd,
|
2096 | Â | - IDC_DIFFUSESOURCE,CB_GETCURSEL,0,0));
|
2097 | Â | - }
|
2098 | Â | - break;
|
2099 | Â | - case IDC_SPECULARSOURCE:
|
2100 | Â | - if(HIWORD(wParam) == CBN_SELCHANGE)
|
2101 | Â | - {
|
2102 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_SPECULARMATERIALSOURCE,SendDlgItemMessage(hWnd,
|
2103 | Â | - IDC_SPECULARSOURCE,CB_GETCURSEL,0,0));
|
2104 | Â | - }
|
2105 | Â | - break;
|
2106 | Â | - case IDC_AMBIENTSOURCE:
|
2107 | Â | - if(HIWORD(wParam) == CBN_SELCHANGE)
|
2108 | Â | - {
|
2109 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_AMBIENTMATERIALSOURCE,SendDlgItemMessage(hWnd,
|
2110 | Â | - IDC_AMBIENTSOURCE,CB_GETCURSEL,0,0));
|
2111 | Â | - }
|
2112 | Â | - break;
|
2113 | Â | - case IDC_EMISSIVESOURCE:
|
2114 | Â | - if(HIWORD(wParam) == CBN_SELCHANGE)
|
2115 | Â | - {
|
2116 | Â | - d3d7dev->SetRenderState(D3DRENDERSTATE_EMISSIVEMATERIALSOURCE,SendDlgItemMessage(hWnd,
|
2117 | Â | - IDC_EMISSIVESOURCE,CB_GETCURSEL,0,0));
|
2118 | Â | - }
|
2119 | Â | - break;
|
2120 | Â | - case IDC_LIGHTNUMBER:
|
2121 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
2122 | Â | - {
|
2123 | Â | - SendDlgItemMessage(hWnd,IDC_LIGHTNUMBER,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
2124 | Â | - number = _ttoi(tmpstring);
|
2125 | Â | - if(number < 0) SendDlgItemMessage(hWnd,IDC_LIGHTNUMBER,WM_SETTEXT,0,(LPARAM)_T("0"));
|
2126 | Â | - if(number > 7) SendDlgItemMessage(hWnd,IDC_LIGHTNUMBER,WM_SETTEXT,0,(LPARAM)_T("7"));
|
2127 | Â | - vertexshaderstate.currentlight = number;
|
2128 | Â | - _itot(hexlightcolor[vertexshaderstate.currentlight].ambient,tmpstring,16);
|
2129 | Â | - strupper(tmpstring); paddwordzeroes(tmpstring);
|
2130 | Â | - SendDlgItemMessage(hWnd,IDC_LIGHTAMBIENT,WM_SETTEXT,0,(LPARAM)tmpstring);
|
2131 | Â | - _itot(hexlightcolor[vertexshaderstate.currentlight].diffuse,tmpstring,16);
|
2132 | Â | - strupper(tmpstring); paddwordzeroes(tmpstring);
|
2133 | Â | - SendDlgItemMessage(hWnd,IDC_LIGHTDIFFUSE,WM_SETTEXT,0,(LPARAM)tmpstring);
|
2134 | Â | - _itot(hexlightcolor[vertexshaderstate.currentlight].specular,tmpstring,16);
|
2135 | Â | - strupper(tmpstring); paddwordzeroes(tmpstring);
|
2136 | Â | - SendDlgItemMessage(hWnd,IDC_LIGHTSPECULAR,WM_SETTEXT,0,(LPARAM)tmpstring);
|
2137 | Â | - SendDlgItemMessage(hWnd,IDC_LIGHTTYPE,CB_SETCURSEL,lights[vertexshaderstate.currentlight].dltType-1,0);
|
2138 | Â | - if(lightenable[vertexshaderstate.currentlight])
|
2139 | Â | - SendDlgItemMessage(hWnd,IDC_LIGHTENABLED,BM_SETCHECK,BST_CHECKED,0);
|
2140 | Â | - else SendDlgItemMessage(hWnd,IDC_LIGHTENABLED,BM_SETCHECK,BST_UNCHECKED,0);
|
2141 | Â | - }
|
2142 | Â | - break;
|
2143 | Â | - case IDC_LIGHTENABLED:
|
2144 | Â | - if(HIWORD(wParam) == BN_CLICKED)
|
2145 | Â | - {
|
2146 | Â | - if(SendDlgItemMessage(hWnd,IDC_LIGHTENABLED,BM_GETCHECK,0,0) == BST_CHECKED)
|
2147 | Â | - {
|
2148 | Â | - lightenable[vertexshaderstate.currentlight] = TRUE;
|
2149 | Â | - d3d7dev->LightEnable(vertexshaderstate.currentlight,TRUE);
|
2150 | Â | - }
|
2151 | Â | - else
|
2152 | Â | - {
|
2153 | Â | - lightenable[vertexshaderstate.currentlight] = FALSE;
|
2154 | Â | - d3d7dev->LightEnable(vertexshaderstate.currentlight,FALSE);
|
2155 | Â | - }
|
2156 | Â | - }
|
2157 | Â | - break;
|
2158 | Â | - case IDC_LIGHTTYPE:
|
2159 | Â | - if(HIWORD(wParam) == CBN_SELCHANGE)
|
2160 | Â | - {
|
2161 | Â | - lights[vertexshaderstate.currentlight].dltType = (D3DLIGHTTYPE)
|
2162 | Â | - (SendDlgItemMessage(hWnd,IDC_LIGHTTYPE,CB_GETCURSEL,0,0) + 1);
|
2163 | Â | - d3d7dev->SetLight(vertexshaderstate.currentlight,&lights[vertexshaderstate.currentlight]);
|
2164 | Â | - }
|
2165 | Â | - break;
|
2166 | Â | - case IDC_LIGHTRANGE:
|
2167 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
2168 | Â | - {
|
2169 | Â | - SendDlgItemMessage(hWnd,IDC_LIGHTRANGE,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
2170 | Â | - lights[vertexshaderstate.currentlight].dvRange = (float)_ttof(tmpstring);
|
2171 | Â | - d3d7dev->SetLight(vertexshaderstate.currentlight,&lights[vertexshaderstate.currentlight]);
|
2172 | Â | - }
|
2173 | Â | - break;
|
2174 | Â | - default:
|
2175 | Â | - return FALSE;
|
2176 | Â | - }
|
2177 | Â | - break;
|
2178 | Â | - case WM_CLOSE:
|
2179 | Â | - if(d3d7dev)
|
2180 | Â | - {
|
2181 | Â | - d3d7dev->Release();
|
2182 | Â | - d3d7dev = NULL;
|
2183 | Â | - }
|
2184 | Â | - if(d3d7)
|
2185 | Â | - {
|
2186 | Â | - d3d7->Release();
|
2187 | Â | - d3d7dev = NULL;
|
2188 | Â | - }
|
2189 | Â | - if(ddsrender)
|
2190 | Â | - {
|
2191 | Â | - ddsrender->Release();
|
2192 | Â | - ddsrender = NULL;
|
2193 | Â | - }
|
2194 | Â | - if(ddsurface)
|
2195 | Â | - {
|
2196 | Â | - ddsurface->Release();
|
2197 | Â | - ddsurface = NULL;
|
2198 | Â | - }
|
2199 | Â | - if(zbuffer)
|
2200 | Â | - {
|
2201 | Â | - zbuffer->Release();
|
2202 | Â | - zbuffer = NULL;
|
2203 | Â | - }
|
2204 | Â | - if(ddclipper)
|
2205 | Â | - {
|
2206 | Â | - ddclipper->Release();
|
2207 | Â | - ddclipper = NULL;
|
2208 | Â | - }
|
2209 | Â | - if(ddinterface)
|
2210 | Â | - {
|
2211 | Â | - ddinterface->Release();
|
2212 | Â | - ddinterface = NULL;
|
2213 | Â | - }
|
2214 | Â | - if(mesh)
|
2215 | Â | - {
|
2216 | Â | - free(mesh);
|
2217 | Â | - mesh = NULL;
|
2218 | Â | - }
|
2219 | Â | - if(vertices)
|
2220 | Â | - {
|
2221 | Â | - free(vertices);
|
2222 | Â | - vertices = NULL;
|
2223 | Â | - }
|
2224 | Â | - if(litvertices)
|
2225 | Â | - {
|
2226 | Â | - free(litvertices);
|
2227 | Â | - litvertices = NULL;
|
2228 | Â | - }
|
2229 | Â | - if(colorvertices)
|
2230 | Â | - {
|
2231 | Â | - free(colorvertices);
|
2232 | Â | - colorvertices = NULL;
|
2233 | Â | - }
|
2234 | Â | - EndDialog(hWnd,IDCANCEL);
|
2235 | Â | - break;
|
2236 | Â | - case WM_APP:
|
2237 | Â | - RunTestTimed3D(testnum);
|
2238 | Â | - break;
|
2239 | Â | - default:
|
2240 | Â | - return FALSE;
|
2241 | Â | - }
|
2242 | Â | - return TRUE;
|
2243 | Â | -}
|
Index: dxgltest/Tests2D.cpp |
— | — | @@ -1,1193 +0,0 @@ |
2 | Â | -// DXGL
|
3 | Â | -// Copyright (C) 2011 William Feely
|
4 | Â | -
|
5 | Â | -// This library is free software; you can redistribute it and/or
|
6 | Â | -// modify it under the terms of the GNU Lesser General Public
|
7 | Â | -// License as published by the Free Software Foundation; either
|
8 | Â | -// version 2.1 of the License, or (at your option) any later version.
|
9 | Â | -
|
10 | Â | -// This library is distributed in the hope that it will be useful,
|
11 | Â | -// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 | Â | -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13 | Â | -// Lesser General Public License for more details.
|
14 | Â | -
|
15 | Â | -// You should have received a copy of the GNU Lesser General Public
|
16 | Â | -// License along with this library; if not, write to the Free Software
|
17 | Â | -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18 | Â | -
|
19 | Â | -#include "common.h"
|
20 | Â | -#include "MultiDD.h"
|
21 | Â | -#include "tests.h"
|
22 | Â | -#include "surfacegen.h"
|
23 | Â | -#include "timer.h"
|
24 | Â | -#include "misc.h"
|
25 | Â | -
|
26 | Â | -void InitTest2D(int test);
|
27 | Â | -void RunTestTimed2D(int test);
|
28 | Â | -void RunTestLooped2D(int test);
|
29 | Â | -void RunTestMouse2D(int test, UINT Msg, WPARAM wParam, LPARAM lParam);
|
30 | Â | -
|
31 | Â | -
|
32 | Â | -static MultiDirectDraw *ddinterface;
|
33 | Â | -static MultiDirectDrawSurface *ddsurface;
|
34 | Â | -static MultiDirectDrawSurface *ddsrender;
|
35 | Â | -static IDirectDrawPalette *pal;
|
36 | Â | -static LPDIRECTDRAWCLIPPER ddclipper;
|
37 | Â | -static int width,height,bpp,refresh,backbuffers;
|
38 | Â | -static double fps;
|
39 | Â | -static bool fullscreen,resizable;
|
40 | Â | -static HWND hWnd;
|
41 | Â | -static int testnum;
|
42 | Â | -static unsigned int randnum;
|
43 | Â | -static int testtypes[] = {0,1,0,1,0,1,2,0,2,1};
|
44 | Â | -static DWORD counter;
|
45 | Â | -
|
46 | Â | -static DDSPRITE sprites[16];
|
47 | Â | -
|
48 | Â | -LRESULT CALLBACK DDWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
49 | Â | -{
|
50 | Â | - bool paintwnd = true;
|
51 | Â | - POINT p;
|
52 | Â | - RECT srcrect,destrect;
|
53 | Â | - HRESULT error;
|
54 | Â | - PAINTSTRUCT paintstruct;
|
55 | Â | - switch(Msg)
|
56 | Â | - {
|
57 | Â | - case WM_CLOSE:
|
58 | Â | - DestroyWindow(hWnd);
|
59 | Â | - break;
|
60 | Â | - case WM_DESTROY:
|
61 | Â | - StopTimer();
|
62 | Â | - for(int i = 0; i < 16; i++)
|
63 | Â | - if(sprites[i].surface) sprites[i].surface->Release();
|
64 | Â | - if(ddsrender)
|
65 | Â | - {
|
66 | Â | - ddsrender->Release();
|
67 | Â | - ddsrender = NULL;
|
68 | Â | - }
|
69 | Â | - if(ddsurface)
|
70 | Â | - {
|
71 | Â | - ddsurface->Release();
|
72 | Â | - ddsurface = NULL;
|
73 | Â | - }
|
74 | Â | - if(pal)
|
75 | Â | - {
|
76 | Â | - pal->Release();
|
77 | Â | - pal = NULL;
|
78 | Â | - }
|
79 | Â | - if(ddclipper)
|
80 | Â | - {
|
81 | Â | - ddclipper->Release();
|
82 | Â | - ddclipper = NULL;
|
83 | Â | - }
|
84 | Â | - if(ddinterface)
|
85 | Â | - {
|
86 | Â | - ddinterface->Release();
|
87 | Â | - ddinterface = NULL;
|
88 | Â | - }
|
89 | Â | - PostQuitMessage(0);
|
90 | Â | - break;
|
91 | Â | - case WM_KEYDOWN:
|
92 | Â | - if(wParam == VK_ESCAPE) DestroyWindow(hWnd);
|
93 | Â | - break;
|
94 | Â | - case WM_APP:
|
95 | Â | - RunTestTimed2D(testnum);
|
96 | Â | - break;
|
97 | Â | - case WM_SIZE:
|
98 | Â | - paintwnd = false;
|
99 | Â | - case WM_PAINT:
|
100 | Â | - if(paintwnd) BeginPaint(hWnd,&paintstruct);
|
101 | Â | - if(!fullscreen)
|
102 | Â | - {
|
103 | Â | - p.x = 0;
|
104 | Â | - p.y = 0;
|
105 | Â | - ClientToScreen(hWnd,&p);
|
106 | Â | - GetClientRect(hWnd,&destrect);
|
107 | Â | - OffsetRect(&destrect,p.x,p.y);
|
108 | Â | - SetRect(&srcrect,0,0,width,height);
|
109 | Â | - if(ddsurface && ddsrender)error = ddsurface->Blt(&destrect,ddsrender,&srcrect,DDBLT_WAIT,NULL);
|
110 | Â | - }
|
111 | Â | - if(paintwnd) EndPaint(hWnd,&paintstruct);
|
112 | Â | - return 0;
|
113 | Â | - case WM_MOUSEMOVE:
|
114 | Â | - case WM_LBUTTONDOWN:
|
115 | Â | - case WM_LBUTTONUP:
|
116 | Â | - case WM_LBUTTONDBLCLK:
|
117 | Â | - case WM_RBUTTONDOWN:
|
118 | Â | - case WM_RBUTTONUP:
|
119 | Â | - case WM_RBUTTONDBLCLK:
|
120 | Â | - case WM_MBUTTONDOWN:
|
121 | Â | - case WM_MBUTTONUP:
|
122 | Â | - case WM_MBUTTONDBLCLK:
|
123 | Â | - case WM_MOUSEWHEEL:
|
124 | Â | - case WM_XBUTTONDOWN:
|
125 | Â | - case WM_XBUTTONUP:
|
126 | Â | - case WM_XBUTTONDBLCLK:
|
127 | Â | - case WM_MOUSEHWHEEL:
|
128 | Â | - RunTestMouse2D(testnum,Msg,wParam,lParam);
|
129 | Â | - if(!fullscreen)
|
130 | Â | - {
|
131 | Â | - if ((testnum != 4) && (testnum != 10) && (testnum != 11))
|
132 | Â | - {
|
133 | Â | - p.x = 0;
|
134 | Â | - p.y = 0;
|
135 | Â | - ClientToScreen(hWnd, &p);
|
136 | Â | - GetClientRect(hWnd, &destrect);
|
137 | Â | - OffsetRect(&destrect, p.x, p.y);
|
138 | Â | - SetRect(&srcrect, 0, 0, width, height);
|
139 | Â | - if (ddsurface && ddsrender)error = ddsurface->Blt(&destrect, ddsrender, &srcrect, DDBLT_WAIT, NULL);
|
140 | Â | - }
|
141 | Â | - }
|
142 | Â | - break;
|
143 | Â | - default:
|
144 | Â | - return DefWindowProc(hWnd,Msg,wParam,lParam);
|
145 | Â | - }
|
146 | Â | - return FALSE;
|
147 | Â | -}
|
148 | Â | -
|
149 | Â | -static int ddtestnum;
|
150 | Â | -static int ddver;
|
151 | Â | -
|
152 | Â | -void RunTestMouse2D(int test, UINT Msg, WPARAM wParam, LPARAM lParam)
|
153 | Â | -{
|
154 | Â | - if(!ddsrender) return;
|
155 | Â | - DDSURFACEDESC2 ddsd;
|
156 | Â | - ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
157 | Â | - DDBLTFX bltfx;
|
158 | Â | - unsigned char *surface;
|
159 | Â | - int bytes;
|
160 | Â | - unsigned int x,y;
|
161 | Â | - bool out = false;
|
162 | Â | - bool msgbottom = false;
|
163 | Â | - TCHAR message[256];
|
164 | Â | - message[0] = 0;
|
165 | Â | - HDC hDC;
|
166 | Â | - switch(test)
|
167 | Â | - {
|
168 | Â | - case 6:
|
169 | Â | - x = LOWORD(lParam);
|
170 | Â | - y = HIWORD(lParam);
|
171 | Â | - ZeroMemory(&bltfx,sizeof(DDBLTFX));
|
172 | Â | - bltfx.dwSize = sizeof(DDBLTFX);
|
173 | Â | - bltfx.dwFillColor = 0;
|
174 | Â | - ddsrender->Blt(NULL,NULL,NULL,DDBLT_COLORFILL,&bltfx);
|
175 | Â | - if(ddver > 3)ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
176 | Â | - else ddsd.dwSize = sizeof(DDSURFACEDESC);
|
177 | Â | - ddsrender->GetSurfaceDesc(&ddsd);
|
178 | Â | - switch(ddsd.ddpfPixelFormat.dwRGBBitCount)
|
179 | Â | - {
|
180 | Â | - case 8:
|
181 | Â | - bytes=1;
|
182 | Â | - break;
|
183 | Â | - case 15:
|
184 | Â | - case 16:
|
185 | Â | - bytes=2;
|
186 | Â | - break;
|
187 | Â | - case 24:
|
188 | Â | - bytes=3;
|
189 | Â | - break;
|
190 | Â | - case 32:
|
191 | Â | - default:
|
192 | Â | - bytes=4;
|
193 | Â | - }
|
194 | Â | - _tcscpy(message,_T("Message: "));
|
195 | Â | - switch(Msg)
|
196 | Â | - {
|
197 | Â | - case WM_MOUSEMOVE:
|
198 | Â | - _tcscat(message,_T("WM_MOUSEMOVE "));
|
199 | Â | - break;
|
200 | Â | - case WM_LBUTTONDOWN:
|
201 | Â | - _tcscat(message,_T("WM_LBUTTONDOWN "));
|
202 | Â | - break;
|
203 | Â | - case WM_LBUTTONUP:
|
204 | Â | - _tcscat(message,_T("WM_LBUTTONUP "));
|
205 | Â | - break;
|
206 | Â | - case WM_LBUTTONDBLCLK:
|
207 | Â | - _tcscat(message,_T("WM_LBUTTONDBLCLK "));
|
208 | Â | - break;
|
209 | Â | - case WM_RBUTTONDOWN:
|
210 | Â | - _tcscat(message,_T("WM_RBUTTONDOWN "));
|
211 | Â | - break;
|
212 | Â | - case WM_RBUTTONUP:
|
213 | Â | - _tcscat(message,_T("WM_RBUTTONUP "));
|
214 | Â | - break;
|
215 | Â | - case WM_RBUTTONDBLCLK:
|
216 | Â | - _tcscat(message,_T("WM_RBUTTONDBLCLK "));
|
217 | Â | - break;
|
218 | Â | - case WM_MBUTTONDOWN:
|
219 | Â | - _tcscat(message,_T("WM_MBUTTONDOWN "));
|
220 | Â | - break;
|
221 | Â | - case WM_MBUTTONUP:
|
222 | Â | - _tcscat(message,_T("WM_MBUTTONUP "));
|
223 | Â | - break;
|
224 | Â | - case WM_MBUTTONDBLCLK:
|
225 | Â | - _tcscat(message,_T("WM_MBUTTONDBLCLK "));
|
226 | Â | - break;
|
227 | Â | - case WM_MOUSEWHEEL:
|
228 | Â | - _tcscat(message,_T("WM_MOUSEWHEEL "));
|
229 | Â | - break;
|
230 | Â | - case WM_XBUTTONDOWN:
|
231 | Â | - _tcscat(message,_T("WM_XBUTTONDOWN "));
|
232 | Â | - break;
|
233 | Â | - case WM_XBUTTONUP:
|
234 | Â | - _tcscat(message,_T("WM_XBUTTONUP "));
|
235 | Â | - break;
|
236 | Â | - case WM_XBUTTONDBLCLK:
|
237 | Â | - _tcscat(message,_T("WM_XBUTTONDBLCLK "));
|
238 | Â | - break;
|
239 | Â | - case WM_MOUSEHWHEEL:
|
240 | Â | - _tcscat(message,_T("WM_MOUSEHWHEEL "));
|
241 | Â | - break;
|
242 | Â | - default:
|
243 | Â | - _tcscat(message,_T("unknown "));
|
244 | Â | - }
|
245 | Â | - _tcscat(message,_T("Keys: "));
|
246 | Â | - if(wParam & MK_CONTROL) _tcscat(message, _T("CTRL "));
|
247 | Â | - if(wParam & MK_SHIFT) _tcscat(message,_T("SHIFT "));
|
248 | Â | - _tcscat(message,_T("Buttons: "));
|
249 | Â | - if(wParam & MK_LBUTTON) _tcscat(message,_T("L "));
|
250 | Â | - if(wParam & MK_MBUTTON) _tcscat(message,_T("M "));
|
251 | Â | - if(wParam & MK_RBUTTON) _tcscat(message,_T("R "));
|
252 | Â | - if(wParam & MK_XBUTTON1) _tcscat(message,_T("X1 "));
|
253 | Â | - if(wParam & MK_XBUTTON2) _tcscat(message,_T("X2 "));
|
254 | Â | - // Add X and Y
|
255 | Â | - ddsrender->Lock(NULL,&ddsd,DDLOCK_WAIT,NULL);
|
256 | Â | - surface = (unsigned char *)ddsd.lpSurface;
|
257 | Â | - if((x > ddsd.dwWidth) || (y > ddsd.dwHeight))
|
258 | Â | - {
|
259 | Â | - out = true;
|
260 | Â | - _tcscat(message,_T(" OUT OF BOUNDS"));
|
261 | Â | - }
|
262 | Â | - else surface[(x*bytes)+(y*ddsd.lPitch)] = 0xFF;
|
263 | Â | - ddsrender->Unlock(NULL);
|
264 | Â | - ddsrender->GetDC(&hDC);
|
265 | Â | - if(out)SetBkColor(hDC,RGB(255,0,0));
|
266 | Â | - else SetBkColor(hDC,RGB(0,0,255));
|
267 | Â | - SetTextColor(hDC,RGB(255,255,255));
|
268 | Â | - if(y > ddsd.dwHeight / 2) TextOut(hDC,0,0,message,_tcslen(message));
|
269 | Â | - else TextOut(hDC,0,ddsd.dwHeight-16,message,_tcslen(message));
|
270 | Â | - ddsrender->ReleaseDC(hDC);
|
271 | Â | - break;
|
272 | Â | - default:
|
273 | Â | - break;
|
274 | Â | - }
|
275 | Â | -}
|
276 | Â | -
|
277 | Â | -const TCHAR wndclassname2d[] = _T("DDTestWndClass");
|
278 | Â | -void RunTest2D(int testnum, int width, int height, int bpp, int refresh, int backbuffers, int apiver,
|
279 | Â | - double fps, bool fullscreen, bool resizable)
|
280 | Â | -{
|
281 | Â | - ZeroMemory(sprites,16*sizeof(DDSPRITE));
|
282 | Â | - DDSURFACEDESC2 ddsd;
|
283 | Â | - BOOL done = false;
|
284 | Â | - ::testnum = testnum;
|
285 | Â | - randnum = (unsigned int)time(NULL);
|
286 | Â | - ZeroMemory(&ddsd,sizeof(DDSURFACEDESC2));
|
287 | Â | - if(apiver > 3) ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
288 | Â | - else ddsd.dwSize = sizeof(DDSURFACEDESC);
|
289 | Â | - ::fullscreen = fullscreen;
|
290 | Â | - ::resizable = resizable;
|
291 | Â | - ::width = width;
|
292 | Â | - ::height = height;
|
293 | Â | - ::bpp = bpp;
|
294 | Â | - ::refresh = refresh;
|
295 | Â | - if(fullscreen)::backbuffers = backbuffers;
|
296 | Â | - else ::backbuffers = backbuffers = 0;
|
297 | Â | - ::fps = fps;
|
298 | Â | - ddtestnum = testnum;
|
299 | Â | - ddver = apiver;
|
300 | Â | - HINSTANCE hinstance = (HINSTANCE)GetModuleHandle(NULL);
|
301 | Â | - WNDCLASSEX wc;
|
302 | Â | - MSG Msg;
|
303 | Â | - ZeroMemory(&wc,sizeof(WNDCLASS));
|
304 | Â | - wc.cbSize = sizeof(WNDCLASSEX);
|
305 | Â | - wc.style = CS_HREDRAW | CS_VREDRAW;
|
306 | Â | - wc.lpfnWndProc = DDWndProc;
|
307 | Â | - wc.hInstance = hinstance;
|
308 | Â | - wc.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(IDI_DXGL));
|
309 | Â | - wc.hIconSm = LoadIcon(hinstance,MAKEINTRESOURCE(IDI_DXGLSM));
|
310 | Â | - if(testnum == 6) wc.hCursor = LoadCursor(NULL,IDC_CROSS);
|
311 | Â | - else wc.hCursor = LoadCursor(NULL,IDC_ARROW);
|
312 | Â | - wc.hbrBackground = NULL;
|
313 | Â | - wc.lpszClassName = wndclassname2d;
|
314 | Â | - if(!RegisterClassEx(&wc))
|
315 | Â | - {
|
316 | Â | - MessageBox(NULL,_T("Can not register window class"),_T("Error"),MB_ICONEXCLAMATION|MB_OK);
|
317 | Â | - return;
|
318 | Â | - }
|
319 | Â | - if(resizable)
|
320 | Â | - hWnd = CreateWindowEx(WS_EX_APPWINDOW,wndclassname2d,_T("DDraw Test Window"),WS_OVERLAPPEDWINDOW,
|
321 | Â | - CW_USEDEFAULT,CW_USEDEFAULT,width,height,NULL,NULL,hinstance,NULL);
|
322 | Â | - else if(!fullscreen)
|
323 | Â | - hWnd = CreateWindowEx(WS_EX_APPWINDOW,wndclassname2d,_T("DDraw Test Window"),WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX,
|
324 | Â | - CW_USEDEFAULT,CW_USEDEFAULT,width,height,NULL,NULL,hinstance,NULL);
|
325 | Â | - else hWnd = CreateWindowEx(0,wndclassname2d,_T("DDraw Test Window"),WS_POPUP,0,0,
|
326 | Â | - GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN),NULL,NULL,hinstance,NULL);
|
327 | Â | - DWORD err = GetLastError();
|
328 | Â | - ShowWindow(hWnd,SW_SHOWNORMAL);
|
329 | Â | - UpdateWindow(hWnd);
|
330 | Â | - RECT r1,r2;
|
331 | Â | - POINT p1;
|
332 | Â | - HRESULT error;
|
333 | Â | - ddinterface = new MultiDirectDraw(ddver,&error,NULL);
|
334 | Â | - if(fullscreen) error = ddinterface->SetCooperativeLevel(hWnd,DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN);
|
335 | Â | - else error = ddinterface->SetCooperativeLevel(hWnd,DDSCL_NORMAL);
|
336 | Â | - if(fullscreen) error = ddinterface->SetDisplayMode(width,height,bpp,refresh,0);
|
337 | Â | - else
|
338 | Â | - {
|
339 | Â | - GetClientRect(hWnd,&r1);
|
340 | Â | - GetWindowRect(hWnd,&r2);
|
341 | Â | - p1.x = (r2.right - r2.left) - r1.right;
|
342 | Â | - p1.y = (r2.bottom - r2.top) - r1.bottom;
|
343 | Â | - MoveWindow(hWnd,r2.left,r2.top,width+p1.x,height+p1.y,TRUE);
|
344 | Â | - }
|
345 | Â | - ddsd.dwFlags = DDSD_CAPS;
|
346 | Â | - ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
347 | Â | - if(fullscreen)
|
348 | Â | - {
|
349 | Â | - if(backbuffers)ddsd.dwFlags |= DDSD_BACKBUFFERCOUNT;
|
350 | Â | - ddsd.dwBackBufferCount = backbuffers;
|
351 | Â | - if(backbuffers) ddsd.ddsCaps.dwCaps |= DDSCAPS_FLIP | DDSCAPS_COMPLEX;
|
352 | Â | - }
|
353 | Â | - error = ddinterface->CreateSurface(&ddsd,&ddsurface,NULL);
|
354 | Â | - if(!fullscreen)
|
355 | Â | - {
|
356 | Â | - error = ddinterface->CreateClipper(0,&ddclipper,NULL);
|
357 | Â | - error = ddclipper->SetHWnd(0,hWnd);
|
358 | Â | - error = ddsurface->SetClipper(ddclipper);
|
359 | Â | - ZeroMemory(&ddsd,sizeof(ddsd));
|
360 | Â | - if(apiver > 3) ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
361 | Â | - else ddsd.dwSize = sizeof(DDSURFACEDESC);
|
362 | Â | - ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
363 | Â | - ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
364 | Â | - ddsd.dwWidth = width;
|
365 | Â | - ddsd.dwHeight = height;
|
366 | Â | - error = ddinterface->CreateSurface(&ddsd,&ddsrender,NULL);
|
367 | Â | - ddsrender->GetSurfaceDesc(&ddsd);
|
368 | Â | - ::bpp = ddsd.ddpfPixelFormat.dwRGBBitCount;
|
369 | Â | - }
|
370 | Â | - else
|
371 | Â | - {
|
372 | Â | - ddsrender = ddsurface;
|
373 | Â | - ddsrender->AddRef();
|
374 | Â | - }
|
375 | Â | - if(bpp == 8)
|
376 | Â | - {
|
377 | Â | - ddinterface->CreatePalette(DDPCAPS_8BIT|DDPCAPS_ALLOW256,(LPPALETTEENTRY)&DefaultPalette,&pal,NULL);
|
378 | Â | - ddsrender->SetPalette(pal);
|
379 | Â | - }
|
380 | Â | - else pal = NULL;
|
381 | Â | - InitTest2D(testnum);
|
382 | Â | - if(!fullscreen) SendMessage(hWnd,WM_PAINT,0,0);
|
383 | Â | - if(testtypes[testnum] == 1)
|
384 | Â | - {
|
385 | Â | - while(!done)
|
386 | Â | - {
|
387 | Â | - if(PeekMessage(&Msg,NULL,0,0,PM_REMOVE))
|
388 | Â | - {
|
389 | Â | - if(Msg.message == WM_PAINT) RunTestLooped2D(testnum);
|
390 | Â | - else if(Msg.message == WM_QUIT) done = TRUE;
|
391 | Â | - else
|
392 | Â | - {
|
393 | Â | - TranslateMessage(&Msg);
|
394 | Â | - DispatchMessage(&Msg);
|
395 | Â | - }
|
396 | Â | - }
|
397 | Â | - else
|
398 | Â | - {
|
399 | Â | - RunTestLooped2D(testnum);
|
400 | Â | - }
|
401 | Â | - }
|
402 | Â | - }
|
403 | Â | - else if(testtypes[testnum] == 0)
|
404 | Â | - {
|
405 | Â | - StartTimer(hWnd,WM_APP,fps);
|
406 | Â | - while(GetMessage(&Msg, NULL, 0, 0) > 0)
|
407 | Â | - {
|
408 | Â | - TranslateMessage(&Msg);
|
409 | Â | - DispatchMessage(&Msg);
|
410 | Â | - }
|
411 | Â | - }
|
412 | Â | - else
|
413 | Â | - {
|
414 | Â | - while(GetMessage(&Msg, NULL, 0, 0) > 0)
|
415 | Â | - {
|
416 | Â | - TranslateMessage(&Msg);
|
417 | Â | - DispatchMessage(&Msg);
|
418 | Â | - }
|
419 | Â | - }
|
420 | Â | - UnregisterClass(wndclassname2d,hinstance);
|
421 | Â | - StopTimer();
|
422 | Â | -}
|
423 | Â | -
|
424 | Â | -
|
425 | Â | -void InitTest2D(int test)
|
426 | Â | -{
|
427 | Â | - DDSURFACEDESC2 ddsd;
|
428 | Â | - DDSCAPS2 ddscaps;
|
429 | Â | - HDC hRenderDC;
|
430 | Â | - ZeroMemory(&ddscaps,sizeof(DDSCAPS2));
|
431 | Â | - LPDIRECTDRAWPALETTE palette;
|
432 | Â | - unsigned char *buffer;
|
433 | Â | - MultiDirectDrawSurface *temp1 = NULL;
|
434 | Â | - MultiDirectDrawSurface *temp2 = NULL;
|
435 | Â | - HRESULT error;
|
436 | Â | - DDCOLORKEY ckey;
|
437 | Â | - ckey.dwColorSpaceHighValue = ckey.dwColorSpaceLowValue = 0;
|
438 | Â | - if(ddver > 3)ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
439 | Â | - else ddsd.dwSize = sizeof(DDSURFACEDESC);
|
440 | Â | - error = ddsrender->GetSurfaceDesc(&ddsd);
|
441 | Â | - switch (test)
|
442 | Â | - {
|
443 | Â | - case 0:
|
444 | Â | - if (!fullscreen) backbuffers = 0;
|
445 | Â | - buffer = (unsigned char *)malloc(ddsd.lPitch*ddsd.dwHeight);
|
446 | Â | - DrawPalette(ddsd, buffer);
|
447 | Â | - error = ddsrender->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
|
448 | Â | - memcpy(ddsd.lpSurface, buffer, ddsd.lPitch*ddsd.dwHeight);
|
449 | Â | - error = ddsrender->Unlock(NULL);
|
450 | Â | - ddsrender->GetPalette(&palette);
|
451 | Â | - if (backbuffers > 0)
|
452 | Â | - {
|
453 | Â | - ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
|
454 | Â | - error = ddsrender->GetAttachedSurface(&ddscaps, &temp1);
|
455 | Â | - DrawGradients(ddsd, buffer, hWnd, palette, 1, 0);
|
456 | Â | - error = temp1->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
|
457 | Â | - memcpy(ddsd.lpSurface, buffer, ddsd.lPitch*ddsd.dwHeight);
|
458 | Â | - error = temp1->Unlock(NULL);
|
459 | Â | - }
|
460 | Â | - if (backbuffers > 1)
|
461 | Â | - {
|
462 | Â | - ddscaps.dwCaps = DDSCAPS_FLIP;
|
463 | Â | - error = temp1->GetAttachedSurface(&ddscaps, &temp2);
|
464 | Â | - temp1->Release();
|
465 | Â | - temp1 = temp2;
|
466 | Â | - DrawGradients(ddsd, buffer, hWnd, palette, 0, 0x0000FF);
|
467 | Â | - error = temp1->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
|
468 | Â | - memcpy(ddsd.lpSurface, buffer, ddsd.lPitch*ddsd.dwHeight);
|
469 | Â | - error = temp1->Unlock(NULL);
|
470 | Â | - }
|
471 | Â | - if (backbuffers > 2)
|
472 | Â | - {
|
473 | Â | - ddscaps.dwCaps = DDSCAPS_FLIP;
|
474 | Â | - error = temp1->GetAttachedSurface(&ddscaps, &temp2);
|
475 | Â | - temp1->Release();
|
476 | Â | - temp1 = temp2;
|
477 | Â | - DrawGradients(ddsd, buffer, hWnd, palette, 0, 0x00FF00);
|
478 | Â | - error = temp1->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
|
479 | Â | - memcpy(ddsd.lpSurface, buffer, ddsd.lPitch*ddsd.dwHeight);
|
480 | Â | - error = temp1->Unlock(NULL);
|
481 | Â | - }
|
482 | Â | - if (backbuffers > 3)
|
483 | Â | - {
|
484 | Â | - ddscaps.dwCaps = DDSCAPS_FLIP;
|
485 | Â | - error = temp1->GetAttachedSurface(&ddscaps, &temp2);
|
486 | Â | - temp1->Release();
|
487 | Â | - temp1 = temp2;
|
488 | Â | - DrawGradients(ddsd, buffer, hWnd, palette, 0, 0xFF0000);
|
489 | Â | - error = temp1->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
|
490 | Â | - memcpy(ddsd.lpSurface, buffer, ddsd.lPitch*ddsd.dwHeight);
|
491 | Â | - error = temp1->Unlock(NULL);
|
492 | Â | - }
|
493 | Â | - if (temp1) temp1->Release();
|
494 | Â | - free(buffer);
|
495 | Â | - if (palette) palette->Release();
|
496 | Â | - break;
|
497 | Â | - case 2:
|
498 | Â | - if (!fullscreen) backbuffers = 0;
|
499 | Â | - error = ddsrender->GetDC(&hRenderDC);
|
500 | Â | - DrawGDIPatterns(ddsd, hRenderDC, 0);
|
501 | Â | - ddsrender->ReleaseDC(hRenderDC);
|
502 | Â | - if (backbuffers > 0)
|
503 | Â | - {
|
504 | Â | - ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
|
505 | Â | - error = ddsrender->GetAttachedSurface(&ddscaps, &temp1);
|
506 | Â | - temp1->GetDC(&hRenderDC);
|
507 | Â | - DrawGDIPatterns(ddsd, hRenderDC, 1);
|
508 | Â | - temp1->ReleaseDC(hRenderDC);
|
509 | Â | - }
|
510 | Â | - if (backbuffers > 1)
|
511 | Â | - {
|
512 | Â | - ddscaps.dwCaps = DDSCAPS_FLIP;
|
513 | Â | - error = temp1->GetAttachedSurface(&ddscaps, &temp2);
|
514 | Â | - temp1->Release();
|
515 | Â | - temp1 = temp2;
|
516 | Â | - temp1->GetDC(&hRenderDC);
|
517 | Â | - DrawGDIPatterns(ddsd, hRenderDC, 2);
|
518 | Â | - temp1->ReleaseDC(hRenderDC);
|
519 | Â | - }
|
520 | Â | - if (backbuffers > 2)
|
521 | Â | - {
|
522 | Â | - ddscaps.dwCaps = DDSCAPS_FLIP;
|
523 | Â | - error = temp1->GetAttachedSurface(&ddscaps, &temp2);
|
524 | Â | - temp1->Release();
|
525 | Â | - temp1 = temp2;
|
526 | Â | - temp1->GetDC(&hRenderDC);
|
527 | Â | - DrawGDIPatterns(ddsd, hRenderDC, 3);
|
528 | Â | - temp1->ReleaseDC(hRenderDC);
|
529 | Â | - }
|
530 | Â | - if (backbuffers > 3)
|
531 | Â | - {
|
532 | Â | - ddscaps.dwCaps = DDSCAPS_FLIP;
|
533 | Â | - error = temp1->GetAttachedSurface(&ddscaps, &temp2);
|
534 | Â | - temp1->Release();
|
535 | Â | - temp1 = temp2;
|
536 | Â | - temp1->GetDC(&hRenderDC);
|
537 | Â | - DrawGDIPatterns(ddsd, hRenderDC, 4);
|
538 | Â | - temp1->ReleaseDC(hRenderDC);
|
539 | Â | - }
|
540 | Â | - if (backbuffers > 4)
|
541 | Â | - {
|
542 | Â | - ddscaps.dwCaps = DDSCAPS_FLIP;
|
543 | Â | - error = temp1->GetAttachedSurface(&ddscaps, &temp2);
|
544 | Â | - temp1->Release();
|
545 | Â | - temp1 = temp2;
|
546 | Â | - temp1->GetDC(&hRenderDC);
|
547 | Â | - DrawGDIPatterns(ddsd, hRenderDC, 5);
|
548 | Â | - temp1->ReleaseDC(hRenderDC);
|
549 | Â | - }
|
550 | Â | - if (backbuffers > 5)
|
551 | Â | - {
|
552 | Â | - ddscaps.dwCaps = DDSCAPS_FLIP;
|
553 | Â | - error = temp1->GetAttachedSurface(&ddscaps, &temp2);
|
554 | Â | - temp1->Release();
|
555 | Â | - temp1 = temp2;
|
556 | Â | - temp1->GetDC(&hRenderDC);
|
557 | Â | - DrawGDIPatterns(ddsd, hRenderDC, 6);
|
558 | Â | - temp1->ReleaseDC(hRenderDC);
|
559 | Â | - }
|
560 | Â | - if (backbuffers > 6)
|
561 | Â | - {
|
562 | Â | - ddscaps.dwCaps = DDSCAPS_FLIP;
|
563 | Â | - error = temp1->GetAttachedSurface(&ddscaps, &temp2);
|
564 | Â | - temp1->Release();
|
565 | Â | - temp1 = temp2;
|
566 | Â | - temp1->GetDC(&hRenderDC);
|
567 | Â | - DrawGDIPatterns(ddsd, hRenderDC, 7);
|
568 | Â | - temp1->ReleaseDC(hRenderDC);
|
569 | Â | - }
|
570 | Â | - if (temp1) temp1->Release();
|
571 | Â | - break;
|
572 | Â | - case 4:
|
573 | Â | - ddsrender->GetSurfaceDesc(&ddsd);
|
574 | Â | - ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
575 | Â | - ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
576 | Â | - ddinterface->CreateSurface(&ddsd, &sprites[0].surface, NULL);
|
577 | Â | - ddsrender->GetPalette(&palette);
|
578 | Â | - error = sprites[0].surface->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
|
579 | Â | - if(palette) palette->Release();
|
580 | Â | - DrawGradients(ddsd, (unsigned char *)ddsd.lpSurface, hWnd, palette, 1, 0);
|
581 | Â | - DrawDitheredColor(&ddsd, (unsigned char *)ddsd.lpSurface, 0, FALSE);
|
582 | Â | - error = sprites[0].surface->Unlock(NULL);
|
583 | Â | - sprites[0].width = (float)ddsd.dwWidth;
|
584 | Â | - sprites[0].height = (float)ddsd.dwHeight;
|
585 | Â | - sprites[0].rect.left = sprites[0].rect.top = 0;
|
586 | Â | - sprites[0].rect.right = ddsd.dwWidth;
|
587 | Â | - sprites[0].rect.bottom = ddsd.dwHeight;
|
588 | Â | - if (backbuffers) ddsrender->GetAttachedSurface(&ddscaps, &temp1);
|
589 | Â | - else temp1 = ddsrender;
|
590 | Â | - temp1->SetColorKey(DDCKEY_DESTBLT, &ckey);
|
591 | Â | - if (backbuffers) temp1->Release();
|
592 | Â | - for (int i = 1; i < 16; i++)
|
593 | Â | - {
|
594 | Â | - switch ((i - 1 & 3))
|
595 | Â | - {
|
596 | Â | - case 0:
|
597 | Â | - sprites[i].width = sprites[i].height = 64.f;
|
598 | Â | - sprites[i].ddsd.dwWidth = sprites[i].ddsd.dwHeight =
|
599 | Â | - sprites[i].rect.right = sprites[i].rect.bottom = 64;
|
600 | Â | - sprites[i].ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
601 | Â | - sprites[i].ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
602 | Â | - if (ddver > 3) sprites[i].ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
603 | Â | - else sprites[i].ddsd.dwSize = sizeof(DDSURFACEDESC);
|
604 | Â | - ddinterface->CreateSurface(&sprites[i].ddsd, &sprites[i].surface, NULL);
|
605 | Â | - error = sprites[i].surface->Lock(NULL, &sprites[i].ddsd, DDLOCK_WAIT, NULL);
|
606 | Â | - DrawPalette(sprites[i].ddsd, (unsigned char *)sprites[i].ddsd.lpSurface);
|
607 | Â | - sprites[i].surface->Unlock(NULL);
|
608 | Â | - break;
|
609 | Â | - case 1:
|
610 | Â | - break;
|
611 | Â | - case 2:
|
612 | Â | - break;
|
613 | Â | - case 3:
|
614 | Â | - break;
|
615 | Â | - default:
|
616 | Â | - break;
|
617 | Â | - }
|
618 | Â | - if (i < 5) sprites[i].bltflags = 0;
|
619 | Â | - else if (i < 9)
|
620 | Â | - {
|
621 | Â | - sprites[i].bltflags = DDBLTFAST_SRCCOLORKEY;
|
622 | Â | - if (sprites[i].surface) sprites[i].surface->SetColorKey(DDCKEY_SRCBLT, &ckey);
|
623 | Â | - }
|
624 | Â | - else if (i < 13) sprites[i].bltflags = DDBLTFAST_DESTCOLORKEY;
|
625 | Â | - else
|
626 | Â | - {
|
627 | Â | - sprites[i].bltflags = DDBLTFAST_SRCCOLORKEY | DDBLTFAST_DESTCOLORKEY;
|
628 | Â | - if (sprites[i].surface) sprites[i].surface->SetColorKey(DDCKEY_SRCBLT, &ckey);
|
629 | Â | - }
|
630 | Â | - sprites[i].x = randfloat((float)ddsd.dwWidth);
|
631 | Â | - sprites[i].y = randfloat((float)ddsd.dwHeight);
|
632 | Â | - sprites[i].xvelocity = randfloat(5);
|
633 | Â | - sprites[i].yvelocity = randfloat(5);
|
634 | Â | - }
|
635 | Â | - break;
|
636 | Â | - case 7:
|
637 | Â | - if (!fullscreen) backbuffers = 0;
|
638 | Â | - ddsrender->GetSurfaceDesc(&ddsd);
|
639 | Â | - ddsrender->GetPalette(&palette);
|
640 | Â | - sprites[0].ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
641 | Â | - sprites[0].ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
642 | Â | - if (ddver > 3) sprites[0].ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
643 | Â | - else sprites[0].ddsd.dwSize = sizeof(DDSURFACEDESC);
|
644 | Â | - memcpy(&sprites[1], &sprites[0], sizeof(DDSPRITE));
|
645 | Â | - memcpy(&sprites[2], &sprites[0], sizeof(DDSPRITE));
|
646 | Â | - memcpy(&sprites[3], &sprites[0], sizeof(DDSPRITE));
|
647 | Â | - memcpy(&sprites[4], &sprites[0], sizeof(DDSPRITE));
|
648 | Â | - memcpy(&sprites[5], &sprites[0], sizeof(DDSPRITE));
|
649 | Â | - sprites[0].width = sprites[0].height = 256.0f;
|
650 | Â | - sprites[1].width = sprites[1].height = 256.0f;
|
651 | Â | - sprites[2].width = sprites[2].height = 16.0f;
|
652 | Â | - sprites[3].width = sprites[3].height = 16.0f;
|
653 | Â | - sprites[4].width = sprites[4].height = 8.0f;
|
654 | Â | - sprites[5].width = sprites[4].height = 6.0f;
|
655 | Â | - sprites[0].ddsd.dwWidth = sprites[0].ddsd.dwHeight =
|
656 | Â | - sprites[0].rect.right = sprites[0].rect.bottom = 256;
|
657 | Â | - sprites[1].ddsd.dwWidth = sprites[1].ddsd.dwHeight =
|
658 | Â | - sprites[1].rect.right = sprites[1].rect.bottom = 256;
|
659 | Â | - sprites[2].ddsd.dwWidth = sprites[2].ddsd.dwHeight =
|
660 | Â | - sprites[2].rect.right = sprites[2].rect.bottom = 16;
|
661 | Â | - sprites[3].ddsd.dwWidth = sprites[3].ddsd.dwHeight =
|
662 | Â | - sprites[3].rect.right = sprites[3].rect.bottom = 16;
|
663 | Â | - sprites[4].ddsd.dwWidth = sprites[4].ddsd.dwHeight =
|
664 | Â | - sprites[4].rect.right = sprites[4].rect.bottom = 8;
|
665 | Â | - sprites[5].ddsd.dwWidth = sprites[5].ddsd.dwHeight =
|
666 | Â | - sprites[5].rect.right = sprites[5].rect.bottom = 6;
|
667 | Â | - ddinterface->CreateSurface(&sprites[0].ddsd, &sprites[0].surface, NULL);
|
668 | Â | - ddinterface->CreateSurface(&sprites[1].ddsd, &sprites[1].surface, NULL);
|
669 | Â | - ddinterface->CreateSurface(&sprites[2].ddsd, &sprites[2].surface, NULL);
|
670 | Â | - ddinterface->CreateSurface(&sprites[3].ddsd, &sprites[3].surface, NULL);
|
671 | Â | - ddinterface->CreateSurface(&sprites[4].ddsd, &sprites[4].surface, NULL);
|
672 | Â | - ddinterface->CreateSurface(&sprites[5].ddsd, &sprites[5].surface, NULL);
|
673 | Â | - DDCAPS ddcaps;
|
674 | Â | - ddcaps.dwSize = sizeof(DDCAPS);
|
675 | Â | - ddinterface->GetCaps(&ddcaps, NULL);
|
676 | Â | - DrawROPPatterns(ddsrender, sprites, backbuffers, ddver, bpp, ddcaps.dwRops,hWnd,palette);
|
677 | Â | - if (palette) palette->Release();
|
678 | Â | - break;
|
679 | Â | - case 8:
|
680 | Â | - ddsrender->GetSurfaceDesc(&ddsd);
|
681 | Â | - sprites[0].ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
682 | Â | - sprites[0].ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
683 | Â | - if (ddver > 3) sprites[0].ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
684 | Â | - else sprites[0].ddsd.dwSize = sizeof(DDSURFACEDESC);
|
685 | Â | - sprites[0].ddsd.dwWidth = sprites[0].ddsd.dwHeight =
|
686 | Â | - sprites[0].rect.right = sprites[0].rect.bottom = 64;
|
687 | Â | - ddinterface->CreateSurface(&sprites[0].ddsd, &sprites[0].surface, NULL);
|
688 | Â | - DrawRotatedBlt(ddsrender, sprites);
|
689 | Â | - break;
|
690 | Â | - case 9:
|
691 | Â | - ddsrender->GetSurfaceDesc(&ddsd);
|
692 | Â | - sprites[0].ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
693 | Â | - sprites[0].ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
694 | Â | - if (ddver > 3) sprites[0].ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
695 | Â | - else sprites[0].ddsd.dwSize = sizeof(DDSURFACEDESC);
|
696 | Â | - sprites[0].ddsd.dwWidth = sprites[0].ddsd.dwHeight =
|
697 | Â | - sprites[0].rect.right = sprites[0].rect.bottom = 255;
|
698 | Â | - ddinterface->CreateSurface(&sprites[0].ddsd, &sprites[0].surface, NULL);
|
699 | Â | - counter = 0;
|
700 | Â | - break;
|
701 | Â | - case 10:
|
702 | Â | - case 11:
|
703 | Â | - ddsrender->GetSurfaceDesc(&ddsd);
|
704 | Â | - sprites[0].ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
705 | Â | - sprites[0].ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
706 | Â | - if (ddver > 3) sprites[0].ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
707 | Â | - else sprites[0].ddsd.dwSize = sizeof(DDSURFACEDESC);
|
708 | Â | - switch (bpp)
|
709 | Â | - {
|
710 | Â | - case 8:
|
711 | Â | - sprites[0].width = sprites[0].height = 16;
|
712 | Â | - break;
|
713 | Â | - case 15:
|
714 | Â | - sprites[0].width = 32;
|
715 | Â | - sprites[0].height = 7;
|
716 | Â | - break;
|
717 | Â | - case 16:
|
718 | Â | - sprites[0].width = 64;
|
719 | Â | - sprites[0].height = 7;
|
720 | Â | - break;
|
721 | Â | - case 24:
|
722 | Â | - case 32:
|
723 | Â | - default:
|
724 | Â | - sprites[0].width = 256;
|
725 | Â | - sprites[0].height = 7;
|
726 | Â | - break;
|
727 | Â | - }
|
728 | Â | - sprites[0].ddsd.dwWidth = sprites[0].width;
|
729 | Â | - sprites[0].ddsd.dwHeight = sprites[0].height;
|
730 | Â | - memcpy(&sprites[1], &sprites[0], sizeof(DDSPRITE));
|
731 | Â | - memcpy(&sprites[2], &sprites[0], sizeof(DDSPRITE));
|
732 | Â | - ddinterface->CreateSurface(&sprites[0].ddsd, &sprites[0].surface, NULL);
|
733 | Â | - ddinterface->CreateSurface(&sprites[1].ddsd, &sprites[1].surface, NULL);
|
734 | Â | - ddinterface->CreateSurface(&sprites[2].ddsd, &sprites[2].surface, NULL);
|
735 | Â | - sprites[1].surface->Lock(NULL, &sprites[1].ddsd, DDLOCK_WAIT, NULL);
|
736 | Â | - DrawColorKeyCompPatterns(sprites[1].ddsd, (unsigned char*)sprites[1].ddsd.lpSurface, bpp, 0);
|
737 | Â | - sprites[1].surface->Unlock(NULL);
|
738 | Â | - sprites[2].surface->Lock(NULL, &sprites[2].ddsd, DDLOCK_WAIT, NULL);
|
739 | Â | - DrawColorKeyCompPatterns(sprites[2].ddsd, (unsigned char*)sprites[2].ddsd.lpSurface, bpp, 1);
|
740 | Â | - sprites[2].surface->Unlock(NULL);
|
741 | Â | - counter = 0;
|
742 | Â | - }
|
743 | Â | -}
|
744 | Â | -
|
745 | Â | -void RunTestTimed2D(int test)
|
746 | Â | -{
|
747 | Â | - if(stoptimer) return;
|
748 | Â | - DDSURFACEDESC2 ddsd;
|
749 | Â | - DDSCAPS2 ddscaps;
|
750 | Â | - DDBLTFX bltfx;
|
751 | Â | - HDC hDCdest, hDCsrc;
|
752 | Â | - RECT r1, r2;
|
753 | Â | - POINT p;
|
754 | Â | - TCHAR message[256];
|
755 | Â | - bltfx.dwSize = sizeof(DDBLTFX);
|
756 | Â | - ZeroMemory(&ddscaps,sizeof(DDSCAPS2));
|
757 | Â | - ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
|
758 | Â | - MultiDirectDrawSurface *temp1 = NULL;
|
759 | Â | - switch(test)
|
760 | Â | - {
|
761 | Â | - case 0: // Palette and gradients
|
762 | Â | - case 2: // GDI patterns
|
763 | Â | - case 7: // ROP patterns
|
764 | Â | - default:
|
765 | Â | - if(fullscreen) ddsurface->Flip(NULL,DDFLIP_WAIT);
|
766 | Â | - break;
|
767 | Â | - case 4: // BltFast sprites
|
768 | Â | - if (backbuffers) ddsrender->GetAttachedSurface(&ddscaps, &temp1);
|
769 | Â | - else temp1 = ddsrender;
|
770 | Â | - bltfx.dwFillColor = 0;
|
771 | Â | - temp1->Blt(NULL, NULL, NULL, DDBLT_COLORFILL, &bltfx);
|
772 | Â | - if (backbuffers) temp1->Release();
|
773 | Â | - for(int i = 0; i < 16; i++)
|
774 | Â | - {
|
775 | Â | - sprites[i].x += sprites[i].xvelocity;
|
776 | Â | - if(sprites[i].xvelocity < 0 && sprites[i].x < 0) sprites[i].xvelocity = -sprites[i].xvelocity;
|
777 | Â | - if(sprites[i].xvelocity > 0 && (sprites[i].x + sprites[i].width) > width)
|
778 | Â | - sprites[i].xvelocity = -sprites[i].xvelocity;
|
779 | Â | - sprites[i].y += sprites[i].yvelocity;
|
780 | Â | - if(sprites[i].yvelocity < 0 && sprites[i].y < 0) sprites[i].yvelocity = -sprites[i].yvelocity;
|
781 | Â | - if(sprites[i].yvelocity > 0 && (sprites[i].y + sprites[i].height) > height)
|
782 | Â | - sprites[i].yvelocity = -sprites[i].yvelocity;
|
783 | Â | - if(sprites[i].surface)
|
784 | Â | - {
|
785 | Â | - if(backbuffers) ddsrender->GetAttachedSurface(&ddscaps,&temp1);
|
786 | Â | - else temp1 = ddsrender;
|
787 | Â | - temp1->BltFast((DWORD)sprites[i].x,(DWORD)sprites[i].y,sprites[i].surface,&sprites[i].rect,sprites[i].bltflags);
|
788 | Â | - if(backbuffers) temp1->Release();
|
789 | Â | - }
|
790 | Â | - }
|
791 | Â | - if (fullscreen)
|
792 | Â | - {
|
793 | Â | - if (backbuffers && ddsrender) ddsrender->Flip(NULL, DDFLIP_WAIT);
|
794 | Â | - }
|
795 | Â | - else
|
796 | Â | - {
|
797 | Â | - p.x = 0;
|
798 | Â | - p.y = 0;
|
799 | Â | - ClientToScreen(hWnd, &p);
|
800 | Â | - GetClientRect(hWnd, &r1);
|
801 | Â | - OffsetRect(&r1, p.x, p.y);
|
802 | Â | - SetRect(&r2, 0, 0, width, height);
|
803 | Â | - if (ddsurface && ddsrender) ddsurface->Blt(&r1, ddsrender, &r2, DDBLT_WAIT, NULL);
|
804 | Â | - }
|
805 | Â | - break;
|
806 | Â | - case 10: // Source Key Override test
|
807 | Â | - case 11: // Destination Key Override Test
|
808 | Â | - if (backbuffers) ddsrender->GetAttachedSurface(&ddscaps, &temp1);
|
809 | Â | - else temp1 = ddsrender;
|
810 | Â | -
|
811 | Â | - sprites[0].surface->Blt(NULL, sprites[1].surface, NULL, DDBLT_WAIT, NULL);
|
812 | Â | - bltfx.dwSize = sizeof(DDBLTFX);
|
813 | Â | - switch (bpp)
|
814 | Â | - {
|
815 | Â | - case 8:
|
816 | Â | - bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
817 | Â | - bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue = counter;
|
818 | Â | - counter++;
|
819 | Â | - if (counter > 255) counter = 0;
|
820 | Â | - r1.left = r1.top = 0;
|
821 | Â | - r1.right = r1.bottom = 16;
|
822 | Â | - break;
|
823 | Â | - case 15:
|
824 | Â | - switch (counter >> 5)
|
825 | Â | - {
|
826 | Â | - case 0:
|
827 | Â | - bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
828 | Â | - bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
829 | Â | - (counter & 31) << 10;
|
830 | Â | - break;
|
831 | Â | - case 1:
|
832 | Â | - bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
833 | Â | - bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
834 | Â | - (counter & 31) << 5;
|
835 | Â | - break;
|
836 | Â | - case 2:
|
837 | Â | - bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
838 | Â | - bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
839 | Â | - (counter & 31);
|
840 | Â | - break;
|
841 | Â | - case 3:
|
842 | Â | - bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
843 | Â | - bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
844 | Â | - (counter & 31) + ((counter & 31) << 5);
|
845 | Â | - break;
|
846 | Â | - case 4:
|
847 | Â | - bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
848 | Â | - bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
849 | Â | - (counter & 31) + ((counter & 31) << 10);
|
850 | Â | - break;
|
851 | Â | - case 5:
|
852 | Â | - bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
853 | Â | - bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
854 | Â | - ((counter & 31) << 5) + ((counter & 31) << 10);
|
855 | Â | - break;
|
856 | Â | - case 6:
|
857 | Â | - default:
|
858 | Â | - bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
859 | Â | - bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
860 | Â | - (counter & 31) + ((counter & 31) << 5) + ((counter & 31) << 10);
|
861 | Â | - break;
|
862 | Â | - }
|
863 | Â | - counter++;
|
864 | Â | - if (counter > 223) counter = 0;
|
865 | Â | - r1.left = r1.top = 0;
|
866 | Â | - r1.right = 32;
|
867 | Â | - r1.bottom = 7;
|
868 | Â | - break;
|
869 | Â | - case 16:
|
870 | Â | - switch (counter >> 6)
|
871 | Â | - {
|
872 | Â | - case 0:
|
873 | Â | - bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
874 | Â | - bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
875 | Â | - ((counter & 63) >> 1) << 11;
|
876 | Â | - break;
|
877 | Â | - case 1:
|
878 | Â | - bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
879 | Â | - bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
880 | Â | - (counter & 63) << 5;
|
881 | Â | - break;
|
882 | Â | - case 2:
|
883 | Â | - bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
884 | Â | - bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
885 | Â | - (counter & 63) >> 1;
|
886 | Â | - break;
|
887 | Â | - case 3:
|
888 | Â | - bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
889 | Â | - bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
890 | Â | - ((counter & 63) >> 1) + ((counter & 63) << 5);
|
891 | Â | - break;
|
892 | Â | - case 4:
|
893 | Â | - bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
894 | Â | - bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
895 | Â | - ((counter & 63) >> 1) + (((counter & 63) >> 1) << 11);
|
896 | Â | - break;
|
897 | Â | - case 5:
|
898 | Â | - bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
899 | Â | - bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
900 | Â | - ((counter & 63) << 5) + (((counter & 63) >> 1) << 11);
|
901 | Â | - break;
|
902 | Â | - case 6:
|
903 | Â | - default:
|
904 | Â | - bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
905 | Â | - bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
906 | Â | - ((counter & 63) >> 1) + ((counter & 63) << 5) + (((counter & 63) >> 1) << 11);
|
907 | Â | - break;
|
908 | Â | - }
|
909 | Â | - counter++;
|
910 | Â | - if (counter > 447) counter = 0;
|
911 | Â | - r1.left = r1.top = 0;
|
912 | Â | - r1.right = 64;
|
913 | Â | - r1.bottom = 7;
|
914 | Â | - break;
|
915 | Â | - case 24:
|
916 | Â | - case 32:
|
917 | Â | - default:
|
918 | Â | - switch (counter >> 8)
|
919 | Â | - {
|
920 | Â | - case 0:
|
921 | Â | - bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
922 | Â | - bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
923 | Â | - (counter & 255) << 16;
|
924 | Â | - break;
|
925 | Â | - case 1:
|
926 | Â | - bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
927 | Â | - bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
928 | Â | - (counter & 255) << 8;
|
929 | Â | - break;
|
930 | Â | - case 2:
|
931 | Â | - bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
932 | Â | - bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
933 | Â | - counter & 255;
|
934 | Â | - break;
|
935 | Â | - case 3:
|
936 | Â | - bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
937 | Â | - bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
938 | Â | - (counter & 255) + ((counter & 255) << 8);
|
939 | Â | - break;
|
940 | Â | - case 4:
|
941 | Â | - bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
942 | Â | - bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
943 | Â | - (counter & 255) + ((counter & 255) << 16);
|
944 | Â | - break;
|
945 | Â | - case 5:
|
946 | Â | - bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
947 | Â | - bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
948 | Â | - ((counter & 255) << 8) + ((counter & 255) << 16);
|
949 | Â | - break;
|
950 | Â | - case 6:
|
951 | Â | - default:
|
952 | Â | - bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
953 | Â | - bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
954 | Â | - (counter & 255) + ((counter & 255) << 8) + ((counter & 255) << 16);
|
955 | Â | - break;
|
956 | Â | - }
|
957 | Â | - counter++;
|
958 | Â | - if (counter > 1791) counter = 0;
|
959 | Â | - r1.left = r1.top = 0;
|
960 | Â | - r1.right = 256;
|
961 | Â | - r1.bottom = 7;
|
962 | Â | - break;
|
963 | Â | - }
|
964 | Â | - if (test == 10)
|
965 | Â | - sprites[0].surface->Blt(NULL, sprites[2].surface, NULL, DDBLT_WAIT | DDBLT_KEYSRCOVERRIDE, &bltfx);
|
966 | Â | - else
|
967 | Â | - sprites[0].surface->Blt(NULL, sprites[2].surface, NULL, DDBLT_WAIT | DDBLT_KEYDESTOVERRIDE, &bltfx);
|
968 | Â | - temp1->GetDC(&hDCdest);
|
969 | Â | - sprites[0].surface->GetDC(&hDCsrc);
|
970 | Â | - if (ddver > 3) ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
971 | Â | - else ddsd.dwSize = sizeof(DDSURFACEDESC);
|
972 | Â | - temp1->GetSurfaceDesc(&ddsd);
|
973 | Â | - StretchBlt(hDCdest, ((ddsd.dwWidth / 2) - 128), ((ddsd.dwHeight / 2) + 128), 256, -256,
|
974 | Â | - hDCsrc, 0, 0, r1.right, r1.bottom, SRCCOPY);
|
975 | Â | - sprites[0].surface->ReleaseDC(hDCsrc);
|
976 | Â | - SetBkColor(hDCdest, RGB(0, 0, 255));
|
977 | Â | - SetTextColor(hDCdest, RGB(255, 255, 255));
|
978 | Â | - if(test == 10)
|
979 | Â | - _tcscpy(message, _T("Source Color Key Override Test"));
|
980 | Â | - else
|
981 | Â | - _tcscpy(message, _T("Destination Color Key Override Test"));
|
982 | Â | - TextOut(hDCdest, 0, 0, message, _tcslen(message));
|
983 | Â | - _stprintf(message, _T("Color: 0x%08X "), bltfx.ddckSrcColorkey.dwColorSpaceHighValue);
|
984 | Â | - TextOut(hDCdest, 0, 16, message, _tcslen(message));
|
985 | Â | - temp1->ReleaseDC(hDCdest);
|
986 | Â | - if (backbuffers) temp1->Release();
|
987 | Â | - if (fullscreen)
|
988 | Â | - {
|
989 | Â | - if (backbuffers && ddsrender) ddsrender->Flip(NULL, DDFLIP_WAIT);
|
990 | Â | - }
|
991 | Â | - else
|
992 | Â | - {
|
993 | Â | - p.x = 0;
|
994 | Â | - p.y = 0;
|
995 | Â | - ClientToScreen(hWnd, &p);
|
996 | Â | - GetClientRect(hWnd, &r1);
|
997 | Â | - OffsetRect(&r1, p.x, p.y);
|
998 | Â | - SetRect(&r2, 0, 0, width, height);
|
999 | Â | - if (ddsurface && ddsrender) ddsurface->Blt(&r1, ddsrender, &r2, DDBLT_WAIT, NULL);
|
1000 | Â | - }
|
1001 | Â | - break;
|
1002 | Â | - }
|
1003 | Â | -}
|
1004 | Â | -
|
1005 | Â | -void RunTestLooped2D(int test)
|
1006 | Â | -{
|
1007 | Â | - randnum += rand(); // Improves randomness of "snow" patterns at certain resolutions
|
1008 | Â | - HDC hdc;
|
1009 | Â | - unsigned int i;
|
1010 | Â | - POINT p;
|
1011 | Â | - HPEN pen;
|
1012 | Â | - HBRUSH brush;
|
1013 | Â | - HANDLE tmphandle,tmphandle2;
|
1014 | Â | - RECT srcrect,destrect;
|
1015 | Â | - HRESULT error;
|
1016 | Â | - DDSURFACEDESC2 ddsd;
|
1017 | Â | - DDBLTFX bltfx;
|
1018 | Â | - if(ddver > 3)ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
1019 | Â | - else ddsd.dwSize = sizeof(DDSURFACEDESC);
|
1020 | Â | - error = ddsrender->GetSurfaceDesc(&ddsd);
|
1021 | Â | - MultiDirectDrawSurface *temp1 = NULL;
|
1022 | Â | - DDSCAPS2 ddscaps;
|
1023 | Â | - DWORD bitmask;
|
1024 | Â | - ZeroMemory(&ddscaps,sizeof(DDSCAPS2));
|
1025 | Â | - ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
|
1026 | Â | - int op;
|
1027 | Â | - switch(test)
|
1028 | Â | - {
|
1029 | Â | - case 1:
|
1030 | Â | - default:
|
1031 | Â | - if(backbuffers)
|
1032 | Â | - {
|
1033 | Â | - ddsrender->GetAttachedSurface(&ddscaps,&temp1);
|
1034 | Â | - temp1->Lock(NULL,&ddsd,DDLOCK_WAIT,NULL);
|
1035 | Â | - }
|
1036 | Â | - else ddsrender->Lock(NULL,&ddsd,DDLOCK_WAIT,NULL);
|
1037 | Â | -
|
1038 | Â | - for(i = 0; i < ((ddsd.lPitch * ddsd.dwHeight)/4); i++)
|
1039 | Â | - ((DWORD*)ddsd.lpSurface)[i] = rand32(randnum);
|
1040 | Â | -
|
1041 | Â | - if(backbuffers)
|
1042 | Â | - {
|
1043 | Â | - temp1->Unlock(NULL);
|
1044 | Â | - ddsrender->Flip(NULL,DDFLIP_WAIT);
|
1045 | Â | - }
|
1046 | Â | - else ddsrender->Unlock(NULL);
|
1047 | Â | - if(!fullscreen)
|
1048 | Â | - {
|
1049 | Â | - p.x = 0;
|
1050 | Â | - p.y = 0;
|
1051 | Â | - ClientToScreen(hWnd,&p);
|
1052 | Â | - GetClientRect(hWnd,&destrect);
|
1053 | Â | - OffsetRect(&destrect,p.x,p.y);
|
1054 | Â | - SetRect(&srcrect,0,0,width,height);
|
1055 | Â | - if(ddsurface && ddsrender)error = ddsurface->Blt(&destrect,ddsrender,&srcrect,DDBLT_WAIT,NULL);
|
1056 | Â | - }
|
1057 | Â | - break;
|
1058 | Â | - case 3:
|
1059 | Â | - ddsrender->GetDC(&hdc);
|
1060 | Â | - op = rand32(randnum) % 4;
|
1061 | Â | - pen = CreatePen(rand32(randnum) % 5,0,RGB(rand32(randnum)%256,rand32(randnum)%256,rand32(randnum)%256));
|
1062 | Â | - brush = CreateSolidBrush(RGB(rand32(randnum)%256,rand32(randnum)%256,rand32(randnum)%256));
|
1063 | Â | - tmphandle = SelectObject(hdc,pen);
|
1064 | Â | - tmphandle2 = SelectObject(hdc,brush);
|
1065 | Â | - SetBkColor(hdc,RGB(rand32(randnum)%256,rand32(randnum)%256,rand32(randnum)%256));
|
1066 | Â | - switch(op)
|
1067 | Â | - {
|
1068 | Â | - case 0:
|
1069 | Â | - default:
|
1070 | Â | - Rectangle(hdc,rand32(randnum)%ddsd.dwWidth,rand32(randnum)%ddsd.dwHeight,
|
1071 | Â | - rand32(randnum)%ddsd.dwWidth,rand32(randnum)%ddsd.dwHeight);
|
1072 | Â | - break;
|
1073 | Â | - case 1:
|
1074 | Â | - Ellipse(hdc,rand32(randnum)%ddsd.dwWidth,rand32(randnum)%ddsd.dwHeight,
|
1075 | Â | - rand32(randnum)%ddsd.dwWidth,rand32(randnum)%ddsd.dwHeight);
|
1076 | Â | - break;
|
1077 | Â | - case 2:
|
1078 | Â | - MoveToEx(hdc,rand32(randnum)%ddsd.dwWidth,rand32(randnum)%ddsd.dwHeight,NULL);
|
1079 | Â | - LineTo(hdc,rand32(randnum)%ddsd.dwWidth,rand32(randnum)%ddsd.dwHeight);
|
1080 | Â | - break;
|
1081 | Â | - case 3:
|
1082 | Â | - SetTextColor(hdc,RGB(rand32(randnum)%256,rand32(randnum)%256,rand32(randnum)%256));
|
1083 | Â | - TextOut(hdc,rand32(randnum)%ddsd.dwWidth,rand32(randnum)%ddsd.dwHeight,_T("Text"),4);
|
1084 | Â | - break;
|
1085 | Â | - }
|
1086 | Â | - SelectObject(hdc,tmphandle2);
|
1087 | Â | - SelectObject(hdc,tmphandle);
|
1088 | Â | - DeleteObject(brush);
|
1089 | Â | - DeleteObject(pen);
|
1090 | Â | - ddsrender->ReleaseDC(hdc);
|
1091 | Â | - if(!fullscreen)
|
1092 | Â | - {
|
1093 | Â | - p.x = 0;
|
1094 | Â | - p.y = 0;
|
1095 | Â | - ClientToScreen(hWnd,&p);
|
1096 | Â | - GetClientRect(hWnd,&destrect);
|
1097 | Â | - OffsetRect(&destrect,p.x,p.y);
|
1098 | Â | - SetRect(&srcrect,0,0,width,height);
|
1099 | Â | - if(ddsurface && ddsrender)error = ddsurface->Blt(&destrect,ddsrender,&srcrect,DDBLT_WAIT,NULL);
|
1100 | Â | - }
|
1101 | Â | - break;
|
1102 | Â | - case 5:
|
1103 | Â | - rndrect5:
|
1104 | Â | - destrect.bottom = rand32(randnum)%ddsd.dwHeight;
|
1105 | Â | - destrect.top = rand32(randnum)%ddsd.dwHeight;
|
1106 | Â | - destrect.left = rand32(randnum)%ddsd.dwWidth;
|
1107 | Â | - destrect.right = rand32(randnum)%ddsd.dwWidth;
|
1108 | Â | - if((destrect.bottom < destrect.top) || (destrect.right < destrect.left)) goto rndrect5;
|
1109 | Â | - bltfx.dwSize = sizeof(DDBLTFX);
|
1110 | Â | - switch(bpp)
|
1111 | Â | - {
|
1112 | Â | - case 8:
|
1113 | Â | - bltfx.dwFillColor = rand32(randnum) % 0xFF;
|
1114 | Â | - break;
|
1115 | Â | - case 15:
|
1116 | Â | - bltfx.dwFillColor = rand32(randnum) % 0x7FFF;
|
1117 | Â | - break;
|
1118 | Â | - case 16:
|
1119 | Â | - bltfx.dwFillColor = rand32(randnum) % 0xFFFF;
|
1120 | Â | - break;
|
1121 | Â | - case 24:
|
1122 | Â | - case 32:
|
1123 | Â | - default:
|
1124 | Â | - bltfx.dwFillColor = rand32(randnum) % 0xFFFFFF;
|
1125 | Â | - break;
|
1126 | Â | - }
|
1127 | Â | - ddsrender->Blt(&destrect,NULL,NULL,DDBLT_COLORFILL,&bltfx);
|
1128 | Â | - if(!fullscreen)
|
1129 | Â | - {
|
1130 | Â | - p.x = 0;
|
1131 | Â | - p.y = 0;
|
1132 | Â | - ClientToScreen(hWnd,&p);
|
1133 | Â | - GetClientRect(hWnd,&destrect);
|
1134 | Â | - OffsetRect(&destrect,p.x,p.y);
|
1135 | Â | - SetRect(&srcrect,0,0,width,height);
|
1136 | Â | - if(ddsurface && ddsrender)error = ddsurface->Blt(&destrect,ddsrender,&srcrect,DDBLT_WAIT,NULL);
|
1137 | Â | - }
|
1138 | Â | - break;
|
1139 | Â | - case 9:
|
1140 | Â | - bltfx.dwSize = sizeof(DDBLTFX);
|
1141 | Â | - switch (bpp)
|
1142 | Â | - {
|
1143 | Â | - case 8:
|
1144 | Â | - bitmask = 0xFF;
|
1145 | Â | - break;
|
1146 | Â | - case 15:
|
1147 | Â | - bitmask = 0x7FFF;
|
1148 | Â | - break;
|
1149 | Â | - case 16:
|
1150 | Â | - bitmask = 0xFFFF;
|
1151 | Â | - break;
|
1152 | Â | - case 24:
|
1153 | Â | - bitmask = 0xFFFFFF;
|
1154 | Â | - break;
|
1155 | Â | - case 32:
|
1156 | Â | - default:
|
1157 | Â | - bitmask = 0xFFFFFFFF;
|
1158 | Â | - break;
|
1159 | Â | - }
|
1160 | Â | - for (int y = 0; y < 255; y++)
|
1161 | Â | - {
|
1162 | Â | - for (int x = 0; x < 255; x++)
|
1163 | Â | - {
|
1164 | Â | - bltfx.dwFillColor = counter & bitmask;
|
1165 | Â | - destrect.left = x;
|
1166 | Â | - destrect.right = x + 1;
|
1167 | Â | - destrect.top = y;
|
1168 | Â | - destrect.bottom = y + 1;
|
1169 | Â | - counter++;
|
1170 | Â | - sprites[0].surface->Blt(&destrect, NULL, NULL, DDBLT_COLORFILL, &bltfx);
|
1171 | Â | - }
|
1172 | Â | - }
|
1173 | Â | - ddsrender->Blt(NULL, sprites[0].surface, NULL, DDBLT_WAIT, NULL);
|
1174 | Â | - if (!fullscreen)
|
1175 | Â | - {
|
1176 | Â | - p.x = 0;
|
1177 | Â | - p.y = 0;
|
1178 | Â | - ClientToScreen(hWnd, &p);
|
1179 | Â | - GetClientRect(hWnd, &destrect);
|
1180 | Â | - OffsetRect(&destrect, p.x, p.y);
|
1181 | Â | - SetRect(&srcrect, 0, 0, width, height);
|
1182 | Â | - if (ddsurface && ddsrender)error = ddsurface->Blt(&destrect, ddsrender, &srcrect, DDBLT_WAIT, NULL);
|
1183 | Â | - }
|
1184 | Â | - break;
|
1185 | Â | - }
|
1186 | Â | - if(temp1) temp1->Release();
|
1187 | Â | -}
|
1188 | Â | -
|
1189 | Â | -/*
|
1190 | Â | -void DDFlipTestWindow::OnQueryNewPalette(wxQueryNewPaletteEvent& event)
|
1191 | Â | -{
|
1192 | Â | - //if(bpp == 8) ddsurface->SetPalette
|
1193 | Â | -}
|
1194 | Â | -*/ |
\ No newline at end of file |
Index: Installer/dxgl.nsi |
— | — | @@ -134,7 +134,7 @@ |
135 | 135 | VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "DXGL ${PRODUCT_VERSION} Installer"
|
136 | 136 | VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${PRODUCT_VERSION}"
|
137 | 137 | VIAddVersionKey /LANG=${LANG_ENGLISH} "InternalName" "DXGL"
|
138 | Â | -VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright © 2011-2015 William Feely"
|
 | 138 | +VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright © 2011-2017 William Feely"
|
139 | 139 | VIAddVersionKey /LANG=${LANG_ENGLISH} "OriginalFilename" "DXGL-${PRODUCT_VERSION}-win32.exe"
|
140 | 140 | VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "DXGL"
|
141 | 141 | VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "${PRODUCT_VERSION}"
|
Index: dxgltest/dxgltest.cpp |
— | — | @@ -210,76 +210,56 @@ |
211 | 211 | int maxver;
|
212 | 212 | int buffermin;
|
213 | 213 | int buffermax;
|
214 | Â | - bool usesfps;
|
 | 214 | + BOOL usesfps;
|
215 | 215 | float defaultfps;
|
216 | Â | - bool usestexture;
|
217 | Â | - bool usesfsaa;
|
 | 216 | + BOOL is3d;
|
 | 217 | + BOOL usestexture;
|
 | 218 | + BOOL usesfsaa;
|
218 | 219 | TCHAR *name;
|
219 | 220 | } TEST_ITEM;
|
220 | 221 |
|
221 | 222 | // Use EXACTLY one line per entry. Don't change layout of the list.
|
222 | Â | -const int START_2D = __LINE__;
|
223 | Â | -const TEST_ITEM Tests2D[] =
|
224 | Â | -{ // minver maxver buffermin max usesfps defaultfps usestexture usesfsaa name
|
225 | Â | - {1, 7, 0, 4, true, 1.0, false, false, _T("Color palette and gradient screens (direct surface access)")},
|
226 | Â | - {1, 7, 0, 1, false, 0.0, false, false, _T("Random noise (continuous surface upload)")},
|
227 | Â | - {1, 7, 0, 7, true, 1.0, false, false, _T("GDI Test patterns (GetDC() test)")},
|
228 | Â | - {1, 7, 0, 0, false, 0.0, false, false, _T("Random GDI patterns (does not clear screen between paints)")},
|
229 | Â | - {1, 7, 0, 1, true, 60.0, false, false, _T("BltFast background and sprites")},
|
230 | Â | - {1, 7, 0, 0, false, 0.0, false, false, _T("Random color fill Blt() paterns")},
|
231 | Â | - {1, 7, 0, 0, false, 0.0, false, false, _T("Mouse pointer event test")},
|
232 | Â | - {1, 7, 1, 1, true, 1.0, false, false, _T("Raster Operation Blt() test")},
|
233 | Â | - {1, 7, 0, 0, false, 0.0, false, false, _T("Mirrored and Rotated Blt() test")},
|
234 | Â | - {1, 7, 0, 1, false, 0.0, false, false, _T("Large batch color fill Blt() operations")},
|
235 | Â | - {1, 7, 0, 1, true, 60.0, false, false, _T("Source Color Key Override test")},
|
236 | Â | - {1, 7, 0, 1, true, 60.0, false, false, _T("Destination Color Key Override test")}
|
 | 223 | +const int START_TESTS = __LINE__;
|
 | 224 | +const TEST_ITEM Tests[] =
|
 | 225 | +{ // minver maxver buffermin max usesfps defaultfps is3d usestexture usesfsaa name
|
 | 226 | + {1, 7, 0, 4, TRUE, 1.0, FALSE, FALSE, FALSE, _T("Color palette and gradient screens (direct surface access)")},
|
 | 227 | + {1, 7, 0, 1, FALSE, 0.0, FALSE, FALSE, FALSE, _T("Random noise (continuous surface upload)")},
|
 | 228 | + {1, 7, 0, 7, TRUE, 1.0, FALSE, FALSE, FALSE, _T("GDI Test patterns (GetDC() test)")},
|
 | 229 | + {1, 7, 0, 0, FALSE, 0.0, FALSE, FALSE, FALSE, _T("Random GDI patterns (does not clear screen between paints)")},
|
 | 230 | + {1, 7, 0, 1, TRUE, 60.0, FALSE, FALSE, FALSE, _T("BltFast background and sprites")},
|
 | 231 | + {1, 7, 0, 0, FALSE, 0.0, FALSE, FALSE, FALSE, _T("Random color fill Blt() paterns")},
|
 | 232 | + {1, 7, 0, 0, FALSE, 0.0, FALSE, FALSE, FALSE, _T("Mouse pointer event test")},
|
 | 233 | + {1, 7, 1, 1, TRUE, 1.0, FALSE, FALSE, FALSE, _T("Raster Operation Blt() test")},
|
 | 234 | + {1, 7, 0, 0, FALSE, 0.0, FALSE, FALSE, FALSE, _T("Mirrored and Rotated Blt() test")},
|
 | 235 | + {1, 7, 0, 1, FALSE, 0.0, FALSE, FALSE, FALSE, _T("Large batch color fill Blt() operations")},
|
 | 236 | + {1, 7, 0, 1, TRUE, 60.0, FALSE, FALSE, FALSE, _T("Source Color Key Override test")},
|
 | 237 | + {1, 7, 0, 1, TRUE, 60.0, FALSE, FALSE, FALSE, _T("Destination Color Key Override test")},
|
 | 238 | + {7, 7, 0, 2, TRUE, 60.0, TRUE, FALSE, TRUE, _T("DrawIndexedPrimitive cube with directional light (DX7)")},
|
 | 239 | + {7, 7, 0, 2, TRUE, 60.0, TRUE, TRUE, TRUE, _T("DrawPrimitive textured cube (DX7)")},
|
 | 240 | + {7, 7, 0, 0, TRUE, 60.0, TRUE, TRUE, TRUE, _T("Texture Stage shaders (Interactive, DX7)")},
|
 | 241 | + {7, 7, 0, 0, TRUE, 60.0, TRUE, TRUE, TRUE, _T("Vertex shaders (Interactive, DX7)")}
|
237 | 242 | };
|
238 | Â | -const int END_2D = __LINE__ - 4;
|
239 | Â | -const int numtests2d = END_2D - START_2D;
|
 | 243 | +const int END_TESTS = __LINE__ - 4;
|
 | 244 | +const int numtests = END_TESTS - START_TESTS;
|
240 | 245 |
|
241 | Â | -int currenttest2d = 0;
|
242 | Â | -int minapi2d = 1;
|
243 | Â | -int maxapi2d = 7;
|
244 | Â | -int minbuffer2d = 0;
|
245 | Â | -int maxbuffer2d = 4;
|
246 | Â | -int fps_enabled2d = false;
|
247 | Â | -int api2d = 1;
|
248 | Â | -int buffer2d = 1;
|
249 | Â | -bool fullscreen2d = true;
|
250 | Â | -bool resizable2d = false;
|
251 | Â | -double framerate2d = 1.00;
|
252 | Â | -TCHAR framerate2dstring[33];
|
 | 246 | +int currenttest = 0;
|
 | 247 | +int minapi = 1;
|
 | 248 | +int maxapi = 7;
|
 | 249 | +int minbuffer = 0;
|
 | 250 | +int maxbuffer = 4;
|
 | 251 | +int fps_enabled = false;
|
 | 252 | +int api = 1;
|
 | 253 | +int buffer = 1;
|
 | 254 | +int filter = 0;
|
 | 255 | +int msaa = 0;
|
 | 256 | +bool fullscreen = true;
|
 | 257 | +bool resizable = false;
|
 | 258 | +double framerate = 1.00;
|
 | 259 | +TCHAR frameratestring[33];
|
253 | 260 |
|
254 | Â | -// Use EXACTLY one line per entry. Don't change layout of the list.
|
255 | Â | -const int START_3D = __LINE__;
|
256 | Â | -const TEST_ITEM Tests3D[] =
|
257 | Â | -{ // minver maxver buffermin max usesfps defaultfps usestexture usesfsaa name
|
258 | Â | - {7, 7, 0, 2, true, 60.0, false, true, _T("DrawIndexedPrimitive cube with directional light (DX7)")},
|
259 | Â | - {7, 7, 0, 2, true, 60.0, true, true, _T("DrawPrimitive textured cube (DX7)")},
|
260 | Â | - {7, 7, 0, 0, true, 60.0, true, true, _T("Texture Stage shaders (Interactive, DX7)")},
|
261 | Â | - {7, 7, 0, 0, true, 60.0, true, true, _T("Vertex shaders (Interactive, DX7)")}
|
262 | Â | -};
|
263 | Â | -const int END_3D = __LINE__ - 4;
|
264 | Â | -const int numtests3d = END_3D - START_3D;
|
 | 261 | +TCHAR tmpstring[33];
|
265 | 262 |
|
266 | Â | -int currenttest3d = 0;
|
267 | Â | -int minapi3d = 7;
|
268 | Â | -int maxapi3d = 7;
|
269 | Â | -int minbuffer3d = 0;
|
270 | Â | -int maxbuffer3d = 2;
|
271 | Â | -int fps_enabled3d = true;
|
272 | Â | -int api3d = 7;
|
273 | Â | -int buffer3d = 1;
|
274 | Â | -int filter3d = 0;
|
275 | Â | -int msaa3d = 0;
|
276 | Â | -bool fullscreen3d = true;
|
277 | Â | -bool resizable3d = true;
|
278 | Â | -double framerate3d = 60.00;
|
279 | Â | -TCHAR framerate3dstring[33];
|
280 | Â | -
|
281 | Â | -
|
282 | Â | -TCHAR tmpstring[33];
|
283 | Â | -INT_PTR CALLBACK Test2DCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
 | 263 | +INT_PTR CALLBACK TestTabCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
284 | 264 | {
|
285 | 265 | int i;
|
286 | 266 | int pos;
|
— | — | @@ -291,14 +271,10 @@ |
292 | 272 | {
|
293 | 273 | case WM_INITDIALOG:
|
294 | 274 | if (_EnableThemeDialogTexture) _EnableThemeDialogTexture(hWnd, ETDT_ENABLETAB);
|
295 | Â | - DestroyWindow(GetDlgItem(hWnd,IDC_FILTERLABEL));
|
296 | Â | - DestroyWindow(GetDlgItem(hWnd,IDC_FILTER));
|
297 | Â | - DestroyWindow(GetDlgItem(hWnd,IDC_FSAALABEL));
|
298 | Â | - DestroyWindow(GetDlgItem(hWnd,IDC_FSAA));
|
299 | 275 | SendDlgItemMessage(hWnd,IDC_FULLSCREEN,BM_SETCHECK,1,0);
|
300 | Â | - SetDlgItemText(hWnd,IDC_TESTHEADER,_T("Test 2D graphics functionality in DXGL or DirectDraw. Press ESC to quit any test."));
|
301 | Â | - for(i = 0; i < numtests2d; i++)
|
302 | Â | - SendDlgItemMessage(hWnd,IDC_TESTLIST,LB_ADDSTRING,0,(LPARAM)Tests2D[i].name);
|
 | 276 | + SetDlgItemText(hWnd,IDC_TESTHEADER,_T("Test graphics functionality in DXGL or DirectDraw. Press ESC to quit any test."));
|
 | 277 | + for(i = 0; i < numtests; i++)
|
 | 278 | + SendDlgItemMessage(hWnd,IDC_TESTLIST,LB_ADDSTRING,0,(LPARAM)Tests[i].name);
|
303 | 279 | error = DirectDrawCreate(NULL,&lpdd,NULL);
|
304 | 280 | if(error == DD_OK)
|
305 | 281 | {
|
— | — | @@ -316,226 +292,28 @@ |
317 | 293 | i = SendDlgItemMessage(hWnd,IDC_TESTLIST,LB_GETCURSEL,0,0);
|
318 | 294 | if(i != -1)
|
319 | 295 | {
|
320 | Â | - currenttest2d = i;
|
321 | Â | - minapi2d = Tests2D[i].minver;
|
322 | Â | - maxapi2d = Tests2D[i].maxver;
|
323 | Â | - minbuffer2d = Tests2D[i].buffermin;
|
324 | Â | - maxbuffer2d = Tests2D[i].buffermax;
|
325 | Â | - fps_enabled2d = Tests2D[i].usesfps;
|
326 | Â | - if(Tests2D[i].usesfps) framerate2d = Tests2D[i].defaultfps;
|
327 | Â | - EnableWindow(GetDlgItem(hWnd,IDC_BUFFERS),TRUE);
|
328 | Â | - EnableWindow(GetDlgItem(hWnd,IDC_APIVER),TRUE);
|
329 | Â | - EnableWindow(GetDlgItem(hWnd,IDC_FRAMERATE),fps_enabled2d);
|
330 | Â | - EnableWindow(GetDlgItem(hWnd,IDC_TEST),TRUE);
|
331 | Â | - SendDlgItemMessage(hWnd,IDC_BUFFERS,EM_SETLIMITTEXT,2,0);
|
332 | Â | - SendDlgItemMessage(hWnd,IDC_APIVER,EM_SETLIMITTEXT,1,0);
|
333 | Â | - SendDlgItemMessage(hWnd,IDC_FRAMERATE,EM_SETLIMITTEXT,5,0);
|
334 | Â | - SendDlgItemMessage(hWnd,IDC_BUFFERS,WM_SETTEXT,0,(LPARAM)_itot(buffer2d,tmpstring,10));
|
335 | Â | - SendDlgItemMessage(hWnd,IDC_APIVER,WM_SETTEXT,0,(LPARAM)_itot(api2d,tmpstring,10));
|
336 | Â | - _stprintf(framerate2dstring,_T("%.2f"),framerate2d);
|
337 | Â | - SendDlgItemMessage(hWnd,IDC_FRAMERATE,WM_SETTEXT,0,(LPARAM)framerate2dstring);
|
338 | Â | - }
|
339 | Â | - }
|
340 | Â | - break;
|
341 | Â | - case IDC_FRAMERATE:
|
342 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
343 | Â | - {
|
344 | Â | - SendDlgItemMessage(hWnd,IDC_FRAMERATE,WM_GETTEXT,6,(LPARAM)tmpstring);
|
345 | Â | - if(_tcscmp(framerate2dstring,tmpstring))
|
346 | Â | - {
|
347 | Â | - pos = LOWORD(SendDlgItemMessage(hWnd,IDC_FRAMERATE,EM_GETSEL,NULL,NULL));
|
348 | Â | - i = _tcslen(tmpstring);
|
349 | Â | - f = _ttof(tmpstring);
|
350 | Â | - if(errno != ERANGE) framerate2d = f;
|
351 | Â | - if(framerate2d < 0.5) framerate2d = 0.5;
|
352 | Â | - if(framerate2d > 99.99) framerate2d = 99.99;
|
353 | Â | - _stprintf(framerate2dstring,_T("%.2f"),framerate2d);
|
354 | Â | - SendDlgItemMessage(hWnd,IDC_FRAMERATE,WM_SETTEXT,0,(LPARAM)framerate2dstring);
|
355 | Â | - SendDlgItemMessage(hWnd,IDC_FRAMERATE,EM_SETSEL,pos,pos);
|
356 | Â | - }
|
357 | Â | - }
|
358 | Â | - break;
|
359 | Â | - case IDC_APIVER:
|
360 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
361 | Â | - {
|
362 | Â | - SendDlgItemMessage(hWnd,IDC_APIVER,WM_GETTEXT,6,(LPARAM)tmpstring);
|
363 | Â | - i = _ttoi(tmpstring);
|
364 | Â | - if(i != api2d)
|
365 | Â | - {
|
366 | Â | - api2d = i;
|
367 | Â | - if(api2d == 5) api2d = 4;
|
368 | Â | - if(api2d == 6) api2d = 7;
|
369 | Â | - if(api2d < minapi2d) api2d = minapi2d;
|
370 | Â | - if(api2d > maxapi2d) api2d = maxapi2d;
|
371 | Â | - _itot(api2d,tmpstring,10);
|
372 | Â | - SendDlgItemMessage(hWnd,IDC_APIVER,WM_SETTEXT,0,(LPARAM)tmpstring);
|
373 | Â | - }
|
374 | Â | - }
|
375 | Â | - break;
|
376 | Â | - case IDC_BUFFERS:
|
377 | Â | - if(HIWORD(wParam) == EN_CHANGE)
|
378 | Â | - {
|
379 | Â | - SendDlgItemMessage(hWnd,IDC_BUFFERS,WM_GETTEXT,6,(LPARAM)tmpstring);
|
380 | Â | - i = _ttoi(tmpstring);
|
381 | Â | - if(i != buffer2d)
|
382 | Â | - {
|
383 | Â | - buffer2d = i;
|
384 | Â | - if(buffer2d < minbuffer2d) buffer2d = minbuffer2d;
|
385 | Â | - if(buffer2d > maxbuffer2d) buffer2d = maxbuffer2d;
|
386 | Â | - _itot(buffer2d,tmpstring,10);
|
387 | Â | - SendDlgItemMessage(hWnd,IDC_BUFFERS,WM_SETTEXT,0,(LPARAM)tmpstring);
|
388 | Â | - }
|
389 | Â | - }
|
390 | Â | - break;
|
391 | Â | - case IDC_TEST:
|
392 | Â | - if(SendDlgItemMessage(hWnd,IDC_RESIZABLE,BM_GETCHECK,0,0)) resizable2d = true;
|
393 | Â | - else resizable2d = false;
|
394 | Â | - if (buffer2d < minbuffer2d) buffer2d = minbuffer2d;
|
395 | Â | - if (buffer2d > maxbuffer2d) buffer2d = maxbuffer2d;
|
396 | Â | - i = SendDlgItemMessage(hWnd, IDC_VIDMODES, LB_GETCURSEL, 0, 0);
|
397 | Â | - SendDlgItemMessage(hWnd,IDC_VIDMODES,LB_GETTEXT,i,(LPARAM)tmpstring);
|
398 | Â | - TranslateResolutionString(tmpstring,width,height,bpp,refresh);
|
399 | Â | - RunTest2D(currenttest2d,width,height,bpp,refresh,buffer2d,api2d,framerate2d,fullscreen2d,resizable2d);
|
400 | Â | - break;
|
401 | Â | - case IDC_WINDOWED:
|
402 | Â | - SendDlgItemMessage(hWnd,IDC_FULLSCREEN,BM_SETCHECK,0,0);
|
403 | Â | - SendDlgItemMessage(hWnd,IDC_WINDOWED,BM_SETCHECK,1,0);
|
404 | Â | - fullscreen2d = false;
|
405 | Â | - break;
|
406 | Â | - case IDC_FULLSCREEN:
|
407 | Â | - SendDlgItemMessage(hWnd,IDC_FULLSCREEN,BM_SETCHECK,1,0);
|
408 | Â | - SendDlgItemMessage(hWnd,IDC_WINDOWED,BM_SETCHECK,0,0);
|
409 | Â | - fullscreen2d = true;
|
410 | Â | - break;
|
411 | Â | - }
|
412 | Â | - break;
|
413 | Â | - case WM_NOTIFY:
|
414 | Â | - switch(((LPNMHDR)lParam)->code)
|
415 | Â | - {
|
416 | Â | - case UDN_DELTAPOS:
|
417 | Â | - switch(((LPNMHDR)lParam)->idFrom)
|
418 | Â | - {
|
419 | Â | - case IDC_SPINFRAME:
|
420 | Â | - framerate2d -= ((LPNMUPDOWN)lParam)->iDelta;
|
421 | Â | - if(framerate2d < 0.01) framerate2d = 0.01;
|
422 | Â | - if(framerate2d > 99.99) framerate2d = 99.99;
|
423 | Â | - _stprintf(framerate2dstring,_T("%.2f"),framerate2d);
|
424 | Â | - SendDlgItemMessage(hWnd,IDC_FRAMERATE,WM_SETTEXT,0,(LPARAM)framerate2dstring);
|
425 | Â | - break;
|
426 | Â | - case IDC_SPINAPI:
|
427 | Â | - if(api2d < 1) api2d = 1;
|
428 | Â | - if(api2d > 7) api2d = 7;
|
429 | Â | - if(((LPNMUPDOWN)lParam)->iDelta > 0)
|
430 | Â | - {
|
431 | Â | - switch(api2d)
|
 | 296 | + currenttest = i;
|
 | 297 | + minapi = Tests[i].minver;
|
 | 298 | + maxapi = Tests[i].maxver;
|
 | 299 | + if (api < minapi)
|
432 | 300 | {
|
433 | Â | - case 1:
|
434 | Â | - case 2:
|
435 | Â | - default:
|
436 | Â | - api2d = 1;
|
437 | Â | - break;
|
438 | Â | - case 3:
|
439 | Â | - api2d = 2;
|
440 | Â | - break;
|
441 | Â | - case 4:
|
442 | Â | - api2d = 3;
|
443 | Â | - break;
|
444 | Â | - case 7:
|
445 | Â | - case 6:
|
446 | Â | - case 5:
|
447 | Â | - api2d = 4;
|
 | 301 | + SendDlgItemMessage(hWnd, IDC_APIVER, WM_SETTEXT, 0, (LPARAM)_itot(minapi, tmpstring, 10));
|
 | 302 | + api = minapi;
|
448 | 303 | }
|
449 | Â | - }
|
450 | Â | - else
|
451 | Â | - {
|
452 | Â | - switch(api2d)
|
 | 304 | + if (api > maxapi)
|
453 | 305 | {
|
454 | Â | - case 1:
|
455 | Â | - default:
|
456 | Â | - api2d = 2;
|
457 | Â | - break;
|
458 | Â | - case 2:
|
459 | Â | - api2d = 3;
|
460 | Â | - break;
|
461 | Â | - case 3:
|
462 | Â | - api2d = 4;
|
463 | Â | - break;
|
464 | Â | - case 4:
|
465 | Â | - case 5:
|
466 | Â | - case 6:
|
467 | Â | - case 7:
|
468 | Â | - api2d = 7;
|
 | 306 | + SendDlgItemMessage(hWnd, IDC_APIVER, WM_SETTEXT, 0, (LPARAM)_itot(maxapi, tmpstring, 10));
|
 | 307 | + api = maxapi;
|
469 | 308 | }
|
470 | Â | - }
|
471 | Â | - if(api2d < minapi2d) api2d = minapi2d;
|
472 | Â | - if(api2d > maxapi2d) api2d = maxapi2d;
|
473 | Â | - SendDlgItemMessage(hWnd,IDC_APIVER,WM_SETTEXT,0,(LPARAM)_itot(api2d,tmpstring,10));
|
474 | Â | - break;
|
475 | Â | - case IDC_SPINBACK:
|
476 | Â | - buffer2d -= ((LPNMUPDOWN)lParam)->iDelta;
|
477 | Â | - if(buffer2d < minbuffer2d) buffer2d = minbuffer2d;
|
478 | Â | - if(buffer2d > maxbuffer2d) buffer2d = maxbuffer2d;
|
479 | Â | - SendDlgItemMessage(hWnd,IDC_BUFFERS,WM_SETTEXT,0,(LPARAM)_itot(buffer2d,tmpstring,10));
|
480 | Â | - break;
|
481 | Â | - default:
|
482 | Â | - break;
|
483 | Â | - }
|
484 | Â | - break;
|
485 | Â | - default:
|
486 | Â | - break;
|
487 | Â | - }
|
488 | Â | - break;
|
489 | Â | - default:
|
490 | Â | - return FALSE;
|
491 | Â | - }
|
492 | Â | - return TRUE;
|
493 | Â | -}
|
494 | Â | -
|
495 | Â | -INT_PTR CALLBACK Test3DCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
496 | Â | -{
|
497 | Â | - int i;
|
498 | Â | - int pos;
|
499 | Â | - double f;
|
500 | Â | - LPDIRECTDRAW lpdd;
|
501 | Â | - HRESULT error;
|
502 | Â | - int width,height,bpp,refresh;
|
503 | Â | - switch(Msg)
|
504 | Â | - {
|
505 | Â | - case WM_INITDIALOG:
|
506 | Â | - if (_EnableThemeDialogTexture) _EnableThemeDialogTexture(hWnd, ETDT_ENABLETAB);
|
507 | Â | - SendDlgItemMessage(hWnd,IDC_FULLSCREEN,BM_SETCHECK,1,0);
|
508 | Â | - SetDlgItemText(hWnd,IDC_TESTHEADER,_T("Test 3D graphics functionality in DXGL or Direct3D. Press ESC to quit any test."));
|
509 | Â | - for(i = 0; i < numtests3d; i++)
|
510 | Â | - SendDlgItemMessage(hWnd,IDC_TESTLIST,LB_ADDSTRING,0,(LPARAM)Tests3D[i].name);
|
511 | Â | - error = DirectDrawCreate(NULL,&lpdd,NULL);
|
512 | Â | - if(error == DD_OK)
|
513 | Â | - {
|
514 | Â | - error = lpdd->EnumDisplayModes(DDEDM_REFRESHRATES,NULL,GetDlgItem(hWnd,IDC_VIDMODES),EnumModesCallback32);
|
515 | Â | - lpdd->Release();
|
516 | Â | - }
|
517 | Â | - SendDlgItemMessage(hWnd,IDC_VIDMODES,LB_SETCURSEL,modenum,0);
|
518 | Â | - break;
|
519 | Â | - case WM_COMMAND:
|
520 | Â | - switch(LOWORD(wParam))
|
521 | Â | - {
|
522 | Â | - case IDC_TESTLIST:
|
523 | Â | - if(HIWORD(wParam) == LBN_SELCHANGE)
|
524 | Â | - {
|
525 | Â | - i = SendDlgItemMessage(hWnd,IDC_TESTLIST,LB_GETCURSEL,0,0);
|
526 | Â | - if(i != -1)
|
527 | Â | - {
|
528 | Â | - currenttest3d = i;
|
529 | Â | - minapi3d = Tests3D[i].minver;
|
530 | Â | - maxapi3d = Tests3D[i].maxver;
|
531 | Â | - minbuffer3d = Tests3D[i].buffermin;
|
532 | Â | - maxbuffer3d = Tests3D[i].buffermax;
|
533 | Â | - fps_enabled3d = Tests3D[i].usesfps;
|
534 | Â | - if(Tests3D[i].usesfps) framerate3d = Tests3D[i].defaultfps;
|
535 | Â | - if((i != 2) && (i !=3))
|
 | 309 | + minbuffer = Tests[i].buffermin;
|
 | 310 | + maxbuffer = Tests[i].buffermax;
|
 | 311 | + fps_enabled = Tests[i].usesfps;
|
 | 312 | + if(Tests[i].usesfps) framerate = Tests[i].defaultfps;
|
 | 313 | + if((i != 14) && (i != 15))
|
536 | 314 | {
|
537 | 315 | EnableWindow(GetDlgItem(hWnd,IDC_BUFFERS),TRUE);
|
538 | 316 | EnableWindow(GetDlgItem(hWnd,IDC_APIVER),TRUE);
|
539 | Â | - EnableWindow(GetDlgItem(hWnd,IDC_FRAMERATE),fps_enabled3d);
|
 | 317 | + EnableWindow(GetDlgItem(hWnd,IDC_FRAMERATE),fps_enabled);
|
540 | 318 | EnableWindow(GetDlgItem(hWnd,IDC_TEST),TRUE);
|
541 | 319 | EnableWindow(GetDlgItem(hWnd,IDC_WINDOWED),TRUE);
|
542 | 320 | EnableWindow(GetDlgItem(hWnd,IDC_FULLSCREEN),TRUE);
|
— | — | @@ -556,15 +334,15 @@ |
557 | 335 | EnableWindow(GetDlgItem(hWnd,IDC_VIDMODES),FALSE);
|
558 | 336 | SendDlgItemMessage(hWnd,IDC_WINDOWED,BM_SETCHECK,BST_CHECKED,0);
|
559 | 337 | SendDlgItemMessage(hWnd,IDC_FULLSCREEN,BM_SETCHECK,BST_UNCHECKED,0);
|
560 | Â | - fullscreen3d = false;
|
 | 338 | + fullscreen = false;
|
561 | 339 | }
|
562 | 340 | SendDlgItemMessage(hWnd,IDC_BUFFERS,EM_SETLIMITTEXT,2,0);
|
563 | 341 | SendDlgItemMessage(hWnd,IDC_APIVER,EM_SETLIMITTEXT,1,0);
|
564 | 342 | SendDlgItemMessage(hWnd,IDC_FRAMERATE,EM_SETLIMITTEXT,5,0);
|
565 | Â | - SendDlgItemMessage(hWnd,IDC_BUFFERS,WM_SETTEXT,0,(LPARAM)_itot(buffer3d,tmpstring,10));
|
566 | Â | - SendDlgItemMessage(hWnd,IDC_APIVER,WM_SETTEXT,0,(LPARAM)_itot(api3d,tmpstring,10));
|
567 | Â | - _stprintf(framerate3dstring,_T("%.2f"),framerate3d);
|
568 | Â | - SendDlgItemMessage(hWnd,IDC_FRAMERATE,WM_SETTEXT,0,(LPARAM)framerate3dstring);
|
 | 343 | + SendDlgItemMessage(hWnd,IDC_BUFFERS,WM_SETTEXT,0,(LPARAM)_itot(buffer,tmpstring,10));
|
 | 344 | + SendDlgItemMessage(hWnd,IDC_APIVER,WM_SETTEXT,0,(LPARAM)_itot(api,tmpstring,10));
|
 | 345 | + _stprintf(frameratestring,_T("%.2f"),framerate);
|
 | 346 | + SendDlgItemMessage(hWnd,IDC_FRAMERATE,WM_SETTEXT,0,(LPARAM)frameratestring);
|
569 | 347 | }
|
570 | 348 | }
|
571 | 349 | break;
|
— | — | @@ -572,16 +350,16 @@ |
573 | 351 | if(HIWORD(wParam) == EN_CHANGE)
|
574 | 352 | {
|
575 | 353 | SendDlgItemMessage(hWnd,IDC_FRAMERATE,WM_GETTEXT,6,(LPARAM)tmpstring);
|
576 | Â | - if(_tcscmp(framerate3dstring,tmpstring))
|
 | 354 | + if(_tcscmp(frameratestring,tmpstring))
|
577 | 355 | {
|
578 | 356 | pos = LOWORD(SendDlgItemMessage(hWnd,IDC_FRAMERATE,EM_GETSEL,NULL,NULL));
|
579 | 357 | i = _tcslen(tmpstring);
|
580 | 358 | f = _ttof(tmpstring);
|
581 | Â | - if(errno != ERANGE) framerate3d = f;
|
582 | Â | - if(framerate3d < 0.5) framerate3d = 0.5;
|
583 | Â | - if(framerate3d > 99.99) framerate3d = 99.99;
|
584 | Â | - _stprintf(framerate3dstring,_T("%.2f"),framerate3d);
|
585 | Â | - SendDlgItemMessage(hWnd,IDC_FRAMERATE,WM_SETTEXT,0,(LPARAM)framerate3dstring);
|
 | 359 | + if(errno != ERANGE) framerate = f;
|
 | 360 | + if(framerate < 0.5) framerate = 0.5;
|
 | 361 | + if(framerate > 99.99) framerate = 99.99;
|
 | 362 | + _stprintf(frameratestring,_T("%.2f"),framerate);
|
 | 363 | + SendDlgItemMessage(hWnd,IDC_FRAMERATE,WM_SETTEXT,0,(LPARAM)frameratestring);
|
586 | 364 | SendDlgItemMessage(hWnd,IDC_FRAMERATE,EM_SETSEL,pos,pos);
|
587 | 365 | }
|
588 | 366 | }
|
— | — | @@ -591,14 +369,14 @@ |
592 | 370 | {
|
593 | 371 | SendDlgItemMessage(hWnd,IDC_APIVER,WM_GETTEXT,6,(LPARAM)tmpstring);
|
594 | 372 | i = _ttoi(tmpstring);
|
595 | Â | - if(i != api3d)
|
 | 373 | + if(i != api)
|
596 | 374 | {
|
597 | Â | - api3d = i;
|
598 | Â | - if(api3d == 5) api3d = 4;
|
599 | Â | - if(api3d == 6) api3d = 7;
|
600 | Â | - if(api3d < minapi3d) api3d = minapi3d;
|
601 | Â | - if(api3d > maxapi3d) api3d = maxapi3d;
|
602 | Â | - _itot(api3d,tmpstring,10);
|
 | 375 | + api = i;
|
 | 376 | + if(api == 5) api = 4;
|
 | 377 | + if(api == 6) api = 7;
|
 | 378 | + if(api < minapi) api = minapi;
|
 | 379 | + if(api > maxapi) api = maxapi;
|
 | 380 | + _itot(api,tmpstring,10);
|
603 | 381 | SendDlgItemMessage(hWnd,IDC_APIVER,WM_SETTEXT,0,(LPARAM)tmpstring);
|
604 | 382 | }
|
605 | 383 | }
|
— | — | @@ -608,33 +386,36 @@ |
609 | 387 | {
|
610 | 388 | SendDlgItemMessage(hWnd,IDC_BUFFERS,WM_GETTEXT,6,(LPARAM)tmpstring);
|
611 | 389 | i = _ttoi(tmpstring);
|
612 | Â | - if(i != buffer3d)
|
 | 390 | + if(i != buffer)
|
613 | 391 | {
|
614 | Â | - buffer3d = i;
|
615 | Â | - if(buffer3d < minbuffer3d) buffer3d = minbuffer3d;
|
616 | Â | - if(buffer3d > maxbuffer3d) buffer3d = maxbuffer3d;
|
617 | Â | - _itot(buffer3d,tmpstring,10);
|
 | 392 | + buffer = i;
|
 | 393 | + if(buffer < minbuffer) buffer = minbuffer;
|
 | 394 | + if(buffer > maxbuffer) buffer = maxbuffer;
|
 | 395 | + _itot(buffer,tmpstring,10);
|
618 | 396 | SendDlgItemMessage(hWnd,IDC_BUFFERS,WM_SETTEXT,0,(LPARAM)tmpstring);
|
619 | 397 | }
|
620 | 398 | }
|
621 | 399 | break;
|
622 | 400 | case IDC_TEST:
|
623 | Â | - if(SendDlgItemMessage(hWnd,IDC_RESIZABLE,BM_GETCHECK,0,0)) resizable3d = true;
|
624 | Â | - else resizable3d = false;
|
625 | Â | - i = SendDlgItemMessage(hWnd,IDC_VIDMODES,LB_GETCURSEL,0,0);
|
 | 401 | + if(SendDlgItemMessage(hWnd,IDC_RESIZABLE,BM_GETCHECK,0,0)) resizable = true;
|
 | 402 | + else resizable = false;
|
 | 403 | + if (buffer < minbuffer) buffer = minbuffer;
|
 | 404 | + if (buffer > maxbuffer) buffer = maxbuffer;
|
 | 405 | + i = SendDlgItemMessage(hWnd, IDC_VIDMODES, LB_GETCURSEL, 0, 0);
|
626 | 406 | SendDlgItemMessage(hWnd,IDC_VIDMODES,LB_GETTEXT,i,(LPARAM)tmpstring);
|
627 | 407 | TranslateResolutionString(tmpstring,width,height,bpp,refresh);
|
628 | Â | - RunTest3D(currenttest3d,width,height,bpp,refresh,buffer3d,api3d,filter3d,msaa3d,framerate3d,fullscreen3d,resizable3d);
|
 | 408 | + RunDXGLTest(currenttest, width, height, bpp, refresh, buffer, api,
|
 | 409 | + filter, msaa, framerate, fullscreen, resizable, Tests[currenttest].is3d);
|
629 | 410 | break;
|
630 | 411 | case IDC_WINDOWED:
|
631 | 412 | SendDlgItemMessage(hWnd,IDC_FULLSCREEN,BM_SETCHECK,0,0);
|
632 | 413 | SendDlgItemMessage(hWnd,IDC_WINDOWED,BM_SETCHECK,1,0);
|
633 | Â | - fullscreen3d = false;
|
 | 414 | + fullscreen = false;
|
634 | 415 | break;
|
635 | 416 | case IDC_FULLSCREEN:
|
636 | 417 | SendDlgItemMessage(hWnd,IDC_FULLSCREEN,BM_SETCHECK,1,0);
|
637 | 418 | SendDlgItemMessage(hWnd,IDC_WINDOWED,BM_SETCHECK,0,0);
|
638 | Â | - fullscreen3d = true;
|
 | 419 | + fullscreen = true;
|
639 | 420 | break;
|
640 | 421 | }
|
641 | 422 | break;
|
— | — | @@ -645,66 +426,66 @@ |
646 | 427 | switch(((LPNMHDR)lParam)->idFrom)
|
647 | 428 | {
|
648 | 429 | case IDC_SPINFRAME:
|
649 | Â | - framerate3d -= ((LPNMUPDOWN)lParam)->iDelta;
|
650 | Â | - if(framerate3d < 0.01) framerate3d = 0.01;
|
651 | Â | - if(framerate3d > 99.99) framerate3d = 99.99;
|
652 | Â | - _stprintf(framerate3dstring,_T("%.2f"),framerate3d);
|
653 | Â | - SendDlgItemMessage(hWnd,IDC_FRAMERATE,WM_SETTEXT,0,(LPARAM)framerate3dstring);
|
 | 430 | + framerate -= ((LPNMUPDOWN)lParam)->iDelta;
|
 | 431 | + if(framerate < 0.01) framerate = 0.01;
|
 | 432 | + if(framerate > 99.99) framerate = 99.99;
|
 | 433 | + _stprintf(frameratestring,_T("%.2f"),framerate);
|
 | 434 | + SendDlgItemMessage(hWnd,IDC_FRAMERATE,WM_SETTEXT,0,(LPARAM)frameratestring);
|
654 | 435 | break;
|
655 | 436 | case IDC_SPINAPI:
|
656 | Â | - if(api3d < 1) api3d = 1;
|
657 | Â | - if(api3d > 7) api3d = 7;
|
 | 437 | + if(api < 1) api = 1;
|
 | 438 | + if(api > 7) api = 7;
|
658 | 439 | if(((LPNMUPDOWN)lParam)->iDelta > 0)
|
659 | 440 | {
|
660 | Â | - switch(api3d)
|
 | 441 | + switch(api)
|
661 | 442 | {
|
662 | 443 | case 1:
|
663 | 444 | case 2:
|
664 | 445 | default:
|
665 | Â | - api3d = 1;
|
 | 446 | + api = 1;
|
666 | 447 | break;
|
667 | 448 | case 3:
|
668 | Â | - api3d = 2;
|
 | 449 | + api = 2;
|
669 | 450 | break;
|
670 | 451 | case 4:
|
671 | Â | - api3d = 7;
|
 | 452 | + api = 3;
|
672 | 453 | break;
|
673 | 454 | case 7:
|
674 | 455 | case 6:
|
675 | 456 | case 5:
|
676 | Â | - api3d = 3;
|
 | 457 | + api = 4;
|
677 | 458 | }
|
678 | 459 | }
|
679 | 460 | else
|
680 | 461 | {
|
681 | Â | - switch(api3d)
|
 | 462 | + switch(api)
|
682 | 463 | {
|
683 | 464 | case 1:
|
684 | 465 | default:
|
685 | Â | - api3d = 2;
|
 | 466 | + api = 2;
|
686 | 467 | break;
|
687 | 468 | case 2:
|
688 | Â | - api3d = 3;
|
 | 469 | + api = 3;
|
689 | 470 | break;
|
690 | 471 | case 3:
|
691 | Â | - api3d = 7;
|
 | 472 | + api = 4;
|
692 | 473 | break;
|
693 | 474 | case 4:
|
694 | 475 | case 5:
|
695 | 476 | case 6:
|
696 | 477 | case 7:
|
697 | Â | - api3d = 7;
|
 | 478 | + api = 7;
|
698 | 479 | }
|
699 | 480 | }
|
700 | Â | - if(api3d < minapi3d) api3d = minapi3d;
|
701 | Â | - if(api3d > maxapi3d) api3d = maxapi3d;
|
702 | Â | - SendDlgItemMessage(hWnd,IDC_APIVER,WM_SETTEXT,0,(LPARAM)_itot(api3d,tmpstring,10));
|
 | 481 | + if(api < minapi) api = minapi;
|
 | 482 | + if(api > maxapi) api = maxapi;
|
 | 483 | + SendDlgItemMessage(hWnd,IDC_APIVER,WM_SETTEXT,0,(LPARAM)_itot(api,tmpstring,10));
|
703 | 484 | break;
|
704 | 485 | case IDC_SPINBACK:
|
705 | Â | - buffer3d -= ((LPNMUPDOWN)lParam)->iDelta;
|
706 | Â | - if(buffer3d < minbuffer3d) buffer3d = minbuffer3d;
|
707 | Â | - if(buffer3d > maxbuffer3d) buffer3d = maxbuffer3d;
|
708 | Â | - SendDlgItemMessage(hWnd,IDC_BUFFERS,WM_SETTEXT,0,(LPARAM)_itot(buffer3d,tmpstring,10));
|
 | 486 | + buffer -= ((LPNMUPDOWN)lParam)->iDelta;
|
 | 487 | + if(buffer < minbuffer) buffer = minbuffer;
|
 | 488 | + if(buffer > maxbuffer) buffer = maxbuffer;
|
 | 489 | + SendDlgItemMessage(hWnd,IDC_BUFFERS,WM_SETTEXT,0,(LPARAM)_itot(buffer,tmpstring,10));
|
709 | 490 | break;
|
710 | 491 | default:
|
711 | 492 | break;
|
— | — | @@ -720,7 +501,6 @@ |
721 | 502 | return TRUE;
|
722 | 503 | }
|
723 | 504 |
|
724 | Â | -
|
725 | 505 | HWND tabwnd[3];
|
726 | 506 | int tabopen;
|
727 | 507 | INT_PTR CALLBACK DXGLTestCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
— | — | @@ -744,14 +524,11 @@ |
745 | 525 | tab.mask = TCIF_TEXT;
|
746 | 526 | tab.pszText = _T("System");
|
747 | 527 | SendDlgItemMessage(hWnd,IDC_TABS,TCM_INSERTITEM,0,(LPARAM)&tab);
|
748 | Â | - tab.pszText = _T("2D Graphics");
|
 | 528 | + tab.pszText = _T("Graphics tests");
|
749 | 529 | hTab = GetDlgItem(hWnd,IDC_TABS);
|
750 | 530 | SendDlgItemMessage(hWnd,IDC_TABS,TCM_INSERTITEM,1,(LPARAM)&tab);
|
751 | Â | - tab.pszText = _T("3D Graphics");
|
752 | Â | - SendDlgItemMessage(hWnd,IDC_TABS,TCM_INSERTITEM,2,(LPARAM)&tab);
|
753 | 531 | tabwnd[0] = CreateDialog(hinstance,MAKEINTRESOURCE(IDD_SYSINFO),hTab,SysTabCallback);
|
754 | Â | - tabwnd[1] = CreateDialog(hinstance,MAKEINTRESOURCE(IDD_TESTGFX),hTab,Test2DCallback);
|
755 | Â | - tabwnd[2] = CreateDialog(hinstance,MAKEINTRESOURCE(IDD_TESTGFX),hTab,Test3DCallback);
|
 | 532 | + tabwnd[1] = CreateDialog(hinstance,MAKEINTRESOURCE(IDD_TESTGFX),hTab,TestTabCallback);
|
756 | 533 | SendDlgItemMessage(hWnd,IDC_TABS,TCM_GETITEMRECT,0,(LPARAM)&tabrect);
|
757 | 534 | SetWindowPos(tabwnd[0],NULL,tabrect.left,tabrect.bottom+3,0,0,SWP_SHOWWINDOW|SWP_NOSIZE);
|
758 | 535 | ShowWindow(tabwnd[1],SW_HIDE);
|
Index: dxgltest/dxgltest.vcxproj |
— | — | @@ -213,7 +213,7 @@ |
214 | 214 | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
215 | 215 | </ClCompile>
|
216 | 216 | <ClCompile Include="MultiDD.cpp" />
|
217 | Â | - <ClCompile Include="Tests2D.cpp" />
|
 | 217 | + <ClCompile Include="tests.cpp" />
|
218 | 218 | <ClCompile Include="dxgltest.cpp" />
|
219 | 219 | <ClCompile Include="palette.cpp" />
|
220 | 220 | <ClCompile Include="precomp.cpp">
|
— | — | @@ -224,7 +224,6 @@ |
225 | 225 | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
226 | 226 | </ClCompile>
|
227 | 227 | <ClCompile Include="surfacegen.cpp" />
|
228 | Â | - <ClCompile Include="Tests3D.cpp" />
|
229 | 228 | <ClCompile Include="timer.cpp" />
|
230 | 229 | </ItemGroup>
|
231 | 230 | <ItemGroup>
|
Index: dxgltest/dxgltest.vcxproj.filters |
— | — | @@ -59,9 +59,6 @@ |
60 | 60 | <ClCompile Include="precomp.cpp">
|
61 | 61 | <Filter>Source Files</Filter>
|
62 | 62 | </ClCompile>
|
63 | Â | - <ClCompile Include="Tests2D.cpp">
|
64 | Â | - <Filter>Source Files</Filter>
|
65 | Â | - </ClCompile>
|
66 | 63 | <ClCompile Include="MultiDD.cpp">
|
67 | 64 | <Filter>Source Files</Filter>
|
68 | 65 | </ClCompile>
|
— | — | @@ -71,7 +68,7 @@ |
72 | 69 | <ClCompile Include="dxguid.cpp">
|
73 | 70 | <Filter>Source Files</Filter>
|
74 | 71 | </ClCompile>
|
75 | Â | - <ClCompile Include="Tests3D.cpp">
|
 | 72 | + <ClCompile Include="tests.cpp">
|
76 | 73 | <Filter>Source Files</Filter>
|
77 | 74 | </ClCompile>
|
78 | 75 | </ItemGroup>
|
Index: dxgltest/tests.cpp |
— | — | @@ -0,0 +1,3173 @@ |
 | 2 | +// DXGL
|
 | 3 | +// Copyright (C) 2011 William Feely
|
 | 4 | +
|
 | 5 | +// This library is free software; you can redistribute it and/or
|
 | 6 | +// modify it under the terms of the GNU Lesser General Public
|
 | 7 | +// License as published by the Free Software Foundation; either
|
 | 8 | +// version 2.1 of the License, or (at your option) any later version.
|
 | 9 | +
|
 | 10 | +// This library is distributed in the hope that it will be useful,
|
 | 11 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
 | 12 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
 | 13 | +// Lesser General Public License for more details.
|
 | 14 | +
|
 | 15 | +// You should have received a copy of the GNU Lesser General Public
|
 | 16 | +// License along with this library; if not, write to the Free Software
|
 | 17 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
 | 18 | +
|
 | 19 | +#include "common.h"
|
 | 20 | +#include "MultiDD.h"
|
 | 21 | +#include "tests.h"
|
 | 22 | +#include "surfacegen.h"
|
 | 23 | +#include "timer.h"
|
 | 24 | +#include "misc.h"
|
 | 25 | +#define D3D_OVERLOADS
|
 | 26 | +#include "../ddraw/include/d3d.h"
|
 | 27 | +
|
 | 28 | +void InitTest(int test);
|
 | 29 | +void RunTestTimed(int test);
|
 | 30 | +void RunTestLooped(int test);
|
 | 31 | +void RunTestMouse(int test, UINT Msg, WPARAM wParam, LPARAM lParam);
|
 | 32 | +
|
 | 33 | +
|
 | 34 | +static MultiDirectDraw *ddinterface;
|
 | 35 | +static MultiDirectDrawSurface *ddsurface;
|
 | 36 | +static MultiDirectDrawSurface *ddsrender;
|
 | 37 | +static MultiDirectDrawSurface *zbuffer;
|
 | 38 | +static MultiDirectDrawSurface *textures[8];
|
 | 39 | +static IDirectDrawPalette *pal;
|
 | 40 | +static IDirect3D7 *d3d7;
|
 | 41 | +static IDirect3DDevice7 *d3d7dev;
|
 | 42 | +D3DMATERIAL7 material;
|
 | 43 | +static LPDIRECTDRAWCLIPPER ddclipper;
|
 | 44 | +static int width,height,bpp,refresh,backbuffers;
|
 | 45 | +static double fps;
|
 | 46 | +static bool fullscreen,resizable;
|
 | 47 | +static HWND hWnd;
|
 | 48 | +static int testnum;
|
 | 49 | +static unsigned int randnum;
|
 | 50 | +static int testtypes[] = {0,1,0,1,0,1,2,0,2,1,0,0,0,0,0,0};
|
 | 51 | +static DWORD counter;
|
 | 52 | +
|
 | 53 | +#define FVF_COLORVERTEX (D3DFVF_VERTEX | D3DFVF_DIFFUSE | D3DFVF_SPECULAR)
|
 | 54 | +struct COLORVERTEX
|
 | 55 | +{
|
 | 56 | + D3DVALUE x;
|
 | 57 | + D3DVALUE y;
|
 | 58 | + D3DVALUE z;
|
 | 59 | + D3DVALUE nx;
|
 | 60 | + D3DVALUE ny;
|
 | 61 | + D3DVALUE nz;
|
 | 62 | + D3DCOLOR color;
|
 | 63 | + D3DCOLOR specular;
|
 | 64 | + D3DVALUE tu;
|
 | 65 | + D3DVALUE tv;
|
 | 66 | +public:
|
 | 67 | + COLORVERTEX() {};
|
 | 68 | + COLORVERTEX(const D3DVECTOR& v, const D3DVECTOR& n, D3DCOLOR _color,
|
 | 69 | + D3DCOLOR _specular, D3DVALUE _tu, D3DVALUE _tv)
|
 | 70 | + {
|
 | 71 | + x = v.x; y = v.y; z = v.z;
|
 | 72 | + nx = n.x; ny = n.y; nz = n.z;
|
 | 73 | + color = _color; specular = _specular;
|
 | 74 | + tu = _tu; tv = _tv;
|
 | 75 | + }
|
 | 76 | +
|
 | 77 | +};
|
 | 78 | +
|
 | 79 | +static int numpoints = 0;
|
 | 80 | +static int numindices = 0;
|
 | 81 | +static D3DVERTEX *vertices = NULL;
|
 | 82 | +static D3DLVERTEX *litvertices = NULL;
|
 | 83 | +static COLORVERTEX *colorvertices = NULL;
|
 | 84 | +static WORD *mesh = NULL;
|
 | 85 | +static D3DLIGHT7 lights[8];
|
 | 86 | +static BOOL lightenable[8];
|
 | 87 | +static DWORD bgcolor = 0;
|
 | 88 | +
|
 | 89 | +typedef struct
|
 | 90 | +{
|
 | 91 | + DWORD ambient;
|
 | 92 | + DWORD diffuse;
|
 | 93 | + DWORD specular;
|
 | 94 | +} HEXLIGHTCOLOR;
|
 | 95 | +HEXLIGHTCOLOR hexlightcolor[8];
|
 | 96 | +
|
 | 97 | +typedef struct
|
 | 98 | +{
|
 | 99 | + D3DTEXTUREOP colorop;
|
 | 100 | + DWORD colorarg1;
|
 | 101 | + DWORD colorarg2;
|
 | 102 | + D3DTEXTUREOP alphaop;
|
 | 103 | + DWORD alphaarg1;
|
 | 104 | + DWORD alphaarg2;
|
 | 105 | + DWORD texturetype;
|
 | 106 | + TCHAR texturefile[MAX_PATH + 1];
|
 | 107 | + MultiDirectDrawSurface* texture;
|
 | 108 | + BOOL colorkey;
|
 | 109 | + DWORD keycolor;
|
 | 110 | +} TEXSTAGE;
|
 | 111 | +
|
 | 112 | +typedef struct
|
 | 113 | +{
|
 | 114 | + int currentstage;
|
 | 115 | + TEXSTAGE texstages[8];
|
 | 116 | + DWORD diffuse;
|
 | 117 | + DWORD specular;
|
 | 118 | + DWORD factor;
|
 | 119 | + D3DFOGMODE vertexfog;
|
 | 120 | + D3DFOGMODE pixelfog;
|
 | 121 | + FLOAT fogstart;
|
 | 122 | + FLOAT fogend;
|
 | 123 | + FLOAT fogdensity;
|
 | 124 | + BOOL rangefog;
|
 | 125 | + DWORD fogcolor;
|
 | 126 | + BOOL alphatest;
|
 | 127 | + BOOL alphastipple;
|
 | 128 | + BOOL colorkey;
|
 | 129 | + BOOL colorkeyblend;
|
 | 130 | + D3DBLEND srcblend;
|
 | 131 | + D3DBLEND destblend;
|
 | 132 | + BYTE refalpha;
|
 | 133 | + D3DCMPFUNC alphafunc;
|
 | 134 | + D3DLINEPATTERN linepattern;
|
 | 135 | + DWORD fillstippletype;
|
 | 136 | + TCHAR fillstipplefile[MAX_PATH + 1];
|
 | 137 | + DWORD fillstipple[32];
|
 | 138 | +} TEXSHADERSTATE;
|
 | 139 | +
|
 | 140 | +static TEXSHADERSTATE texshaderstate;
|
 | 141 | +const TEXSHADERSTATE defaulttexshaderstate =
|
 | 142 | +{
|
 | 143 | + 0,
|
 | 144 | + {
|
 | 145 | + { D3DTOP_MODULATE,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_SELECTARG1,D3DTA_TEXTURE,D3DTA_CURRENT,0,_T(""),NULL,FALSE,0 },
|
 | 146 | + { D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,0,_T(""),NULL,FALSE,0 },
|
 | 147 | + { D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,0,_T(""),NULL,FALSE,0 },
|
 | 148 | + { D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,0,_T(""),NULL,FALSE,0 },
|
 | 149 | + { D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,0,_T(""),NULL,FALSE,0 },
|
 | 150 | + { D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,0,_T(""),NULL,FALSE,0 },
|
 | 151 | + { D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,0,_T(""),NULL,FALSE,0 },
|
 | 152 | + { D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,D3DTOP_DISABLE,D3DTA_TEXTURE,D3DTA_CURRENT,0,_T(""),NULL,FALSE,0 },
|
 | 153 | + },
|
 | 154 | + 0xFFFFFFFF,
|
 | 155 | + 0,
|
 | 156 | + 0xFFFFFFFF,
|
 | 157 | + D3DFOG_NONE,
|
 | 158 | + D3DFOG_NONE,
|
 | 159 | + 0.0,
|
 | 160 | + 1.0,
|
 | 161 | + 1.0,
|
 | 162 | + FALSE,
|
 | 163 | + 0,
|
 | 164 | + FALSE,
|
 | 165 | + FALSE,
|
 | 166 | + FALSE,
|
 | 167 | + FALSE,
|
 | 168 | + D3DBLEND_ONE,
|
 | 169 | + D3DBLEND_ZERO,
|
 | 170 | + 0,
|
 | 171 | + D3DCMP_ALWAYS,
|
 | 172 | + { 0,0 }
|
 | 173 | +};
|
 | 174 | +
|
 | 175 | +typedef struct
|
 | 176 | +{
|
 | 177 | + DWORD texturetype;
|
 | 178 | + TCHAR texturefile[MAX_PATH + 1];
|
 | 179 | + MultiDirectDrawSurface* texture;
|
 | 180 | + int currentlight;
|
 | 181 | +} VERTEXSHADERSTATE;
|
 | 182 | +static VERTEXSHADERSTATE vertexshaderstate;
|
 | 183 | +
|
 | 184 | +static DDSPRITE sprites[16];
|
 | 185 | +
|
 | 186 | +LRESULT CALLBACK DDWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
 | 187 | +{
|
 | 188 | + bool paintwnd = true;
|
 | 189 | + POINT p;
|
 | 190 | + RECT srcrect,destrect;
|
 | 191 | + HRESULT error;
|
 | 192 | + PAINTSTRUCT paintstruct;
|
 | 193 | + switch(Msg)
|
 | 194 | + {
|
 | 195 | + case WM_CLOSE:
|
 | 196 | + DestroyWindow(hWnd);
|
 | 197 | + break;
|
 | 198 | + case WM_DESTROY:
|
 | 199 | + StopTimer();
|
 | 200 | + for(int i = 0; i < 16; i++)
|
 | 201 | + if(sprites[i].surface) sprites[i].surface->Release();
|
 | 202 | + for (int i = 0; i < 8; i++)
|
 | 203 | + {
|
 | 204 | + if (textures[i])
|
 | 205 | + {
|
 | 206 | + textures[i]->Release();
|
 | 207 | + textures[i] = NULL;
|
 | 208 | + }
|
 | 209 | + }
|
 | 210 | + if (d3d7dev)
|
 | 211 | + {
|
 | 212 | + d3d7dev->Release();
|
 | 213 | + d3d7dev = NULL;
|
 | 214 | + }
|
 | 215 | + if (d3d7)
|
 | 216 | + {
|
 | 217 | + d3d7->Release();
|
 | 218 | + d3d7dev = NULL;
|
 | 219 | + }
|
 | 220 | + if(ddsrender)
|
 | 221 | + {
|
 | 222 | + ddsrender->Release();
|
 | 223 | + ddsrender = NULL;
|
 | 224 | + }
|
 | 225 | + if(ddsurface)
|
 | 226 | + {
|
 | 227 | + ddsurface->Release();
|
 | 228 | + ddsurface = NULL;
|
 | 229 | + }
|
 | 230 | + if (zbuffer)
|
 | 231 | + {
|
 | 232 | + zbuffer->Release();
|
 | 233 | + zbuffer = NULL;
|
 | 234 | + }
|
 | 235 | + if(pal)
|
 | 236 | + {
|
 | 237 | + pal->Release();
|
 | 238 | + pal = NULL;
|
 | 239 | + }
|
 | 240 | + if(ddclipper)
|
 | 241 | + {
|
 | 242 | + ddclipper->Release();
|
 | 243 | + ddclipper = NULL;
|
 | 244 | + }
|
 | 245 | + if(ddinterface)
|
 | 246 | + {
|
 | 247 | + ddinterface->Release();
|
 | 248 | + ddinterface = NULL;
|
 | 249 | + }
|
 | 250 | + if (mesh)
|
 | 251 | + {
|
 | 252 | + free(mesh);
|
 | 253 | + mesh = NULL;
|
 | 254 | + }
|
 | 255 | + if (vertices)
|
 | 256 | + {
|
 | 257 | + free(vertices);
|
 | 258 | + vertices = NULL;
|
 | 259 | + }
|
 | 260 | + if (litvertices)
|
 | 261 | + {
|
 | 262 | + free(litvertices);
|
 | 263 | + litvertices = NULL;
|
 | 264 | + }
|
 | 265 | + if (colorvertices)
|
 | 266 | + {
|
 | 267 | + free(colorvertices);
|
 | 268 | + colorvertices = NULL;
|
 | 269 | + }
|
 | 270 | + PostQuitMessage(0);
|
 | 271 | + break;
|
 | 272 | + case WM_KEYDOWN:
|
 | 273 | + if(wParam == VK_ESCAPE) DestroyWindow(hWnd);
|
 | 274 | + break;
|
 | 275 | + case WM_APP:
|
 | 276 | + RunTestTimed(testnum);
|
 | 277 | + break;
|
 | 278 | + case WM_SIZE:
|
 | 279 | + paintwnd = false;
|
 | 280 | + case WM_PAINT:
|
 | 281 | + if(paintwnd) BeginPaint(hWnd,&paintstruct);
|
 | 282 | + if(!fullscreen)
|
 | 283 | + {
|
 | 284 | + p.x = 0;
|
 | 285 | + p.y = 0;
|
 | 286 | + ClientToScreen(hWnd,&p);
|
 | 287 | + GetClientRect(hWnd,&destrect);
|
 | 288 | + OffsetRect(&destrect,p.x,p.y);
|
 | 289 | + SetRect(&srcrect,0,0,width,height);
|
 | 290 | + if(ddsurface && ddsrender)error = ddsurface->Blt(&destrect,ddsrender,&srcrect,DDBLT_WAIT,NULL);
|
 | 291 | + }
|
 | 292 | + if(paintwnd) EndPaint(hWnd,&paintstruct);
|
 | 293 | + return 0;
|
 | 294 | + case WM_MOUSEMOVE:
|
 | 295 | + case WM_LBUTTONDOWN:
|
 | 296 | + case WM_LBUTTONUP:
|
 | 297 | + case WM_LBUTTONDBLCLK:
|
 | 298 | + case WM_RBUTTONDOWN:
|
 | 299 | + case WM_RBUTTONUP:
|
 | 300 | + case WM_RBUTTONDBLCLK:
|
 | 301 | + case WM_MBUTTONDOWN:
|
 | 302 | + case WM_MBUTTONUP:
|
 | 303 | + case WM_MBUTTONDBLCLK:
|
 | 304 | + case WM_MOUSEWHEEL:
|
 | 305 | + case WM_XBUTTONDOWN:
|
 | 306 | + case WM_XBUTTONUP:
|
 | 307 | + case WM_XBUTTONDBLCLK:
|
 | 308 | + case WM_MOUSEHWHEEL:
|
 | 309 | + RunTestMouse(testnum,Msg,wParam,lParam);
|
 | 310 | + if(!fullscreen)
|
 | 311 | + {
|
 | 312 | + if ((testnum != 4) && (testnum != 10) && (testnum != 11))
|
 | 313 | + {
|
 | 314 | + p.x = 0;
|
 | 315 | + p.y = 0;
|
 | 316 | + ClientToScreen(hWnd, &p);
|
 | 317 | + GetClientRect(hWnd, &destrect);
|
 | 318 | + OffsetRect(&destrect, p.x, p.y);
|
 | 319 | + SetRect(&srcrect, 0, 0, width, height);
|
 | 320 | + if (ddsurface && ddsrender)error = ddsurface->Blt(&destrect, ddsrender, &srcrect, DDBLT_WAIT, NULL);
|
 | 321 | + }
|
 | 322 | + }
|
 | 323 | + break;
|
 | 324 | + default:
|
 | 325 | + return DefWindowProc(hWnd,Msg,wParam,lParam);
|
 | 326 | + }
|
 | 327 | + return FALSE;
|
 | 328 | +}
|
 | 329 | +
|
 | 330 | +static int ddtestnum;
|
 | 331 | +static int d3dver;
|
 | 332 | +static int ddver;
|
 | 333 | +
|
 | 334 | +void RunTestMouse(int test, UINT Msg, WPARAM wParam, LPARAM lParam)
|
 | 335 | +{
|
 | 336 | + if(!ddsrender) return;
|
 | 337 | + DDSURFACEDESC2 ddsd;
|
 | 338 | + ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
 | 339 | + DDBLTFX bltfx;
|
 | 340 | + unsigned char *surface;
|
 | 341 | + int bytes;
|
 | 342 | + unsigned int x,y;
|
 | 343 | + bool out = false;
|
 | 344 | + bool msgbottom = false;
|
 | 345 | + TCHAR message[256];
|
 | 346 | + message[0] = 0;
|
 | 347 | + HDC hDC;
|
 | 348 | + switch(test)
|
 | 349 | + {
|
 | 350 | + case 6:
|
 | 351 | + x = LOWORD(lParam);
|
 | 352 | + y = HIWORD(lParam);
|
 | 353 | + ZeroMemory(&bltfx,sizeof(DDBLTFX));
|
 | 354 | + bltfx.dwSize = sizeof(DDBLTFX);
|
 | 355 | + bltfx.dwFillColor = 0;
|
 | 356 | + ddsrender->Blt(NULL,NULL,NULL,DDBLT_COLORFILL,&bltfx);
|
 | 357 | + if(ddver > 3)ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
 | 358 | + else ddsd.dwSize = sizeof(DDSURFACEDESC);
|
 | 359 | + ddsrender->GetSurfaceDesc(&ddsd);
|
 | 360 | + switch(ddsd.ddpfPixelFormat.dwRGBBitCount)
|
 | 361 | + {
|
 | 362 | + case 8:
|
 | 363 | + bytes=1;
|
 | 364 | + break;
|
 | 365 | + case 15:
|
 | 366 | + case 16:
|
 | 367 | + bytes=2;
|
 | 368 | + break;
|
 | 369 | + case 24:
|
 | 370 | + bytes=3;
|
 | 371 | + break;
|
 | 372 | + case 32:
|
 | 373 | + default:
|
 | 374 | + bytes=4;
|
 | 375 | + }
|
 | 376 | + _tcscpy(message,_T("Message: "));
|
 | 377 | + switch(Msg)
|
 | 378 | + {
|
 | 379 | + case WM_MOUSEMOVE:
|
 | 380 | + _tcscat(message,_T("WM_MOUSEMOVE "));
|
 | 381 | + break;
|
 | 382 | + case WM_LBUTTONDOWN:
|
 | 383 | + _tcscat(message,_T("WM_LBUTTONDOWN "));
|
 | 384 | + break;
|
 | 385 | + case WM_LBUTTONUP:
|
 | 386 | + _tcscat(message,_T("WM_LBUTTONUP "));
|
 | 387 | + break;
|
 | 388 | + case WM_LBUTTONDBLCLK:
|
 | 389 | + _tcscat(message,_T("WM_LBUTTONDBLCLK "));
|
 | 390 | + break;
|
 | 391 | + case WM_RBUTTONDOWN:
|
 | 392 | + _tcscat(message,_T("WM_RBUTTONDOWN "));
|
 | 393 | + break;
|
 | 394 | + case WM_RBUTTONUP:
|
 | 395 | + _tcscat(message,_T("WM_RBUTTONUP "));
|
 | 396 | + break;
|
 | 397 | + case WM_RBUTTONDBLCLK:
|
 | 398 | + _tcscat(message,_T("WM_RBUTTONDBLCLK "));
|
 | 399 | + break;
|
 | 400 | + case WM_MBUTTONDOWN:
|
 | 401 | + _tcscat(message,_T("WM_MBUTTONDOWN "));
|
 | 402 | + break;
|
 | 403 | + case WM_MBUTTONUP:
|
 | 404 | + _tcscat(message,_T("WM_MBUTTONUP "));
|
 | 405 | + break;
|
 | 406 | + case WM_MBUTTONDBLCLK:
|
 | 407 | + _tcscat(message,_T("WM_MBUTTONDBLCLK "));
|
 | 408 | + break;
|
 | 409 | + case WM_MOUSEWHEEL:
|
 | 410 | + _tcscat(message,_T("WM_MOUSEWHEEL "));
|
 | 411 | + break;
|
 | 412 | + case WM_XBUTTONDOWN:
|
 | 413 | + _tcscat(message,_T("WM_XBUTTONDOWN "));
|
 | 414 | + break;
|
 | 415 | + case WM_XBUTTONUP:
|
 | 416 | + _tcscat(message,_T("WM_XBUTTONUP "));
|
 | 417 | + break;
|
 | 418 | + case WM_XBUTTONDBLCLK:
|
 | 419 | + _tcscat(message,_T("WM_XBUTTONDBLCLK "));
|
 | 420 | + break;
|
 | 421 | + case WM_MOUSEHWHEEL:
|
 | 422 | + _tcscat(message,_T("WM_MOUSEHWHEEL "));
|
 | 423 | + break;
|
 | 424 | + default:
|
 | 425 | + _tcscat(message,_T("unknown "));
|
 | 426 | + }
|
 | 427 | + _tcscat(message,_T("Keys: "));
|
 | 428 | + if(wParam & MK_CONTROL) _tcscat(message, _T("CTRL "));
|
 | 429 | + if(wParam & MK_SHIFT) _tcscat(message,_T("SHIFT "));
|
 | 430 | + _tcscat(message,_T("Buttons: "));
|
 | 431 | + if(wParam & MK_LBUTTON) _tcscat(message,_T("L "));
|
 | 432 | + if(wParam & MK_MBUTTON) _tcscat(message,_T("M "));
|
 | 433 | + if(wParam & MK_RBUTTON) _tcscat(message,_T("R "));
|
 | 434 | + if(wParam & MK_XBUTTON1) _tcscat(message,_T("X1 "));
|
 | 435 | + if(wParam & MK_XBUTTON2) _tcscat(message,_T("X2 "));
|
 | 436 | + // Add X and Y
|
 | 437 | + ddsrender->Lock(NULL,&ddsd,DDLOCK_WAIT,NULL);
|
 | 438 | + surface = (unsigned char *)ddsd.lpSurface;
|
 | 439 | + if((x > ddsd.dwWidth) || (y > ddsd.dwHeight))
|
 | 440 | + {
|
 | 441 | + out = true;
|
 | 442 | + _tcscat(message,_T(" OUT OF BOUNDS"));
|
 | 443 | + }
|
 | 444 | + else surface[(x*bytes)+(y*ddsd.lPitch)] = 0xFF;
|
 | 445 | + ddsrender->Unlock(NULL);
|
 | 446 | + ddsrender->GetDC(&hDC);
|
 | 447 | + if(out)SetBkColor(hDC,RGB(255,0,0));
|
 | 448 | + else SetBkColor(hDC,RGB(0,0,255));
|
 | 449 | + SetTextColor(hDC,RGB(255,255,255));
|
 | 450 | + if(y > ddsd.dwHeight / 2) TextOut(hDC,0,0,message,_tcslen(message));
|
 | 451 | + else TextOut(hDC,0,ddsd.dwHeight-16,message,_tcslen(message));
|
 | 452 | + ddsrender->ReleaseDC(hDC);
|
 | 453 | + break;
|
 | 454 | + default:
|
 | 455 | + break;
|
 | 456 | + }
|
 | 457 | +}
|
 | 458 | +
|
 | 459 | +const TCHAR wndclassname[] = _T("DDTestWndClass");
|
 | 460 | +
|
 | 461 | +static HRESULT WINAPI zcallback(DDPIXELFORMAT *ddpf, VOID *context)
|
 | 462 | +{
|
 | 463 | + if (ddpf->dwFlags == DDPF_ZBUFFER)
|
 | 464 | + {
|
 | 465 | + memcpy(context, ddpf, sizeof(DDPIXELFORMAT));
|
 | 466 | + return D3DENUMRET_CANCEL;
|
 | 467 | + }
|
 | 468 | + return D3DENUMRET_OK;
|
 | 469 | +}
|
 | 470 | +
|
 | 471 | +INT_PTR CALLBACK TexShader7Proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
 | 472 | +INT_PTR CALLBACK VertexShader7Proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
 | 473 | +
|
 | 474 | +void RunDXGLTest(int testnum, int width, int height, int bpp, int refresh, int backbuffers, int apiver,
|
 | 475 | + int filter, int msaa, double fps, bool fullscreen, bool resizable, BOOL is3d)
|
 | 476 | +{
|
 | 477 | + ZeroMemory(sprites,16*sizeof(DDSPRITE));
|
 | 478 | + if(testnum == 14)
|
 | 479 | + {
|
 | 480 | + DialogBox(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_TEXSHADER),NULL,TexShader7Proc);
|
 | 481 | + return;
|
 | 482 | + }
|
 | 483 | + if(testnum == 15)
|
 | 484 | + {
|
 | 485 | + DialogBox(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_VERTEXSHADER),NULL,VertexShader7Proc);
|
 | 486 | + return;
|
 | 487 | + }
|
 | 488 | + DDSCAPS2 caps;
|
 | 489 | + DDSURFACEDESC2 ddsd;
|
 | 490 | + DDPIXELFORMAT ddpfz;
|
 | 491 | + BOOL done = false;
|
 | 492 | + ::testnum = testnum;
|
 | 493 | + randnum = (unsigned int)time(NULL);
|
 | 494 | + ZeroMemory(&ddsd,sizeof(DDSURFACEDESC2));
|
 | 495 | + ZeroMemory(textures,8*sizeof(MultiDirectDrawSurface*));
|
 | 496 | + if(apiver > 3) ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
 | 497 | + else ddsd.dwSize = sizeof(DDSURFACEDESC);
|
 | 498 | + ::fullscreen = fullscreen;
|
 | 499 | + ::resizable = resizable;
|
 | 500 | + ::width = width;
|
 | 501 | + ::height = height;
|
 | 502 | + ::bpp = bpp;
|
 | 503 | + ::refresh = refresh;
|
 | 504 | + if(fullscreen)::backbuffers = backbuffers;
|
 | 505 | + else ::backbuffers = backbuffers = 0;
|
 | 506 | + ::fps = fps;
|
 | 507 | + ::testnum = testnum;
|
 | 508 | + d3dver = apiver;
|
 | 509 | + if(apiver == 3) ddver = 4;
|
 | 510 | + else ddver = apiver;
|
 | 511 | + HINSTANCE hinstance = (HINSTANCE)GetModuleHandle(NULL);
|
 | 512 | + WNDCLASSEX wc;
|
 | 513 | + MSG Msg;
|
 | 514 | + ZeroMemory(&wc,sizeof(WNDCLASS));
|
 | 515 | + wc.cbSize = sizeof(WNDCLASSEX);
|
 | 516 | + wc.style = CS_HREDRAW | CS_VREDRAW;
|
 | 517 | + wc.lpfnWndProc = DDWndProc;
|
 | 518 | + wc.hInstance = hinstance;
|
 | 519 | + wc.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(IDI_DXGL));
|
 | 520 | + wc.hIconSm = LoadIcon(hinstance,MAKEINTRESOURCE(IDI_DXGLSM));
|
 | 521 | + if(testnum == 6) wc.hCursor = LoadCursor(NULL,IDC_CROSS);
|
 | 522 | + else wc.hCursor = LoadCursor(NULL,IDC_ARROW);
|
 | 523 | + wc.hbrBackground = NULL;
|
 | 524 | + wc.lpszClassName = wndclassname;
|
 | 525 | + if(!RegisterClassEx(&wc))
|
 | 526 | + {
|
 | 527 | + MessageBox(NULL,_T("Can not register window class"),_T("Error"),MB_ICONEXCLAMATION|MB_OK);
|
 | 528 | + return;
|
 | 529 | + }
|
 | 530 | + if(resizable)
|
 | 531 | + hWnd = CreateWindowEx(WS_EX_APPWINDOW,wndclassname,_T("DDraw Test Window"),WS_OVERLAPPEDWINDOW,
|
 | 532 | + CW_USEDEFAULT,CW_USEDEFAULT,width,height,NULL,NULL,hinstance,NULL);
|
 | 533 | + else if(!fullscreen)
|
 | 534 | + hWnd = CreateWindowEx(WS_EX_APPWINDOW,wndclassname,_T("DDraw Test Window"),WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX,
|
 | 535 | + CW_USEDEFAULT,CW_USEDEFAULT,width,height,NULL,NULL,hinstance,NULL);
|
 | 536 | + else hWnd = CreateWindowEx(0,wndclassname,_T("DDraw Test Window"),WS_POPUP,0,0,
|
 | 537 | + GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN),NULL,NULL,hinstance,NULL);
|
 | 538 | + DWORD err = GetLastError();
|
 | 539 | + ShowWindow(hWnd,SW_SHOWNORMAL);
|
 | 540 | + UpdateWindow(hWnd);
|
 | 541 | + RECT r1,r2;
|
 | 542 | + POINT p1;
|
 | 543 | + HRESULT error;
|
 | 544 | + ddinterface = new MultiDirectDraw(ddver,&error,NULL);
|
 | 545 | + if(fullscreen) error = ddinterface->SetCooperativeLevel(hWnd,DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN);
|
 | 546 | + else error = ddinterface->SetCooperativeLevel(hWnd,DDSCL_NORMAL);
|
 | 547 | + if(fullscreen) error = ddinterface->SetDisplayMode(width,height,bpp,refresh,0);
|
 | 548 | + else
|
 | 549 | + {
|
 | 550 | + GetClientRect(hWnd,&r1);
|
 | 551 | + GetWindowRect(hWnd,&r2);
|
 | 552 | + p1.x = (r2.right - r2.left) - r1.right;
|
 | 553 | + p1.y = (r2.bottom - r2.top) - r1.bottom;
|
 | 554 | + MoveWindow(hWnd,r2.left,r2.top,width+p1.x,height+p1.y,TRUE);
|
 | 555 | + }
|
 | 556 | + ddsd.dwFlags = DDSD_CAPS;
|
 | 557 | + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
 | 558 | + if(fullscreen)
|
 | 559 | + {
|
 | 560 | + if(backbuffers)ddsd.dwFlags |= DDSD_BACKBUFFERCOUNT;
|
 | 561 | + ddsd.dwBackBufferCount = backbuffers;
|
 | 562 | + if(backbuffers) ddsd.ddsCaps.dwCaps |= DDSCAPS_FLIP | DDSCAPS_COMPLEX;
|
 | 563 | + if(is3d) ddsd.ddsCaps.dwCaps |= DDSCAPS_3DDEVICE;
|
 | 564 | + }
|
 | 565 | + error = ddinterface->CreateSurface(&ddsd,&ddsurface,NULL);
|
 | 566 | + if(!fullscreen)
|
 | 567 | + {
|
 | 568 | + error = ddinterface->CreateClipper(0,&ddclipper,NULL);
|
 | 569 | + error = ddclipper->SetHWnd(0,hWnd);
|
 | 570 | + error = ddsurface->SetClipper(ddclipper);
|
 | 571 | + ZeroMemory(&ddsd,sizeof(ddsd));
|
 | 572 | + if(apiver > 3) ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
 | 573 | + else ddsd.dwSize = sizeof(DDSURFACEDESC);
|
 | 574 | + ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
 | 575 | + if(is3d) ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
|
 | 576 | + else ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
 | 577 | + ddsd.dwWidth = width;
|
 | 578 | + ddsd.dwHeight = height;
|
 | 579 | + error = ddinterface->CreateSurface(&ddsd,&ddsrender,NULL);
|
 | 580 | + ddsrender->GetSurfaceDesc(&ddsd);
|
 | 581 | + ::bpp = ddsd.ddpfPixelFormat.dwRGBBitCount;
|
 | 582 | + }
|
 | 583 | + else
|
 | 584 | + {
|
 | 585 | + ddsrender = ddsurface;
|
 | 586 | + ddsrender->AddRef();
|
 | 587 | + }
|
 | 588 | + if(bpp == 8)
|
 | 589 | + {
|
 | 590 | + ddinterface->CreatePalette(DDPCAPS_8BIT|DDPCAPS_ALLOW256,(LPPALETTEENTRY)&DefaultPalette,&pal,NULL);
|
 | 591 | + ddsrender->SetPalette(pal);
|
 | 592 | + }
|
 | 593 | + else pal = NULL;
|
 | 594 | + if (is3d)
|
 | 595 | + {
|
 | 596 | + error = ddinterface->QueryInterface(IID_IDirect3D7, (VOID**)&d3d7);
|
 | 597 | + error = d3d7->EnumZBufferFormats(IID_IDirect3DRGBDevice, zcallback, &ddpfz);
|
 | 598 | + error = ddsrender->GetSurfaceDesc(&ddsd);
|
 | 599 | + ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
|
 | 600 | + ddsd.ddsCaps.dwCaps = DDSCAPS_ZBUFFER | DDSCAPS_VIDEOMEMORY;
|
 | 601 | + memcpy(&ddsd.ddpfPixelFormat, &ddpfz, sizeof(DDPIXELFORMAT));
|
 | 602 | + error = ddinterface->CreateSurface(&ddsd, &zbuffer, NULL);
|
 | 603 | + error = ddsrender->AddAttachedSurface(zbuffer);
|
 | 604 | + error = d3d7->CreateDevice(IID_IDirect3DHALDevice, (LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(), &d3d7dev);
|
 | 605 | + if (error != D3D_OK)
|
 | 606 | + error = d3d7->CreateDevice(IID_IDirect3DRGBDevice, (LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(), &d3d7dev);
|
 | 607 | + ddsrender->GetSurfaceDesc(&ddsd);
|
 | 608 | + D3DVIEWPORT7 vp = { 0,0,ddsd.dwWidth,ddsd.dwHeight,0.0f,1.0f };
|
 | 609 | + error = d3d7dev->SetViewport(&vp);
|
 | 610 | + error = d3d7dev->SetRenderState(D3DRENDERSTATE_ZENABLE, TRUE);
|
 | 611 | + }
|
 | 612 | + InitTest(testnum);
|
 | 613 | + if(!fullscreen) SendMessage(hWnd,WM_PAINT,0,0);
|
 | 614 | + if(testtypes[testnum] == 1)
|
 | 615 | + {
|
 | 616 | + while(!done)
|
 | 617 | + {
|
 | 618 | + if(PeekMessage(&Msg,NULL,0,0,PM_REMOVE))
|
 | 619 | + {
|
 | 620 | + if(Msg.message == WM_PAINT) RunTestLooped(testnum);
|
 | 621 | + else if(Msg.message == WM_QUIT) done = TRUE;
|
 | 622 | + else
|
 | 623 | + {
|
 | 624 | + TranslateMessage(&Msg);
|
 | 625 | + DispatchMessage(&Msg);
|
 | 626 | + }
|
 | 627 | + }
|
 | 628 | + else
|
 | 629 | + {
|
 | 630 | + RunTestLooped(testnum);
|
 | 631 | + }
|
 | 632 | + }
|
 | 633 | + }
|
 | 634 | + else if(testtypes[testnum] == 0)
|
 | 635 | + {
|
 | 636 | + StartTimer(hWnd,WM_APP,fps);
|
 | 637 | + while(GetMessage(&Msg, NULL, 0, 0) > 0)
|
 | 638 | + {
|
 | 639 | + TranslateMessage(&Msg);
|
 | 640 | + DispatchMessage(&Msg);
|
 | 641 | + }
|
 | 642 | + }
|
 | 643 | + else
|
 | 644 | + {
|
 | 645 | + while(GetMessage(&Msg, NULL, 0, 0) > 0)
|
 | 646 | + {
|
 | 647 | + TranslateMessage(&Msg);
|
 | 648 | + DispatchMessage(&Msg);
|
 | 649 | + }
|
 | 650 | + }
|
 | 651 | + UnregisterClass(wndclassname,hinstance);
|
 | 652 | + StopTimer();
|
 | 653 | +}
|
 | 654 | +
|
 | 655 | +void MakeCube3D(float size, int detail)
|
 | 656 | +{
|
 | 657 | + if (detail < 2) return;
|
 | 658 | + D3DVECTOR normals[6];
|
 | 659 | + normals[0] = D3DVECTOR(0.0f, 0.0f, -1.0f);
|
 | 660 | + normals[1] = D3DVECTOR(1.0f, 0.0f, 0.0f);
|
 | 661 | + normals[2] = D3DVECTOR(0.0f, 0.0f, 1.0f);
|
 | 662 | + normals[3] = D3DVECTOR(-1.0f, 0.0f, 0.0f);
|
 | 663 | + normals[4] = D3DVECTOR(0.0f, 1.0f, 0.0f);
|
 | 664 | + normals[5] = D3DVECTOR(0.0f, -1.0f, 0.0f);
|
 | 665 | + int numfacevertices = detail*detail;
|
 | 666 | + D3DVECTOR *face = (D3DVECTOR*)malloc(numfacevertices * sizeof(D3DVECTOR));
|
 | 667 | + int numfaceindices = ((detail - 1)*(detail - 1)) * 6;
|
 | 668 | + WORD *faceindex = (WORD*)malloc(numfaceindices * sizeof(WORD));
|
 | 669 | + int ptr = 0;
|
 | 670 | + float fx, fy;
|
 | 671 | + // Generate points
|
 | 672 | + for (int y = 0; y < detail; y++)
|
 | 673 | + {
|
 | 674 | + fy = (((float)(y / (float)(detail - 1))) - .5f)*size;
|
 | 675 | + for (int x = 0; x < detail; x++)
|
 | 676 | + {
|
 | 677 | + fx = (((float)(x / (float)(detail - 1))) - .5f)*size;
|
 | 678 | + face[ptr] = D3DVECTOR(fx, fy, 0);
|
 | 679 | + ptr++;
|
 | 680 | + }
|
 | 681 | + }
|
 | 682 | + // Generate triangle indices
|
 | 683 | + ptr = 0;
|
 | 684 | + for (int y = 0; y < (detail - 1); y++)
|
 | 685 | + {
|
 | 686 | + for (int x = 0; x < (detail - 1); x++)
|
 | 687 | + {
|
 | 688 | + faceindex[ptr++] = x + (detail*y);
|
 | 689 | + faceindex[ptr++] = x + (detail*(y + 1));
|
 | 690 | + faceindex[ptr++] = (x + 1) + (detail*y);
|
 | 691 | + faceindex[ptr++] = (x + 1) + (detail*y);
|
 | 692 | + faceindex[ptr++] = x + (detail*(y + 1));
|
 | 693 | + faceindex[ptr++] = (x + 1) + (detail*(y + 1));
|
 | 694 | + }
|
 | 695 | + }
|
 | 696 | + numpoints = (detail*detail) * 6;
|
 | 697 | + numindices = ((detail - 1)*(detail - 1)) * 36;
|
 | 698 | + if (vertices) free(vertices);
|
 | 699 | + if (litvertices) free(litvertices);
|
 | 700 | + if (colorvertices) free(colorvertices);
|
 | 701 | + if (mesh) free(mesh);
|
 | 702 | + vertices = (D3DVERTEX*)malloc(numpoints * sizeof(D3DVERTEX));
|
 | 703 | + litvertices = (D3DLVERTEX*)malloc(numpoints * sizeof(D3DLVERTEX));
|
 | 704 | + colorvertices = (COLORVERTEX*)malloc(numpoints * sizeof(COLORVERTEX));
|
 | 705 | + mesh = (WORD*)malloc(numindices * sizeof(WORD));
|
 | 706 | + // Generate vertex list
|
 | 707 | + float u, v;
|
 | 708 | + D3DVECTOR pos;
|
 | 709 | + D3DVECTOR normal;
|
 | 710 | + // Front face
|
 | 711 | + ptr = 0;
|
 | 712 | + for (int y = 0; y < detail; y++)
|
 | 713 | + {
|
 | 714 | + for (int x = 0; x < detail; x++)
|
 | 715 | + {
|
 | 716 | + u = (float)x / (float)(detail - 1);
|
 | 717 | + v = 1.f - ((float)y / (float)(detail - 1));
|
 | 718 | + ptr = x + (detail*y);
|
 | 719 | + pos = D3DVECTOR(face[ptr].x, face[ptr].y, -size / 2.f);
|
 | 720 | + normal = D3DVECTOR(0, 0, -1);
|
 | 721 | + vertices[ptr] = D3DVERTEX(pos, normal, u, v);
|
 | 722 | + litvertices[ptr] = D3DLVERTEX(pos, 0xFFFFFFFF, 0, u, v);
|
 | 723 | + colorvertices[ptr] = COLORVERTEX(pos, normal, 0xFFFFFFFF, 0, u, v);
|
 | 724 | + }
|
 | 725 | + }
|
 | 726 | + // Right face
|
 | 727 | + ptr = 0;
|
 | 728 | + for (int y = 0; y < detail; y++)
|
 | 729 | + {
|
 | 730 | + for (int x = 0; x < detail; x++)
|
 | 731 | + {
|
 | 732 | + u = (float)x / (float)(detail - 1);
|
 | 733 | + v = 1.f - ((float)y / (float)(detail - 1));
|
 | 734 | + ptr = x + (detail*y);
|
 | 735 | + pos = D3DVECTOR(size / 2.f, face[ptr].y, face[ptr].x);
|
 | 736 | + normal = D3DVECTOR(1, 0, 0);
|
 | 737 | + vertices[ptr + numfacevertices] = D3DVERTEX(pos, normal, u, v);
|
 | 738 | + litvertices[ptr + numfacevertices] = D3DLVERTEX(pos, 0xFFFFFFFF, 0, u, v);
|
 | 739 | + colorvertices[ptr + numfacevertices] = COLORVERTEX(pos, normal, 0xFFFFFFFF, 0, u, v);
|
 | 740 | + }
|
 | 741 | + }
|
 | 742 | + // Back face
|
 | 743 | + ptr = 0;
|
 | 744 | + for (int y = 0; y < detail; y++)
|
 | 745 | + {
|
 | 746 | + for (int x = 0; x < detail; x++)
|
 | 747 | + {
|
 | 748 | + u = (float)x / (float)(detail - 1);
|
 | 749 | + v = 1.f - ((float)y / (float)(detail - 1));
|
 | 750 | + ptr = x + (detail*y);
|
 | 751 | + pos = D3DVECTOR(-face[ptr].x, face[ptr].y, size / 2.f);
|
 | 752 | + normal = D3DVECTOR(0, 0, 1);
|
 | 753 | + vertices[ptr + (numfacevertices * 2)] = D3DVERTEX(pos, normal, u, v);
|
 | 754 | + litvertices[ptr + (numfacevertices * 2)] = D3DLVERTEX(pos, 0xFFFFFFFF, 0, u, v);
|
 | 755 | + colorvertices[ptr + (numfacevertices * 2)] = COLORVERTEX(pos, normal, 0xFFFFFFFF, 0, u, v);
|
 | 756 | + }
|
 | 757 | + }
|
 | 758 | + // Left face
|
 | 759 | + ptr = 0;
|
 | 760 | + for (int y = 0; y < detail; y++)
|
 | 761 | + {
|
 | 762 | + for (int x = 0; x < detail; x++)
|
 | 763 | + {
|
 | 764 | + u = (float)x / (float)(detail - 1);
|
 | 765 | + v = 1.f - ((float)y / (float)(detail - 1));
|
 | 766 | + ptr = x + (detail*y);
|
 | 767 | + pos = D3DVECTOR(-size / 2.f, face[ptr].y, -face[ptr].x);
|
 | 768 | + normal = D3DVECTOR(-1, 0, 0);
|
 | 769 | + vertices[ptr + (numfacevertices * 3)] = D3DVERTEX(pos, normal, u, v);
|
 | 770 | + litvertices[ptr + (numfacevertices * 3)] = D3DLVERTEX(pos, 0xFFFFFFFF, 0, u, v);
|
 | 771 | + colorvertices[ptr + (numfacevertices * 3)] = COLORVERTEX(pos, normal, 0xFFFFFFFF, 0, u, v);
|
 | 772 | + }
|
 | 773 | + }
|
 | 774 | + // Top face
|
 | 775 | + for (int y = 0; y < detail; y++)
|
 | 776 | + {
|
 | 777 | + for (int x = 0; x < detail; x++)
|
 | 778 | + {
|
 | 779 | + u = (float)x / (float)(detail - 1);
|
 | 780 | + v = 1.f - ((float)y / (float)(detail - 1));
|
 | 781 | + ptr = x + (detail*y);
|
 | 782 | + pos = D3DVECTOR(face[ptr].x, size / 2.f, face[ptr].y);
|
 | 783 | + normal = D3DVECTOR(0, 1, 0);
|
 | 784 | + vertices[ptr + (numfacevertices * 4)] = D3DVERTEX(pos, normal, u, v);
|
 | 785 | + litvertices[ptr + (numfacevertices * 4)] = D3DLVERTEX(pos, 0xFFFFFFFF, 0, u, v);
|
 | 786 | + colorvertices[ptr + (numfacevertices * 4)] = COLORVERTEX(pos, normal, 0xFFFFFFFF, 0, u, v);
|
 | 787 | + }
|
 | 788 | + }
|
 | 789 | + // Bottom face
|
 | 790 | + for (int y = 0; y < detail; y++)
|
 | 791 | + {
|
 | 792 | + for (int x = 0; x < detail; x++)
|
 | 793 | + {
|
 | 794 | + u = (float)x / (float)(detail - 1);
|
 | 795 | + v = 1.f - ((float)y / (float)(detail - 1));
|
 | 796 | + ptr = x + (detail*y);
|
 | 797 | + pos = D3DVECTOR(face[ptr].x, -size / 2.f, -face[ptr].y);
|
 | 798 | + normal = D3DVECTOR(0, -1, 0);
|
 | 799 | + vertices[ptr + (numfacevertices * 5)] = D3DVERTEX(pos, normal, u, v);
|
 | 800 | + litvertices[ptr + (numfacevertices * 5)] = D3DLVERTEX(pos, 0xFFFFFFFF, 0, u, v);
|
 | 801 | + colorvertices[ptr + (numfacevertices * 5)] = COLORVERTEX(pos, normal, 0xFFFFFFFF, 0, u, v);
|
 | 802 | + }
|
 | 803 | + }
|
 | 804 | + free(face);
|
 | 805 | + // Generate index table
|
 | 806 | + ptr = 0;
|
 | 807 | + for (int i = 0; i < 6; i++)
|
 | 808 | + {
|
 | 809 | + for (int j = 0; j < numfaceindices; j++)
|
 | 810 | + mesh[ptr++] = faceindex[j] + (i*numfacevertices);
|
 | 811 | + }
|
 | 812 | + free(faceindex);
|
 | 813 | +}
|
 | 814 | +
|
 | 815 | +void SetVertexColor(D3DLVERTEX *start, COLORVERTEX *start_color, int count, DWORD color)
|
 | 816 | +{
|
 | 817 | + for (int i = 0; i < count; i++)
|
 | 818 | + {
|
 | 819 | + start[i].color = color;
|
 | 820 | + start_color[i].color = color;
|
 | 821 | + }
|
 | 822 | +}
|
 | 823 | +
|
 | 824 | +void SetVertexSpecular(D3DLVERTEX *start, COLORVERTEX *start_color, int count, DWORD color)
|
 | 825 | +{
|
 | 826 | + for (int i = 0; i < count; i++)
|
 | 827 | + {
|
 | 828 | + start[i].specular = color;
|
 | 829 | + start_color[i].specular = color;
|
 | 830 | + }
|
 | 831 | +}
|
 | 832 | +
|
 | 833 | +
|
 | 834 | +DDPIXELFORMAT texformats[256];
|
 | 835 | +int texformatindex = 0;
|
 | 836 | +
|
 | 837 | +void cleartexformats()
|
 | 838 | +{
|
 | 839 | + ZeroMemory(texformats, 256 * sizeof(DDPIXELFORMAT));
|
 | 840 | + texformatindex = 0;
|
 | 841 | +}
|
 | 842 | +
|
 | 843 | +HRESULT CALLBACK gettexformat(LPDDPIXELFORMAT lpDDPixFmt, LPVOID lpContext)
|
 | 844 | +{
|
 | 845 | + memcpy(&texformats[texformatindex], lpDDPixFmt, sizeof(DDPIXELFORMAT));
|
 | 846 | + texformatindex++;
|
 | 847 | + if (texformatindex >= 256) return D3DENUMRET_CANCEL;
|
 | 848 | + return D3DENUMRET_OK;
|
 | 849 | +}
|
 | 850 | +
|
 | 851 | +static bool gentexture(const DDPIXELFORMAT format, MultiDirectDrawSurface **surface, int width, int height, int pattern)
|
 | 852 | +{
|
 | 853 | + DDSURFACEDESC2 ddsd;
|
 | 854 | + ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
|
 | 855 | + ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
 | 856 | + ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_TEXTURESTAGE;
|
 | 857 | + ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
|
 | 858 | + ddsd.dwWidth = width;
|
 | 859 | + ddsd.dwHeight = height;
|
 | 860 | + ddsd.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE;
|
 | 861 | + ddsd.ddpfPixelFormat = format;
|
 | 862 | + HRESULT error = ddinterface->CreateSurface(&ddsd, surface, NULL);
|
 | 863 | + if (error != D3D_OK) return false;
|
 | 864 | + switch (pattern)
|
 | 865 | + {
|
 | 866 | + case 0:
|
 | 867 | + default:
|
 | 868 | + (*surface)->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
|
 | 869 | + DrawPalette(ddsd, (unsigned char *)ddsd.lpSurface);
|
 | 870 | + (*surface)->Unlock(NULL);
|
 | 871 | + }
|
 | 872 | + return true;
|
 | 873 | +}
|
 | 874 | +
|
 | 875 | +void MakeLights()
|
 | 876 | +{
|
 | 877 | + for (int i = 0; i < 8; i++)
|
 | 878 | + {
|
 | 879 | + lightenable[i] = FALSE;
|
 | 880 | + ZeroMemory(&lights[i], sizeof(D3DLIGHT7));
|
 | 881 | + lights[i].dcvDiffuse.r = lights[i].dcvDiffuse.g = lights[i].dcvDiffuse.b = 1;
|
 | 882 | + lights[i].dltType = D3DLIGHT_DIRECTIONAL;
|
 | 883 | + hexlightcolor[i].diffuse = 0xFFFFFF;
|
 | 884 | + }
|
 | 885 | + lightenable[0] = TRUE;
|
 | 886 | + lights[0].dvPosition = D3DVECTOR(-10, -10, -10);
|
 | 887 | + lights[1].dvPosition = D3DVECTOR(10, -10, -10);
|
 | 888 | + lights[2].dvPosition = D3DVECTOR(-10, 10, -10);
|
 | 889 | + lights[3].dvPosition = D3DVECTOR(10, 10, -10);
|
 | 890 | + lights[4].dvPosition = D3DVECTOR(-10, -10, 10);
|
 | 891 | + lights[5].dvPosition = D3DVECTOR(10, -10, 10);
|
 | 892 | + lights[6].dvPosition = D3DVECTOR(-10, 10, 10);
|
 | 893 | + lights[7].dvPosition = D3DVECTOR(10, 10, 10);
|
 | 894 | + lights[0].dvDirection = D3DVECTOR(1, 1, 1);
|
 | 895 | + lights[1].dvDirection = D3DVECTOR(-1, 1, 1);
|
 | 896 | + lights[2].dvDirection = D3DVECTOR(1, -1, 1);
|
 | 897 | + lights[3].dvDirection = D3DVECTOR(-1, -1, 1);
|
 | 898 | + lights[4].dvDirection = D3DVECTOR(1, 1, -1);
|
 | 899 | + lights[5].dvDirection = D3DVECTOR(-1, 1, -1);
|
 | 900 | + lights[6].dvDirection = D3DVECTOR(1, -1, -1);
|
 | 901 | + lights[7].dvDirection = D3DVECTOR(-1, -1, -1);
|
 | 902 | +}
|
 | 903 | +
|
 | 904 | +static const DDPIXELFORMAT fmt_rgba4444 = { sizeof(DDPIXELFORMAT),DDPF_RGB | DDPF_ALPHAPIXELS,0,16,0xF00,0xF0,0xF,0xF000 };
|
 | 905 | +static const DDPIXELFORMAT fmt_rgba1555 = { sizeof(DDPIXELFORMAT),DDPF_RGB | DDPF_ALPHAPIXELS,0,16,0x7C00,0x3E0,0x1F,0x8000 };
|
 | 906 | +static const DDPIXELFORMAT fmt_rgb565 = { sizeof(DDPIXELFORMAT),DDPF_RGB,0,16,0xF800,0x7E0,0x1F,0 };
|
 | 907 | +static const DDPIXELFORMAT fmt_rgba8888 = { sizeof(DDPIXELFORMAT),DDPF_RGB | DDPF_ALPHAPIXELS,0,32,0xFF0000,0xFF00,0xFF,0xFF000000 };
|
 | 908 | +
|
 | 909 | +void InitTest(int test)
|
 | 910 | +{
|
 | 911 | + DDSURFACEDESC2 ddsd;
|
 | 912 | + DDSCAPS2 ddscaps;
|
 | 913 | + HDC hRenderDC;
|
 | 914 | + ZeroMemory(&ddscaps,sizeof(DDSCAPS2));
|
 | 915 | + LPDIRECTDRAWPALETTE palette;
|
 | 916 | + unsigned char *buffer;
|
 | 917 | + MultiDirectDrawSurface *temp1 = NULL;
|
 | 918 | + MultiDirectDrawSurface *temp2 = NULL;
|
 | 919 | + HRESULT error;
|
 | 920 | + D3DMATRIX matWorld;
|
 | 921 | + D3DMATRIX matView;
|
 | 922 | + D3DMATRIX matProj;
|
 | 923 | + D3DMATRIX mat;
|
 | 924 | + bgcolor = 0;
|
 | 925 | + DDCOLORKEY ckey;
|
 | 926 | + ckey.dwColorSpaceHighValue = ckey.dwColorSpaceLowValue = 0;
|
 | 927 | + if(ddver > 3)ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
 | 928 | + else ddsd.dwSize = sizeof(DDSURFACEDESC);
|
 | 929 | + error = ddsrender->GetSurfaceDesc(&ddsd);
|
 | 930 | + switch (test)
|
 | 931 | + {
|
 | 932 | + case 0:
|
 | 933 | + if (!fullscreen) backbuffers = 0;
|
 | 934 | + buffer = (unsigned char *)malloc(ddsd.lPitch*ddsd.dwHeight);
|
 | 935 | + DrawPalette(ddsd, buffer);
|
 | 936 | + error = ddsrender->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
|
 | 937 | + memcpy(ddsd.lpSurface, buffer, ddsd.lPitch*ddsd.dwHeight);
|
 | 938 | + error = ddsrender->Unlock(NULL);
|
 | 939 | + ddsrender->GetPalette(&palette);
|
 | 940 | + if (backbuffers > 0)
|
 | 941 | + {
|
 | 942 | + ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
|
 | 943 | + error = ddsrender->GetAttachedSurface(&ddscaps, &temp1);
|
 | 944 | + DrawGradients(ddsd, buffer, hWnd, palette, 1, 0);
|
 | 945 | + error = temp1->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
|
 | 946 | + memcpy(ddsd.lpSurface, buffer, ddsd.lPitch*ddsd.dwHeight);
|
 | 947 | + error = temp1->Unlock(NULL);
|
 | 948 | + }
|
 | 949 | + if (backbuffers > 1)
|
 | 950 | + {
|
 | 951 | + ddscaps.dwCaps = DDSCAPS_FLIP;
|
 | 952 | + error = temp1->GetAttachedSurface(&ddscaps, &temp2);
|
 | 953 | + temp1->Release();
|
 | 954 | + temp1 = temp2;
|
 | 955 | + DrawGradients(ddsd, buffer, hWnd, palette, 0, 0x0000FF);
|
 | 956 | + error = temp1->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
|
 | 957 | + memcpy(ddsd.lpSurface, buffer, ddsd.lPitch*ddsd.dwHeight);
|
 | 958 | + error = temp1->Unlock(NULL);
|
 | 959 | + }
|
 | 960 | + if (backbuffers > 2)
|
 | 961 | + {
|
 | 962 | + ddscaps.dwCaps = DDSCAPS_FLIP;
|
 | 963 | + error = temp1->GetAttachedSurface(&ddscaps, &temp2);
|
 | 964 | + temp1->Release();
|
 | 965 | + temp1 = temp2;
|
 | 966 | + DrawGradients(ddsd, buffer, hWnd, palette, 0, 0x00FF00);
|
 | 967 | + error = temp1->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
|
 | 968 | + memcpy(ddsd.lpSurface, buffer, ddsd.lPitch*ddsd.dwHeight);
|
 | 969 | + error = temp1->Unlock(NULL);
|
 | 970 | + }
|
 | 971 | + if (backbuffers > 3)
|
 | 972 | + {
|
 | 973 | + ddscaps.dwCaps = DDSCAPS_FLIP;
|
 | 974 | + error = temp1->GetAttachedSurface(&ddscaps, &temp2);
|
 | 975 | + temp1->Release();
|
 | 976 | + temp1 = temp2;
|
 | 977 | + DrawGradients(ddsd, buffer, hWnd, palette, 0, 0xFF0000);
|
 | 978 | + error = temp1->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
|
 | 979 | + memcpy(ddsd.lpSurface, buffer, ddsd.lPitch*ddsd.dwHeight);
|
 | 980 | + error = temp1->Unlock(NULL);
|
 | 981 | + }
|
 | 982 | + if (temp1) temp1->Release();
|
 | 983 | + free(buffer);
|
 | 984 | + if (palette) palette->Release();
|
 | 985 | + break;
|
 | 986 | + case 2:
|
 | 987 | + if (!fullscreen) backbuffers = 0;
|
 | 988 | + error = ddsrender->GetDC(&hRenderDC);
|
 | 989 | + DrawGDIPatterns(ddsd, hRenderDC, 0);
|
 | 990 | + ddsrender->ReleaseDC(hRenderDC);
|
 | 991 | + if (backbuffers > 0)
|
 | 992 | + {
|
 | 993 | + ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
|
 | 994 | + error = ddsrender->GetAttachedSurface(&ddscaps, &temp1);
|
 | 995 | + temp1->GetDC(&hRenderDC);
|
 | 996 | + DrawGDIPatterns(ddsd, hRenderDC, 1);
|
 | 997 | + temp1->ReleaseDC(hRenderDC);
|
 | 998 | + }
|
 | 999 | + if (backbuffers > 1)
|
 | 1000 | + {
|
 | 1001 | + ddscaps.dwCaps = DDSCAPS_FLIP;
|
 | 1002 | + error = temp1->GetAttachedSurface(&ddscaps, &temp2);
|
 | 1003 | + temp1->Release();
|
 | 1004 | + temp1 = temp2;
|
 | 1005 | + temp1->GetDC(&hRenderDC);
|
 | 1006 | + DrawGDIPatterns(ddsd, hRenderDC, 2);
|
 | 1007 | + temp1->ReleaseDC(hRenderDC);
|
 | 1008 | + }
|
 | 1009 | + if (backbuffers > 2)
|
 | 1010 | + {
|
 | 1011 | + ddscaps.dwCaps = DDSCAPS_FLIP;
|
 | 1012 | + error = temp1->GetAttachedSurface(&ddscaps, &temp2);
|
 | 1013 | + temp1->Release();
|
 | 1014 | + temp1 = temp2;
|
 | 1015 | + temp1->GetDC(&hRenderDC);
|
 | 1016 | + DrawGDIPatterns(ddsd, hRenderDC, 3);
|
 | 1017 | + temp1->ReleaseDC(hRenderDC);
|
 | 1018 | + }
|
 | 1019 | + if (backbuffers > 3)
|
 | 1020 | + {
|
 | 1021 | + ddscaps.dwCaps = DDSCAPS_FLIP;
|
 | 1022 | + error = temp1->GetAttachedSurface(&ddscaps, &temp2);
|
 | 1023 | + temp1->Release();
|
 | 1024 | + temp1 = temp2;
|
 | 1025 | + temp1->GetDC(&hRenderDC);
|
 | 1026 | + DrawGDIPatterns(ddsd, hRenderDC, 4);
|
 | 1027 | + temp1->ReleaseDC(hRenderDC);
|
 | 1028 | + }
|
 | 1029 | + if (backbuffers > 4)
|
 | 1030 | + {
|
 | 1031 | + ddscaps.dwCaps = DDSCAPS_FLIP;
|
 | 1032 | + error = temp1->GetAttachedSurface(&ddscaps, &temp2);
|
 | 1033 | + temp1->Release();
|
 | 1034 | + temp1 = temp2;
|
 | 1035 | + temp1->GetDC(&hRenderDC);
|
 | 1036 | + DrawGDIPatterns(ddsd, hRenderDC, 5);
|
 | 1037 | + temp1->ReleaseDC(hRenderDC);
|
 | 1038 | + }
|
 | 1039 | + if (backbuffers > 5)
|
 | 1040 | + {
|
 | 1041 | + ddscaps.dwCaps = DDSCAPS_FLIP;
|
 | 1042 | + error = temp1->GetAttachedSurface(&ddscaps, &temp2);
|
 | 1043 | + temp1->Release();
|
 | 1044 | + temp1 = temp2;
|
 | 1045 | + temp1->GetDC(&hRenderDC);
|
 | 1046 | + DrawGDIPatterns(ddsd, hRenderDC, 6);
|
 | 1047 | + temp1->ReleaseDC(hRenderDC);
|
 | 1048 | + }
|
 | 1049 | + if (backbuffers > 6)
|
 | 1050 | + {
|
 | 1051 | + ddscaps.dwCaps = DDSCAPS_FLIP;
|
 | 1052 | + error = temp1->GetAttachedSurface(&ddscaps, &temp2);
|
 | 1053 | + temp1->Release();
|
 | 1054 | + temp1 = temp2;
|
 | 1055 | + temp1->GetDC(&hRenderDC);
|
 | 1056 | + DrawGDIPatterns(ddsd, hRenderDC, 7);
|
 | 1057 | + temp1->ReleaseDC(hRenderDC);
|
 | 1058 | + }
|
 | 1059 | + if (temp1) temp1->Release();
|
 | 1060 | + break;
|
 | 1061 | + case 4:
|
 | 1062 | + ddsrender->GetSurfaceDesc(&ddsd);
|
 | 1063 | + ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
 | 1064 | + ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
 | 1065 | + ddinterface->CreateSurface(&ddsd, &sprites[0].surface, NULL);
|
 | 1066 | + ddsrender->GetPalette(&palette);
|
 | 1067 | + error = sprites[0].surface->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
|
 | 1068 | + if(palette) palette->Release();
|
 | 1069 | + DrawGradients(ddsd, (unsigned char *)ddsd.lpSurface, hWnd, palette, 1, 0);
|
 | 1070 | + DrawDitheredColor(&ddsd, (unsigned char *)ddsd.lpSurface, 0, FALSE);
|
 | 1071 | + error = sprites[0].surface->Unlock(NULL);
|
 | 1072 | + sprites[0].width = (float)ddsd.dwWidth;
|
 | 1073 | + sprites[0].height = (float)ddsd.dwHeight;
|
 | 1074 | + sprites[0].rect.left = sprites[0].rect.top = 0;
|
 | 1075 | + sprites[0].rect.right = ddsd.dwWidth;
|
 | 1076 | + sprites[0].rect.bottom = ddsd.dwHeight;
|
 | 1077 | + if (backbuffers) ddsrender->GetAttachedSurface(&ddscaps, &temp1);
|
 | 1078 | + else temp1 = ddsrender;
|
 | 1079 | + temp1->SetColorKey(DDCKEY_DESTBLT, &ckey);
|
 | 1080 | + if (backbuffers) temp1->Release();
|
 | 1081 | + for (int i = 1; i < 16; i++)
|
 | 1082 | + {
|
 | 1083 | + switch ((i - 1 & 3))
|
 | 1084 | + {
|
 | 1085 | + case 0:
|
 | 1086 | + sprites[i].width = sprites[i].height = 64.f;
|
 | 1087 | + sprites[i].ddsd.dwWidth = sprites[i].ddsd.dwHeight =
|
 | 1088 | + sprites[i].rect.right = sprites[i].rect.bottom = 64;
|
 | 1089 | + sprites[i].ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
 | 1090 | + sprites[i].ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
 | 1091 | + if (ddver > 3) sprites[i].ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
 | 1092 | + else sprites[i].ddsd.dwSize = sizeof(DDSURFACEDESC);
|
 | 1093 | + ddinterface->CreateSurface(&sprites[i].ddsd, &sprites[i].surface, NULL);
|
 | 1094 | + error = sprites[i].surface->Lock(NULL, &sprites[i].ddsd, DDLOCK_WAIT, NULL);
|
 | 1095 | + DrawPalette(sprites[i].ddsd, (unsigned char *)sprites[i].ddsd.lpSurface);
|
 | 1096 | + sprites[i].surface->Unlock(NULL);
|
 | 1097 | + break;
|
 | 1098 | + case 1:
|
 | 1099 | + break;
|
 | 1100 | + case 2:
|
 | 1101 | + break;
|
 | 1102 | + case 3:
|
 | 1103 | + break;
|
 | 1104 | + default:
|
 | 1105 | + break;
|
 | 1106 | + }
|
 | 1107 | + if (i < 5) sprites[i].bltflags = 0;
|
 | 1108 | + else if (i < 9)
|
 | 1109 | + {
|
 | 1110 | + sprites[i].bltflags = DDBLTFAST_SRCCOLORKEY;
|
 | 1111 | + if (sprites[i].surface) sprites[i].surface->SetColorKey(DDCKEY_SRCBLT, &ckey);
|
 | 1112 | + }
|
 | 1113 | + else if (i < 13) sprites[i].bltflags = DDBLTFAST_DESTCOLORKEY;
|
 | 1114 | + else
|
 | 1115 | + {
|
 | 1116 | + sprites[i].bltflags = DDBLTFAST_SRCCOLORKEY | DDBLTFAST_DESTCOLORKEY;
|
 | 1117 | + if (sprites[i].surface) sprites[i].surface->SetColorKey(DDCKEY_SRCBLT, &ckey);
|
 | 1118 | + }
|
 | 1119 | + sprites[i].x = randfloat((float)ddsd.dwWidth);
|
 | 1120 | + sprites[i].y = randfloat((float)ddsd.dwHeight);
|
 | 1121 | + sprites[i].xvelocity = randfloat(5);
|
 | 1122 | + sprites[i].yvelocity = randfloat(5);
|
 | 1123 | + }
|
 | 1124 | + break;
|
 | 1125 | + case 7:
|
 | 1126 | + if (!fullscreen) backbuffers = 0;
|
 | 1127 | + ddsrender->GetSurfaceDesc(&ddsd);
|
 | 1128 | + ddsrender->GetPalette(&palette);
|
 | 1129 | + sprites[0].ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
 | 1130 | + sprites[0].ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
 | 1131 | + if (ddver > 3) sprites[0].ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
 | 1132 | + else sprites[0].ddsd.dwSize = sizeof(DDSURFACEDESC);
|
 | 1133 | + memcpy(&sprites[1], &sprites[0], sizeof(DDSPRITE));
|
 | 1134 | + memcpy(&sprites[2], &sprites[0], sizeof(DDSPRITE));
|
 | 1135 | + memcpy(&sprites[3], &sprites[0], sizeof(DDSPRITE));
|
 | 1136 | + memcpy(&sprites[4], &sprites[0], sizeof(DDSPRITE));
|
 | 1137 | + memcpy(&sprites[5], &sprites[0], sizeof(DDSPRITE));
|
 | 1138 | + sprites[0].width = sprites[0].height = 256.0f;
|
 | 1139 | + sprites[1].width = sprites[1].height = 256.0f;
|
 | 1140 | + sprites[2].width = sprites[2].height = 16.0f;
|
 | 1141 | + sprites[3].width = sprites[3].height = 16.0f;
|
 | 1142 | + sprites[4].width = sprites[4].height = 8.0f;
|
 | 1143 | + sprites[5].width = sprites[4].height = 6.0f;
|
 | 1144 | + sprites[0].ddsd.dwWidth = sprites[0].ddsd.dwHeight =
|
 | 1145 | + sprites[0].rect.right = sprites[0].rect.bottom = 256;
|
 | 1146 | + sprites[1].ddsd.dwWidth = sprites[1].ddsd.dwHeight =
|
 | 1147 | + sprites[1].rect.right = sprites[1].rect.bottom = 256;
|
 | 1148 | + sprites[2].ddsd.dwWidth = sprites[2].ddsd.dwHeight =
|
 | 1149 | + sprites[2].rect.right = sprites[2].rect.bottom = 16;
|
 | 1150 | + sprites[3].ddsd.dwWidth = sprites[3].ddsd.dwHeight =
|
 | 1151 | + sprites[3].rect.right = sprites[3].rect.bottom = 16;
|
 | 1152 | + sprites[4].ddsd.dwWidth = sprites[4].ddsd.dwHeight =
|
 | 1153 | + sprites[4].rect.right = sprites[4].rect.bottom = 8;
|
 | 1154 | + sprites[5].ddsd.dwWidth = sprites[5].ddsd.dwHeight =
|
 | 1155 | + sprites[5].rect.right = sprites[5].rect.bottom = 6;
|
 | 1156 | + ddinterface->CreateSurface(&sprites[0].ddsd, &sprites[0].surface, NULL);
|
 | 1157 | + ddinterface->CreateSurface(&sprites[1].ddsd, &sprites[1].surface, NULL);
|
 | 1158 | + ddinterface->CreateSurface(&sprites[2].ddsd, &sprites[2].surface, NULL);
|
 | 1159 | + ddinterface->CreateSurface(&sprites[3].ddsd, &sprites[3].surface, NULL);
|
 | 1160 | + ddinterface->CreateSurface(&sprites[4].ddsd, &sprites[4].surface, NULL);
|
 | 1161 | + ddinterface->CreateSurface(&sprites[5].ddsd, &sprites[5].surface, NULL);
|
 | 1162 | + DDCAPS ddcaps;
|
 | 1163 | + ddcaps.dwSize = sizeof(DDCAPS);
|
 | 1164 | + ddinterface->GetCaps(&ddcaps, NULL);
|
 | 1165 | + DrawROPPatterns(ddsrender, sprites, backbuffers, ddver, bpp, ddcaps.dwRops,hWnd,palette);
|
 | 1166 | + if (palette) palette->Release();
|
 | 1167 | + break;
|
 | 1168 | + case 8:
|
 | 1169 | + ddsrender->GetSurfaceDesc(&ddsd);
|
 | 1170 | + sprites[0].ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
 | 1171 | + sprites[0].ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
 | 1172 | + if (ddver > 3) sprites[0].ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
 | 1173 | + else sprites[0].ddsd.dwSize = sizeof(DDSURFACEDESC);
|
 | 1174 | + sprites[0].ddsd.dwWidth = sprites[0].ddsd.dwHeight =
|
 | 1175 | + sprites[0].rect.right = sprites[0].rect.bottom = 64;
|
 | 1176 | + ddinterface->CreateSurface(&sprites[0].ddsd, &sprites[0].surface, NULL);
|
 | 1177 | + DrawRotatedBlt(ddsrender, sprites);
|
 | 1178 | + break;
|
 | 1179 | + case 9:
|
 | 1180 | + ddsrender->GetSurfaceDesc(&ddsd);
|
 | 1181 | + sprites[0].ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
 | 1182 | + sprites[0].ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
 | 1183 | + if (ddver > 3) sprites[0].ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
 | 1184 | + else sprites[0].ddsd.dwSize = sizeof(DDSURFACEDESC);
|
 | 1185 | + sprites[0].ddsd.dwWidth = sprites[0].ddsd.dwHeight =
|
 | 1186 | + sprites[0].rect.right = sprites[0].rect.bottom = 255;
|
 | 1187 | + ddinterface->CreateSurface(&sprites[0].ddsd, &sprites[0].surface, NULL);
|
 | 1188 | + counter = 0;
|
 | 1189 | + break;
|
 | 1190 | + case 10:
|
 | 1191 | + case 11:
|
 | 1192 | + ddsrender->GetSurfaceDesc(&ddsd);
|
 | 1193 | + sprites[0].ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
 | 1194 | + sprites[0].ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
 | 1195 | + if (ddver > 3) sprites[0].ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
 | 1196 | + else sprites[0].ddsd.dwSize = sizeof(DDSURFACEDESC);
|
 | 1197 | + switch (bpp)
|
 | 1198 | + {
|
 | 1199 | + case 8:
|
 | 1200 | + sprites[0].width = sprites[0].height = 16;
|
 | 1201 | + break;
|
 | 1202 | + case 15:
|
 | 1203 | + sprites[0].width = 32;
|
 | 1204 | + sprites[0].height = 7;
|
 | 1205 | + break;
|
 | 1206 | + case 16:
|
 | 1207 | + sprites[0].width = 64;
|
 | 1208 | + sprites[0].height = 7;
|
 | 1209 | + break;
|
 | 1210 | + case 24:
|
 | 1211 | + case 32:
|
 | 1212 | + default:
|
 | 1213 | + sprites[0].width = 256;
|
 | 1214 | + sprites[0].height = 7;
|
 | 1215 | + break;
|
 | 1216 | + }
|
 | 1217 | + sprites[0].ddsd.dwWidth = sprites[0].width;
|
 | 1218 | + sprites[0].ddsd.dwHeight = sprites[0].height;
|
 | 1219 | + memcpy(&sprites[1], &sprites[0], sizeof(DDSPRITE));
|
 | 1220 | + memcpy(&sprites[2], &sprites[0], sizeof(DDSPRITE));
|
 | 1221 | + ddinterface->CreateSurface(&sprites[0].ddsd, &sprites[0].surface, NULL);
|
 | 1222 | + ddinterface->CreateSurface(&sprites[1].ddsd, &sprites[1].surface, NULL);
|
 | 1223 | + ddinterface->CreateSurface(&sprites[2].ddsd, &sprites[2].surface, NULL);
|
 | 1224 | + sprites[1].surface->Lock(NULL, &sprites[1].ddsd, DDLOCK_WAIT, NULL);
|
 | 1225 | + DrawColorKeyCompPatterns(sprites[1].ddsd, (unsigned char*)sprites[1].ddsd.lpSurface, bpp, 0);
|
 | 1226 | + sprites[1].surface->Unlock(NULL);
|
 | 1227 | + sprites[2].surface->Lock(NULL, &sprites[2].ddsd, DDLOCK_WAIT, NULL);
|
 | 1228 | + DrawColorKeyCompPatterns(sprites[2].ddsd, (unsigned char*)sprites[2].ddsd.lpSurface, bpp, 1);
|
 | 1229 | + sprites[2].surface->Unlock(NULL);
|
 | 1230 | + counter = 0;
|
 | 1231 | + break;
|
 | 1232 | + case 12:
|
 | 1233 | + MakeCube3D(5, 2);
|
 | 1234 | + ZeroMemory(&material, sizeof(D3DMATERIAL7));
|
 | 1235 | + material.ambient.r = 0.5f;
|
 | 1236 | + material.ambient.g = 0.5f;
|
 | 1237 | + material.ambient.b = 0.0f;
|
 | 1238 | + material.diffuse.r = 1.0f;
|
 | 1239 | + material.diffuse.g = 1.0f;
|
 | 1240 | + material.diffuse.b = 1.0f;
|
 | 1241 | + error = d3d7dev->SetMaterial(&material);
|
 | 1242 | + error = d3d7dev->LightEnable(0, TRUE);
|
 | 1243 | + error = d3d7dev->SetRenderState(D3DRENDERSTATE_LIGHTING, TRUE);
|
 | 1244 | + error = d3d7dev->SetRenderState(D3DRENDERSTATE_AMBIENT, 0x7f7f7f7f);
|
 | 1245 | + mat._11 = mat._22 = mat._33 = mat._44 = 1.0f;
|
 | 1246 | + mat._12 = mat._13 = mat._14 = mat._41 = 0.0f;
|
 | 1247 | + mat._21 = mat._23 = mat._24 = mat._42 = 0.0f;
|
 | 1248 | + mat._31 = mat._32 = mat._34 = mat._43 = 0.0f;
|
 | 1249 | + matWorld = mat;
|
 | 1250 | + error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_WORLD, &matWorld);
|
 | 1251 | + matView = mat;
|
 | 1252 | + matView._43 = 10.0f;
|
 | 1253 | + error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_VIEW, &matView);
|
 | 1254 | + matProj = mat;
|
 | 1255 | + matProj._11 = 2.0f;
|
 | 1256 | + matProj._22 = 2.0f;
|
 | 1257 | + matProj._34 = 1.0f;
|
 | 1258 | + matProj._43 = -1.0f;
|
 | 1259 | + matProj._44 = 0.0f;
|
 | 1260 | + error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_PROJECTION, &matProj);
|
 | 1261 | + ZeroMemory(&lights[0], sizeof(D3DLIGHT7));
|
 | 1262 | + lights[0].dltType = D3DLIGHT_DIRECTIONAL;
|
 | 1263 | + lights[0].dcvDiffuse.r = 1;
|
 | 1264 | + lights[0].dcvDiffuse.g = 0;
|
 | 1265 | + lights[0].dcvDiffuse.b = 1;
|
 | 1266 | + lights[0].dvDirection = D3DVECTOR(5, 5, 5);
|
 | 1267 | + lights[0].dvRange = D3DLIGHT_RANGE_MAX;
|
 | 1268 | + lights[0].dvAttenuation1 = 0.4f;
|
 | 1269 | + error = d3d7dev->SetLight(0, &lights[0]);
|
 | 1270 | + break;
|
 | 1271 | + case 13:
|
 | 1272 | + MakeCube3D(5, 2);
|
 | 1273 | + cleartexformats();
|
 | 1274 | + d3d7dev->EnumTextureFormats(gettexformat, NULL);
|
 | 1275 | + gentexture(fmt_rgba4444, &textures[0], 256, 256, 0);
|
 | 1276 | + gentexture(fmt_rgba1555, &textures[1], 256, 256, 0);
|
 | 1277 | + gentexture(fmt_rgb565, &textures[2], 256, 256, 0);
|
 | 1278 | + gentexture(fmt_rgba8888, &textures[3], 256, 256, 0);
|
 | 1279 | + ZeroMemory(&material, sizeof(D3DMATERIAL7));
|
 | 1280 | + material.ambient.r = 1.0f;
|
 | 1281 | + material.ambient.g = 1.0f;
|
 | 1282 | + material.ambient.b = 1.0f;
|
 | 1283 | + material.diffuse.r = 1.0f;
|
 | 1284 | + material.diffuse.g = 1.0f;
|
 | 1285 | + material.diffuse.b = 1.0f;
|
 | 1286 | + error = d3d7dev->SetMaterial(&material);
|
 | 1287 | + error = d3d7dev->LightEnable(0, TRUE);
|
 | 1288 | + error = d3d7dev->SetRenderState(D3DRENDERSTATE_LIGHTING, TRUE);
|
 | 1289 | + error = d3d7dev->SetRenderState(D3DRENDERSTATE_AMBIENT, 0xFFFFFFFF);
|
 | 1290 | + error = d3d7dev->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW);
|
 | 1291 | + mat._11 = mat._22 = mat._33 = mat._44 = 1.0f;
|
 | 1292 | + mat._12 = mat._13 = mat._14 = mat._41 = 0.0f;
|
 | 1293 | + mat._21 = mat._23 = mat._24 = mat._42 = 0.0f;
|
 | 1294 | + mat._31 = mat._32 = mat._34 = mat._43 = 0.0f;
|
 | 1295 | + matWorld = mat;
|
 | 1296 | + error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_WORLD, &matWorld);
|
 | 1297 | + matView = mat;
|
 | 1298 | + matView._43 = 10.0f;
|
 | 1299 | + error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_VIEW, &matView);
|
 | 1300 | + matProj = mat;
|
 | 1301 | + matProj._11 = 2.0f;
|
 | 1302 | + matProj._22 = 2.0f;
|
 | 1303 | + matProj._34 = 1.0f;
|
 | 1304 | + matProj._43 = -1.0f;
|
 | 1305 | + matProj._44 = 0.0f;
|
 | 1306 | + error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_PROJECTION, &matProj);
|
 | 1307 | + ZeroMemory(&lights[0], sizeof(D3DLIGHT7));
|
 | 1308 | + lights[0].dltType = D3DLIGHT_DIRECTIONAL;
|
 | 1309 | + lights[0].dcvDiffuse.r = 1;
|
 | 1310 | + lights[0].dcvDiffuse.g = 0;
|
 | 1311 | + lights[0].dcvDiffuse.b = 1;
|
 | 1312 | + lights[0].dvDirection = D3DVECTOR(5, 5, 5);
|
 | 1313 | + lights[0].dvRange = D3DLIGHT_RANGE_MAX;
|
 | 1314 | + lights[0].dvAttenuation1 = 0.4f;
|
 | 1315 | + error = d3d7dev->SetLight(0, &lights[0]);
|
 | 1316 | + break;
|
 | 1317 | + case 15:
|
 | 1318 | + ZeroMemory(lights, 8 * sizeof(D3DLIGHT7));
|
 | 1319 | + MakeLights();
|
 | 1320 | + case 14:
|
 | 1321 | + MakeCube3D(5, 8);
|
 | 1322 | + ZeroMemory(&material, sizeof(D3DMATERIAL7));
|
 | 1323 | + material.ambient.r = 1.0f;
|
 | 1324 | + material.ambient.g = 1.0f;
|
 | 1325 | + material.ambient.b = 1.0f;
|
 | 1326 | + material.ambient.a = 1.0f;
|
 | 1327 | + material.diffuse.r = 1.0f;
|
 | 1328 | + material.diffuse.g = 1.0f;
|
 | 1329 | + material.diffuse.b = 1.0f;
|
 | 1330 | + material.diffuse.a = 1.0f;
|
 | 1331 | + error = d3d7dev->SetMaterial(&material);
|
 | 1332 | + error = d3d7dev->SetRenderState(D3DRENDERSTATE_LIGHTING, FALSE);
|
 | 1333 | + error = d3d7dev->SetRenderState(D3DRENDERSTATE_AMBIENT, 0xffffffff);
|
 | 1334 | + mat._11 = mat._22 = mat._33 = mat._44 = 1.0f;
|
 | 1335 | + mat._12 = mat._13 = mat._14 = mat._41 = 0.0f;
|
 | 1336 | + mat._21 = mat._23 = mat._24 = mat._42 = 0.0f;
|
 | 1337 | + mat._31 = mat._32 = mat._34 = mat._43 = 0.0f;
|
 | 1338 | + matWorld = mat;
|
 | 1339 | + error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_WORLD, &matWorld);
|
 | 1340 | + matView = mat;
|
 | 1341 | + matView._43 = 10.0f;
|
 | 1342 | + error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_VIEW, &matView);
|
 | 1343 | + matProj = mat;
|
 | 1344 | + matProj._11 = 2.0f;
|
 | 1345 | + matProj._22 = 2.0f;
|
 | 1346 | + matProj._34 = 1.0f;
|
 | 1347 | + matProj._43 = -1.0f;
|
 | 1348 | + matProj._44 = 0.0f;
|
 | 1349 | + error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_PROJECTION, &matProj);
|
 | 1350 | + texshaderstate = defaulttexshaderstate;
|
 | 1351 | + break;
|
 | 1352 | + default:
|
 | 1353 | + break;
|
 | 1354 | + }
|
 | 1355 | +}
|
 | 1356 | +
|
 | 1357 | +void RunTestTimed(int test)
|
 | 1358 | +{
|
 | 1359 | + if(stoptimer) return;
|
 | 1360 | + DDSURFACEDESC2 ddsd;
|
 | 1361 | + DDSCAPS2 ddscaps;
|
 | 1362 | + DDBLTFX bltfx;
|
 | 1363 | + HDC hDCdest, hDCsrc;
|
 | 1364 | + RECT r1, r2;
|
 | 1365 | + POINT p;
|
 | 1366 | + RECT srcrect, destrect;
|
 | 1367 | + HRESULT error;
|
 | 1368 | + D3DMATRIX mat;
|
 | 1369 | + TCHAR message[256];
|
 | 1370 | + bltfx.dwSize = sizeof(DDBLTFX);
|
 | 1371 | + ZeroMemory(&ddscaps,sizeof(DDSCAPS2));
|
 | 1372 | + ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
|
 | 1373 | + MultiDirectDrawSurface *temp1 = NULL;
|
 | 1374 | + ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
|
 | 1375 | + if (d3dver >= 3) ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
 | 1376 | + else ddsd.dwSize = sizeof(DDSURFACEDESC);
|
 | 1377 | + float time;
|
 | 1378 | + switch(test)
|
 | 1379 | + {
|
 | 1380 | + case 0: // Palette and gradients
|
 | 1381 | + case 2: // GDI patterns
|
 | 1382 | + case 7: // ROP patterns
|
 | 1383 | + default:
|
 | 1384 | + if(fullscreen) ddsurface->Flip(NULL,DDFLIP_WAIT);
|
 | 1385 | + break;
|
 | 1386 | + case 4: // BltFast sprites
|
 | 1387 | + if (backbuffers) ddsrender->GetAttachedSurface(&ddscaps, &temp1);
|
 | 1388 | + else temp1 = ddsrender;
|
 | 1389 | + bltfx.dwFillColor = 0;
|
 | 1390 | + temp1->Blt(NULL, NULL, NULL, DDBLT_COLORFILL, &bltfx);
|
 | 1391 | + if (backbuffers) temp1->Release();
|
 | 1392 | + for(int i = 0; i < 16; i++)
|
 | 1393 | + {
|
 | 1394 | + sprites[i].x += sprites[i].xvelocity;
|
 | 1395 | + if(sprites[i].xvelocity < 0 && sprites[i].x < 0) sprites[i].xvelocity = -sprites[i].xvelocity;
|
 | 1396 | + if(sprites[i].xvelocity > 0 && (sprites[i].x + sprites[i].width) > width)
|
 | 1397 | + sprites[i].xvelocity = -sprites[i].xvelocity;
|
 | 1398 | + sprites[i].y += sprites[i].yvelocity;
|
 | 1399 | + if(sprites[i].yvelocity < 0 && sprites[i].y < 0) sprites[i].yvelocity = -sprites[i].yvelocity;
|
 | 1400 | + if(sprites[i].yvelocity > 0 && (sprites[i].y + sprites[i].height) > height)
|
 | 1401 | + sprites[i].yvelocity = -sprites[i].yvelocity;
|
 | 1402 | + if(sprites[i].surface)
|
 | 1403 | + {
|
 | 1404 | + if(backbuffers) ddsrender->GetAttachedSurface(&ddscaps,&temp1);
|
 | 1405 | + else temp1 = ddsrender;
|
 | 1406 | + temp1->BltFast((DWORD)sprites[i].x,(DWORD)sprites[i].y,sprites[i].surface,&sprites[i].rect,sprites[i].bltflags);
|
 | 1407 | + if(backbuffers) temp1->Release();
|
 | 1408 | + }
|
 | 1409 | + }
|
 | 1410 | + if (fullscreen)
|
 | 1411 | + {
|
 | 1412 | + if (backbuffers && ddsrender) ddsrender->Flip(NULL, DDFLIP_WAIT);
|
 | 1413 | + }
|
 | 1414 | + else
|
 | 1415 | + {
|
 | 1416 | + p.x = 0;
|
 | 1417 | + p.y = 0;
|
 | 1418 | + ClientToScreen(hWnd, &p);
|
 | 1419 | + GetClientRect(hWnd, &r1);
|
 | 1420 | + OffsetRect(&r1, p.x, p.y);
|
 | 1421 | + SetRect(&r2, 0, 0, width, height);
|
 | 1422 | + if (ddsurface && ddsrender) ddsurface->Blt(&r1, ddsrender, &r2, DDBLT_WAIT, NULL);
|
 | 1423 | + }
|
 | 1424 | + break;
|
 | 1425 | + case 10: // Source Key Override test
|
 | 1426 | + case 11: // Destination Key Override Test
|
 | 1427 | + if (backbuffers) ddsrender->GetAttachedSurface(&ddscaps, &temp1);
|
 | 1428 | + else temp1 = ddsrender;
|
 | 1429 | +
|
 | 1430 | + sprites[0].surface->Blt(NULL, sprites[1].surface, NULL, DDBLT_WAIT, NULL);
|
 | 1431 | + bltfx.dwSize = sizeof(DDBLTFX);
|
 | 1432 | + switch (bpp)
|
 | 1433 | + {
|
 | 1434 | + case 8:
|
 | 1435 | + bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
 | 1436 | + bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue = counter;
|
 | 1437 | + counter++;
|
 | 1438 | + if (counter > 255) counter = 0;
|
 | 1439 | + r1.left = r1.top = 0;
|
 | 1440 | + r1.right = r1.bottom = 16;
|
 | 1441 | + break;
|
 | 1442 | + case 15:
|
 | 1443 | + switch (counter >> 5)
|
 | 1444 | + {
|
 | 1445 | + case 0:
|
 | 1446 | + bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
 | 1447 | + bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
 | 1448 | + (counter & 31) << 10;
|
 | 1449 | + break;
|
 | 1450 | + case 1:
|
 | 1451 | + bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
 | 1452 | + bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
 | 1453 | + (counter & 31) << 5;
|
 | 1454 | + break;
|
 | 1455 | + case 2:
|
 | 1456 | + bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
 | 1457 | + bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
 | 1458 | + (counter & 31);
|
 | 1459 | + break;
|
 | 1460 | + case 3:
|
 | 1461 | + bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
 | 1462 | + bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
 | 1463 | + (counter & 31) + ((counter & 31) << 5);
|
 | 1464 | + break;
|
 | 1465 | + case 4:
|
 | 1466 | + bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
 | 1467 | + bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
 | 1468 | + (counter & 31) + ((counter & 31) << 10);
|
 | 1469 | + break;
|
 | 1470 | + case 5:
|
 | 1471 | + bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
 | 1472 | + bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
 | 1473 | + ((counter & 31) << 5) + ((counter & 31) << 10);
|
 | 1474 | + break;
|
 | 1475 | + case 6:
|
 | 1476 | + default:
|
 | 1477 | + bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
 | 1478 | + bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
 | 1479 | + (counter & 31) + ((counter & 31) << 5) + ((counter & 31) << 10);
|
 | 1480 | + break;
|
 | 1481 | + }
|
 | 1482 | + counter++;
|
 | 1483 | + if (counter > 223) counter = 0;
|
 | 1484 | + r1.left = r1.top = 0;
|
 | 1485 | + r1.right = 32;
|
 | 1486 | + r1.bottom = 7;
|
 | 1487 | + break;
|
 | 1488 | + case 16:
|
 | 1489 | + switch (counter >> 6)
|
 | 1490 | + {
|
 | 1491 | + case 0:
|
 | 1492 | + bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
 | 1493 | + bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
 | 1494 | + ((counter & 63) >> 1) << 11;
|
 | 1495 | + break;
|
 | 1496 | + case 1:
|
 | 1497 | + bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
 | 1498 | + bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
 | 1499 | + (counter & 63) << 5;
|
 | 1500 | + break;
|
 | 1501 | + case 2:
|
 | 1502 | + bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
 | 1503 | + bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
 | 1504 | + (counter & 63) >> 1;
|
 | 1505 | + break;
|
 | 1506 | + case 3:
|
 | 1507 | + bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
 | 1508 | + bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
 | 1509 | + ((counter & 63) >> 1) + ((counter & 63) << 5);
|
 | 1510 | + break;
|
 | 1511 | + case 4:
|
 | 1512 | + bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
 | 1513 | + bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
 | 1514 | + ((counter & 63) >> 1) + (((counter & 63) >> 1) << 11);
|
 | 1515 | + break;
|
 | 1516 | + case 5:
|
 | 1517 | + bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
 | 1518 | + bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
 | 1519 | + ((counter & 63) << 5) + (((counter & 63) >> 1) << 11);
|
 | 1520 | + break;
|
 | 1521 | + case 6:
|
 | 1522 | + default:
|
 | 1523 | + bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
 | 1524 | + bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
 | 1525 | + ((counter & 63) >> 1) + ((counter & 63) << 5) + (((counter & 63) >> 1) << 11);
|
 | 1526 | + break;
|
 | 1527 | + }
|
 | 1528 | + counter++;
|
 | 1529 | + if (counter > 447) counter = 0;
|
 | 1530 | + r1.left = r1.top = 0;
|
 | 1531 | + r1.right = 64;
|
 | 1532 | + r1.bottom = 7;
|
 | 1533 | + break;
|
 | 1534 | + case 24:
|
 | 1535 | + case 32:
|
 | 1536 | + default:
|
 | 1537 | + switch (counter >> 8)
|
 | 1538 | + {
|
 | 1539 | + case 0:
|
 | 1540 | + bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
 | 1541 | + bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
 | 1542 | + (counter & 255) << 16;
|
 | 1543 | + break;
|
 | 1544 | + case 1:
|
 | 1545 | + bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
 | 1546 | + bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
 | 1547 | + (counter & 255) << 8;
|
 | 1548 | + break;
|
 | 1549 | + case 2:
|
 | 1550 | + bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
 | 1551 | + bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
 | 1552 | + counter & 255;
|
 | 1553 | + break;
|
 | 1554 | + case 3:
|
 | 1555 | + bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
 | 1556 | + bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
 | 1557 | + (counter & 255) + ((counter & 255) << 8);
|
 | 1558 | + break;
|
 | 1559 | + case 4:
|
 | 1560 | + bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
 | 1561 | + bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
 | 1562 | + (counter & 255) + ((counter & 255) << 16);
|
 | 1563 | + break;
|
 | 1564 | + case 5:
|
 | 1565 | + bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
 | 1566 | + bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
 | 1567 | + ((counter & 255) << 8) + ((counter & 255) << 16);
|
 | 1568 | + break;
|
 | 1569 | + case 6:
|
 | 1570 | + default:
|
 | 1571 | + bltfx.ddckSrcColorkey.dwColorSpaceHighValue = bltfx.ddckSrcColorkey.dwColorSpaceLowValue =
|
 | 1572 | + bltfx.ddckDestColorkey.dwColorSpaceHighValue = bltfx.ddckDestColorkey.dwColorSpaceLowValue =
|
 | 1573 | + (counter & 255) + ((counter & 255) << 8) + ((counter & 255) << 16);
|
 | 1574 | + break;
|
 | 1575 | + }
|
 | 1576 | + counter++;
|
 | 1577 | + if (counter > 1791) counter = 0;
|
 | 1578 | + r1.left = r1.top = 0;
|
 | 1579 | + r1.right = 256;
|
 | 1580 | + r1.bottom = 7;
|
 | 1581 | + break;
|
 | 1582 | + }
|
 | 1583 | + if (test == 10)
|
 | 1584 | + sprites[0].surface->Blt(NULL, sprites[2].surface, NULL, DDBLT_WAIT | DDBLT_KEYSRCOVERRIDE, &bltfx);
|
 | 1585 | + else
|
 | 1586 | + sprites[0].surface->Blt(NULL, sprites[2].surface, NULL, DDBLT_WAIT | DDBLT_KEYDESTOVERRIDE, &bltfx);
|
 | 1587 | + temp1->GetDC(&hDCdest);
|
 | 1588 | + sprites[0].surface->GetDC(&hDCsrc);
|
 | 1589 | + if (ddver > 3) ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
 | 1590 | + else ddsd.dwSize = sizeof(DDSURFACEDESC);
|
 | 1591 | + temp1->GetSurfaceDesc(&ddsd);
|
 | 1592 | + StretchBlt(hDCdest, ((ddsd.dwWidth / 2) - 128), ((ddsd.dwHeight / 2) + 128), 256, -256,
|
 | 1593 | + hDCsrc, 0, 0, r1.right, r1.bottom, SRCCOPY);
|
 | 1594 | + sprites[0].surface->ReleaseDC(hDCsrc);
|
 | 1595 | + SetBkColor(hDCdest, RGB(0, 0, 255));
|
 | 1596 | + SetTextColor(hDCdest, RGB(255, 255, 255));
|
 | 1597 | + if(test == 10)
|
 | 1598 | + _tcscpy(message, _T("Source Color Key Override Test"));
|
 | 1599 | + else
|
 | 1600 | + _tcscpy(message, _T("Destination Color Key Override Test"));
|
 | 1601 | + TextOut(hDCdest, 0, 0, message, _tcslen(message));
|
 | 1602 | + _stprintf(message, _T("Color: 0x%08X "), bltfx.ddckSrcColorkey.dwColorSpaceHighValue);
|
 | 1603 | + TextOut(hDCdest, 0, 16, message, _tcslen(message));
|
 | 1604 | + temp1->ReleaseDC(hDCdest);
|
 | 1605 | + if (backbuffers) temp1->Release();
|
 | 1606 | + if (fullscreen)
|
 | 1607 | + {
|
 | 1608 | + if (backbuffers && ddsrender) ddsrender->Flip(NULL, DDFLIP_WAIT);
|
 | 1609 | + }
|
 | 1610 | + else
|
 | 1611 | + {
|
 | 1612 | + p.x = 0;
|
 | 1613 | + p.y = 0;
|
 | 1614 | + ClientToScreen(hWnd, &p);
|
 | 1615 | + GetClientRect(hWnd, &r1);
|
 | 1616 | + OffsetRect(&r1, p.x, p.y);
|
 | 1617 | + SetRect(&r2, 0, 0, width, height);
|
 | 1618 | + if (ddsurface && ddsrender) ddsurface->Blt(&r1, ddsrender, &r2, DDBLT_WAIT, NULL);
|
 | 1619 | + }
|
 | 1620 | + break;
|
 | 1621 | + case 12:
|
 | 1622 | + error = d3d7dev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, bgcolor, 1.0, 0);
|
 | 1623 | + time = (float)clock() / (float)CLOCKS_PER_SEC;
|
 | 1624 | + mat._11 = mat._22 = mat._33 = mat._44 = 1.0f;
|
 | 1625 | + mat._12 = mat._13 = mat._14 = mat._41 = 0.0f;
|
 | 1626 | + mat._21 = mat._23 = mat._24 = mat._42 = 0.0f;
|
 | 1627 | + mat._31 = mat._32 = mat._34 = mat._43 = 0.0f;
|
 | 1628 | + mat._11 = (FLOAT)cos( (float)time );
|
 | 1629 | + mat._33 = (FLOAT)cos( (float)time );
|
 | 1630 | + mat._13 = -(FLOAT)sin( (float)time );
|
 | 1631 | + mat._31 = (FLOAT)sin( (float)time );
|
 | 1632 | + error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_WORLD, &mat);
|
 | 1633 | + error = d3d7dev->BeginScene();
|
 | 1634 | + error = d3d7dev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,D3DFVF_VERTEX,vertices,numpoints,mesh,numindices,0);
|
 | 1635 | + error = d3d7dev->EndScene();
|
 | 1636 | + if (fullscreen)
|
 | 1637 | + {
|
 | 1638 | + if (backbuffers) ddsurface->Flip(NULL, DDFLIP_WAIT);
|
 | 1639 | + }
|
 | 1640 | + else
|
 | 1641 | + {
|
 | 1642 | + p.x = 0;
|
 | 1643 | + p.y = 0;
|
 | 1644 | + ClientToScreen(hWnd, &p);
|
 | 1645 | + GetClientRect(hWnd, &destrect);
|
 | 1646 | + OffsetRect(&destrect, p.x, p.y);
|
 | 1647 | + SetRect(&srcrect, 0, 0, width, height);
|
 | 1648 | + if (ddsurface && ddsrender)error = ddsurface->Blt(&destrect, ddsrender, &srcrect, DDBLT_WAIT, NULL);
|
 | 1649 | + }
|
 | 1650 | + break;
|
 | 1651 | + case 13:
|
 | 1652 | + error = d3d7dev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, bgcolor, 1.0, 0);
|
 | 1653 | + time = (float)clock() / (float)CLOCKS_PER_SEC;
|
 | 1654 | + mat._11 = mat._22 = mat._33 = mat._44 = 1.0f;
|
 | 1655 | + mat._12 = mat._13 = mat._14 = mat._41 = 0.0f;
|
 | 1656 | + mat._21 = mat._23 = mat._24 = mat._42 = 0.0f;
|
 | 1657 | + mat._31 = mat._32 = mat._34 = mat._43 = 0.0f;
|
 | 1658 | + mat._11 = (FLOAT)cos( (float)time );
|
 | 1659 | + mat._33 = (FLOAT)cos( (float)time );
|
 | 1660 | + mat._13 = -(FLOAT)sin( (float)time );
|
 | 1661 | + mat._31 = (FLOAT)sin( (float)time );
|
 | 1662 | + error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_WORLD, &mat);
|
 | 1663 | + error = d3d7dev->BeginScene();
|
 | 1664 | + error = d3d7dev->SetTexture(0,(LPDIRECTDRAWSURFACE7)textures[0]->GetSurface());
|
 | 1665 | + error = d3d7dev->DrawPrimitive(D3DPT_TRIANGLESTRIP,D3DFVF_VERTEX,vertices,4,0);
|
 | 1666 | + error = d3d7dev->SetTexture(0,(LPDIRECTDRAWSURFACE7)textures[1]->GetSurface());
|
 | 1667 | + error = d3d7dev->DrawPrimitive(D3DPT_TRIANGLESTRIP,D3DFVF_VERTEX,vertices+4,4,0);
|
 | 1668 | + error = d3d7dev->SetTexture(0,(LPDIRECTDRAWSURFACE7)textures[2]->GetSurface());
|
 | 1669 | + error = d3d7dev->DrawPrimitive(D3DPT_TRIANGLESTRIP,D3DFVF_VERTEX,vertices+8,4,0);
|
 | 1670 | + error = d3d7dev->SetTexture(0,(LPDIRECTDRAWSURFACE7)textures[3]->GetSurface());
|
 | 1671 | + error = d3d7dev->DrawPrimitive(D3DPT_TRIANGLESTRIP,D3DFVF_VERTEX,vertices+12,4,0);
|
 | 1672 | + error = d3d7dev->EndScene();
|
 | 1673 | + if (fullscreen)
|
 | 1674 | + {
|
 | 1675 | + if (backbuffers) ddsurface->Flip(NULL, DDFLIP_WAIT);
|
 | 1676 | + }
|
 | 1677 | + else
|
 | 1678 | + {
|
 | 1679 | + p.x = 0;
|
 | 1680 | + p.y = 0;
|
 | 1681 | + ClientToScreen(hWnd, &p);
|
 | 1682 | + GetClientRect(hWnd, &destrect);
|
 | 1683 | + OffsetRect(&destrect, p.x, p.y);
|
 | 1684 | + SetRect(&srcrect, 0, 0, width, height);
|
 | 1685 | + if (ddsurface && ddsrender)error = ddsurface->Blt(&destrect, ddsrender, &srcrect, DDBLT_WAIT, NULL);
|
 | 1686 | + }
|
 | 1687 | + break;
|
 | 1688 | + case 14:
|
 | 1689 | + error = d3d7dev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, bgcolor, 1.0, 0);
|
 | 1690 | + time = (float)clock() / (float)CLOCKS_PER_SEC;
|
 | 1691 | + mat._11 = mat._22 = mat._33 = mat._44 = 1.0f;
|
 | 1692 | + mat._12 = mat._13 = mat._14 = mat._41 = 0.0f;
|
 | 1693 | + mat._21 = mat._23 = mat._24 = mat._42 = 0.0f;
|
 | 1694 | + mat._31 = mat._32 = mat._34 = mat._43 = 0.0f;
|
 | 1695 | + mat._11 = (FLOAT)cos( (float)time );
|
 | 1696 | + mat._33 = (FLOAT)cos( (float)time );
|
 | 1697 | + mat._13 = -(FLOAT)sin( (float)time );
|
 | 1698 | + mat._31 = (FLOAT)sin( (float)time );
|
 | 1699 | + error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_WORLD, &mat);
|
 | 1700 | + error = d3d7dev->BeginScene();
|
 | 1701 | + error = d3d7dev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,D3DFVF_LVERTEX,litvertices,numpoints,mesh,numindices,0);
|
 | 1702 | + error = d3d7dev->EndScene();
|
 | 1703 | + if (fullscreen)
|
 | 1704 | + {
|
 | 1705 | + if (backbuffers) ddsurface->Flip(NULL, DDFLIP_WAIT);
|
 | 1706 | + }
|
 | 1707 | + else
|
 | 1708 | + {
|
 | 1709 | + p.x = 0;
|
 | 1710 | + p.y = 0;
|
 | 1711 | + ClientToScreen(hWnd, &p);
|
 | 1712 | + GetClientRect(hWnd, &destrect);
|
 | 1713 | + OffsetRect(&destrect, p.x, p.y);
|
 | 1714 | + SetRect(&srcrect, 0, 0, width, height);
|
 | 1715 | + if (ddsurface && ddsrender)error = ddsurface->Blt(&destrect, ddsrender, &srcrect, DDBLT_WAIT, NULL);
|
 | 1716 | + }
|
 | 1717 | + break;
|
 | 1718 | + case 15:
|
 | 1719 | + error = d3d7dev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, bgcolor, 1.0, 0);
|
 | 1720 | + time = (float)clock() / (float)CLOCKS_PER_SEC;
|
 | 1721 | + mat._11 = mat._22 = mat._33 = mat._44 = 1.0f;
|
 | 1722 | + mat._12 = mat._13 = mat._14 = mat._41 = 0.0f;
|
 | 1723 | + mat._21 = mat._23 = mat._24 = mat._42 = 0.0f;
|
 | 1724 | + mat._31 = mat._32 = mat._34 = mat._43 = 0.0f;
|
 | 1725 | + mat._11 = (FLOAT)cos( (float)time );
|
 | 1726 | + mat._33 = (FLOAT)cos( (float)time );
|
 | 1727 | + mat._13 = -(FLOAT)sin( (float)time );
|
 | 1728 | + mat._31 = (FLOAT)sin( (float)time );
|
 | 1729 | + error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_WORLD, &mat);
|
 | 1730 | + error = d3d7dev->BeginScene();
|
 | 1731 | + error = d3d7dev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,FVF_COLORVERTEX,colorvertices,numpoints,mesh,numindices,0);
|
 | 1732 | + error = d3d7dev->EndScene();
|
 | 1733 | + if (fullscreen)
|
 | 1734 | + {
|
 | 1735 | + if (backbuffers) ddsurface->Flip(NULL, DDFLIP_WAIT);
|
 | 1736 | + }
|
 | 1737 | + else
|
 | 1738 | + {
|
 | 1739 | + p.x = 0;
|
 | 1740 | + p.y = 0;
|
 | 1741 | + ClientToScreen(hWnd, &p);
|
 | 1742 | + GetClientRect(hWnd, &destrect);
|
 | 1743 | + OffsetRect(&destrect, p.x, p.y);
|
 | 1744 | + SetRect(&srcrect, 0, 0, width, height);
|
 | 1745 | + if (ddsurface && ddsrender)error = ddsurface->Blt(&destrect, ddsrender, &srcrect, DDBLT_WAIT, NULL);
|
 | 1746 | + }
|
 | 1747 | + break;
|
 | 1748 | + }
|
 | 1749 | +}
|
 | 1750 | +
|
 | 1751 | +void RunTestLooped(int test)
|
 | 1752 | +{
|
 | 1753 | + randnum += rand(); // Improves randomness of "snow" patterns at certain resolutions
|
 | 1754 | + HDC hdc;
|
 | 1755 | + unsigned int i;
|
 | 1756 | + POINT p;
|
 | 1757 | + HPEN pen;
|
 | 1758 | + HBRUSH brush;
|
 | 1759 | + HANDLE tmphandle,tmphandle2;
|
 | 1760 | + RECT srcrect,destrect;
|
 | 1761 | + HRESULT error;
|
 | 1762 | + DDSURFACEDESC2 ddsd;
|
 | 1763 | + DDBLTFX bltfx;
|
 | 1764 | + if(ddver > 3)ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
 | 1765 | + else ddsd.dwSize = sizeof(DDSURFACEDESC);
|
 | 1766 | + error = ddsrender->GetSurfaceDesc(&ddsd);
|
 | 1767 | + MultiDirectDrawSurface *temp1 = NULL;
|
 | 1768 | + DDSCAPS2 ddscaps;
|
 | 1769 | + DWORD bitmask;
|
 | 1770 | + ZeroMemory(&ddscaps,sizeof(DDSCAPS2));
|
 | 1771 | + ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
|
 | 1772 | + int op;
|
 | 1773 | + switch(test)
|
 | 1774 | + {
|
 | 1775 | + case 1:
|
 | 1776 | + default:
|
 | 1777 | + if(backbuffers)
|
 | 1778 | + {
|
 | 1779 | + ddsrender->GetAttachedSurface(&ddscaps,&temp1);
|
 | 1780 | + temp1->Lock(NULL,&ddsd,DDLOCK_WAIT,NULL);
|
 | 1781 | + }
|
 | 1782 | + else ddsrender->Lock(NULL,&ddsd,DDLOCK_WAIT,NULL);
|
 | 1783 | +
|
 | 1784 | + for(i = 0; i < ((ddsd.lPitch * ddsd.dwHeight)/4); i++)
|
 | 1785 | + ((DWORD*)ddsd.lpSurface)[i] = rand32(randnum);
|
 | 1786 | +
|
 | 1787 | + if(backbuffers)
|
 | 1788 | + {
|
 | 1789 | + temp1->Unlock(NULL);
|
 | 1790 | + ddsrender->Flip(NULL,DDFLIP_WAIT);
|
 | 1791 | + }
|
 | 1792 | + else ddsrender->Unlock(NULL);
|
 | 1793 | + if(!fullscreen)
|
 | 1794 | + {
|
 | 1795 | + p.x = 0;
|
 | 1796 | + p.y = 0;
|
 | 1797 | + ClientToScreen(hWnd,&p);
|
 | 1798 | + GetClientRect(hWnd,&destrect);
|
 | 1799 | + OffsetRect(&destrect,p.x,p.y);
|
 | 1800 | + SetRect(&srcrect,0,0,width,height);
|
 | 1801 | + if(ddsurface && ddsrender)error = ddsurface->Blt(&destrect,ddsrender,&srcrect,DDBLT_WAIT,NULL);
|
 | 1802 | + }
|
 | 1803 | + break;
|
 | 1804 | + case 3:
|
 | 1805 | + ddsrender->GetDC(&hdc);
|
 | 1806 | + op = rand32(randnum) % 4;
|
 | 1807 | + pen = CreatePen(rand32(randnum) % 5,0,RGB(rand32(randnum)%256,rand32(randnum)%256,rand32(randnum)%256));
|
 | 1808 | + brush = CreateSolidBrush(RGB(rand32(randnum)%256,rand32(randnum)%256,rand32(randnum)%256));
|
 | 1809 | + tmphandle = SelectObject(hdc,pen);
|
 | 1810 | + tmphandle2 = SelectObject(hdc,brush);
|
 | 1811 | + SetBkColor(hdc,RGB(rand32(randnum)%256,rand32(randnum)%256,rand32(randnum)%256));
|
 | 1812 | + switch(op)
|
 | 1813 | + {
|
 | 1814 | + case 0:
|
 | 1815 | + default:
|
 | 1816 | + Rectangle(hdc,rand32(randnum)%ddsd.dwWidth,rand32(randnum)%ddsd.dwHeight,
|
 | 1817 | + rand32(randnum)%ddsd.dwWidth,rand32(randnum)%ddsd.dwHeight);
|
 | 1818 | + break;
|
 | 1819 | + case 1:
|
 | 1820 | + Ellipse(hdc,rand32(randnum)%ddsd.dwWidth,rand32(randnum)%ddsd.dwHeight,
|
 | 1821 | + rand32(randnum)%ddsd.dwWidth,rand32(randnum)%ddsd.dwHeight);
|
 | 1822 | + break;
|
 | 1823 | + case 2:
|
 | 1824 | + MoveToEx(hdc,rand32(randnum)%ddsd.dwWidth,rand32(randnum)%ddsd.dwHeight,NULL);
|
 | 1825 | + LineTo(hdc,rand32(randnum)%ddsd.dwWidth,rand32(randnum)%ddsd.dwHeight);
|
 | 1826 | + break;
|
 | 1827 | + case 3:
|
 | 1828 | + SetTextColor(hdc,RGB(rand32(randnum)%256,rand32(randnum)%256,rand32(randnum)%256));
|
 | 1829 | + TextOut(hdc,rand32(randnum)%ddsd.dwWidth,rand32(randnum)%ddsd.dwHeight,_T("Text"),4);
|
 | 1830 | + break;
|
 | 1831 | + }
|
 | 1832 | + SelectObject(hdc,tmphandle2);
|
 | 1833 | + SelectObject(hdc,tmphandle);
|
 | 1834 | + DeleteObject(brush);
|
 | 1835 | + DeleteObject(pen);
|
 | 1836 | + ddsrender->ReleaseDC(hdc);
|
 | 1837 | + if(!fullscreen)
|
 | 1838 | + {
|
 | 1839 | + p.x = 0;
|
 | 1840 | + p.y = 0;
|
 | 1841 | + ClientToScreen(hWnd,&p);
|
 | 1842 | + GetClientRect(hWnd,&destrect);
|
 | 1843 | + OffsetRect(&destrect,p.x,p.y);
|
 | 1844 | + SetRect(&srcrect,0,0,width,height);
|
 | 1845 | + if(ddsurface && ddsrender)error = ddsurface->Blt(&destrect,ddsrender,&srcrect,DDBLT_WAIT,NULL);
|
 | 1846 | + }
|
 | 1847 | + break;
|
 | 1848 | + case 5:
|
 | 1849 | + rndrect5:
|
 | 1850 | + destrect.bottom = rand32(randnum)%ddsd.dwHeight;
|
 | 1851 | + destrect.top = rand32(randnum)%ddsd.dwHeight;
|
 | 1852 | + destrect.left = rand32(randnum)%ddsd.dwWidth;
|
 | 1853 | + destrect.right = rand32(randnum)%ddsd.dwWidth;
|
 | 1854 | + if((destrect.bottom < destrect.top) || (destrect.right < destrect.left)) goto rndrect5;
|
 | 1855 | + bltfx.dwSize = sizeof(DDBLTFX);
|
 | 1856 | + switch(bpp)
|
 | 1857 | + {
|
 | 1858 | + case 8:
|
 | 1859 | + bltfx.dwFillColor = rand32(randnum) % 0xFF;
|
 | 1860 | + break;
|
 | 1861 | + case 15:
|
 | 1862 | + bltfx.dwFillColor = rand32(randnum) % 0x7FFF;
|
 | 1863 | + break;
|
 | 1864 | + case 16:
|
 | 1865 | + bltfx.dwFillColor = rand32(randnum) % 0xFFFF;
|
 | 1866 | + break;
|
 | 1867 | + case 24:
|
 | 1868 | + case 32:
|
 | 1869 | + default:
|
 | 1870 | + bltfx.dwFillColor = rand32(randnum) % 0xFFFFFF;
|
 | 1871 | + break;
|
 | 1872 | + }
|
 | 1873 | + ddsrender->Blt(&destrect,NULL,NULL,DDBLT_COLORFILL,&bltfx);
|
 | 1874 | + if(!fullscreen)
|
 | 1875 | + {
|
 | 1876 | + p.x = 0;
|
 | 1877 | + p.y = 0;
|
 | 1878 | + ClientToScreen(hWnd,&p);
|
 | 1879 | + GetClientRect(hWnd,&destrect);
|
 | 1880 | + OffsetRect(&destrect,p.x,p.y);
|
 | 1881 | + SetRect(&srcrect,0,0,width,height);
|
 | 1882 | + if(ddsurface && ddsrender)error = ddsurface->Blt(&destrect,ddsrender,&srcrect,DDBLT_WAIT,NULL);
|
 | 1883 | + }
|
 | 1884 | + break;
|
 | 1885 | + case 9:
|
 | 1886 | + bltfx.dwSize = sizeof(DDBLTFX);
|
 | 1887 | + switch (bpp)
|
 | 1888 | + {
|
 | 1889 | + case 8:
|
 | 1890 | + bitmask = 0xFF;
|
 | 1891 | + break;
|
 | 1892 | + case 15:
|
 | 1893 | + bitmask = 0x7FFF;
|
 | 1894 | + break;
|
 | 1895 | + case 16:
|
 | 1896 | + bitmask = 0xFFFF;
|
 | 1897 | + break;
|
 | 1898 | + case 24:
|
 | 1899 | + bitmask = 0xFFFFFF;
|
 | 1900 | + break;
|
 | 1901 | + case 32:
|
 | 1902 | + default:
|
 | 1903 | + bitmask = 0xFFFFFFFF;
|
 | 1904 | + break;
|
 | 1905 | + }
|
 | 1906 | + for (int y = 0; y < 255; y++)
|
 | 1907 | + {
|
 | 1908 | + for (int x = 0; x < 255; x++)
|
 | 1909 | + {
|
 | 1910 | + bltfx.dwFillColor = counter & bitmask;
|
 | 1911 | + destrect.left = x;
|
 | 1912 | + destrect.right = x + 1;
|
 | 1913 | + destrect.top = y;
|
 | 1914 | + destrect.bottom = y + 1;
|
 | 1915 | + counter++;
|
 | 1916 | + sprites[0].surface->Blt(&destrect, NULL, NULL, DDBLT_COLORFILL, &bltfx);
|
 | 1917 | + }
|
 | 1918 | + }
|
 | 1919 | + ddsrender->Blt(NULL, sprites[0].surface, NULL, DDBLT_WAIT, NULL);
|
 | 1920 | + if (!fullscreen)
|
 | 1921 | + {
|
 | 1922 | + p.x = 0;
|
 | 1923 | + p.y = 0;
|
 | 1924 | + ClientToScreen(hWnd, &p);
|
 | 1925 | + GetClientRect(hWnd, &destrect);
|
 | 1926 | + OffsetRect(&destrect, p.x, p.y);
|
 | 1927 | + SetRect(&srcrect, 0, 0, width, height);
|
 | 1928 | + if (ddsurface && ddsrender)error = ddsurface->Blt(&destrect, ddsrender, &srcrect, DDBLT_WAIT, NULL);
|
 | 1929 | + }
|
 | 1930 | + break;
|
 | 1931 | + }
|
 | 1932 | + if(temp1) temp1->Release();
|
 | 1933 | +}
|
 | 1934 | +
|
 | 1935 | +void PopulateArgCombo(HWND hWnd)
|
 | 1936 | +{
|
 | 1937 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Diffuse"));
|
 | 1938 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Current"));
|
 | 1939 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Texture"));
|
 | 1940 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Factor"));
|
 | 1941 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Specular"));
|
 | 1942 | +}
|
 | 1943 | +
|
 | 1944 | +void PopulateOpCombo(HWND hWnd, bool color)
|
 | 1945 | +{
|
 | 1946 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Disable"));
|
 | 1947 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Select Arg 1"));
|
 | 1948 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Select Arg 2"));
|
 | 1949 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Modulate"));
|
 | 1950 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Modulate 2x"));
|
 | 1951 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Modulate 4x"));
|
 | 1952 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Add"));
|
 | 1953 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Add Signed"));
|
 | 1954 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Add Signed 2x"));
|
 | 1955 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Subtract"));
|
 | 1956 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Add Smooth"));
|
 | 1957 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Blend Diffuse Alpha"));
|
 | 1958 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Blend Texture Alpha"));
|
 | 1959 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Blend Factor Alpha"));
|
 | 1960 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Blend Texture Alpha PM"));
|
 | 1961 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Blend Current Alpha"));
|
 | 1962 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Premodulate"));
|
 | 1963 | + if (color)
|
 | 1964 | + {
|
 | 1965 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Modulate Alpha Add Color"));
|
 | 1966 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Modulate Color Add Alpha"));
|
 | 1967 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Modulate Inv. Alpha Add Color"));
|
 | 1968 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Modulate Inv. Color Add Alpha"));
|
 | 1969 | + }
|
 | 1970 | + else
|
 | 1971 | + {
|
 | 1972 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("(invalid)"));
|
 | 1973 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("(invalid)"));
|
 | 1974 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("(invalid)"));
|
 | 1975 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("(invalid)"));
|
 | 1976 | + }
|
 | 1977 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Bump Env. Map"));
|
 | 1978 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Bump Env. Map Luminance"));
|
 | 1979 | + if (color) SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Dot Product3"));
|
 | 1980 | +}
|
 | 1981 | +
|
 | 1982 | +void PopulateBlendCombo(HWND hWnd, bool src)
|
 | 1983 | +{
|
 | 1984 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Zero"));
|
 | 1985 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("One"));
|
 | 1986 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Source Color"));
|
 | 1987 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Inv. Src. Color"));
|
 | 1988 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Source Alpha"));
|
 | 1989 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Inv. Src. Alpha"));
|
 | 1990 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Dest. Alpha"));
|
 | 1991 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Inv. Dest. Alpha"));
|
 | 1992 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Dest. Color"));
|
 | 1993 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Inv. Dest. Color"));
|
 | 1994 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Src. Alpha Sat."));
|
 | 1995 | + if (src)
|
 | 1996 | + {
|
 | 1997 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Both Src. Alpha"));
|
 | 1998 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Both Inv. Src. Alpha"));
|
 | 1999 | + }
|
 | 2000 | +}
|
 | 2001 | +
|
 | 2002 | +void PopulateCompareCombo(HWND hWnd)
|
 | 2003 | +{
|
 | 2004 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Never"));
|
 | 2005 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Less"));
|
 | 2006 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Equal"));
|
 | 2007 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Less or Equal"));
|
 | 2008 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Greater"));
|
 | 2009 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Not Equal"));
|
 | 2010 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Greater or Equal"));
|
 | 2011 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Always"));
|
 | 2012 | +}
|
 | 2013 | +
|
 | 2014 | +void PopulateFogCombo(HWND hWnd)
|
 | 2015 | +{
|
 | 2016 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("None"));
|
 | 2017 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Exponential"));
|
 | 2018 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Exp. Squared"));
|
 | 2019 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Linear"));
|
 | 2020 | +}
|
 | 2021 | +
|
 | 2022 | +void PopulateSourceCombo(HWND hWnd)
|
 | 2023 | +{
|
 | 2024 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Material"));
|
 | 2025 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Color 1"));
|
 | 2026 | + SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)_T("Color 2"));
|
 | 2027 | +}
|
 | 2028 | +
|
 | 2029 | +void strupper(TCHAR *str)
|
 | 2030 | +{
|
 | 2031 | + TCHAR *ptr = str;
|
 | 2032 | + while (*ptr != 0)
|
 | 2033 | + {
|
 | 2034 | + *ptr = _totupper(*ptr);
|
 | 2035 | + ptr++;
|
 | 2036 | + }
|
 | 2037 | +}
|
 | 2038 | +
|
 | 2039 | +void paddwordzeroes(TCHAR *str)
|
 | 2040 | +{
|
 | 2041 | + TCHAR str2[16];
|
 | 2042 | + str2[0] = 0;
|
 | 2043 | + int len = _tcslen(str);
|
 | 2044 | + if (len < 8)
|
 | 2045 | + {
|
 | 2046 | + for (int i = 0; i < 8 - len; i++)
|
 | 2047 | + _tcscat(str2, _T("0"));
|
 | 2048 | + _tcscat(str2, str);
|
 | 2049 | + _tcscpy(str, str2);
|
 | 2050 | + }
|
 | 2051 | +}
|
 | 2052 | +
|
 | 2053 | +HRESULT CALLBACK SelectTextureFormatCallback(LPDDPIXELFORMAT lpDDPixFmt, LPVOID lpContext)
|
 | 2054 | +{
|
 | 2055 | + if (lpDDPixFmt->dwFlags & (DDPF_LUMINANCE | DDPF_BUMPLUMINANCE | DDPF_BUMPDUDV)) return D3DENUMRET_OK;
|
 | 2056 | + if (lpDDPixFmt->dwFourCC != 0) return D3DENUMRET_OK;
|
 | 2057 | + if (!(lpDDPixFmt->dwFlags & DDPF_ALPHAPIXELS)) return D3DENUMRET_OK;
|
 | 2058 | + if (lpDDPixFmt->dwRGBBitCount < 32) return D3DENUMRET_OK;
|
 | 2059 | + memcpy(lpContext, lpDDPixFmt, sizeof(DDPIXELFORMAT));
|
 | 2060 | + return D3DENUMRET_CANCEL;
|
 | 2061 | +}
|
 | 2062 | +
|
 | 2063 | +void CreateSurfaceFromBitmap(MultiDirectDrawSurface **surface, DDSURFACEDESC2 *ddsd, HDC hdc, int width, int height)
|
 | 2064 | +{
|
 | 2065 | + ddinterface->CreateSurface(ddsd, surface, NULL);
|
 | 2066 | + HDC surfacedc;
|
 | 2067 | + if (surface)
|
 | 2068 | + {
|
 | 2069 | + (*surface)->GetDC(&surfacedc);
|
 | 2070 | + BitBlt(surfacedc, 0, 0, width, height, hdc, 0, 0, SRCCOPY);
|
 | 2071 | + (*surface)->ReleaseDC(surfacedc);
|
 | 2072 | + }
|
 | 2073 | +}
|
 | 2074 | +
|
 | 2075 | +void SelectTexture(MultiDirectDrawSurface **surface, int type, DWORD colorkey, bool haskey, LPCTSTR file)
|
 | 2076 | +{
|
 | 2077 | + DDSURFACEDESC2 ddsd;
|
 | 2078 | + ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
|
 | 2079 | + ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
 | 2080 | + BITMAPV4HEADER bi;
|
 | 2081 | + HBITMAP bitmap;
|
 | 2082 | + HDC hdc;
|
 | 2083 | + HDC hmemdc;
|
 | 2084 | + HBITMAP holdbmp;
|
 | 2085 | + HICON icon;
|
 | 2086 | + VOID *bmpbits;
|
 | 2087 | + ZeroMemory(&bi, sizeof(BITMAPV4HEADER));
|
 | 2088 | + bi.bV4Size = sizeof(BITMAPV4HEADER);
|
 | 2089 | + bi.bV4Planes = 1;
|
 | 2090 | + bi.bV4BitCount = 32;
|
 | 2091 | + bi.bV4V4Compression = BI_BITFIELDS;
|
 | 2092 | + bi.bV4RedMask = 0x00FF0000;
|
 | 2093 | + bi.bV4GreenMask = 0x0000FF00;
|
 | 2094 | + bi.bV4BlueMask = 0x000000FF;
|
 | 2095 | + bi.bV4AlphaMask = 0xFF000000;
|
 | 2096 | + d3d7dev->EnumTextureFormats(SelectTextureFormatCallback, &ddsd.ddpfPixelFormat);
|
 | 2097 | + ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
|
 | 2098 | + ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_TEXTURESTAGE;
|
 | 2099 | + DDCOLORKEY ckey;
|
 | 2100 | + ckey.dwColorSpaceHighValue = ckey.dwColorSpaceLowValue = colorkey;
|
 | 2101 | + if (haskey) ddsd.dwFlags |= DDSD_CKSRCBLT;
|
 | 2102 | + if (*surface)
|
 | 2103 | + {
|
 | 2104 | + d3d7dev->SetTexture(texshaderstate.currentstage, NULL);
|
 | 2105 | + (*surface)->Release();
|
 | 2106 | + *surface = NULL;
|
 | 2107 | + }
|
 | 2108 | + switch (type)
|
 | 2109 | + {
|
 | 2110 | + case 0:
|
 | 2111 | + default:
|
 | 2112 | + break;
|
 | 2113 | + case 1:
|
 | 2114 | + break;
|
 | 2115 | + case 2:
|
 | 2116 | + hdc = GetDC(NULL);
|
 | 2117 | + bi.bV4Width = ddsd.dwWidth = bi.bV4Height = ddsd.dwHeight = 16;
|
 | 2118 | + bitmap = CreateDIBSection(hdc, (BITMAPINFO*)&bi, DIB_RGB_COLORS, &bmpbits, NULL, 0);
|
 | 2119 | + hmemdc = CreateCompatibleDC(hdc);
|
 | 2120 | + ReleaseDC(NULL, hdc);
|
 | 2121 | + holdbmp = (HBITMAP)SelectObject(hmemdc, bitmap);
|
 | 2122 | + icon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_DXGL), IMAGE_ICON, 16, 16, 0);
|
 | 2123 | + DrawIconEx(hmemdc, 0, 0, icon, 16, 16, 0, NULL, DI_NORMAL);
|
 | 2124 | + CreateSurfaceFromBitmap(surface, &ddsd, hmemdc, 16, 16);
|
 | 2125 | + SelectObject(hmemdc, holdbmp);
|
 | 2126 | + DeleteDC(hmemdc);
|
 | 2127 | + DeleteObject(bitmap);
|
 | 2128 | + if (*surface && haskey) (*surface)->SetColorKey(DDCKEY_SRCBLT, &ckey);
|
 | 2129 | + if (*surface) d3d7dev->SetTexture(texshaderstate.currentstage, (LPDIRECTDRAWSURFACE7)(*surface)->GetSurface());
|
 | 2130 | + break;
|
 | 2131 | + case 3:
|
 | 2132 | + hdc = GetDC(NULL);
|
 | 2133 | + bi.bV4Width = ddsd.dwWidth = bi.bV4Height = ddsd.dwHeight = 256;
|
 | 2134 | + bitmap = CreateDIBSection(hdc, (BITMAPINFO*)&bi, DIB_RGB_COLORS, &bmpbits, NULL, 0);
|
 | 2135 | + hmemdc = CreateCompatibleDC(hdc);
|
 | 2136 | + ReleaseDC(NULL, hdc);
|
 | 2137 | + holdbmp = (HBITMAP)SelectObject(hmemdc, bitmap);
|
 | 2138 | + icon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_DXGL), IMAGE_ICON, 256, 256, 0);
|
 | 2139 | + DrawIconEx(hmemdc, 0, 0, icon, 256, 256, 0, NULL, DI_NORMAL);
|
 | 2140 | + CreateSurfaceFromBitmap(surface, &ddsd, hmemdc, 256, 256);
|
 | 2141 | + SelectObject(hmemdc, holdbmp);
|
 | 2142 | + DeleteDC(hmemdc);
|
 | 2143 | + DeleteObject(bitmap);
|
 | 2144 | + if (*surface && haskey) (*surface)->SetColorKey(DDCKEY_SRCBLT, &ckey);
|
 | 2145 | + if (*surface) d3d7dev->SetTexture(texshaderstate.currentstage, (LPDIRECTDRAWSURFACE7)(*surface)->GetSurface());
|
 | 2146 | + break;
|
 | 2147 | + case 4:
|
 | 2148 | + break;
|
 | 2149 | + }
|
 | 2150 | +}
|
 | 2151 | +
|
 | 2152 | +void SetShaderArg(HWND hWnd, UINT dropdown, UINT checkalpha, UINT checkinv, DWORD *texarg)
|
 | 2153 | +{
|
 | 2154 | + DWORD arg = SendDlgItemMessage(hWnd, dropdown, CB_GETCURSEL, 0, 0);
|
 | 2155 | + if (SendDlgItemMessage(hWnd, checkalpha, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
 | 2156 | + arg |= D3DTA_ALPHAREPLICATE;
|
 | 2157 | + if (SendDlgItemMessage(hWnd, checkinv, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
 | 2158 | + arg |= D3DTA_COMPLEMENT;
|
 | 2159 | + *texarg = arg;
|
 | 2160 | +}
|
 | 2161 | +
|
 | 2162 | +INT_PTR CALLBACK TexShader7Proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
 | 2163 | +{
|
 | 2164 | + HRESULT error;
|
 | 2165 | + D3DVIEWPORT7 vp;
|
 | 2166 | + HWND hDisplay;
|
 | 2167 | + int number;
|
 | 2168 | + float f;
|
 | 2169 | + TCHAR tmpstring[MAX_PATH + 1];
|
 | 2170 | + switch (Msg)
|
 | 2171 | + {
|
 | 2172 | + case WM_INITDIALOG:
|
 | 2173 | + RECT r;
|
 | 2174 | + DDSCAPS2 caps;
|
 | 2175 | + DDSURFACEDESC2 ddsd;
|
 | 2176 | + DDPIXELFORMAT ddpfz;
|
 | 2177 | + testnum = 2;
|
 | 2178 | + ddinterface = new MultiDirectDraw(7, &error, NULL);
|
 | 2179 | + hDisplay = GetDlgItem(hWnd, IDC_DISPLAY);
|
 | 2180 | + ::hWnd = hDisplay;
|
 | 2181 | + error = ddinterface->SetCooperativeLevel(hDisplay, DDSCL_NORMAL);
|
 | 2182 | + ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
|
 | 2183 | + ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
 | 2184 | + ddsd.dwFlags = DDSD_CAPS;
|
 | 2185 | + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
 | 2186 | + error = ddinterface->CreateSurface(&ddsd, &ddsurface, NULL);
|
 | 2187 | + error = ddinterface->CreateClipper(0, &ddclipper, NULL);
|
 | 2188 | + error = ddclipper->SetHWnd(0, hDisplay);
|
 | 2189 | + error = ddsurface->SetClipper(ddclipper);
|
 | 2190 | + ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
|
 | 2191 | + ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
 | 2192 | + ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
 | 2193 | + ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
|
 | 2194 | + GetClientRect(hDisplay, &r);
|
 | 2195 | + ddsd.dwWidth = r.right;
|
 | 2196 | + ddsd.dwHeight = r.bottom;
|
 | 2197 | + error = ddinterface->CreateSurface(&ddsd, &ddsrender, NULL);
|
 | 2198 | + error = ddinterface->QueryInterface(IID_IDirect3D7, (VOID**)&d3d7);
|
 | 2199 | + error = d3d7->EnumZBufferFormats(IID_IDirect3DRGBDevice, zcallback, &ddpfz);
|
 | 2200 | + error = ddsrender->GetSurfaceDesc(&ddsd);
|
 | 2201 | + ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
|
 | 2202 | + ddsd.ddsCaps.dwCaps = DDSCAPS_ZBUFFER | DDSCAPS_VIDEOMEMORY;
|
 | 2203 | + memcpy(&ddsd.ddpfPixelFormat, &ddpfz, sizeof(DDPIXELFORMAT));
|
 | 2204 | + error = ddinterface->CreateSurface(&ddsd, &zbuffer, NULL);
|
 | 2205 | + error = ddsrender->AddAttachedSurface(zbuffer);
|
 | 2206 | + error = d3d7->CreateDevice(IID_IDirect3DHALDevice, (LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(), &d3d7dev);
|
 | 2207 | + if (error != D3D_OK)
|
 | 2208 | + error = d3d7->CreateDevice(IID_IDirect3DRGBDevice, (LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(), &d3d7dev);
|
 | 2209 | + ddsrender->GetSurfaceDesc(&ddsd);
|
 | 2210 | + vp.dvMaxZ = 1.0f;
|
 | 2211 | + vp.dvMinZ = 0.0f;
|
 | 2212 | + vp.dwX = vp.dwY = 0;
|
 | 2213 | + vp.dwWidth = ddsd.dwWidth;
|
 | 2214 | + vp.dwHeight = ddsd.dwHeight;
|
 | 2215 | + error = d3d7dev->SetViewport(&vp);
|
 | 2216 | + error = d3d7dev->SetRenderState(D3DRENDERSTATE_ZENABLE, TRUE);
|
 | 2217 | + InitTest(14);
|
 | 2218 | + SendDlgItemMessage(hWnd, IDC_TEXTURE, CB_ADDSTRING, 0, (LPARAM)_T("None"));
|
 | 2219 | + SendDlgItemMessage(hWnd, IDC_TEXTURE, CB_ADDSTRING, 0, (LPARAM)_T("Gradients"));
|
 | 2220 | + SendDlgItemMessage(hWnd, IDC_TEXTURE, CB_ADDSTRING, 0, (LPARAM)_T("DXGL logo (small)"));
|
 | 2221 | + SendDlgItemMessage(hWnd, IDC_TEXTURE, CB_ADDSTRING, 0, (LPARAM)_T("DXGL logo (large)"));
|
 | 2222 | + SendDlgItemMessage(hWnd, IDC_TEXTURE, CB_ADDSTRING, 0, (LPARAM)_T("Texture file"));
|
 | 2223 | + SendDlgItemMessage(hWnd, IDC_TEXTURE, CB_SETCURSEL, 0, 0);
|
 | 2224 | + SendDlgItemMessage(hWnd, IDC_TEXCOLORKEY, WM_SETTEXT, 0, (LPARAM)_T(""));
|
 | 2225 | + PopulateArgCombo(GetDlgItem(hWnd, IDC_CARG1));
|
 | 2226 | + PopulateArgCombo(GetDlgItem(hWnd, IDC_CARG2));
|
 | 2227 | + PopulateArgCombo(GetDlgItem(hWnd, IDC_AARG1));
|
 | 2228 | + PopulateArgCombo(GetDlgItem(hWnd, IDC_AARG2));
|
 | 2229 | + SendDlgItemMessage(hWnd, IDC_CARG1, CB_SETCURSEL, D3DTA_TEXTURE, 0);
|
 | 2230 | + SendDlgItemMessage(hWnd, IDC_CARG2, CB_SETCURSEL, D3DTA_CURRENT, 0);
|
 | 2231 | + SendDlgItemMessage(hWnd, IDC_AARG1, CB_SETCURSEL, D3DTA_TEXTURE, 0);
|
 | 2232 | + SendDlgItemMessage(hWnd, IDC_AARG2, CB_SETCURSEL, D3DTA_CURRENT, 0);
|
 | 2233 | + PopulateOpCombo(GetDlgItem(hWnd, IDC_COLOROP), true);
|
 | 2234 | + PopulateOpCombo(GetDlgItem(hWnd, IDC_ALPHAOP), false);
|
 | 2235 | + SendDlgItemMessage(hWnd, IDC_COLOROP, CB_SETCURSEL, D3DTOP_MODULATE - 1, 0);
|
 | 2236 | + SendDlgItemMessage(hWnd, IDC_ALPHAOP, CB_SETCURSEL, D3DTOP_SELECTARG1 - 1, 0);
|
 | 2237 | + SendDlgItemMessage(hWnd, IDC_DIFFUSE, WM_SETTEXT, 0, (LPARAM)_T("FFFFFFFF"));
|
 | 2238 | + SendDlgItemMessage(hWnd, IDC_SPECULAR, WM_SETTEXT, 0, (LPARAM)_T("00000000"));
|
 | 2239 | + SendDlgItemMessage(hWnd, IDC_FACTOR, WM_SETTEXT, 0, (LPARAM)_T("00000000"));
|
 | 2240 | + SendDlgItemMessage(hWnd, IDC_FOGCOLOR, WM_SETTEXT, 0, (LPARAM)_T("00000000"));
|
 | 2241 | + SendDlgItemMessage(hWnd, IDC_BGCOLOR, WM_SETTEXT, 0, (LPARAM)_T("00000000"));
|
 | 2242 | + PopulateBlendCombo(GetDlgItem(hWnd, IDC_SRCBLEND), true);
|
 | 2243 | + PopulateBlendCombo(GetDlgItem(hWnd, IDC_DESTBLEND), true);
|
 | 2244 | + SendDlgItemMessage(hWnd, IDC_SRCBLEND, CB_SETCURSEL, D3DBLEND_ONE - 1, 0);
|
 | 2245 | + SendDlgItemMessage(hWnd, IDC_DESTBLEND, CB_SETCURSEL, D3DBLEND_ZERO - 1, 0);
|
 | 2246 | + PopulateCompareCombo(GetDlgItem(hWnd, IDC_ALPHAFUNC));
|
 | 2247 | + SendDlgItemMessage(hWnd, IDC_ALPHAFUNC, CB_SETCURSEL, D3DCMP_ALWAYS - 1, 0);
|
 | 2248 | + PopulateFogCombo(GetDlgItem(hWnd, IDC_VERTEXFOGMODE));
|
 | 2249 | + PopulateFogCombo(GetDlgItem(hWnd, IDC_PIXELFOGMODE));
|
 | 2250 | + SendDlgItemMessage(hWnd, IDC_VERTEXFOGMODE, CB_SETCURSEL, D3DFOG_NONE, 0);
|
 | 2251 | + SendDlgItemMessage(hWnd, IDC_PIXELFOGMODE, CB_SETCURSEL, D3DFOG_NONE, 0);
|
 | 2252 | + SendDlgItemMessage(hWnd, IDC_FOGSTART, WM_SETTEXT, 0, (LPARAM)_T("0.0"));
|
 | 2253 | + SendDlgItemMessage(hWnd, IDC_FOGEND, WM_SETTEXT, 0, (LPARAM)_T("1.0"));
|
 | 2254 | + SendDlgItemMessage(hWnd, IDC_FOGDENSITY, WM_SETTEXT, 0, (LPARAM)_T("1.0"));
|
 | 2255 | + SendDlgItemMessage(hWnd, IDC_SPINSTAGE, UDM_SETRANGE32, 0, 7);
|
 | 2256 | + SendDlgItemMessage(hWnd, IDC_SPINALPHAREF, UDM_SETRANGE32, 0, 255);
|
 | 2257 | + ::width = ddsd.dwWidth;
|
 | 2258 | + ::height = ddsd.dwHeight;
|
 | 2259 | + StartTimer(hWnd, WM_APP, 60);
|
 | 2260 | + break;
|
 | 2261 | + case WM_COMMAND:
|
 | 2262 | + switch (LOWORD(wParam))
|
 | 2263 | + {
|
 | 2264 | + case IDC_TEXSTAGE:
|
 | 2265 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 2266 | + {
|
 | 2267 | + SendDlgItemMessage(hWnd, IDC_TEXSTAGE, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2268 | + number = _ttoi(tmpstring);
|
 | 2269 | + if (number < 0) SendDlgItemMessage(hWnd, IDC_TEXSTAGE, WM_SETTEXT, 0, (LPARAM)_T("0"));
|
 | 2270 | + if (number > 7) SendDlgItemMessage(hWnd, IDC_TEXSTAGE, WM_SETTEXT, 0, (LPARAM)_T("7"));
|
 | 2271 | + if (number < 0) number = 0;
|
 | 2272 | + if (number > 7) number = 7;
|
 | 2273 | + texshaderstate.currentstage = number;
|
 | 2274 | + _itot(texshaderstate.texstages[number].keycolor, tmpstring, 16);
|
 | 2275 | + strupper(tmpstring);
|
 | 2276 | + paddwordzeroes(tmpstring);
|
 | 2277 | + if (texshaderstate.texstages[number].colorkey == FALSE) tmpstring[0] = 0;
|
 | 2278 | + SendDlgItemMessage(hWnd, IDC_TEXCOLORKEY, WM_SETTEXT, 0, (LPARAM)tmpstring);
|
 | 2279 | + SendDlgItemMessage(hWnd, IDC_TEXTURE, CB_SETCURSEL, texshaderstate.texstages[number].texturetype, 0);
|
 | 2280 | + SendDlgItemMessage(hWnd, IDC_TEXTUREFILE, WM_SETTEXT, 0, (LPARAM)texshaderstate.texstages[number].texturefile);
|
 | 2281 | + SendDlgItemMessage(hWnd, IDC_CARG1, CB_SETCURSEL, texshaderstate.texstages[number].colorarg1 & D3DTA_SELECTMASK, 0);
|
 | 2282 | + SendDlgItemMessage(hWnd, IDC_CARG2, CB_SETCURSEL, texshaderstate.texstages[number].colorarg2 & D3DTA_SELECTMASK, 0);
|
 | 2283 | + SendDlgItemMessage(hWnd, IDC_AARG1, CB_SETCURSEL, texshaderstate.texstages[number].alphaarg1 & D3DTA_SELECTMASK, 0);
|
 | 2284 | + SendDlgItemMessage(hWnd, IDC_AARG2, CB_SETCURSEL, texshaderstate.texstages[number].alphaarg2 & D3DTA_SELECTMASK, 0);
|
 | 2285 | + if (texshaderstate.texstages[number].colorarg1 & D3DTA_ALPHAREPLICATE)
|
 | 2286 | + SendDlgItemMessage(hWnd, IDC_CARG1A, BM_SETCHECK, BST_CHECKED, 0);
|
 | 2287 | + else SendDlgItemMessage(hWnd, IDC_CARG1A, BM_SETCHECK, BST_UNCHECKED, 0);
|
 | 2288 | + if (texshaderstate.texstages[number].colorarg2 & D3DTA_ALPHAREPLICATE)
|
 | 2289 | + SendDlgItemMessage(hWnd, IDC_CARG2A, BM_SETCHECK, BST_CHECKED, 0);
|
 | 2290 | + else SendDlgItemMessage(hWnd, IDC_CARG2A, BM_SETCHECK, BST_UNCHECKED, 0);
|
 | 2291 | + if (texshaderstate.texstages[number].alphaarg1 & D3DTA_ALPHAREPLICATE)
|
 | 2292 | + SendDlgItemMessage(hWnd, IDC_AARG1A, BM_SETCHECK, BST_CHECKED, 0);
|
 | 2293 | + else SendDlgItemMessage(hWnd, IDC_AARG1A, BM_SETCHECK, BST_UNCHECKED, 0);
|
 | 2294 | + if (texshaderstate.texstages[number].alphaarg2 & D3DTA_ALPHAREPLICATE)
|
 | 2295 | + SendDlgItemMessage(hWnd, IDC_AARG2A, BM_SETCHECK, BST_CHECKED, 0);
|
 | 2296 | + else SendDlgItemMessage(hWnd, IDC_AARG2A, BM_SETCHECK, BST_UNCHECKED, 0);
|
 | 2297 | + if (texshaderstate.texstages[number].colorarg1 & D3DTA_COMPLEMENT)
|
 | 2298 | + SendDlgItemMessage(hWnd, IDC_CARG1INV, BM_SETCHECK, BST_CHECKED, 0);
|
 | 2299 | + else SendDlgItemMessage(hWnd, IDC_CARG1INV, BM_SETCHECK, BST_UNCHECKED, 0);
|
 | 2300 | + if (texshaderstate.texstages[number].colorarg2 & D3DTA_COMPLEMENT)
|
 | 2301 | + SendDlgItemMessage(hWnd, IDC_CARG2INV, BM_SETCHECK, BST_CHECKED, 0);
|
 | 2302 | + else SendDlgItemMessage(hWnd, IDC_CARG2INV, BM_SETCHECK, BST_UNCHECKED, 0);
|
 | 2303 | + if (texshaderstate.texstages[number].alphaarg1 & D3DTA_COMPLEMENT)
|
 | 2304 | + SendDlgItemMessage(hWnd, IDC_AARG1INV, BM_SETCHECK, BST_CHECKED, 0);
|
 | 2305 | + else SendDlgItemMessage(hWnd, IDC_AARG1INV, BM_SETCHECK, BST_UNCHECKED, 0);
|
 | 2306 | + if (texshaderstate.texstages[number].alphaarg2 & D3DTA_COMPLEMENT)
|
 | 2307 | + SendDlgItemMessage(hWnd, IDC_AARG2INV, BM_SETCHECK, BST_CHECKED, 0);
|
 | 2308 | + else SendDlgItemMessage(hWnd, IDC_AARG2INV, BM_SETCHECK, BST_UNCHECKED, 0);
|
 | 2309 | + SendDlgItemMessage(hWnd, IDC_COLOROP, CB_SETCURSEL, texshaderstate.texstages[number].colorop - 1, 0);
|
 | 2310 | + SendDlgItemMessage(hWnd, IDC_ALPHAOP, CB_SETCURSEL, texshaderstate.texstages[number].alphaop - 1, 0);
|
 | 2311 | + }
|
 | 2312 | + break;
|
 | 2313 | + case IDC_TEXTURE:
|
 | 2314 | + if (HIWORD(wParam) == CBN_SELCHANGE)
|
 | 2315 | + {
|
 | 2316 | + number = texshaderstate.currentstage;
|
 | 2317 | + texshaderstate.texstages[number].texturetype =
|
 | 2318 | + SendDlgItemMessage(hWnd, IDC_TEXTURE, CB_GETCURSEL, 0, 0);
|
 | 2319 | + SelectTexture(&texshaderstate.texstages[number].texture, texshaderstate.texstages[number].texturetype,
|
 | 2320 | + texshaderstate.texstages[number].keycolor, texshaderstate.texstages[number].colorkey,
|
 | 2321 | + texshaderstate.texstages[number].texturefile);
|
 | 2322 | + }
|
 | 2323 | + break;
|
 | 2324 | + case IDC_TEXTUREFILE:
|
 | 2325 | + if (HIWORD(wParam) == EN_KILLFOCUS)
|
 | 2326 | + {
|
 | 2327 | + number = texshaderstate.currentstage;
|
 | 2328 | + SendDlgItemMessage(hWnd, IDC_TEXTUREFILE, WM_GETTEXT, MAX_PATH + 1,
|
 | 2329 | + (LPARAM)texshaderstate.texstages[number].texturefile);
|
 | 2330 | + SelectTexture(&texshaderstate.texstages[number].texture, texshaderstate.texstages[number].texturetype,
|
 | 2331 | + texshaderstate.texstages[number].keycolor, texshaderstate.texstages[number].colorkey,
|
 | 2332 | + texshaderstate.texstages[number].texturefile);
|
 | 2333 | + }
|
 | 2334 | + break;
|
 | 2335 | + case IDC_CARG1:
|
 | 2336 | + if (HIWORD(wParam) == CBN_SELCHANGE)
|
 | 2337 | + {
|
 | 2338 | + number = texshaderstate.currentstage;
|
 | 2339 | + SetShaderArg(hWnd, IDC_CARG1, IDC_CARG1A, IDC_CARG1INV, &texshaderstate.texstages[number].colorarg1);
|
 | 2340 | + d3d7dev->SetTextureStageState(number, D3DTSS_COLORARG1, texshaderstate.texstages[number].colorarg1);
|
 | 2341 | + }
|
 | 2342 | + break;
|
 | 2343 | + case IDC_CARG1A:
|
 | 2344 | + case IDC_CARG1INV:
|
 | 2345 | + if (HIWORD(wParam) == BN_CLICKED)
|
 | 2346 | + {
|
 | 2347 | + number = texshaderstate.currentstage;
|
 | 2348 | + SetShaderArg(hWnd, IDC_CARG1, IDC_CARG1A, IDC_CARG1INV, &texshaderstate.texstages[number].colorarg2);
|
 | 2349 | + d3d7dev->SetTextureStageState(number, D3DTSS_COLORARG1, texshaderstate.texstages[number].colorarg2);
|
 | 2350 | + }
|
 | 2351 | + break;
|
 | 2352 | + case IDC_CARG2:
|
 | 2353 | + if (HIWORD(wParam) == CBN_SELCHANGE)
|
 | 2354 | + {
|
 | 2355 | + number = texshaderstate.currentstage;
|
 | 2356 | + SetShaderArg(hWnd, IDC_CARG2, IDC_CARG2A, IDC_CARG2INV, &texshaderstate.texstages[number].colorarg2);
|
 | 2357 | + d3d7dev->SetTextureStageState(number, D3DTSS_COLORARG2, texshaderstate.texstages[number].colorarg2);
|
 | 2358 | + }
|
 | 2359 | + break;
|
 | 2360 | + case IDC_CARG2A:
|
 | 2361 | + case IDC_CARG2INV:
|
 | 2362 | + if (HIWORD(wParam) == BN_CLICKED)
|
 | 2363 | + {
|
 | 2364 | + number = texshaderstate.currentstage;
|
 | 2365 | + SetShaderArg(hWnd, IDC_CARG2, IDC_CARG2A, IDC_CARG2INV, &texshaderstate.texstages[number].colorarg1);
|
 | 2366 | + d3d7dev->SetTextureStageState(number, D3DTSS_COLORARG2, texshaderstate.texstages[number].colorarg1);
|
 | 2367 | + }
|
 | 2368 | + break;
|
 | 2369 | + case IDC_AARG1:
|
 | 2370 | + if (HIWORD(wParam) == CBN_SELCHANGE)
|
 | 2371 | + {
|
 | 2372 | + number = texshaderstate.currentstage;
|
 | 2373 | + SetShaderArg(hWnd, IDC_AARG1, IDC_AARG1A, IDC_AARG1INV, &texshaderstate.texstages[number].alphaarg1);
|
 | 2374 | + d3d7dev->SetTextureStageState(number, D3DTSS_ALPHAARG1, texshaderstate.texstages[number].alphaarg1);
|
 | 2375 | + }
|
 | 2376 | + break;
|
 | 2377 | + case IDC_AARG1A:
|
 | 2378 | + case IDC_AARG1INV:
|
 | 2379 | + if (HIWORD(wParam) == BN_CLICKED)
|
 | 2380 | + {
|
 | 2381 | + number = texshaderstate.currentstage;
|
 | 2382 | + SetShaderArg(hWnd, IDC_AARG1, IDC_AARG1A, IDC_AARG1INV, &texshaderstate.texstages[number].alphaarg1);
|
 | 2383 | + d3d7dev->SetTextureStageState(number, D3DTSS_ALPHAARG1, texshaderstate.texstages[number].alphaarg1);
|
 | 2384 | + }
|
 | 2385 | + break;
|
 | 2386 | + case IDC_AARG2:
|
 | 2387 | + if (HIWORD(wParam) == CBN_SELCHANGE)
|
 | 2388 | + {
|
 | 2389 | + number = texshaderstate.currentstage;
|
 | 2390 | + SetShaderArg(hWnd, IDC_AARG2, IDC_AARG2A, IDC_AARG2INV, &texshaderstate.texstages[number].alphaarg2);
|
 | 2391 | + d3d7dev->SetTextureStageState(number, D3DTSS_ALPHAARG2, texshaderstate.texstages[number].alphaarg2);
|
 | 2392 | + }
|
 | 2393 | + break;
|
 | 2394 | + case IDC_AARG2A:
|
 | 2395 | + case IDC_AARG2INV:
|
 | 2396 | + if (HIWORD(wParam) == BN_CLICKED)
|
 | 2397 | + {
|
 | 2398 | + number = texshaderstate.currentstage;
|
 | 2399 | + SetShaderArg(hWnd, IDC_AARG2, IDC_AARG2A, IDC_AARG2INV, &texshaderstate.texstages[number].alphaarg2);
|
 | 2400 | + d3d7dev->SetTextureStageState(number, D3DTSS_ALPHAARG2, texshaderstate.texstages[number].alphaarg2);
|
 | 2401 | + }
|
 | 2402 | + break;
|
 | 2403 | + case IDC_COLOROP:
|
 | 2404 | + if (HIWORD(wParam) == CBN_SELCHANGE)
|
 | 2405 | + {
|
 | 2406 | + number = texshaderstate.currentstage;
|
 | 2407 | + texshaderstate.texstages[number].colorop = (D3DTEXTUREOP)(SendDlgItemMessage(hWnd, IDC_COLOROP, CB_GETCURSEL, 0, 0) + 1);
|
 | 2408 | + d3d7dev->SetTextureStageState(number, D3DTSS_COLOROP, texshaderstate.texstages[number].colorop);
|
 | 2409 | + }
|
 | 2410 | + break;
|
 | 2411 | + case IDC_ALPHAOP:
|
 | 2412 | + if (HIWORD(wParam) == CBN_SELCHANGE)
|
 | 2413 | + {
|
 | 2414 | + number = texshaderstate.currentstage;
|
 | 2415 | + texshaderstate.texstages[number].alphaop = (D3DTEXTUREOP)(SendDlgItemMessage(hWnd, IDC_ALPHAOP, CB_GETCURSEL, 0, 0) + 1);
|
 | 2416 | + d3d7dev->SetTextureStageState(number, D3DTSS_ALPHAOP, texshaderstate.texstages[number].alphaop);
|
 | 2417 | + }
|
 | 2418 | + break;
|
 | 2419 | + case IDC_BGCOLOR:
|
 | 2420 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 2421 | + {
|
 | 2422 | + SendDlgItemMessage(hWnd, IDC_BGCOLOR, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2423 | + if (!_stscanf(tmpstring, _T("%x"), &bgcolor)) bgcolor = 0;
|
 | 2424 | + }
|
 | 2425 | + break;
|
 | 2426 | + case IDC_DIFFUSE:
|
 | 2427 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 2428 | + {
|
 | 2429 | + SendDlgItemMessage(hWnd, IDC_DIFFUSE, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2430 | + if (!_stscanf(tmpstring, _T("%x"), &number)) number = 0;
|
 | 2431 | + SetVertexColor(litvertices, colorvertices, numpoints, number);
|
 | 2432 | + }
|
 | 2433 | + break;
|
 | 2434 | + case IDC_SPECULAR:
|
 | 2435 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 2436 | + {
|
 | 2437 | + SendDlgItemMessage(hWnd, IDC_SPECULAR, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2438 | + if (!_stscanf(tmpstring, _T("%x"), &number)) number = 0;
|
 | 2439 | + SetVertexSpecular(litvertices, colorvertices, numpoints, number);
|
 | 2440 | + }
|
 | 2441 | + break;
|
 | 2442 | + case IDC_FACTOR:
|
 | 2443 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 2444 | + {
|
 | 2445 | + SendDlgItemMessage(hWnd, IDC_FACTOR, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2446 | + if (!_stscanf(tmpstring, _T("%x"), &number)) number = 0;
|
 | 2447 | + d3d7dev->SetRenderState(D3DRENDERSTATE_TEXTUREFACTOR, number);
|
 | 2448 | + }
|
 | 2449 | + break;
|
 | 2450 | + case IDC_FOGCOLOR:
|
 | 2451 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 2452 | + {
|
 | 2453 | + SendDlgItemMessage(hWnd, IDC_FOGCOLOR, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2454 | + if (!_stscanf(tmpstring, _T("%x"), &number)) number = 0;
|
 | 2455 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGCOLOR, number);
|
 | 2456 | + }
|
 | 2457 | + break;
|
 | 2458 | + case IDC_TEXCOLORKEY:
|
 | 2459 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 2460 | + {
|
 | 2461 | + SendDlgItemMessage(hWnd, IDC_TEXCOLORKEY, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2462 | + number = texshaderstate.currentstage;
|
 | 2463 | + if (tmpstring[0] == 0)
|
 | 2464 | + {
|
 | 2465 | + texshaderstate.texstages[number].colorkey = FALSE;
|
 | 2466 | + texshaderstate.texstages[number].keycolor = 0;
|
 | 2467 | + }
|
 | 2468 | + else
|
 | 2469 | + {
|
 | 2470 | + texshaderstate.texstages[number].colorkey = TRUE;
|
 | 2471 | + if (!_stscanf(tmpstring, _T("%x"), &texshaderstate.texstages[number].keycolor))
|
 | 2472 | + texshaderstate.texstages[number].keycolor = 0;
|
 | 2473 | + }
|
 | 2474 | + SelectTexture(&texshaderstate.texstages[number].texture, texshaderstate.texstages[number].texturetype,
|
 | 2475 | + texshaderstate.texstages[number].keycolor, texshaderstate.texstages[number].colorkey,
|
 | 2476 | + texshaderstate.texstages[number].texturefile);
|
 | 2477 | + }
|
 | 2478 | + case IDC_ALPHABLEND:
|
 | 2479 | + if (HIWORD(wParam) == BN_CLICKED)
|
 | 2480 | + {
|
 | 2481 | + if (SendDlgItemMessage(hWnd, IDC_ALPHABLEND, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
 | 2482 | + d3d7dev->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
|
 | 2483 | + else d3d7dev->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE);
|
 | 2484 | + }
|
 | 2485 | + break;
|
 | 2486 | + case IDC_SRCBLEND:
|
 | 2487 | + if (HIWORD(wParam) == CBN_SELCHANGE)
|
 | 2488 | + {
|
 | 2489 | + d3d7dev->SetRenderState(D3DRENDERSTATE_SRCBLEND, SendDlgItemMessage(hWnd,
|
 | 2490 | + IDC_SRCBLEND, CB_GETCURSEL, 0, 0) + 1);
|
 | 2491 | + }
|
 | 2492 | + case IDC_DESTBLEND:
|
 | 2493 | + if (HIWORD(wParam) == CBN_SELCHANGE)
|
 | 2494 | + {
|
 | 2495 | + d3d7dev->SetRenderState(D3DRENDERSTATE_DESTBLEND, SendDlgItemMessage(hWnd,
|
 | 2496 | + IDC_DESTBLEND, CB_GETCURSEL, 0, 0) + 1);
|
 | 2497 | + }
|
 | 2498 | + break;
|
 | 2499 | + case IDC_ALPHATEST:
|
 | 2500 | + if (HIWORD(wParam) == BN_CLICKED)
|
 | 2501 | + {
|
 | 2502 | + if (SendDlgItemMessage(hWnd, IDC_ALPHATEST, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
 | 2503 | + d3d7dev->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, TRUE);
|
 | 2504 | + else d3d7dev->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, FALSE);
|
 | 2505 | + }
|
 | 2506 | + case IDC_ALPHAFUNC:
|
 | 2507 | + if (HIWORD(wParam) == CBN_SELCHANGE)
|
 | 2508 | + {
|
 | 2509 | + d3d7dev->SetRenderState(D3DRENDERSTATE_ALPHAFUNC, SendDlgItemMessage(hWnd,
|
 | 2510 | + IDC_ALPHAFUNC, CB_GETCURSEL, 0, 0) + 1);
|
 | 2511 | + }
|
 | 2512 | + break;
|
 | 2513 | + case IDC_ALPHAREF:
|
 | 2514 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 2515 | + {
|
 | 2516 | + SendDlgItemMessage(hWnd, IDC_ALPHAREF, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2517 | + number = _ttoi(tmpstring);
|
 | 2518 | + if (number < 0) SendDlgItemMessage(hWnd, IDC_ALPHAREF, WM_SETTEXT, 0, (LPARAM)_T("0"));
|
 | 2519 | + if (number > 255) SendDlgItemMessage(hWnd, IDC_ALPHAREF, WM_SETTEXT, 0, (LPARAM)_T("255"));
|
 | 2520 | + if (number < 0) number = 0;
|
 | 2521 | + if (number > 255) number = 255;
|
 | 2522 | + if (d3d7dev) d3d7dev->SetRenderState(D3DRENDERSTATE_ALPHAREF, number);
|
 | 2523 | + }
|
 | 2524 | + case IDC_COLORKEY:
|
 | 2525 | + if (HIWORD(wParam) == BN_CLICKED)
|
 | 2526 | + {
|
 | 2527 | + if (SendDlgItemMessage(hWnd, IDC_COLORKEY, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
 | 2528 | + d3d7dev->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, TRUE);
|
 | 2529 | + else d3d7dev->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, FALSE);
|
 | 2530 | + }
|
 | 2531 | + break;
|
 | 2532 | + case IDC_FOGENABLE:
|
 | 2533 | + if (HIWORD(wParam) == BN_CLICKED)
|
 | 2534 | + {
|
 | 2535 | + if (SendDlgItemMessage(hWnd, IDC_FOGENABLE, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
 | 2536 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE);
|
 | 2537 | + else d3d7dev->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE);
|
 | 2538 | + }
|
 | 2539 | + break;
|
 | 2540 | + case IDC_VERTEXFOGMODE:
|
 | 2541 | + if (HIWORD(wParam) == CBN_SELCHANGE)
|
 | 2542 | + {
|
 | 2543 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGVERTEXMODE, SendDlgItemMessage(hWnd,
|
 | 2544 | + IDC_VERTEXFOGMODE, CB_GETCURSEL, 0, 0));
|
 | 2545 | + }
|
 | 2546 | + break;
|
 | 2547 | + case IDC_PIXELFOGMODE:
|
 | 2548 | + if (HIWORD(wParam) == CBN_SELCHANGE)
|
 | 2549 | + {
|
 | 2550 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, SendDlgItemMessage(hWnd,
|
 | 2551 | + IDC_PIXELFOGMODE, CB_GETCURSEL, 0, 0));
|
 | 2552 | + }
|
 | 2553 | + break;
|
 | 2554 | + case IDC_FOGSTART:
|
 | 2555 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 2556 | + {
|
 | 2557 | + SendDlgItemMessage(hWnd, IDC_FOGSTART, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2558 | + f = (float)_ttof(tmpstring);
|
 | 2559 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGSTART, *((LPDWORD)(&f)));
|
 | 2560 | + }
|
 | 2561 | + break;
|
 | 2562 | + case IDC_FOGEND:
|
 | 2563 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 2564 | + {
|
 | 2565 | + SendDlgItemMessage(hWnd, IDC_FOGEND, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2566 | + f = (float)_ttof(tmpstring);
|
 | 2567 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGEND, *((LPDWORD)(&f)));
|
 | 2568 | + }
|
 | 2569 | + break;
|
 | 2570 | + case IDC_FOGDENSITY:
|
 | 2571 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 2572 | + {
|
 | 2573 | + SendDlgItemMessage(hWnd, IDC_FOGDENSITY, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2574 | + f = (float)_ttof(tmpstring);
|
 | 2575 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGDENSITY, *((LPDWORD)(&f)));
|
 | 2576 | + }
|
 | 2577 | + break;
|
 | 2578 | + default:
|
 | 2579 | + return FALSE;
|
 | 2580 | + }
|
 | 2581 | + break;
|
 | 2582 | + case WM_CLOSE:
|
 | 2583 | + if (d3d7dev)
|
 | 2584 | + {
|
 | 2585 | + d3d7dev->Release();
|
 | 2586 | + d3d7dev = NULL;
|
 | 2587 | + }
|
 | 2588 | + if (d3d7)
|
 | 2589 | + {
|
 | 2590 | + d3d7->Release();
|
 | 2591 | + d3d7dev = NULL;
|
 | 2592 | + }
|
 | 2593 | + if (ddsrender)
|
 | 2594 | + {
|
 | 2595 | + ddsrender->Release();
|
 | 2596 | + ddsrender = NULL;
|
 | 2597 | + }
|
 | 2598 | + if (ddsurface)
|
 | 2599 | + {
|
 | 2600 | + ddsurface->Release();
|
 | 2601 | + ddsurface = NULL;
|
 | 2602 | + }
|
 | 2603 | + if (zbuffer)
|
 | 2604 | + {
|
 | 2605 | + zbuffer->Release();
|
 | 2606 | + zbuffer = NULL;
|
 | 2607 | + }
|
 | 2608 | + if (ddclipper)
|
 | 2609 | + {
|
 | 2610 | + ddclipper->Release();
|
 | 2611 | + ddclipper = NULL;
|
 | 2612 | + }
|
 | 2613 | + if (ddinterface)
|
 | 2614 | + {
|
 | 2615 | + ddinterface->Release();
|
 | 2616 | + ddinterface = NULL;
|
 | 2617 | + }
|
 | 2618 | + if (mesh)
|
 | 2619 | + {
|
 | 2620 | + free(mesh);
|
 | 2621 | + mesh = NULL;
|
 | 2622 | + }
|
 | 2623 | + if (vertices)
|
 | 2624 | + {
|
 | 2625 | + free(vertices);
|
 | 2626 | + vertices = NULL;
|
 | 2627 | + }
|
 | 2628 | + if (litvertices)
|
 | 2629 | + {
|
 | 2630 | + free(litvertices);
|
 | 2631 | + litvertices = NULL;
|
 | 2632 | + }
|
 | 2633 | + if (colorvertices)
|
 | 2634 | + {
|
 | 2635 | + free(colorvertices);
|
 | 2636 | + colorvertices = NULL;
|
 | 2637 | + }
|
 | 2638 | + EndDialog(hWnd, IDCANCEL);
|
 | 2639 | + break;
|
 | 2640 | + case WM_APP:
|
 | 2641 | + RunTestTimed(testnum);
|
 | 2642 | + break;
|
 | 2643 | + default:
|
 | 2644 | + return FALSE;
|
 | 2645 | + }
|
 | 2646 | + return TRUE;
|
 | 2647 | +
|
 | 2648 | +
|
 | 2649 | +}
|
 | 2650 | +
|
 | 2651 | +INT_PTR CALLBACK VertexShader7Proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
 | 2652 | +{
|
 | 2653 | + HRESULT error;
|
 | 2654 | + D3DVIEWPORT7 vp;
|
 | 2655 | + HWND hDisplay;
|
 | 2656 | + int number;
|
 | 2657 | + float f;
|
 | 2658 | + TCHAR tmpstring[MAX_PATH + 1];
|
 | 2659 | + switch (Msg)
|
 | 2660 | + {
|
 | 2661 | + case WM_INITDIALOG:
|
 | 2662 | + RECT r;
|
 | 2663 | + DDSCAPS2 caps;
|
 | 2664 | + DDSURFACEDESC2 ddsd;
|
 | 2665 | + DDPIXELFORMAT ddpfz;
|
 | 2666 | + testnum = 3;
|
 | 2667 | + ddinterface = new MultiDirectDraw(7, &error, NULL);
|
 | 2668 | + hDisplay = GetDlgItem(hWnd, IDC_DISPLAY);
|
 | 2669 | + ::hWnd = hDisplay;
|
 | 2670 | + error = ddinterface->SetCooperativeLevel(hDisplay, DDSCL_NORMAL);
|
 | 2671 | + ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
|
 | 2672 | + ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
 | 2673 | + ddsd.dwFlags = DDSD_CAPS;
|
 | 2674 | + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
 | 2675 | + error = ddinterface->CreateSurface(&ddsd, &ddsurface, NULL);
|
 | 2676 | + error = ddinterface->CreateClipper(0, &ddclipper, NULL);
|
 | 2677 | + error = ddclipper->SetHWnd(0, hDisplay);
|
 | 2678 | + error = ddsurface->SetClipper(ddclipper);
|
 | 2679 | + ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
|
 | 2680 | + ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
 | 2681 | + ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
 | 2682 | + ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
|
 | 2683 | + GetClientRect(hDisplay, &r);
|
 | 2684 | + ddsd.dwWidth = r.right;
|
 | 2685 | + ddsd.dwHeight = r.bottom;
|
 | 2686 | + error = ddinterface->CreateSurface(&ddsd, &ddsrender, NULL);
|
 | 2687 | + error = ddinterface->QueryInterface(IID_IDirect3D7, (VOID**)&d3d7);
|
 | 2688 | + error = d3d7->EnumZBufferFormats(IID_IDirect3DRGBDevice, zcallback, &ddpfz);
|
 | 2689 | + error = ddsrender->GetSurfaceDesc(&ddsd);
|
 | 2690 | + ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
|
 | 2691 | + ddsd.ddsCaps.dwCaps = DDSCAPS_ZBUFFER | DDSCAPS_VIDEOMEMORY;
|
 | 2692 | + memcpy(&ddsd.ddpfPixelFormat, &ddpfz, sizeof(DDPIXELFORMAT));
|
 | 2693 | + error = ddinterface->CreateSurface(&ddsd, &zbuffer, NULL);
|
 | 2694 | + error = ddsrender->AddAttachedSurface(zbuffer);
|
 | 2695 | + error = d3d7->CreateDevice(IID_IDirect3DHALDevice, (LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(), &d3d7dev);
|
 | 2696 | + if (error != D3D_OK)
|
 | 2697 | + error = d3d7->CreateDevice(IID_IDirect3DRGBDevice, (LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(), &d3d7dev);
|
 | 2698 | + ddsrender->GetSurfaceDesc(&ddsd);
|
 | 2699 | + vp.dvMaxZ = 1.0f;
|
 | 2700 | + vp.dvMinZ = 0.0f;
|
 | 2701 | + vp.dwX = vp.dwY = 0;
|
 | 2702 | + vp.dwWidth = ddsd.dwWidth;
|
 | 2703 | + vp.dwHeight = ddsd.dwHeight;
|
 | 2704 | + error = d3d7dev->SetViewport(&vp);
|
 | 2705 | + error = d3d7dev->SetRenderState(D3DRENDERSTATE_ZENABLE, TRUE);
|
 | 2706 | + InitTest(15);
|
 | 2707 | + SendDlgItemMessage(hWnd, IDC_TEXTURE, CB_ADDSTRING, 0, (LPARAM)_T("None"));
|
 | 2708 | + SendDlgItemMessage(hWnd, IDC_TEXTURE, CB_ADDSTRING, 0, (LPARAM)_T("Gradients"));
|
 | 2709 | + SendDlgItemMessage(hWnd, IDC_TEXTURE, CB_ADDSTRING, 0, (LPARAM)_T("DXGL logo (small)"));
|
 | 2710 | + SendDlgItemMessage(hWnd, IDC_TEXTURE, CB_ADDSTRING, 0, (LPARAM)_T("DXGL logo (large)"));
|
 | 2711 | + SendDlgItemMessage(hWnd, IDC_TEXTURE, CB_ADDSTRING, 0, (LPARAM)_T("Texture file"));
|
 | 2712 | + SendDlgItemMessage(hWnd, IDC_TEXTURE, CB_SETCURSEL, 0, 0);
|
 | 2713 | + SendDlgItemMessage(hWnd, IDC_DIFFUSE, WM_SETTEXT, 0, (LPARAM)_T("FFFFFFFF"));
|
 | 2714 | + SendDlgItemMessage(hWnd, IDC_SPECULAR, WM_SETTEXT, 0, (LPARAM)_T("00000000"));
|
 | 2715 | + SendDlgItemMessage(hWnd, IDC_FACTOR, WM_SETTEXT, 0, (LPARAM)_T("00000000"));
|
 | 2716 | + SendDlgItemMessage(hWnd, IDC_FOGCOLOR, WM_SETTEXT, 0, (LPARAM)_T("00000000"));
|
 | 2717 | + SendDlgItemMessage(hWnd, IDC_BGCOLOR, WM_SETTEXT, 0, (LPARAM)_T("00000000"));
|
 | 2718 | + SendDlgItemMessage(hWnd, IDC_AMBIENT, WM_SETTEXT, 0, (LPARAM)_T("FFFFFFFF"));
|
 | 2719 | + SendDlgItemMessage(hWnd, IDC_EMISSIVE, WM_SETTEXT, 0, (LPARAM)_T("00000000"));
|
 | 2720 | + SendDlgItemMessage(hWnd, IDC_MATAMBIENT, WM_SETTEXT, 0, (LPARAM)_T("FFFFFFFF"));
|
 | 2721 | + SendDlgItemMessage(hWnd, IDC_MATDIFFUSE, WM_SETTEXT, 0, (LPARAM)_T("FFFFFFFF"));
|
 | 2722 | + SendDlgItemMessage(hWnd, IDC_MATSPECULAR, WM_SETTEXT, 0, (LPARAM)_T("00000000"));
|
 | 2723 | + PopulateFogCombo(GetDlgItem(hWnd, IDC_VERTEXFOGMODE));
|
 | 2724 | + PopulateFogCombo(GetDlgItem(hWnd, IDC_PIXELFOGMODE));
|
 | 2725 | + SendDlgItemMessage(hWnd, IDC_VERTEXFOGMODE, CB_SETCURSEL, D3DFOG_NONE, 0);
|
 | 2726 | + SendDlgItemMessage(hWnd, IDC_PIXELFOGMODE, CB_SETCURSEL, D3DFOG_NONE, 0);
|
 | 2727 | + SendDlgItemMessage(hWnd, IDC_FOGSTART, WM_SETTEXT, 0, (LPARAM)_T("0.0"));
|
 | 2728 | + SendDlgItemMessage(hWnd, IDC_FOGEND, WM_SETTEXT, 0, (LPARAM)_T("1.0"));
|
 | 2729 | + SendDlgItemMessage(hWnd, IDC_FOGDENSITY, WM_SETTEXT, 0, (LPARAM)_T("1.0"));
|
 | 2730 | + SendDlgItemMessage(hWnd, IDC_FILLMODE, CB_ADDSTRING, 0, (LPARAM)_T("Points"));
|
 | 2731 | + SendDlgItemMessage(hWnd, IDC_FILLMODE, CB_ADDSTRING, 0, (LPARAM)_T("Wireframe"));
|
 | 2732 | + SendDlgItemMessage(hWnd, IDC_FILLMODE, CB_ADDSTRING, 0, (LPARAM)_T("Solid"));
|
 | 2733 | + SendDlgItemMessage(hWnd, IDC_FILLMODE, CB_SETCURSEL, 2, 0);
|
 | 2734 | + SendDlgItemMessage(hWnd, IDC_SHADEMODE, CB_ADDSTRING, 0, (LPARAM)_T("Flat"));
|
 | 2735 | + SendDlgItemMessage(hWnd, IDC_SHADEMODE, CB_ADDSTRING, 0, (LPARAM)_T("Gouraud"));
|
 | 2736 | + SendDlgItemMessage(hWnd, IDC_SHADEMODE, CB_ADDSTRING, 0, (LPARAM)_T("Phong"));
|
 | 2737 | + SendDlgItemMessage(hWnd, IDC_SHADEMODE, CB_SETCURSEL, 1, 0);
|
 | 2738 | + SendDlgItemMessage(hWnd, IDC_CULLMODE, CB_ADDSTRING, 0, (LPARAM)_T("None"));
|
 | 2739 | + SendDlgItemMessage(hWnd, IDC_CULLMODE, CB_ADDSTRING, 0, (LPARAM)_T("CW"));
|
 | 2740 | + SendDlgItemMessage(hWnd, IDC_CULLMODE, CB_ADDSTRING, 0, (LPARAM)_T("CCW"));
|
 | 2741 | + SendDlgItemMessage(hWnd, IDC_CULLMODE, CB_SETCURSEL, 2, 0);
|
 | 2742 | + SendDlgItemMessage(hWnd, IDC_VERTEXCOLOR, BM_SETCHECK, BST_CHECKED, 0);
|
 | 2743 | + PopulateSourceCombo(GetDlgItem(hWnd, IDC_DIFFUSESOURCE));
|
 | 2744 | + PopulateSourceCombo(GetDlgItem(hWnd, IDC_SPECULARSOURCE));
|
 | 2745 | + PopulateSourceCombo(GetDlgItem(hWnd, IDC_AMBIENTSOURCE));
|
 | 2746 | + PopulateSourceCombo(GetDlgItem(hWnd, IDC_EMISSIVESOURCE));
|
 | 2747 | + SendDlgItemMessage(hWnd, IDC_DIFFUSESOURCE, CB_SETCURSEL, D3DMCS_COLOR1, 0);
|
 | 2748 | + SendDlgItemMessage(hWnd, IDC_SPECULARSOURCE, CB_SETCURSEL, D3DMCS_COLOR2, 0);
|
 | 2749 | + SendDlgItemMessage(hWnd, IDC_AMBIENTSOURCE, CB_SETCURSEL, D3DMCS_MATERIAL, 0);
|
 | 2750 | + SendDlgItemMessage(hWnd, IDC_EMISSIVESOURCE, CB_SETCURSEL, D3DMCS_MATERIAL, 0);
|
 | 2751 | + SendDlgItemMessage(hWnd, IDC_SPINDETAIL, UDM_SETRANGE32, 2, 64);
|
 | 2752 | + SendDlgItemMessage(hWnd, IDC_SPINDETAIL, UDM_SETPOS32, 0, 8);
|
 | 2753 | + SendDlgItemMessage(hWnd, IDC_SPINLIGHT, UDM_SETRANGE32, 0, 7);
|
 | 2754 | + SendDlgItemMessage(hWnd, IDC_LIGHTDIFFUSE, WM_SETTEXT, 0, (LPARAM)_T("00FFFFFF"));
|
 | 2755 | + SendDlgItemMessage(hWnd, IDC_LIGHTAMBIENT, WM_SETTEXT, 0, (LPARAM)_T("00000000"));
|
 | 2756 | + SendDlgItemMessage(hWnd, IDC_LIGHTSPECULAR, WM_SETTEXT, 0, (LPARAM)_T("00000000"));
|
 | 2757 | + SendDlgItemMessage(hWnd, IDC_LIGHTRANGE, WM_SETTEXT, 0, (LPARAM)_T("0"));
|
 | 2758 | + SendDlgItemMessage(hWnd, IDC_LIGHTFALLOFF, WM_SETTEXT, 0, (LPARAM)_T("0"));
|
 | 2759 | + SendDlgItemMessage(hWnd, IDC_LIGHTTHETA, WM_SETTEXT, 0, (LPARAM)_T("0"));
|
 | 2760 | + SendDlgItemMessage(hWnd, IDC_LIGHTPHI, WM_SETTEXT, 0, (LPARAM)_T("0"));
|
 | 2761 | + SendDlgItemMessage(hWnd, IDC_LIGHTATTEN0, WM_SETTEXT, 0, (LPARAM)_T("0"));
|
 | 2762 | + SendDlgItemMessage(hWnd, IDC_LIGHTATTEN1, WM_SETTEXT, 0, (LPARAM)_T("0"));
|
 | 2763 | + SendDlgItemMessage(hWnd, IDC_LIGHTATTEN2, WM_SETTEXT, 0, (LPARAM)_T("0"));
|
 | 2764 | + SendDlgItemMessage(hWnd, IDC_POWER, WM_SETTEXT, 0, (LPARAM)_T("0"));
|
 | 2765 | + SendDlgItemMessage(hWnd, IDC_LIGHTTYPE, CB_ADDSTRING, 0, (LPARAM)_T("Point"));
|
 | 2766 | + SendDlgItemMessage(hWnd, IDC_LIGHTTYPE, CB_ADDSTRING, 0, (LPARAM)_T("Spot"));
|
 | 2767 | + SendDlgItemMessage(hWnd, IDC_LIGHTTYPE, CB_ADDSTRING, 0, (LPARAM)_T("Directional"));
|
 | 2768 | + SendDlgItemMessage(hWnd, IDC_LIGHTTYPE, CB_ADDSTRING, 0, (LPARAM)_T("Parallel Point"));
|
 | 2769 | + SendDlgItemMessage(hWnd, IDC_LIGHTTYPE, CB_ADDSTRING, 0, (LPARAM)_T("GL Spot"));
|
 | 2770 | + SendDlgItemMessage(hWnd, IDC_LIGHTTYPE, CB_SETCURSEL, D3DLIGHT_DIRECTIONAL - 1, 0);
|
 | 2771 | + SendDlgItemMessage(hWnd, IDC_LIGHTENABLED, BM_SETCHECK, BST_CHECKED, 0);
|
 | 2772 | + ::width = ddsd.dwWidth;
|
 | 2773 | + ::height = ddsd.dwHeight;
|
 | 2774 | + vertexshaderstate.texture = NULL;
|
 | 2775 | + vertexshaderstate.texturefile[0] = 0;
|
 | 2776 | + vertexshaderstate.texturetype = 0;
|
 | 2777 | + vertexshaderstate.currentlight = 0;
|
 | 2778 | + StartTimer(hWnd, WM_APP, 60);
|
 | 2779 | + break;
|
 | 2780 | + case WM_COMMAND:
|
 | 2781 | + switch (LOWORD(wParam))
|
 | 2782 | + {
|
 | 2783 | + case IDC_TEXTURE:
|
 | 2784 | + if (HIWORD(wParam) == CBN_SELCHANGE)
|
 | 2785 | + {
|
 | 2786 | + number = texshaderstate.currentstage;
|
 | 2787 | + vertexshaderstate.texturetype =
|
 | 2788 | + SendDlgItemMessage(hWnd, IDC_TEXTURE, CB_GETCURSEL, 0, 0);
|
 | 2789 | + SelectTexture(&vertexshaderstate.texture, vertexshaderstate.texturetype,
|
 | 2790 | + 0, FALSE, vertexshaderstate.texturefile);
|
 | 2791 | + if ((vertexshaderstate.texturetype == 2) || (vertexshaderstate.texturetype == 3))
|
 | 2792 | + d3d7dev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_BLENDTEXTUREALPHAPM);
|
 | 2793 | + else d3d7dev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
 | 2794 | + }
|
 | 2795 | + break;
|
 | 2796 | + case IDC_TEXTUREFILE:
|
 | 2797 | + if (HIWORD(wParam) == EN_KILLFOCUS)
|
 | 2798 | + {
|
 | 2799 | + number = texshaderstate.currentstage;
|
 | 2800 | + SendDlgItemMessage(hWnd, IDC_TEXTUREFILE, WM_GETTEXT, MAX_PATH + 1,
|
 | 2801 | + (LPARAM)vertexshaderstate.texturefile);
|
 | 2802 | + SelectTexture(&vertexshaderstate.texture, vertexshaderstate.texturetype,
|
 | 2803 | + 0, FALSE, vertexshaderstate.texturefile);
|
 | 2804 | + }
|
 | 2805 | + break;
|
 | 2806 | + case IDC_FOGENABLE:
|
 | 2807 | + if (HIWORD(wParam) == BN_CLICKED)
|
 | 2808 | + {
|
 | 2809 | + if (SendDlgItemMessage(hWnd, IDC_FOGENABLE, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
 | 2810 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE);
|
 | 2811 | + else d3d7dev->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE);
|
 | 2812 | + }
|
 | 2813 | + break;
|
 | 2814 | + case IDC_VERTEXFOGMODE:
|
 | 2815 | + if (HIWORD(wParam) == CBN_SELCHANGE)
|
 | 2816 | + {
|
 | 2817 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGVERTEXMODE, SendDlgItemMessage(hWnd,
|
 | 2818 | + IDC_VERTEXFOGMODE, CB_GETCURSEL, 0, 0));
|
 | 2819 | + }
|
 | 2820 | + break;
|
 | 2821 | + case IDC_PIXELFOGMODE:
|
 | 2822 | + if (HIWORD(wParam) == CBN_SELCHANGE)
|
 | 2823 | + {
|
 | 2824 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, SendDlgItemMessage(hWnd,
|
 | 2825 | + IDC_PIXELFOGMODE, CB_GETCURSEL, 0, 0));
|
 | 2826 | + }
|
 | 2827 | + break;
|
 | 2828 | + case IDC_FOGSTART:
|
 | 2829 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 2830 | + {
|
 | 2831 | + SendDlgItemMessage(hWnd, IDC_FOGSTART, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2832 | + f = (float)_ttof(tmpstring);
|
 | 2833 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGSTART, *((LPDWORD)(&f)));
|
 | 2834 | + }
|
 | 2835 | + break;
|
 | 2836 | + case IDC_FOGEND:
|
 | 2837 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 2838 | + {
|
 | 2839 | + SendDlgItemMessage(hWnd, IDC_FOGEND, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2840 | + f = (float)_ttof(tmpstring);
|
 | 2841 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGEND, *((LPDWORD)(&f)));
|
 | 2842 | + }
|
 | 2843 | + break;
|
 | 2844 | + case IDC_FOGDENSITY:
|
 | 2845 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 2846 | + {
|
 | 2847 | + SendDlgItemMessage(hWnd, IDC_FOGDENSITY, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2848 | + f = (float)_ttof(tmpstring);
|
 | 2849 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGDENSITY, *((LPDWORD)(&f)));
|
 | 2850 | + }
|
 | 2851 | + break;
|
 | 2852 | + case IDC_RANGEBASEDFOG:
|
 | 2853 | + if (HIWORD(wParam) == BN_CLICKED)
|
 | 2854 | + {
|
 | 2855 | + if (SendDlgItemMessage(hWnd, IDC_RANGEBASEDFOG, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
 | 2856 | + d3d7dev->SetRenderState(D3DRENDERSTATE_RANGEFOGENABLE, TRUE);
|
 | 2857 | + else d3d7dev->SetRenderState(D3DRENDERSTATE_RANGEFOGENABLE, FALSE);
|
 | 2858 | + }
|
 | 2859 | + break;
|
 | 2860 | + case IDC_FILLMODE:
|
 | 2861 | + if (HIWORD(wParam) == CBN_SELCHANGE)
|
 | 2862 | + {
|
 | 2863 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FILLMODE, SendDlgItemMessage(hWnd,
|
 | 2864 | + IDC_FILLMODE, CB_GETCURSEL, 0, 0) + 1);
|
 | 2865 | + }
|
 | 2866 | + break;
|
 | 2867 | + case IDC_SHADEMODE:
|
 | 2868 | + if (HIWORD(wParam) == CBN_SELCHANGE)
|
 | 2869 | + {
|
 | 2870 | + d3d7dev->SetRenderState(D3DRENDERSTATE_SHADEMODE, SendDlgItemMessage(hWnd,
|
 | 2871 | + IDC_SHADEMODE, CB_GETCURSEL, 0, 0) + 1);
|
 | 2872 | + }
|
 | 2873 | + break;
|
 | 2874 | + case IDC_CULLMODE:
|
 | 2875 | + if (HIWORD(wParam) == CBN_SELCHANGE)
|
 | 2876 | + {
|
 | 2877 | + d3d7dev->SetRenderState(D3DRENDERSTATE_CULLMODE, SendDlgItemMessage(hWnd,
|
 | 2878 | + IDC_CULLMODE, CB_GETCURSEL, 0, 0) + 1);
|
 | 2879 | + }
|
 | 2880 | + break;
|
 | 2881 | + case IDC_DIFFUSE:
|
 | 2882 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 2883 | + {
|
 | 2884 | + SendDlgItemMessage(hWnd, IDC_DIFFUSE, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2885 | + if (!_stscanf(tmpstring, _T("%x"), &number)) number = 0;
|
 | 2886 | + SetVertexColor(litvertices, colorvertices, numpoints, number);
|
 | 2887 | + }
|
 | 2888 | + break;
|
 | 2889 | + case IDC_SPECULAR:
|
 | 2890 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 2891 | + {
|
 | 2892 | + SendDlgItemMessage(hWnd, IDC_SPECULAR, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2893 | + if (!_stscanf(tmpstring, _T("%x"), &number)) number = 0;
|
 | 2894 | + SetVertexSpecular(litvertices, colorvertices, numpoints, number);
|
 | 2895 | + }
|
 | 2896 | + break;
|
 | 2897 | + case IDC_FACTOR:
|
 | 2898 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 2899 | + {
|
 | 2900 | + SendDlgItemMessage(hWnd, IDC_FACTOR, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2901 | + if (!_stscanf(tmpstring, _T("%x"), &number)) number = 0;
|
 | 2902 | + d3d7dev->SetRenderState(D3DRENDERSTATE_TEXTUREFACTOR, number);
|
 | 2903 | + }
|
 | 2904 | + break;
|
 | 2905 | + case IDC_FOGCOLOR:
|
 | 2906 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 2907 | + {
|
 | 2908 | + SendDlgItemMessage(hWnd, IDC_FOGCOLOR, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2909 | + if (!_stscanf(tmpstring, _T("%x"), &number)) number = 0;
|
 | 2910 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGCOLOR, number);
|
 | 2911 | + }
|
 | 2912 | + break;
|
 | 2913 | + case IDC_BGCOLOR:
|
 | 2914 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 2915 | + {
|
 | 2916 | + SendDlgItemMessage(hWnd, IDC_BGCOLOR, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2917 | + if (!_stscanf(tmpstring, _T("%x"), &bgcolor)) bgcolor = 0;
|
 | 2918 | + }
|
 | 2919 | + break;
|
 | 2920 | + case IDC_AMBIENT:
|
 | 2921 | + {
|
 | 2922 | + SendDlgItemMessage(hWnd, IDC_AMBIENT, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2923 | + if (!_stscanf(tmpstring, _T("%x"), &number)) number = 0;
|
 | 2924 | + d3d7dev->SetRenderState(D3DRENDERSTATE_AMBIENT, number);
|
 | 2925 | + }
|
 | 2926 | + break;
|
 | 2927 | + case IDC_EMISSIVE:
|
 | 2928 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 2929 | + {
|
 | 2930 | + SendDlgItemMessage(hWnd, IDC_EMISSIVE, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2931 | + if (!_stscanf(tmpstring, _T("%x"), &number)) number = 0;
|
 | 2932 | + material.emissive.b = (float)(number & 255) / 255.0;
|
 | 2933 | + material.emissive.g = (float)((number >> 8) & 255) / 255.0;
|
 | 2934 | + material.emissive.r = (float)((number >> 16) & 255) / 255.0;
|
 | 2935 | + material.emissive.a = (float)((number >> 24) & 255) / 255.0;
|
 | 2936 | + d3d7dev->SetMaterial(&material);
|
 | 2937 | + }
|
 | 2938 | + break;
|
 | 2939 | + case IDC_MATAMBIENT:
|
 | 2940 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 2941 | + {
|
 | 2942 | + SendDlgItemMessage(hWnd, IDC_MATAMBIENT, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2943 | + if (!_stscanf(tmpstring, _T("%x"), &number)) number = 0;
|
 | 2944 | + material.ambient.b = (float)(number & 255) / 255.0;
|
 | 2945 | + material.ambient.g = (float)((number >> 8) & 255) / 255.0;
|
 | 2946 | + material.ambient.r = (float)((number >> 16) & 255) / 255.0;
|
 | 2947 | + material.ambient.a = (float)((number >> 24) & 255) / 255.0;
|
 | 2948 | + d3d7dev->SetMaterial(&material);
|
 | 2949 | + }
|
 | 2950 | + break;
|
 | 2951 | + case IDC_MATDIFFUSE:
|
 | 2952 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 2953 | + {
|
 | 2954 | + SendDlgItemMessage(hWnd, IDC_MATDIFFUSE, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2955 | + if (!_stscanf(tmpstring, _T("%x"), &number)) number = 0;
|
 | 2956 | + material.diffuse.b = (float)(number & 255) / 255.0;
|
 | 2957 | + material.diffuse.g = (float)((number >> 8) & 255) / 255.0;
|
 | 2958 | + material.diffuse.r = (float)((number >> 16) & 255) / 255.0;
|
 | 2959 | + material.diffuse.a = (float)((number >> 24) & 255) / 255.0;
|
 | 2960 | + d3d7dev->SetMaterial(&material);
|
 | 2961 | + }
|
 | 2962 | + break;
|
 | 2963 | + case IDC_MATSPECULAR:
|
 | 2964 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 2965 | + {
|
 | 2966 | + SendDlgItemMessage(hWnd, IDC_MATSPECULAR, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2967 | + if (!_stscanf(tmpstring, _T("%x"), &number)) number = 0;
|
 | 2968 | + material.specular.b = (float)(number & 255) / 255.0;
|
 | 2969 | + material.specular.g = (float)((number >> 8) & 255) / 255.0;
|
 | 2970 | + material.specular.r = (float)((number >> 16) & 255) / 255.0;
|
 | 2971 | + material.specular.a = (float)((number >> 24) & 255) / 255.0;
|
 | 2972 | + d3d7dev->SetMaterial(&material);
|
 | 2973 | + }
|
 | 2974 | + break;
|
 | 2975 | + case IDC_POWER:
|
 | 2976 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 2977 | + {
|
 | 2978 | + SendDlgItemMessage(hWnd, IDC_POWER, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 2979 | + material.power = (float)_ttof(tmpstring);
|
 | 2980 | + d3d7dev->SetMaterial(&material);
|
 | 2981 | + }
|
 | 2982 | + break;
|
 | 2983 | + case IDC_ENABLELIGHT:
|
 | 2984 | + if (HIWORD(wParam) == BN_CLICKED)
|
 | 2985 | + {
|
 | 2986 | + if (SendDlgItemMessage(hWnd, IDC_ENABLELIGHT, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
 | 2987 | + {
|
 | 2988 | + d3d7dev->SetRenderState(D3DRENDERSTATE_LIGHTING, TRUE);
|
 | 2989 | + for (int i = 0; i < 8; i++)
|
 | 2990 | + {
|
 | 2991 | + d3d7dev->SetLight(i, &lights[i]);
|
 | 2992 | + d3d7dev->LightEnable(i, lightenable[i]);
|
 | 2993 | + }
|
 | 2994 | + }
|
 | 2995 | + else d3d7dev->SetRenderState(D3DRENDERSTATE_LIGHTING, FALSE);
|
 | 2996 | + }
|
 | 2997 | + break;
|
 | 2998 | + case IDC_VERTEXCOLOR:
|
 | 2999 | + if (HIWORD(wParam) == BN_CLICKED)
|
 | 3000 | + {
|
 | 3001 | + if (SendDlgItemMessage(hWnd, IDC_VERTEXCOLOR, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
 | 3002 | + d3d7dev->SetRenderState(D3DRENDERSTATE_COLORVERTEX, TRUE);
|
 | 3003 | + else d3d7dev->SetRenderState(D3DRENDERSTATE_COLORVERTEX, FALSE);
|
 | 3004 | + }
|
 | 3005 | + break;
|
 | 3006 | + case IDC_DETAIL:
|
 | 3007 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 3008 | + {
|
 | 3009 | + SendDlgItemMessage(hWnd, IDC_DETAIL, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 3010 | + number = _ttoi(tmpstring);
|
 | 3011 | + if (number < 2) SendDlgItemMessage(hWnd, IDC_DETAIL, WM_SETTEXT, 0, (LPARAM)_T("2"));
|
 | 3012 | + if (number > 64) SendDlgItemMessage(hWnd, IDC_DETAIL, WM_SETTEXT, 0, (LPARAM)_T("64"));
|
 | 3013 | + MakeCube3D(5, number);
|
 | 3014 | + }
|
 | 3015 | + break;
|
 | 3016 | + case IDC_DIFFUSESOURCE:
|
 | 3017 | + if (HIWORD(wParam) == CBN_SELCHANGE)
|
 | 3018 | + {
|
 | 3019 | + d3d7dev->SetRenderState(D3DRENDERSTATE_DIFFUSEMATERIALSOURCE, SendDlgItemMessage(hWnd,
|
 | 3020 | + IDC_DIFFUSESOURCE, CB_GETCURSEL, 0, 0));
|
 | 3021 | + }
|
 | 3022 | + break;
|
 | 3023 | + case IDC_SPECULARSOURCE:
|
 | 3024 | + if (HIWORD(wParam) == CBN_SELCHANGE)
|
 | 3025 | + {
|
 | 3026 | + d3d7dev->SetRenderState(D3DRENDERSTATE_SPECULARMATERIALSOURCE, SendDlgItemMessage(hWnd,
|
 | 3027 | + IDC_SPECULARSOURCE, CB_GETCURSEL, 0, 0));
|
 | 3028 | + }
|
 | 3029 | + break;
|
 | 3030 | + case IDC_AMBIENTSOURCE:
|
 | 3031 | + if (HIWORD(wParam) == CBN_SELCHANGE)
|
 | 3032 | + {
|
 | 3033 | + d3d7dev->SetRenderState(D3DRENDERSTATE_AMBIENTMATERIALSOURCE, SendDlgItemMessage(hWnd,
|
 | 3034 | + IDC_AMBIENTSOURCE, CB_GETCURSEL, 0, 0));
|
 | 3035 | + }
|
 | 3036 | + break;
|
 | 3037 | + case IDC_EMISSIVESOURCE:
|
 | 3038 | + if (HIWORD(wParam) == CBN_SELCHANGE)
|
 | 3039 | + {
|
 | 3040 | + d3d7dev->SetRenderState(D3DRENDERSTATE_EMISSIVEMATERIALSOURCE, SendDlgItemMessage(hWnd,
|
 | 3041 | + IDC_EMISSIVESOURCE, CB_GETCURSEL, 0, 0));
|
 | 3042 | + }
|
 | 3043 | + break;
|
 | 3044 | + case IDC_LIGHTNUMBER:
|
 | 3045 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 3046 | + {
|
 | 3047 | + SendDlgItemMessage(hWnd, IDC_LIGHTNUMBER, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 3048 | + number = _ttoi(tmpstring);
|
 | 3049 | + if (number < 0) SendDlgItemMessage(hWnd, IDC_LIGHTNUMBER, WM_SETTEXT, 0, (LPARAM)_T("0"));
|
 | 3050 | + if (number > 7) SendDlgItemMessage(hWnd, IDC_LIGHTNUMBER, WM_SETTEXT, 0, (LPARAM)_T("7"));
|
 | 3051 | + vertexshaderstate.currentlight = number;
|
 | 3052 | + _itot(hexlightcolor[vertexshaderstate.currentlight].ambient, tmpstring, 16);
|
 | 3053 | + strupper(tmpstring); paddwordzeroes(tmpstring);
|
 | 3054 | + SendDlgItemMessage(hWnd, IDC_LIGHTAMBIENT, WM_SETTEXT, 0, (LPARAM)tmpstring);
|
 | 3055 | + _itot(hexlightcolor[vertexshaderstate.currentlight].diffuse, tmpstring, 16);
|
 | 3056 | + strupper(tmpstring); paddwordzeroes(tmpstring);
|
 | 3057 | + SendDlgItemMessage(hWnd, IDC_LIGHTDIFFUSE, WM_SETTEXT, 0, (LPARAM)tmpstring);
|
 | 3058 | + _itot(hexlightcolor[vertexshaderstate.currentlight].specular, tmpstring, 16);
|
 | 3059 | + strupper(tmpstring); paddwordzeroes(tmpstring);
|
 | 3060 | + SendDlgItemMessage(hWnd, IDC_LIGHTSPECULAR, WM_SETTEXT, 0, (LPARAM)tmpstring);
|
 | 3061 | + SendDlgItemMessage(hWnd, IDC_LIGHTTYPE, CB_SETCURSEL, lights[vertexshaderstate.currentlight].dltType - 1, 0);
|
 | 3062 | + if (lightenable[vertexshaderstate.currentlight])
|
 | 3063 | + SendDlgItemMessage(hWnd, IDC_LIGHTENABLED, BM_SETCHECK, BST_CHECKED, 0);
|
 | 3064 | + else SendDlgItemMessage(hWnd, IDC_LIGHTENABLED, BM_SETCHECK, BST_UNCHECKED, 0);
|
 | 3065 | + }
|
 | 3066 | + break;
|
 | 3067 | + case IDC_LIGHTENABLED:
|
 | 3068 | + if (HIWORD(wParam) == BN_CLICKED)
|
 | 3069 | + {
|
 | 3070 | + if (SendDlgItemMessage(hWnd, IDC_LIGHTENABLED, BM_GETCHECK, 0, 0) == BST_CHECKED)
|
 | 3071 | + {
|
 | 3072 | + lightenable[vertexshaderstate.currentlight] = TRUE;
|
 | 3073 | + d3d7dev->LightEnable(vertexshaderstate.currentlight, TRUE);
|
 | 3074 | + }
|
 | 3075 | + else
|
 | 3076 | + {
|
 | 3077 | + lightenable[vertexshaderstate.currentlight] = FALSE;
|
 | 3078 | + d3d7dev->LightEnable(vertexshaderstate.currentlight, FALSE);
|
 | 3079 | + }
|
 | 3080 | + }
|
 | 3081 | + break;
|
 | 3082 | + case IDC_LIGHTTYPE:
|
 | 3083 | + if (HIWORD(wParam) == CBN_SELCHANGE)
|
 | 3084 | + {
|
 | 3085 | + lights[vertexshaderstate.currentlight].dltType = (D3DLIGHTTYPE)
|
 | 3086 | + (SendDlgItemMessage(hWnd, IDC_LIGHTTYPE, CB_GETCURSEL, 0, 0) + 1);
|
 | 3087 | + d3d7dev->SetLight(vertexshaderstate.currentlight, &lights[vertexshaderstate.currentlight]);
|
 | 3088 | + }
|
 | 3089 | + break;
|
 | 3090 | + case IDC_LIGHTRANGE:
|
 | 3091 | + if (HIWORD(wParam) == EN_CHANGE)
|
 | 3092 | + {
|
 | 3093 | + SendDlgItemMessage(hWnd, IDC_LIGHTRANGE, WM_GETTEXT, MAX_PATH, (LPARAM)tmpstring);
|
 | 3094 | + lights[vertexshaderstate.currentlight].dvRange = (float)_ttof(tmpstring);
|
 | 3095 | + d3d7dev->SetLight(vertexshaderstate.currentlight, &lights[vertexshaderstate.currentlight]);
|
 | 3096 | + }
|
 | 3097 | + break;
|
 | 3098 | + default:
|
 | 3099 | + return FALSE;
|
 | 3100 | + }
|
 | 3101 | + break;
|
 | 3102 | + case WM_CLOSE:
|
 | 3103 | + if (d3d7dev)
|
 | 3104 | + {
|
 | 3105 | + d3d7dev->Release();
|
 | 3106 | + d3d7dev = NULL;
|
 | 3107 | + }
|
 | 3108 | + if (d3d7)
|
 | 3109 | + {
|
 | 3110 | + d3d7->Release();
|
 | 3111 | + d3d7dev = NULL;
|
 | 3112 | + }
|
 | 3113 | + if (ddsrender)
|
 | 3114 | + {
|
 | 3115 | + ddsrender->Release();
|
 | 3116 | + ddsrender = NULL;
|
 | 3117 | + }
|
 | 3118 | + if (ddsurface)
|
 | 3119 | + {
|
 | 3120 | + ddsurface->Release();
|
 | 3121 | + ddsurface = NULL;
|
 | 3122 | + }
|
 | 3123 | + if (zbuffer)
|
 | 3124 | + {
|
 | 3125 | + zbuffer->Release();
|
 | 3126 | + zbuffer = NULL;
|
 | 3127 | + }
|
 | 3128 | + if (ddclipper)
|
 | 3129 | + {
|
 | 3130 | + ddclipper->Release();
|
 | 3131 | + ddclipper = NULL;
|
 | 3132 | + }
|
 | 3133 | + if (ddinterface)
|
 | 3134 | + {
|
 | 3135 | + ddinterface->Release();
|
 | 3136 | + ddinterface = NULL;
|
 | 3137 | + }
|
 | 3138 | + if (mesh)
|
 | 3139 | + {
|
 | 3140 | + free(mesh);
|
 | 3141 | + mesh = NULL;
|
 | 3142 | + }
|
 | 3143 | + if (vertices)
|
 | 3144 | + {
|
 | 3145 | + free(vertices);
|
 | 3146 | + vertices = NULL;
|
 | 3147 | + }
|
 | 3148 | + if (litvertices)
|
 | 3149 | + {
|
 | 3150 | + free(litvertices);
|
 | 3151 | + litvertices = NULL;
|
 | 3152 | + }
|
 | 3153 | + if (colorvertices)
|
 | 3154 | + {
|
 | 3155 | + free(colorvertices);
|
 | 3156 | + colorvertices = NULL;
|
 | 3157 | + }
|
 | 3158 | + EndDialog(hWnd, IDCANCEL);
|
 | 3159 | + break;
|
 | 3160 | + case WM_APP:
|
 | 3161 | + RunTestTimed(testnum);
|
 | 3162 | + break;
|
 | 3163 | + default:
|
 | 3164 | + return FALSE;
|
 | 3165 | + }
|
 | 3166 | + return TRUE;
|
 | 3167 | +}
|
 | 3168 | +
|
 | 3169 | +/*
|
 | 3170 | +void DDFlipTestWindow::OnQueryNewPalette(wxQueryNewPaletteEvent& event)
|
 | 3171 | +{
|
 | 3172 | + //if(bpp == 8) ddsurface->SetPalette
|
 | 3173 | +}
|
 | 3174 | +*/ |
\ No newline at end of file |
Index: dxgltest/tests.h |
— | — | @@ -33,10 +33,7 @@ |
34 | 34 | RECT rect;
|
35 | 35 | } DDSPRITE;
|
36 | 36 |
|
37 | Â | -void RunTest2D(int testnum, int width, int height, int bpp, int refresh, int backbuffers, int apiver,
|
38 | Â | - double fps, bool fullscreen, bool resizable);
|
 | 37 | +void RunDXGLTest(int testnum, int width, int height, int bpp, int refresh, int backbuffers, int apiver,
|
 | 38 | + int filter, int msaa, double fps, bool fullscreen, bool resizable, BOOL is3d);
|
39 | 39 |
|
40 | Â | -void RunTest3D(int testnum, int width, int height, int bpp, int refresh, int backbuffers, int apiver,
|
41 | Â | - int filter, int msaa, double fps, bool fullscreen, bool resizable);
|
42 | Â | -
|
43 | 40 | #endif //_TESTS_H
|