DXGL r54 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r53‎ | r54 | r55 >
Date:18:10, 28 December 2011
Author:admin
Status:new
Tags:
Comment:
Begin adding D3D test initialization code
Fix D3D headers compilation under MSVC
add Wine d3dvec.inl file
Modified paths:
  • /ddraw/ddraw.vcxproj (modified) (history)
  • /ddraw/ddraw.vcxproj.filters (modified) (history)
  • /ddraw/include/d3d.h (modified) (history)
  • /ddraw/include/d3dtypes.h (modified) (history)
  • /ddraw/include/d3dvec.inl (added) (history)
  • /ddraw/include/winedef.h (modified) (history)
  • /dxgltest/MultiDD.cpp (modified) (history)
  • /dxgltest/Tests2D.cpp (modified) (history)
  • /dxgltest/Tests3D.cpp (modified) (history)
  • /dxgltest/dxgltest.cpp (modified) (history)

Diff [purge]

Index: ddraw/ddraw.vcxproj
@@ -157,6 +157,7 @@
158158 </ItemDefinitionGroup>
159159 <ItemGroup>
160160 <None Include="ddraw.def" />
 161+ <None Include="include\d3dvec.inl" />
161162 </ItemGroup>
162163 <ItemGroup>
163164 <ClInclude Include="common.h" />
Index: ddraw/ddraw.vcxproj.filters
@@ -24,6 +24,9 @@
2525 <None Include="ddraw.def">
2626 <Filter>Source Files</Filter>
2727 </None>
 28+ <None Include="include\d3dvec.inl">
 29+ <Filter>Header Files\include</Filter>
 30+ </None>
2831 </ItemGroup>
2932 <ItemGroup>
3033 <ClInclude Include="ddraw.h">
Index: ddraw/include/d3d.h
@@ -18,6 +18,7 @@
1919
2020 #ifndef __WINE_D3D_H
2121 #define __WINE_D3D_H
 22+#include "winedef.h"
2223
2324 #include <stdlib.h>
2425
Index: ddraw/include/d3dtypes.h
@@ -326,24 +326,48 @@
327327 #endif
328328 } D3DVERTEX, *LPD3DVERTEX;
329329
 330+#ifdef _MSC_VER
330331 typedef struct _D3DMATRIX {
 332+ union{
 333+ struct{
331334 D3DVALUE _11, _12, _13, _14;
332335 D3DVALUE _21, _22, _23, _24;
333336 D3DVALUE _31, _32, _33, _34;
334337 D3DVALUE _41, _42, _43, _44;
 338+ };
 339+ D3DVALUE m[4][4];
 340+ };
335341 #if defined(__cplusplus) && defined(D3D_OVERLOADS)
336342 _D3DMATRIX() { }
337343
338 - /* This is different from MS, but avoids anonymous structs. */
339344 D3DVALUE &operator () (int r, int c)
340 - { return ((D3DVALUE [4][4])&_11)[r][c]; }
 345+ { return m[r][c]; }
341346 const D3DVALUE &operator() (int r, int c) const
342 - { return ((const D3DVALUE [4][4])&_11)[r][c]; }
 347+ { return m[r][c]; }
343348 #endif
344349 } D3DMATRIX, *LPD3DMATRIX;
345350
 351+#else
 352+typedef struct _D3DMATRIX {
 353+ D3DVALUE _11, _12, _13, _14;
 354+ D3DVALUE _21, _22, _23, _24;
 355+ D3DVALUE _31, _32, _33, _34;
 356+ D3DVALUE _41, _42, _43, _44;
 357+#if defined(__cplusplus) && defined(D3D_OVERLOADS)
 358+ _D3DMATRIX() { }
 359+
 360+ /* This is different from MS, but avoids anonymous structs. */
 361+ D3DVALUE &operator () (int r, int c)
 362+ { return (&_11)[r*4 + c]; }
 363+ const D3DVALUE &operator() (int r, int c) const
 364+ { return (&_11)[r*4 + c]; }
 365+#endif
 366+} D3DMATRIX, *LPD3DMATRIX;
 367+
 368+#endif
 369+
346370 #if defined(__cplusplus) && defined(D3D_OVERLOADS)
347 -#include <d3dvec.inl>
 371+#include "d3dvec.inl"
