Index: ddraw/ddraw.vcxproj |
— | — | @@ -157,6 +157,7 @@ |
158 | 158 | </ItemDefinitionGroup>
|
159 | 159 | <ItemGroup>
|
160 | 160 | <None Include="ddraw.def" />
|
| 161 | + <None Include="include\d3dvec.inl" />
|
161 | 162 | </ItemGroup>
|
162 | 163 | <ItemGroup>
|
163 | 164 | <ClInclude Include="common.h" />
|
Index: ddraw/ddraw.vcxproj.filters |
— | — | @@ -24,6 +24,9 @@ |
25 | 25 | <None Include="ddraw.def">
|
26 | 26 | <Filter>Source Files</Filter>
|
27 | 27 | </None>
|
| 28 | + <None Include="include\d3dvec.inl">
|
| 29 | + <Filter>Header Files\include</Filter>
|
| 30 | + </None>
|
28 | 31 | </ItemGroup>
|
29 | 32 | <ItemGroup>
|
30 | 33 | <ClInclude Include="ddraw.h">
|
Index: ddraw/include/d3d.h |
— | — | @@ -18,6 +18,7 @@ |
19 | 19 | |
20 | 20 | #ifndef __WINE_D3D_H |
21 | 21 | #define __WINE_D3D_H |
| 22 | +#include "winedef.h" |
22 | 23 | |
23 | 24 | #include <stdlib.h> |
24 | 25 | |
Index: ddraw/include/d3dtypes.h |
— | — | @@ -326,24 +326,48 @@ |
327 | 327 | #endif |
328 | 328 | } D3DVERTEX, *LPD3DVERTEX; |
329 | 329 | |
| 330 | +#ifdef _MSC_VER |
330 | 331 | typedef struct _D3DMATRIX { |
| 332 | + union{ |
| 333 | + struct{ |
331 | 334 | D3DVALUE _11, _12, _13, _14; |
332 | 335 | D3DVALUE _21, _22, _23, _24; |
333 | 336 | D3DVALUE _31, _32, _33, _34; |
334 | 337 | D3DVALUE _41, _42, _43, _44; |
| 338 | + }; |
| 339 | + D3DVALUE m[4][4]; |
| 340 | + }; |
335 | 341 | #if defined(__cplusplus) && defined(D3D_OVERLOADS) |
336 | 342 | _D3DMATRIX() { } |
337 | 343 | |
338 | | - /* This is different from MS, but avoids anonymous structs. */ |
339 | 344 | D3DVALUE &operator () (int r, int c) |
340 | | - { return ((D3DVALUE [4][4])&_11)[r][c]; } |
| 345 | + { return m[r][c]; } |
341 | 346 | const D3DVALUE &operator() (int r, int c) const |
342 | | - { return ((const D3DVALUE [4][4])&_11)[r][c]; } |
| 347 | + { return m[r][c]; } |
343 | 348 | #endif |
344 | 349 | } D3DMATRIX, *LPD3DMATRIX; |
345 | 350 | |
| 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 | + |
346 | 370 | #if defined(__cplusplus) && defined(D3D_OVERLOADS) |
347 | | -#include <d3dvec.inl> |
| 371 | +#include "d3dvec.inl" |
348 | 372 | #endif |
349 | 373 | |
350 | 374 | 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.
|
21 | 6 | */
|
22 | 7 |
|
23 | | -
|
24 | | -
|
25 | 8 | #pragma once
|
26 | 9 | #ifndef _WINEDEF_H
|
27 | 10 | #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 */
|
28 | 31 |
|
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
|
32 | 35 | # else
|
33 | | -# define WINELIB_NAME_AW(func) func##A
|
| 36 | +# define DUMMYSTRUCTNAME
|
34 | 37 | # endif
|
| 38 | +#endif
|
35 | 39 |
|
| 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 | +
|
36 | 64 | #endif //_WINEDEF_H
|
Index: dxgltest/MultiDD.cpp |
— | — | @@ -187,8 +187,26 @@ |
188 | 188 | return DDERR_GENERIC;
|
189 | 189 | }
|
190 | 190 | }
|
| 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 | +}
|
191 | 208 |
|
192 | 209 |
|
| 210 | +
|
193 | 211 | MultiDirectDrawSurface::MultiDirectDrawSurface(int version, LPVOID surface)
|
194 | 212 | {
|
195 | 213 | dds1 = NULL;
|
— | — | @@ -606,4 +624,42 @@ |
607 | 625 | default:
|
608 | 626 | return DDERR_GENERIC;
|
609 | 627 | }
|
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 @@ |
23 | 23 | #include "timer.h"
|
24 | 24 | #include "misc.h"
|
25 | 25 |
|
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);
|
30 | 30 |
|
31 | 31 |
|
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};
|
44 | 44 |
|
45 | 45 | typedef struct
|
46 | 46 | {
|
— | — | @@ -55,7 +55,7 @@ |
56 | 56 | RECT rect;
|
57 | 57 | } DDSPRITE;
|
58 | 58 |
|
59 | | -DDSPRITE sprites[16];
|
| 59 | +static DDSPRITE sprites[16];
|
60 | 60 |
|
61 | 61 | LRESULT CALLBACK DDWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
62 | 62 | {
|
— | — | @@ -104,7 +104,7 @@ |
105 | 105 | if(wParam == VK_ESCAPE) DestroyWindow(hWnd);
|
106 | 106 | break;
|
107 | 107 | case WM_APP:
|
108 | | - RunTestTimed(testnum);
|
| 108 | + RunTestTimed2D(testnum);
|
109 | 109 | break;
|
110 | 110 | case WM_SIZE:
|
111 | 111 | paintwnd = false;
|
— | — | @@ -137,7 +137,7 @@ |
138 | 138 | case WM_XBUTTONUP:
|
139 | 139 | case WM_XBUTTONDBLCLK:
|
140 | 140 | case WM_MOUSEHWHEEL:
|
141 | | - RunTestMouse(testnum,Msg,wParam,lParam);
|
| 141 | + RunTestMouse2D(testnum,Msg,wParam,lParam);
|
142 | 142 | if(!fullscreen)
|
143 | 143 | {
|
144 | 144 | p.x = 0;
|
— | — | @@ -155,10 +155,10 @@ |
156 | 156 | return FALSE;
|
157 | 157 | }
|
158 | 158 |
|
159 | | -int ddtestnum;
|
160 | | -int ddver;
|
| 159 | +static int ddtestnum;
|
| 160 | +static int ddver;
|
161 | 161 |
|
162 | | -void RunTestMouse(int test, UINT Msg, WPARAM wParam, LPARAM lParam)
|
| 162 | +void RunTestMouse2D(int test, UINT Msg, WPARAM wParam, LPARAM lParam)
|
163 | 163 | {
|
164 | 164 | DDSURFACEDESC2 ddsd;
|
165 | 165 | ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
— | — | @@ -385,7 +385,7 @@ |
386 | 386 | ddsrender->SetPalette(pal);
|
387 | 387 | }
|
388 | 388 | else pal = NULL;
|
389 | | - InitTest(testnum);
|
| 389 | + InitTest2D(testnum);
|
390 | 390 | if(!fullscreen) SendMessage(hWnd,WM_PAINT,0,0);
|
391 | 391 | if(testtypes[testnum] == 1)
|
392 | 392 | {
|
— | — | @@ -393,7 +393,7 @@ |
394 | 394 | {
|
395 | 395 | if(PeekMessage(&Msg,NULL,0,0,PM_REMOVE))
|
396 | 396 | {
|
397 | | - if(Msg.message == WM_PAINT) RunTestLooped(testnum);
|
| 397 | + if(Msg.message == WM_PAINT) RunTestLooped2D(testnum);
|
398 | 398 | else if(Msg.message == WM_QUIT) done = TRUE;
|
399 | 399 | else
|
400 | 400 | {
|
— | — | @@ -403,7 +403,7 @@ |
404 | 404 | }
|
405 | 405 | else
|
406 | 406 | {
|
407 | | - RunTestLooped(testnum);
|
| 407 | + RunTestLooped2D(testnum);
|
408 | 408 | }
|
409 | 409 | }
|
410 | 410 | }
|
— | — | @@ -429,7 +429,7 @@ |
430 | 430 | }
|
431 | 431 |
|
432 | 432 |
|
433 | | -void InitTest(int test)
|
| 433 | +void InitTest2D(int test)
|
434 | 434 | {
|
435 | 435 | DDSURFACEDESC2 ddsd;
|
436 | 436 | DDSCAPS2 ddscaps;
|
— | — | @@ -633,7 +633,7 @@ |
634 | 634 | }
|
635 | 635 | }
|
636 | 636 |
|
637 | | -void RunTestTimed(int test)
|
| 637 | +void RunTestTimed2D(int test)
|
638 | 638 | {
|
639 | 639 | DDSCAPS2 ddscaps;
|
640 | 640 | ZeroMemory(&ddscaps,sizeof(DDSCAPS2));
|
— | — | @@ -670,7 +670,7 @@ |
671 | 671 | }
|
672 | 672 | }
|
673 | 673 |
|
674 | | -void RunTestLooped(int test)
|
| 674 | +void RunTestLooped2D(int test)
|
675 | 675 | {
|
676 | 676 | randnum += rand(); // Improves randomness of "snow" patterns at certain resolutions
|
677 | 677 | HDC hdc;
|
Index: dxgltest/Tests3D.cpp |
— | — | @@ -18,10 +18,300 @@ |
19 | 19 | #include "common.h"
|
20 | 20 | #include "tests.h"
|
21 | 21 | #include "surfacegen.h"
|
| 22 | +#include "MultiDD.h"
|
22 | 23 | #include "timer.h"
|
23 | 24 | #include "misc.h"
|
| 25 | +#define D3D_OVERLOADS
|
| 26 | +#include "../ddraw/include/d3d.h"
|
24 | 27 |
|
| 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);
|
25 | 32 |
|
| 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 | +
|
26 | 149 | void RunTest3D(int testnum, int width, int height, int bpp, int refresh, int backbuffers, int apiver,
|
27 | 150 | 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 @@ |
605 | 605 | api3d = 2;
|
606 | 606 | break;
|
607 | 607 | case 4:
|
608 | | - api3d = 3;
|
| 608 | + api3d = 7;
|
609 | 609 | break;
|
610 | 610 | case 7:
|
611 | 611 | case 6:
|
612 | 612 | case 5:
|
613 | | - api3d = 4;
|
| 613 | + api3d = 3;
|
614 | 614 | }
|
615 | 615 | }
|
616 | 616 | else
|
— | — | @@ -624,7 +624,7 @@ |
625 | 625 | api3d = 3;
|
626 | 626 | break;
|
627 | 627 | case 3:
|
628 | | - api3d = 4;
|
| 628 | + api3d = 7;
|
629 | 629 | break;
|
630 | 630 | case 4:
|
631 | 631 | case 5:
|