ReactOS 0.4.16-dev-340-g0540c21
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 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)
 
 START_TEST (line)
 

Macro Definition Documentation

◆ admitted_error

#define admitted_error   0.0001f

Definition at line 22 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", \
U(*__m1).m[0][0], U(*__m1).m[0][1], U(*__m1).m[0][2], U(*__m1).m[0][3], \
U(*__m1).m[1][0], U(*__m1).m[1][1], U(*__m1).m[1][2], U(*__m1).m[1][3], \
U(*__m1).m[2][0], U(*__m1).m[2][1], U(*__m1).m[2][2], U(*__m1).m[2][3], \
U(*__m1).m[3][0], U(*__m1).m[3][1], U(*__m1).m[3][2], U(*__m1).m[3][3], \
U(*__m2).m[0][0], U(*__m2).m[0][1], U(*__m2).m[0][2], U(*__m2).m[0][3], \
U(*__m2).m[1][0], U(*__m2).m[1][1], U(*__m2).m[1][2], U(*__m2).m[1][3], \
U(*__m2).m[2][0], U(*__m2).m[2][1], U(*__m2).m[2][2], U(*__m2).m[2][3], \
U(*__m2).m[3][0], U(*__m2).m[3][1], U(*__m2).m[3][2], U(*__m2).m[3][3]); \
} while(0)
#define U(x)
Definition: wordpad.c:45
static BOOL compare_matrix(const D3DXMATRIX *m1, const D3DXMATRIX *m2)
Definition: line.c:26

Definition at line 42 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 24 of file line.c.

Function Documentation

◆ compare_matrix()

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

Definition at line 26 of file line.c.

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}
#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:24
#define admitted_error
Definition: line.c:22

◆ START_TEST()

START_TEST ( line  )

Definition at line 118 of file line.c.

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 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:235
#define IDirect3D9_Release(p)
Definition: d3d9.h:220
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1508
#define NULL
Definition: types.h:112
#define FAILED(hr)
Definition: intsafe.h:51
static void test_create_line(IDirect3DDevice9 *device)
Definition: line.c:58
#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
HRESULT hr
Definition: shlfolder.c:183
D3DSWAPEFFECT SwapEffect
Definition: d3d8types.h:1128
Definition: devices.h:37
#define ZeroMemory
Definition: winbase.h:1737
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4318
BOOL WINAPI DestroyWindow(_In_ HWND)

◆ test_create_line()

static void test_create_line ( IDirect3DDevice9 *  device)
static

Definition at line 58 of file line.c.

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}
#define ok(value,...)
Definition: atltest.h:57
#define D3DTS_WORLD
Definition: d3d8types.h:85
#define IDirect3DDevice9_SetTransform(p, a, b)
Definition: d3d9.h:1551
#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
HRESULT WINAPI D3DXCreateLine(struct IDirect3DDevice9 *device, struct ID3DXLine **line)
Definition: line.c:297
GLuint64EXT * result
Definition: glext.h:11304
#define expect_mat(expectedmat, gotmat)
Definition: line.c:42
#define S(x)
Definition: test.h:220
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().