ReactOS 0.4.17-dev-966-gf06eace
line.c File Reference
#include "wine/test.h"
#include "d3dx9.h"
Include dependency graph for line.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 
#define admitted_error   0.0001f
 
#define relative_error(exp, out)   ((exp == 0.0f) ? fabs(exp - out) : (fabs(1.0f - out/ exp) ))
 
#define expect_mat(expectedmat, gotmat)
 

Functions

static BOOL compare_matrix (const D3DXMATRIX *m1, const D3DXMATRIX *m2)
 
static void test_create_line (IDirect3DDevice9 *device)
 
static void test_line_width (IDirect3DDevice9 *device)
 
 START_TEST (line)
 

Macro Definition Documentation

◆ admitted_error

#define admitted_error   0.0001f

Definition at line 23 of file line.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 19 of file line.c.

◆ expect_mat

#define expect_mat (   expectedmat,
  gotmat 
)
Value:
do { \
const D3DXMATRIX *__m1 = (expectedmat); \
const D3DXMATRIX *__m2 = (gotmat); \
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" \
"Got matrix=\n(%f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f)\n", \
__m1->m[0][0], __m1->m[0][1], __m1->m[0][2], __m1->m[0][3], \
__m1->m[1][0], __m1->m[1][1], __m1->m[1][2], __m1->m[1][3], \
__m1->m[2][0], __m1->m[2][1], __m1->m[2][2], __m1->m[2][3], \
__m1->m[3][0], __m1->m[3][1], __m1->m[3][2], __m1->m[3][3], \
__m2->m[0][0], __m2->m[0][1], __m2->m[0][2], __m2->m[0][3], \
__m2->m[1][0], __m2->m[1][1], __m2->m[1][2], __m2->m[1][3], \
__m2->m[2][0], __m2->m[2][1], __m2->m[2][2], __m2->m[2][3], \
__m2->m[3][0], __m2->m[3][1], __m2->m[3][2], __m2->m[3][3]); \
} while(0)
static BOOL compare_matrix(const D3DXMATRIX *m1, const D3DXMATRIX *m2)
Definition: line.c:27
float m[4][4]
Definition: d3d8types.h:1116

Definition at line 43 of file line.c.

◆ relative_error

#define relative_error (   exp,
  out 
)    ((exp == 0.0f) ? fabs(exp - out) : (fabs(1.0f - out/ exp) ))

Definition at line 25 of file line.c.

Function Documentation

◆ compare_matrix()

static BOOL compare_matrix ( const D3DXMATRIX *  m1,
const D3DXMATRIX *  m2 
)
inlinestatic

Definition at line 27 of file line.c.

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}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
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 relative_error(exp, out)
Definition: line.c:25
#define admitted_error
Definition: line.c:23

◆ START_TEST()

START_TEST ( line  )

Definition at line 151 of file line.c.

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 skip(...)
Definition: atltest.h:64
@ D3DSWAPEFFECT_DISCARD
Definition: d3d8types.h:851
@ D3DDEVTYPE_HAL
Definition: d3d8types.h:576
IDirect3D9 *WINAPI Direct3DCreate9(UINT SDKVersion)
Definition: d3d9.c:57
#define IDirect3D9_CreateDevice(p, a, b, c, d, e, f)
Definition: d3d9.h:224
#define IDirect3D9_Release(p)
Definition: d3d9.h:209
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1336
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
DWORD IDirect3DDevice9
Definition: dxva2api.idl:22
#define FAILED(hr)
Definition: intsafe.h:51
#define ZeroMemory
Definition: minwinbase.h:31
static void test_create_line(IDirect3DDevice9 *device)
Definition: line.c:59
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
D3DSWAPEFFECT SwapEffect
Definition: d3d8types.h:1128
Definition: devices.h:37

◆ test_create_line()

static void test_create_line ( IDirect3DDevice9 *  device)
static

Definition at line 59 of file line.c.

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}
#define ok(value,...)
Definition: atltest.h:57
#define D3DERR_INVALIDCALL
Definition: d3d10_private.h:42
#define D3DTS_WORLD
Definition: d3d8types.h:85
#define IDirect3DDevice9_SetTransform(p, a, b)
Definition: d3d9.h:1379
#define IDirect3DDevice9_GetTransform(p, a, b)
Definition: d3d9.h:1380
#define D3D_OK
Definition: d3d.h:106
HRESULT WINAPI D3DXCreateLine(struct IDirect3DDevice9 *device, struct ID3DXLine **line)
Definition: line.c:303
#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
GLuint64EXT * result
Definition: glext.h:11304
#define expect_mat(expectedmat, gotmat)
Definition: line.c:43
float _13
Definition: d3d8types.h:1111
float _14
Definition: d3d8types.h:1111
float _11
Definition: d3d8types.h:1111
float _12
Definition: d3d8types.h:1111
Definition: parser.c:49
Definition: send.c:48
float FLOAT
Definition: typedefs.h:69
uint32_t ULONG
Definition: typedefs.h:59

Referenced by START_TEST().

◆ test_line_width()

static void test_line_width ( IDirect3DDevice9 *  device)
static

Definition at line 119 of file line.c.

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}
#define ID3DXLine_GetWidth(p)
Definition: d3dx9core.h:257
#define ID3DXLine_SetWidth(p, a)
Definition: d3dx9core.h:256
GLint GLint GLsizei width
Definition: gl.h:1546

Referenced by START_TEST().