ReactOS 0.4.17-dev-966-gf06eace
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#define COBJMACROS
20#include "wine/test.h"
21#include "d3dx9.h"
22
23#define admitted_error 0.0001f
24
25#define relative_error(exp, out) ((exp == 0.0f) ? fabs(exp - out) : (fabs(1.0f - out/ exp) ))
26
27static inline BOOL compare_matrix(const D3DXMATRIX *m1, const D3DXMATRIX *m2)
28{
29 int i, j;
30
31 for (i = 0; i < 4; ++i)
32 {
33 for (j = 0; j < 4; ++j)
34 {
35 if (relative_error(m1->m[i][j], m2->m[i][j]) > admitted_error)
36 return FALSE;
37 }
38 }
39
40 return TRUE;
41}
42
43#define expect_mat(expectedmat, gotmat) \
44do { \
45 const D3DXMATRIX *__m1 = (expectedmat); \
46 const D3DXMATRIX *__m2 = (gotmat); \
47 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" \
48 "Got matrix=\n(%f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f)\n", \
49 __m1->m[0][0], __m1->m[0][1], __m1->m[0][2], __m1->m[0][3], \
50 __m1->m[1][0], __m1->m[1][1], __m1->m[1][2], __m1->m[1][3], \
51 __m1->m[2][0], __m1->m[2][1], __m1->m[2][2], __m1->m[2][3], \
52 __m1->m[3][0], __m1->m[3][1], __m1->m[3][2], __m1->m[3][3], \
53 __m2->m[0][0], __m2->m[0][1], __m2->m[0][2], __m2->m[0][3], \
54 __m2->m[1][0], __m2->m[1][1], __m2->m[1][2], __m2->m[1][3], \
55 __m2->m[2][0], __m2->m[2][1], __m2->m[2][2], __m2->m[2][3], \
56 __m2->m[3][0], __m2->m[3][1], __m2->m[3][2], __m2->m[3][3]); \
57} while(0)
58
60{
61 HRESULT hr;
62 ID3DXLine *line = NULL;
63 struct IDirect3DDevice9 *return_device;
65 FLOAT r11, r12, r13, r14;
66 ULONG ref;
67
68 /* Arbitrary values for matrix tests. */
69 r11 = 0.1421; r12 = 0.2114; r13 = 0.8027; r14 = 0.4587;
70
72 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
73
75 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
76
78 ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n", hr);
79
80 if (FAILED(hr))
81 {
82 return;
83 }
84
86 ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
87
88 hr = ID3DXLine_GetDevice(line, &return_device);
89 ok(hr == D3D_OK, "Got result %lx, expected %lx (D3D_OK)\n", hr, D3D_OK);
90 ok(return_device == device, "Expected line device %p, got %p\n", device, return_device);
91
92 D3DXMatrixIdentity(&world);
93 D3DXMatrixIdentity(&identity);
94 world._11 = r11; world._12 = r12; world._13 = r13; world._14 = r14;
95
97 ok(hr == D3D_OK, "Got result %lx, expected %lx (D3D_OK)\n", hr, D3D_OK);
98
100 ok(hr == D3D_OK, "Got result %lx, expected %lx (D3D_OK)\n", hr, D3D_OK);
101
103 ok(hr == D3D_OK, "Got result %lx, expected %lx (D3D_OK)\n", hr, D3D_OK);
105
107 ok(hr == D3D_OK, "Got result %lx, expected %lx (D3D_OK)\n", hr, D3D_OK);
108
110 ok(hr == D3D_OK, "Got result %lx, expected %lx (D3D_OK)\n", hr, D3D_OK);
111 expect_mat(&world, &result);
112
113 IDirect3DDevice9_Release(return_device);
114
116 ok(ref == 0, "Got %lx references to line %p, expected 0\n", ref, line);
117}
118
120{
121 ID3DXLine *line = NULL;
122 ULONG refcount;
123 float width;
124 HRESULT hr;
125
127 ok(hr == D3D_OK, "Failed to create a line, hr %#lx.\n", hr);
128
130 ok(width == 1.0f, "Unexpected line width %.8e.\n", width);
131
132 hr = ID3DXLine_SetWidth(line, 0.0f);
133 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
135 ok(width == 1.0f, "Unexpected line width %.8e.\n", width);
136
137 hr = ID3DXLine_SetWidth(line, -1.0f);
138 ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
140 ok(width == 1.0f, "Unexpected line width %.8e.\n", width);
141
142 hr = ID3DXLine_SetWidth(line, 10.0f);
143 ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
145 ok(width == 10.0f, "Unexpected line width %.8e.\n", width);
146
147 refcount = ID3DXLine_Release(line);
148 ok(!refcount, "Got %lu references to line.\n", refcount);
149}
150
152{
153 HWND wnd;
154 IDirect3D9* d3d;
157 HRESULT hr;
158
159 if (!(wnd = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0,
160 640, 480, NULL, NULL, NULL, NULL)))
161 {
162 skip("Couldn't create application window\n");
163 return;
164 }
165 if (!(d3d = Direct3DCreate9(D3D_SDK_VERSION)))
166 {
167 skip("Couldn't create IDirect3D9 object\n");
168 DestroyWindow(wnd);
169 return;
170 }
171
172 ZeroMemory(&d3dpp, sizeof(d3dpp));
173 d3dpp.Windowed = TRUE;
176 if (FAILED(hr)) {
177 skip("Failed to create IDirect3DDevice9 object %#lx\n", hr);
179 DestroyWindow(wnd);
180 return;
181 }
182
185
188 DestroyWindow(wnd);
189}
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define D3DERR_INVALIDCALL
Definition: d3d10_private.h:42
@ 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:224
#define IDirect3DDevice9_SetTransform(p, a, b)
Definition: d3d9.h:1379
#define IDirect3D9_Release(p)
Definition: d3d9.h:209
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1336
#define IDirect3DDevice9_GetTransform(p, a, b)
Definition: d3d9.h:1380
#define D3D_OK
Definition: d3d.h:106
HRESULT hr
Definition: delayimp.cpp:582
#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:303
#define ID3DXLine_End(p)
Definition: d3dx9core.h:262
#define ID3DXLine_GetWidth(p)
Definition: d3dx9core.h:257
#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 ID3DXLine_SetWidth(p, a)
Definition: d3dx9core.h:256
DWORD IDirect3DDevice9
Definition: dxva2api.idl:22
unsigned int BOOL
Definition: ntddk_ex.h:94
GLint GLint GLsizei width
Definition: gl.h:1546
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 ZeroMemory
Definition: minwinbase.h:31
#define expect_mat(expectedmat, gotmat)
Definition: line.c:43
#define relative_error(exp, out)
Definition: line.c:25
static void test_create_line(IDirect3DDevice9 *device)
Definition: line.c:59
static BOOL compare_matrix(const D3DXMATRIX *m1, const D3DXMATRIX *m2)
Definition: line.c:27
#define admitted_error
Definition: line.c:23
static void test_line_width(IDirect3DDevice9 *device)
Definition: line.c:119
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4469
BOOL WINAPI DestroyWindow(_In_ HWND)
#define D3DADAPTER_DEFAULT
Definition: d3d8.h:53
#define D3D_SDK_VERSION
Definition: d3d8.h:52
#define D3DCREATE_SOFTWARE_VERTEXPROCESSING
Definition: d3d8.h:40
float _13
Definition: d3d8types.h:1111
float _14
Definition: d3d8types.h:1111
float _11
Definition: d3d8types.h:1111
float m[4][4]
Definition: d3d8types.h:1116
float _12
Definition: d3d8types.h:1111
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