348372 #endif
349373
350374 typedef struct _D3DVIEWPORT {
Index: ddraw/include/d3dvec.inl
@@ -0,0 +1,143 @@
 2+/*
 3+ * Copyright (C) 2000 Ove Kaaven
 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 St, Fifth Floor, Boston, MA 02110-1301, USA
 18+ */
 19+
 20+#ifndef __WINE_D3DVEC_INL
 21+#define __WINE_D3DVEC_INL
 22+
 23+#include <math.h>
 24+
 25+/*** constructors ***/
 26+
 27+inline _D3DVECTOR::_D3DVECTOR(D3DVALUE f)
 28+{
 29+ x = y = z = f;
 30+}
 31+
 32+inline _D3DVECTOR::_D3DVECTOR(D3DVALUE _x, D3DVALUE _y, D3DVALUE _z)
 33+{
 34+ x = _x; y = _y; z = _z;
 35+}
 36+
 37+/*** assignment operators ***/
 38+
 39+inline _D3DVECTOR& _D3DVECTOR::operator += (const _D3DVECTOR& v)
 40+{
 41+ x += v.x; y += v.y; z += v.z;
 42+ return *this;
 43+}
 44+
 45+inline _D3DVECTOR& _D3DVECTOR::operator -= (const _D3DVECTOR& v)
 46+{
 47+ x -= v.x; y -= v.y; z -= v.z;
 48+ return *this;
 49+}
 50+
 51+inline _D3DVECTOR& _D3DVECTOR::operator *= (const _D3DVECTOR& v)
 52+{
 53+ x *= v.x; y *= v.y; z *= v.z;
 54+ return *this;
 55+}
 56+
 57+inline _D3DVECTOR& _D3DVECTOR::operator /= (const _D3DVECTOR& v)
 58+{
 59+ x /= v.x; y /= v.y; z /= v.z;
 60+ return *this;
 61+}
 62+
 63+inline _D3DVECTOR& _D3DVECTOR::operator *= (D3DVALUE s)
 64+{
 65+ x *= s; y *= s; z *= s;
 66+ return *this;
 67+}
 68+
 69+inline _D3DVECTOR& _D3DVECTOR::operator /= (D3DVALUE s)
 70+{
 71+ x /= s; y /= s; z /= s;
 72+ return *this;
 73+}
 74+
 75+/*** unary operators ***/
 76+
 77+inline _D3DVECTOR operator + (const _D3DVECTOR& v)
 78+{
 79+ return v;
 80+}
 81+
 82+inline _D3DVECTOR operator - (const _D3DVECTOR& v)
 83+{
 84+ return _D3DVECTOR(-v.x, -v.y, -v.z);
 85+}
 86+
 87+/*** binary operators ***/
 88+
 89+inline _D3DVECTOR operator + (const _D3DVECTOR& v1, const _D3DVECTOR& v2)
 90+{
 91+ return _D3DVECTOR(v1.x+v2.x, v1.y+v2.y, v1.z+v2.z);
 92+}
 93+
 94+inline _D3DVECTOR operator - (const _D3DVECTOR& v1, const _D3DVECTOR& v2)
 95+{
 96+ return _D3DVECTOR(v1.x-v2.x, v1.y-v2.y, v1.z-v2.z);
 97+}
 98+
 99+inline _D3DVECTOR operator * (const _D3DVECTOR& v, D3DVALUE s)
 100+{
 101+ return _D3DVECTOR(v.x*s, v.y*s, v.z*s);
 102+}
 103+
 104+inline _D3DVECTOR operator * (D3DVALUE s, const _D3DVECTOR& v)
 105+{
 106+ return _D3DVECTOR(v.x*s, v.y*s, v.z*s);
 107+}
 108+
 109+inline _D3DVECTOR operator / (const _D3DVECTOR& v, D3DVALUE s)
 110+{
 111+ return _D3DVECTOR(v.x/s, v.y/s, v.z/s);
 112+}
 113+
 114+inline D3DVALUE SquareMagnitude(const _D3DVECTOR& v)
 115+{
 116+ return v.x*v.x + v.y*v.y + v.z*v.z; /* DotProduct(v, v) */
 117+}
 118+
 119+inline D3DVALUE Magnitude(const _D3DVECTOR& v)
 120+{
 121+ return sqrt(SquareMagnitude(v));
 122+}
 123+
 124+inline _D3DVECTOR Normalize(const _D3DVECTOR& v)
 125+{
 126+ return v / Magnitude(v);
 127+}
 128+
 129+inline D3DVALUE DotProduct(const _D3DVECTOR& v1, const _D3DVECTOR& v2)
 130+{
 131+ return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
 132+}
 133+
 134+inline _D3DVECTOR CrossProduct(const _D3DVECTOR& v1, const _D3DVECTOR& v2)
 135+{
 136+ _D3DVECTOR res;
 137+ /* this is a left-handed cross product, right? */
 138+ res.x = v1.y * v2.z - v1.z * v2.y;
 139+ res.y = v1.z * v2.x - v1.x * v2.z;
 140+ res.z = v1.x * v2.y - v1.y * v2.x;
 141+ return res;
 142+}
 143+
 144+#endif
Index: ddraw/include/winedef.h
@@ -1,35 +1,63 @@
2 -// Part of windef.h from Wine source code, subject to the following license:
3 -/*
4 - * Basic types definitions
5 - *
6 - * Copyright 1996 Alexandre Julliard
7 - *
8 - * This library is free software; you can redistribute it and/or
9 - * modify it under the terms of the GNU Lesser General Public
10 - * License as published by the Free Software Foundation; either
11 - * version 2.1 of the License, or (at your option) any later version.
12 - *
13 - * This library is distributed in the hope that it will be useful,
14 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 - * Lesser General Public License for more details.
17 - *
18 - * You should have received a copy of the GNU Lesser General Public
19 - * License along with this library; if not, write to the Free Software
20 - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 2+/**
 3+ * This file has no copyright assigned and is placed in the Public Domain.
 4+ * This file is part of the w64 mingw-runtime package.
 5+ * No warranty is given; refer to the file DISCLAIMER within this package.
216 */
227
23 -
24 -
258 #pragma once
269 #ifndef _WINEDEF_H
2710 #define _WINEDEF_H
 11+#ifndef DUMMYUNIONNAME1
 12+#define DUMMYUNIONNAME1 // fix MSVC
 13+#endif //DUMMYUNIONNAME1
 14+#ifndef DUMMYUNIONNAME
 15+# ifdef NONAMELESSUNION
 16+# define DUMMYUNIONNAME u
 17+# define DUMMYUNIONNAME1 u1
 18+# define DUMMYUNIONNAME2 u2
 19+# define DUMMYUNIONNAME3 u3
 20+# define DUMMYUNIONNAME4 u4
 21+# define DUMMYUNIONNAME5 u5
 22+# else /* NONAMELESSUNION */
 23+# define DUMMYUNIONNAME
 24+# define DUMMYUNIONNAME1
 25+# define DUMMYUNIONNAME2
 26+# define DUMMYUNIONNAME3
 27+# define DUMMYUNIONNAME4
 28+# define DUMMYUNIONNAME5
 29+# endif
 30+#endif /* DUMMYUNIONNAME */
2831
29 -# define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
30 -# ifdef UNICODE
31 -# define WINELIB_NAME_AW(func) func##W
 32+#ifndef DUMMYSTRUCTNAME
 33+# ifdef NONAMELESSSTRUCT
 34+# define DUMMYSTRUCTNAME s
3235 # else
33 -# define WINELIB_NAME_AW(func) func##A
 36+# define DUMMYSTRUCTNAME
3437 # endif
 38+#endif
3539
 40+
 41+/* These are for compatibility with the Wine source tree */
 42+
 43+#ifndef WINELIB_NAME_AW
 44+# ifdef __MINGW_NAME_AW
 45+# define WINELIB_NAME_AW __MINGW_NAME_AW
 46+# else
 47+# ifdef UNICODE
 48+# define WINELIB_NAME_AW(func) func##W
 49+# else
 50+# define WINELIB_NAME_AW(func) func##A
 51+# endif
 52+# endif
 53+#endif /* WINELIB_NAME_AW */
 54+
 55+#ifndef DECL_WINELIB_TYPE_AW
 56+# ifdef __MINGW_TYPEDEF_AW
 57+# define DECL_WINELIB_TYPE_AW __MINGW_TYPEDEF_AW
 58+# else
 59+# define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
 60+# endif
 61+#endif /* DECL_WINELIB_TYPE_AW */
 62+
 63+
3664 #endif //_WINEDEF_H
Index: dxgltest/MultiDD.cpp
@@ -187,8 +187,26 @@
188188 return DDERR_GENERIC;
189189 }
190190 }
 191+HRESULT MultiDirectDraw::QueryInterface(REFIID riid, void** ppvObj)
 192+{
 193+ switch(version)
 194+ {
 195+ case 1:
 196+ return dd1->QueryInterface(riid,ppvObj);
 197+ case 2:
 198+ case 3:
 199+ return dd2->QueryInterface(riid,ppvObj);
 200+ case 4:
 201+ return dd4->QueryInterface(riid,ppvObj);
 202+ case 7:
 203+ return dd7->QueryInterface(riid,ppvObj);
 204+ default:
 205+ return NULL;
 206+ }
 207+}
