ReactOS 0.4.15-dev-7924-g5949c20
line.c
Go to the documentation of this file.
1/*
2 * Copyright 2010 Christian Costa
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#include "wine/test.h"
20#include "d3dx9.h"
21
22#define admitted_error 0.0001f
23
24#define relative_error(exp, out) ((exp == 0.0f) ? fabs(exp - out) : (fabs(1.0f - out/ exp) ))
25
26static inline BOOL compare_matrix(const D3DXMATRIX *m1, const D3DXMATRIX *m2)
27{
28 int i, j;
29
30 for (i = 0; i < 4; ++i)
31 {
32 for (j = 0; j < 4; ++j)
33 {
34 if (relative_error(U(*m1).m[i][j], U(*m2).m[i][j]) > admitted_error)
35 return FALSE;
36 }
37 }
38
39 return TRUE;
40}
41
42#define expect_mat(expectedmat, gotmat) \
43do { \
44 const D3DXMATRIX *__m1 = (expectedmat); \
45 const D3DXMATRIX *__m2 = (gotmat); \
46 ok(compare_matrix(__m1, __m2), "Expected matrix=\n(%f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n)\n\n" \
47 "Got matrix=\n(%f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f)\n", \
48 U(*__m1).m[0][0], U(*__m1).m[0][1], U(*__m1).m[0][2], U(*__m1).m[0][3], \
49 U(*__m1).m[1][0], U(*__m1).m[1][1], U(*__m1).m[1][2], U(*__m1).m[1][3], \
50 U(*__m1).m[2][0], U(*__m1).m[2][1], U(*__m1).m[2][2], U(*__m1).m[2][3], \
51 U(*__m1).m[3][0], U(*__m1).m[3][1], U(*__m1).m[3][2], U(*__m1).m[3][3], \
52 U(*__m2).m[0][0], U(*__m2).m[0][1], U(*__m2).m[0][2], U(*__m2).m[0][3], \
53 U(*__m2).m[1][0], U(*__m2).m[1][1], U(*__m2).m[1][2], U(*__m2).m[1][3], \
54 U(*__m2).m[2][0], U(*__m2).m[2][1], U(*__m2).m[2][2], U(*__m2).m[2][3], \
55 U(*__m2).m[3][0], U(*__m2).m[3][1], U(*__m2).m[3][2], U(*__m2).m[3][3]); \
56} while(0)
57
58static void test_create_line(IDirect3DDevice9* device)
59{
60 HRESULT hr;
61 ID3DXLine *line = NULL;
62 struct IDirect3DDevice9 *return_device;
64 FLOAT r11, r12, r13, r14;
65 ULONG ref;
66
67 /* Arbitrary values for matrix tests. */
68 r11 = 0.1421; r12 = 0.2114; r13 = 0.8027; r14 = 0.4587;
69
71 ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
72
74 ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
75
77 ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
78
79 if (FAILED(hr))
80 {
81 return;
82 }
83
85 ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
86
87 hr = ID3DXLine_GetDevice(line, &return_device);
88 ok(hr == D3D_OK, "Got result %x, expected %x (D3D_OK)\n", hr, D3D_OK);
89 ok(return_device == device, "Expected line device %p, got %p\n", device, return_device);
90
91 D3DXMatrixIdentity(&world);
92 D3DXMatrixIdentity(&identity);
93 S(U(world))._11 = r11; S(U(world))._12 = r12; S(U(world))._13 = r13; S(U(world))._14 = r14;
94
96 ok(hr == D3D_OK, "Got result %x, expected %x (D3D_OK)\n", hr, D3D_OK);
97
99 ok(hr == D3D_OK, "Got result %x, expected %x (D3D_OK)\n", hr, D3D_OK);
100
102 ok(hr == D3D_OK, "Got result %x, expected %x (D3D_OK)\n", hr, D3D_OK);
104
106 ok(hr == D3D_OK, "Got result %x, expected %x (D3D_OK)\n", hr, D3D_OK);
107
109 ok(hr == D3D_OK, "Got result %x, expected %x (D3D_OK)\n", hr, D3D_OK);
110 expect_mat(&world, &result);
111
112 IDirect3DDevice9_Release(return_device);
113
115 ok(ref == 0, "Got %x references to line %p, expected 0\n", ref, line);
116}
117
119{
120 HWND wnd;
121 IDirect3D9* d3d;
122 IDirect3DDevice9* device;
124 HRESULT hr;
125
126 if (!(wnd = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0,
127 640, 480, NULL, NULL, NULL, NULL)))
128 {
129 skip("Couldn't create application window\n");
130 return;
131 }
132 if (!(d3d = Direct3DCreate9(D3D_SDK_VERSION)))
133 {
134 skip("Couldn't create IDirect3D9 object\n");
135 DestroyWindow(wnd);
136 return;
137 }
138
139 ZeroMemory(&d3dpp, sizeof(d3dpp));
140 d3dpp.Windowed = TRUE;
143 if (FAILED(hr)) {
144 skip("Failed to create IDirect3DDevice9 object %#x\n", hr);
146 DestroyWindow(wnd);
147 return;
148 }
149
151
154 DestroyWindow(wnd);
155}
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define U(x)
Definition: wordpad.c:45
@ D3DSWAPEFFECT_DISCARD
Definition: d3d8types.h:851
@ D3DDEVTYPE_HAL
Definition: d3d8types.h:576
#define D3DTS_WORLD
Definition: d3d8types.h:85
IDirect3D9 *WINAPI Direct3DCreate9(UINT SDKVersion)
Definition: d3d9.c:57
#define IDirect3D9_CreateDevice(p, a, b, c, d, e, f)
Definition: d3d9.h:235
#define IDirect3DDevice9_SetTransform(p, a, b)
Definition: d3d9.h:1551
#define IDirect3D9_Release(p)
Definition: d3d9.h:220
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1508
#define IDirect3DDevice9_GetTransform(p, a, b)
Definition: d3d9.h:1552
#define D3D_OK
Definition: d3d.h:106
#define D3DERR_INVALIDCALL
#define ID3DXLine_End(p)
Definition: d3dx9core.h:262
#define ID3DXLine_Release(p)
Definition: d3dx9core.h:246
#define ID3DXLine_Begin(p)
Definition: d3dx9core.h:249
#define ID3DXLine_GetDevice(p, a)
Definition: d3dx9core.h:248
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HRESULT WINAPI D3DXCreateLine(struct IDirect3DDevice9 *device, struct ID3DXLine **line)
Definition: line.c:297
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint64EXT * result
Definition: glext.h:11304
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define FAILED(hr)
Definition: intsafe.h:51
#define expect_mat(expectedmat, gotmat)
Definition: line.c:42
#define relative_error(exp, out)
Definition: line.c:24
static void test_create_line(IDirect3DDevice9 *device)
Definition: line.c:58
static BOOL compare_matrix(const D3DXMATRIX *m1, const D3DXMATRIX *m2)
Definition: line.c:26
#define admitted_error
Definition: line.c:22
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define D3DADAPTER_DEFAULT
Definition: d3d8.h:57
#define D3D_SDK_VERSION
Definition: d3d8.h:56
#define D3DCREATE_SOFTWARE_VERTEXPROCESSING
Definition: d3d8.h:44
#define S(x)
Definition: test.h:217
HRESULT hr
Definition: shlfolder.c:183
D3DSWAPEFFECT SwapEffect
Definition: d3d8types.h:1128
Definition: devices.h:37
Definition: parser.c:49
Definition: send.c:48
float FLOAT
Definition: typedefs.h:69
uint32_t ULONG
Definition: typedefs.h:59
#define ZeroMemory
Definition: winbase.h:1712
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4315
BOOL WINAPI DestroyWindow(_In_ HWND)