191208
192209
 210+
193211 MultiDirectDrawSurface::MultiDirectDrawSurface(int version, LPVOID surface)
194212 {
195213 dds1 = NULL;
@@ -606,4 +624,42 @@
607625 default:
608626 return DDERR_GENERIC;
609627 }
610 -}
\ No newline at end of file
 628+}
 629+
 630+LPVOID MultiDirectDrawSurface::GetSurface()
 631+{
 632+ switch(version)
 633+ {
 634+ case 1:
 635+ return dds1;
 636+ case 2:
 637+ return dds2;
 638+ case 3:
 639+ return dds3;
 640+ case 4:
 641+ return dds4;
 642+ case 7:
 643+ return dds7;
 644+ default:
 645+ return NULL;
 646+ }
 647+}
 648+
 649+HRESULT MultiDirectDrawSurface::QueryInterface(REFIID riid, void** ppvObj)
 650+{
 651+ switch(version)
 652+ {
 653+ case 1:
 654+ return dds1->QueryInterface(riid,ppvObj);
 655+ case 2:
 656+ return dds2->QueryInterface(riid,ppvObj);
 657+ case 3:
 658+ return dds3->QueryInterface(riid,ppvObj);
 659+ case 4:
 660+ return dds4->QueryInterface(riid,ppvObj);
 661+ case 7:
 662+ return dds7->QueryInterface(riid,ppvObj);
 663+ default:
 664+ return DDERR_GENERIC;
 665+ }
 666+}
Index: dxgltest/Tests2D.cpp
@@ -22,24 +22,24 @@
2323 #include "timer.h"
2424 #include "misc.h"
2525
26 -void InitTest(int test);
27 -void RunTestTimed(int test);
28 -void RunTestLooped(int test);
29 -void RunTestMouse(int test, UINT Msg, WPARAM wParam, LPARAM lParam);
 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);
3030
3131
32 -MultiDirectDraw *ddinterface;
33 -MultiDirectDrawSurface *ddsurface;
34 -MultiDirectDrawSurface *ddsrender;
35 -IDirectDrawPalette *pal;
36 -LPDIRECTDRAWCLIPPER ddclipper;
37 -int width,height,bpp,refresh,backbuffers;
38 -double fps;
39 -bool fullscreen,resizable;
40 -HWND hWnd;
41 -int testnum;
42 -unsigned int randnum;
43 -int testtypes[] = {0,1,0,1,0,1,2};
 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};
4444
4545 typedef struct
4646 {
@@ -55,7 +55,7 @@
5656 RECT rect;
5757 } DDSPRITE;
5858
59 -DDSPRITE sprites[16];
 59+static DDSPRITE sprites[16];
6060
6161 LRESULT CALLBACK DDWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
6262 {
@@ -104,7 +104,7 @@
105105 if(wParam == VK_ESCAPE) DestroyWindow(hWnd);
106106 break;
107107 case WM_APP:
108 - RunTestTimed(testnum);
 108+ RunTestTimed2D(testnum);
109109 break;
110110 case WM_SIZE:
111111 paintwnd = false;
@@ -137,7 +137,7 @@
138138 case WM_XBUTTONUP:
139139 case WM_XBUTTONDBLCLK:
140140 case WM_MOUSEHWHEEL:
141 - RunTestMouse(testnum,Msg,wParam,lParam);
 141+ RunTestMouse2D(testnum,Msg,wParam,lParam);
142142 if(!fullscreen)
143143 {
144144 p.x = 0;
@@ -155,10 +155,10 @@
156156 return FALSE;
157157 }
158158
159 -int ddtestnum;
160 -int ddver;
 159+static int ddtestnum;
 160+static int ddver;
161161
162 -void RunTestMouse(int test, UINT Msg, WPARAM wParam, LPARAM lParam)
 162+void RunTestMouse2D(int test, UINT Msg, WPARAM wParam, LPARAM lParam)
163163 {
164164 DDSURFACEDESC2 ddsd;
165165 ddsd.dwSize = sizeof(DDSURFACEDESC2);
@@ -385,7 +385,7 @@
386386 ddsrender->SetPalette(pal);
387387 }
388388 else pal = NULL;
389 - InitTest(testnum);
 389+ InitTest2D(testnum);
390390 if(!fullscreen) SendMessage(hWnd,WM_PAINT,0,0);
391391 if(testtypes[testnum] == 1)
392392 {
@@ -393,7 +393,7 @@
394394 {
395395 if(PeekMessage(&Msg,NULL,0,0,PM_REMOVE))
396396 {
397 - if(Msg.message == WM_PAINT) RunTestLooped(testnum);
 397+ if(Msg.message == WM_PAINT) RunTestLooped2D(testnum);
398398 else if(Msg.message == WM_QUIT) done = TRUE;
399399 else
400400 {
@@ -403,7 +403,7 @@
404404 }
405405 else
406406 {
407 - RunTestLooped(testnum);
 407+ RunTestLooped2D(testnum);
408408 }
409409 }
410410 }
@@ -429,7 +429,7 @@
430430 }
431431
432432
433 -void InitTest(int test)
 433+void InitTest2D(int test)
434434 {
435435 DDSURFACEDESC2 ddsd;
436436 DDSCAPS2 ddscaps;
@@ -633,7 +633,7 @@
634634 }
635635 }
636636
637 -void RunTestTimed(int test)
 637+void RunTestTimed2D(int test)
638638 {
639639 DDSCAPS2 ddscaps;
640640 ZeroMemory(&ddscaps,sizeof(DDSCAPS2));
@@ -670,7 +670,7 @@
671671 }
672672 }
673673
674 -void RunTestLooped(int test)
 674+void RunTestLooped2D(int test)
675675 {
676676 randnum += rand(); // Improves randomness of "snow" patterns at certain resolutions
677677 HDC hdc;
Index: dxgltest/Tests3D.cpp
@@ -18,10 +18,300 @@
1919 #include "common.h"
2020 #include "tests.h"
2121 #include "surfacegen.h"
 22+#include "MultiDD.h"
2223 #include "timer.h"
2324 #include "misc.h"
 25+#define D3D_OVERLOADS
 26+#include "../ddraw/include/d3d.h"
2427
 28+void InitTest3D(int test);
 29+void RunTestTimed3D(int test);
 30+void RunTestLooped3D(int test);
 31+void RunTestMouse3D(int test, UINT Msg, WPARAM wParam, LPARAM lParam);
2532
 33+
 34+static MultiDirectDraw *ddinterface;
 35+static MultiDirectDrawSurface *ddsurface;
 36+static MultiDirectDrawSurface *ddsrender;
 37+static IDirect3D7 *d3d7;
 38+static IDirect3DDevice7 *d3d7dev;
 39+static LPDIRECTDRAWCLIPPER ddclipper;
 40+static int width,height,bpp,refresh,backbuffers;
 41+static double fps;
 42+static bool fullscreen,resizable;
 43+static HWND hWnd;
 44+static int testnum;
 45+static unsigned int randnum;
 46+static int testtypes[] = {0};
 47+
 48+LRESULT CALLBACK D3DWndProc(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+ if(ddsrender)
 63+ {
 64+ ddsrender->Release();
 65+ ddsrender = NULL;
 66+ }
 67+ if(ddsurface)
 68+ {
 69+ ddsurface->Release();
 70+ ddsurface = NULL;
 71+ }
 72+ if(ddclipper)
 73+ {
 74+ ddclipper->Release();
 75+ ddclipper = NULL;
 76+ }
 77+ if(ddinterface)
 78+ {
 79+ ddinterface->Release();
 80+ ddinterface = NULL;
 81+ }
 82+ PostQuitMessage(0);
 83+ break;
 84+ case WM_KEYDOWN:
 85+ if(wParam == VK_ESCAPE) DestroyWindow(hWnd);
 86+ break;
 87+ case WM_APP:
 88+ RunTestTimed3D(testnum);
 89+ break;
 90+ case WM_SIZE:
 91+ paintwnd = false;
 92+ case WM_PAINT:
 93+ if(paintwnd) BeginPaint(hWnd,&paintstruct);
 94+ if(!fullscreen)
 95+ {
 96+ p.x = 0;
 97+ p.y = 0;
 98+ ClientToScreen(hWnd,&p);
 99+ GetClientRect(hWnd,&destrect);
 100+ OffsetRect(&destrect,p.x,p.y);
 101+ SetRect(&srcrect,0,0,width,height);
 102+ if(ddsurface && ddsrender)error = ddsurface->Blt(&destrect,ddsrender,&srcrect,DDBLT_WAIT,NULL);
 103+ }
 104+ if(paintwnd) EndPaint(hWnd,&paintstruct);
 105+ return 0;
 106+ case WM_MOUSEMOVE:
 107+ case WM_LBUTTONDOWN:
 108+ case WM_LBUTTONUP:
 109+ case WM_LBUTTONDBLCLK:
 110+ case WM_RBUTTONDOWN:
 111+ case WM_RBUTTONUP:
 112+ case WM_RBUTTONDBLCLK:
 113+ case WM_MBUTTONDOWN:
 114+ case WM_MBUTTONUP:
 115+ case WM_MBUTTONDBLCLK:
 116+ case WM_MOUSEWHEEL:
 117+ case WM_XBUTTONDOWN:
 118+ case WM_XBUTTONUP:
 119+ case WM_XBUTTONDBLCLK:
 120+ case WM_MOUSEHWHEEL:
 121+ RunTestMouse3D(testnum,Msg,wParam,lParam);
 122+ if(!fullscreen)
 123+ {
 124+ p.x = 0;
 125+ p.y = 0;
 126+ ClientToScreen(hWnd,&p);
 127+ GetClientRect(hWnd,&destrect);
 128+ OffsetRect(&destrect,p.x,p.y);
 129+ SetRect(&srcrect,0,0,width,height);
 130+ if(ddsurface && ddsrender)error = ddsurface->Blt(&destrect,ddsrender,&srcrect,DDBLT_WAIT,NULL);
 131+ }
 132+ break;
 133+ default:
 134+ return DefWindowProc(hWnd,Msg,wParam,lParam);
 135+ }
 136+ return FALSE;
 137+}
 138+
 139+static int d3dtestnum;
 140+static int d3dver;
 141+static int ddver;
 142+
 143+void RunTestMouse3D(int test, UINT Msg, WPARAM wParam, LPARAM lParam)
 144+{}
 145+
 146+const TCHAR wndclassname3d[] = _T("D3DTestWndClass");
 147+
 148+
26149 void RunTest3D(int testnum, int width, int height, int bpp, int refresh, int backbuffers, int apiver,
27150 int filter, int msaa, double fps, bool fullscreen, bool resizable)
28 -{}
\ No newline at end of file
 151+{
 152+ DDSURFACEDESC2 ddsd;
 153+ BOOL done = false;
 154+ ::testnum = testnum;
 155+ randnum = (unsigned int)time(NULL);
 156+ ZeroMemory(&ddsd,sizeof(DDSURFACEDESC2));
 157+ if(apiver >= 3) ddsd.dwSize = sizeof(DDSURFACEDESC2);
 158+ else ddsd.dwSize = sizeof(DDSURFACEDESC);
 159+ ::fullscreen = fullscreen;
 160+ ::resizable = resizable;
 161+ ::width = width;
 162+ ::height = height;
 163+ ::bpp = bpp;
 164+ ::refresh = refresh;
 165+ if(fullscreen)::backbuffers = backbuffers;
 166+ else ::backbuffers = backbuffers = 0;
 167+ ::fps = fps;
 168+ d3dtestnum = testnum;
 169+ d3dver = apiver;
 170+ if(apiver == 3) ddver = 4;
 171+ else ddver = apiver;
 172+ HINSTANCE hinstance = (HINSTANCE)GetModuleHandle(NULL);
 173+ WNDCLASSEX wc;
 174+ MSG Msg;
 175+ ZeroMemory(&wc,sizeof(WNDCLASS));
 176+ wc.cbSize = sizeof(WNDCLASSEX);
 177+ wc.style = CS_HREDRAW | CS_VREDRAW;
 178+ wc.lpfnWndProc = D3DWndProc;
 179+ wc.hInstance = hinstance;
 180+ wc.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(IDI_DXGL));
 181+ wc.hIconSm = LoadIcon(hinstance,MAKEINTRESOURCE(IDI_DXGLSM));
 182+ if(testnum == 6) wc.hCursor = LoadCursor(NULL,IDC_CROSS);
 183+ else wc.hCursor = LoadCursor(NULL,IDC_ARROW);
 184+ wc.hbrBackground = NULL;
 185+ wc.lpszClassName = wndclassname3d;
 186+ if(!RegisterClassEx(&wc))
 187+ {
 188+ MessageBox(NULL,_T("Can not register window class"),_T("Error"),MB_ICONEXCLAMATION|MB_OK);
 189+ return;
 190+ }
 191+ if(resizable)
 192+ hWnd = CreateWindowEx(WS_EX_APPWINDOW,wndclassname3d,_T("DDraw Test Window"),WS_OVERLAPPEDWINDOW,
 193+ CW_USEDEFAULT,CW_USEDEFAULT,width,height,NULL,NULL,hinstance,NULL);
 194+ else if(!fullscreen)
 195+ hWnd = CreateWindowEx(WS_EX_APPWINDOW,wndclassname3d,_T("DDraw Test Window"),WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX,
 196+ CW_USEDEFAULT,CW_USEDEFAULT,width,height,NULL,NULL,hinstance,NULL);
 197+ else hWnd = CreateWindowEx(WS_EX_TOPMOST,wndclassname3d,_T("DDraw Test Window"),WS_POPUP,0,0,
 198+ GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN),NULL,NULL,hinstance,NULL);
 199+
 200+ DWORD err = GetLastError();
 201+ ShowWindow(hWnd,SW_SHOWNORMAL);
 202+ UpdateWindow(hWnd);
 203+ RECT r1,r2;
 204+ POINT p1;
 205+ HRESULT error;
 206+ ddinterface = new MultiDirectDraw(ddver,&error,NULL);
 207+ if(fullscreen) error = ddinterface->SetCooperativeLevel(hWnd,DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN);
 208+ else error = ddinterface->SetCooperativeLevel(hWnd,DDSCL_NORMAL);
 209+ if(fullscreen) error = ddinterface->SetDisplayMode(width,height,bpp,refresh,0);
 210+ else
 211+ {
 212+ GetClientRect(hWnd,&r1);
 213+ GetWindowRect(hWnd,&r2);
 214+ p1.x = (r2.right - r2.left) - r1.right;
 215+ p1.y = (r2.bottom - r2.top) - r1.bottom;
 216+ MoveWindow(hWnd,r2.left,r2.top,width+p1.x,height+p1.y,TRUE);
 217+ }
 218+ ddsd.dwFlags = DDSD_CAPS;
 219+ ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 220+ if(fullscreen)
 221+ {
 222+ if(backbuffers)ddsd.dwFlags |= DDSD_BACKBUFFERCOUNT;
 223+ ddsd.dwBackBufferCount = backbuffers;
 224+ if(backbuffers) ddsd.ddsCaps.dwCaps |= DDSCAPS_FLIP | DDSCAPS_COMPLEX;
 225+ ddsd.ddsCaps.dwCaps |= DDSCAPS_3DDEVICE;
 226+ }
 227+ error = ddinterface->CreateSurface(&ddsd,&ddsurface,NULL);
 228+ if(!fullscreen)
 229+ {
 230+ error = ddinterface->CreateClipper(0,&ddclipper,NULL);
 231+ error = ddclipper->SetHWnd(0,hWnd);
 232+ error = ddsurface->SetClipper(ddclipper);
 233+ ZeroMemory(&ddsd,sizeof(ddsd));
 234+ if(apiver > 3) ddsd.dwSize = sizeof(DDSURFACEDESC2);
 235+ else ddsd.dwSize = sizeof(DDSURFACEDESC);
 236+ ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
 237+ ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN|DDSCAPS_3DDEVICE;
 238+ ddsd.dwWidth = width;
 239+ ddsd.dwHeight = height;
 240+ error = ddinterface->CreateSurface(&ddsd,&ddsrender,NULL);
 241+ }
 242+ else
 243+ {
 244+ ddsrender = ddsurface;
 245+ ddsrender->AddRef();
 246+ }
 247+ error = ddinterface->QueryInterface(IID_IDirect3D7,(VOID**)&d3d7);
 248+ error = d3d7->CreateDevice(IID_IDirect3DHALDevice,(LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(),&d3d7dev);
 249+ if(error != D3D_OK)
 250+ error = d3d7->CreateDevice(IID_IDirect3DRGBDevice,(LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(),&d3d7dev);
 251+ ddsrender->GetSurfaceDesc(&ddsd);
 252+ D3DVIEWPORT7 vp = {0,0,ddsd.dwWidth,ddsd.dwHeight,0.0f,1.0f};
 253+ error = d3d7dev->SetViewport(&vp);
 254+
 255+ InitTest3D(testnum);
 256+ if(!fullscreen) SendMessage(hWnd,WM_PAINT,0,0);
 257+ if(testtypes[testnum] == 1)
 258+ {
 259+ while(!done)
 260+ {
 261+ if(PeekMessage(&Msg,NULL,0,0,PM_REMOVE))
 262+ {
 263+ if(Msg.message == WM_PAINT) RunTestLooped3D(testnum);
 264+ else if(Msg.message == WM_QUIT) done = TRUE;
 265+ else
 266+ {
 267+ TranslateMessage(&Msg);
 268+ DispatchMessage(&Msg);
 269+ }
 270+ }
 271+ else
 272+ {
 273+ RunTestLooped3D(testnum);
 274+ }
 275+ }
 276+ }
 277+ else if(testtypes[testnum] == 0)
 278+ {
 279+ StartTimer(hWnd,WM_APP,fps);
 280+ while(GetMessage(&Msg, NULL, 0, 0) > 0)
 281+ {
 282+ TranslateMessage(&Msg);
 283+ DispatchMessage(&Msg);
 284+ }
 285+ }
 286+ else
 287+ {
 288+ while(GetMessage(&Msg, NULL, 0, 0) > 0)
 289+ {
 290+ TranslateMessage(&Msg);
 291+ DispatchMessage(&Msg);
 292+ }
 293+ }
 294+ UnregisterClass(wndclassname3d,hinstance);
 295+ StopTimer();
 296+}
 297+
 298+void InitTest3D(int test)
 299+{
 300+ D3DVECTOR p0,p1,p2,p3,p4,p5,p6,p7;
 301+ D3DVERTEX vertices[256];
 302+ switch(test)
 303+ {
 304+ case 0:
 305+ p0 = D3DVECTOR(0.0f,0.0f,0.0f);
 306+ break;
 307+ default:
 308+ break;
 309+ }
 310+}
 311+
 312+void RunTestTimed3D(int test)
 313+{
 314+}
 315+
 316+void RunTestLooped3D(int test)
 317+{
 318+}
Index: dxgltest/dxgltest.cpp
@@ -604,12 +604,12 @@
605605 api3d = 2;
606606 break;
607607 case 4:
608 - api3d = 3;
 608+ api3d = 7;
609609 break;
610610 case 7:
611611 case 6:
612612 case 5:
613 - api3d = 4;
 613+ api3d = 3;
614614 }
615615 }
616616 else
@@ -624,7 +624,7 @@
625625 api3d = 3;
626626 break;
627627 case 3:
628 - api3d = 4;
 628+ api3d = 7;
629629 break;
630630 case 4:
631631 case 5: