ReactOS 0.4.15-dev-6068-g8061a6f
mesh.c File Reference
#include <stdio.h>
#include <float.h>
#include <limits.h>
#include "wine/test.h"
#include "d3dx9.h"
#include "initguid.h"
#include "rmxftmpl.h"
#include "rmxfguid.h"
Include dependency graph for mesh.c:

Go to the source code of this file.

Classes

struct  vertex
 
struct  test_context
 
struct  mesh
 
struct  sincos_table
 
struct  dynamic_array
 
struct  point2d
 
struct  outline
 
struct  outline_array
 
struct  glyphinfo
 
struct  udec3
 
struct  dec3n
 

Macros

#define COBJMACROS
 
#define NAN   __port_nan()
 
#define TRACECALLBACK   if(winetest_debug > 1) trace
 
#define admitted_error   0.0001f
 
#define compare_vertex_sizes(type, exp)
 
#define compare_float(got, exp)
 
#define check_floats(got, exp, dim)   check_floats_(__LINE__, "", got, exp, dim)
 
#define check_vertex_buffer(mesh, vertices, num_vertices, fvf)    check_vertex_buffer_(__LINE__, mesh, vertices, num_vertices, fvf)
 
#define check_index_buffer(mesh, indices, num_indices, index_size)    check_index_buffer_(__LINE__, mesh, indices, num_indices, index_size)
 
#define check_matrix(got, expected)   check_matrix_(__LINE__, got, expected)
 
#define check_materials(got, got_count, expected, expected_count)    check_materials_(__LINE__, got, got_count, expected, expected_count)
 
#define check_generated_adjacency(mesh, got, epsilon)   check_generated_adjacency_(__LINE__, mesh, got, epsilon)
 
#define check_generated_effects(materials, num_materials, effects)    check_generated_effects_(__LINE__, materials, num_materials, effects)
 
#define EFFECT_TABLE_ENTRY(str, field)    {str, sizeof(str), sizeof(materials->MatD3D.field), offsetof(D3DXMATERIAL, MatD3D.field)}
 
#define test_LoadMeshFromX(device, xfile_str, vertex_array, fvf, index_array, materials_array, check_adjacency)
 

Typedefs

typedef WORD face[3]
 

Enumerations

enum  pointtype {
  POINTTYPE_CURVE = 0 , POINTTYPE_CORNER , POINTTYPE_CURVE_START , POINTTYPE_CURVE_END ,
  POINTTYPE_CURVE_MIDDLE , POINTTYPE_CURVE = 0 , POINTTYPE_CORNER , POINTTYPE_CURVE_START ,
  POINTTYPE_CURVE_END , POINTTYPE_CURVE_MIDDLE
}
 

Functions

static float __port_nan (void)
 
static BOOL compare (FLOAT u, FLOAT v)
 
static BOOL compare_vec3 (D3DXVECTOR3 u, D3DXVECTOR3 v)
 
static BOOL compare_vec4 (D3DXVECTOR4 u, D3DXVECTOR4 v)
 
static void check_floats_ (int line, const char *prefix, const float *got, const float *exp, int dim)
 
static BOOL compare_face (face a, face b)
 
static struct test_contextnew_test_context (void)
 
static void free_test_context (struct test_context *test_context)
 
static void free_mesh (struct mesh *mesh)
 
static BOOL new_mesh (struct mesh *mesh, DWORD number_of_vertices, DWORD number_of_faces)
 
static void compare_mesh (const char *name, ID3DXMesh *d3dxmesh, struct mesh *mesh)
 
static void D3DXBoundProbeTest (void)
 
static void D3DXComputeBoundingBoxTest (void)
 
static void D3DXComputeBoundingSphereTest (void)
 
static void print_elements (const D3DVERTEXELEMENT9 *elements)
 
static void compare_elements (const D3DVERTEXELEMENT9 *elements, const D3DVERTEXELEMENT9 *expected_elements, unsigned int line, unsigned int test_id)
 
static void test_fvf_to_decl (DWORD test_fvf, const D3DVERTEXELEMENT9 expected_elements[], HRESULT expected_hr, unsigned int line, unsigned int test_id)
 
static void test_decl_to_fvf (const D3DVERTEXELEMENT9 *decl, DWORD expected_fvf, HRESULT expected_hr, unsigned int line, unsigned int test_id)
 
static void test_fvf_decl_conversion (void)
 
static void D3DXGetFVFVertexSizeTest (void)
 
static void D3DXIntersectTriTest (void)
 
static void D3DXCreateMeshTest (void)
 
static void D3DXCreateMeshFVFTest (void)
 
static void check_vertex_buffer_ (int line, ID3DXMesh *mesh, const void *vertices, DWORD num_vertices, DWORD fvf)
 
static void check_index_buffer_ (int line, ID3DXMesh *mesh, const void *indices, DWORD num_indices, DWORD index_size)
 
static void check_matrix_ (int line, const D3DXMATRIX *got, const D3DXMATRIX *expected)
 
static void check_colorvalue_ (int line, const char *prefix, const D3DCOLORVALUE got, const D3DCOLORVALUE expected)
 
static void check_materials_ (int line, const D3DXMATERIAL *got, DWORD got_count, const D3DXMATERIAL *expected, DWORD expected_count)
 
static void check_generated_adjacency_ (int line, ID3DXMesh *mesh, const DWORD *got, FLOAT epsilon)
 
static void check_generated_effects_ (int line, const D3DXMATERIAL *materials, DWORD num_materials, const D3DXEFFECTINSTANCE *effects)
 
static charstrdupA (const char *p)
 
static HRESULT CALLBACK ID3DXAllocateHierarchyImpl_DestroyFrame (ID3DXAllocateHierarchy *iface, LPD3DXFRAME frame)
 
static HRESULT CALLBACK ID3DXAllocateHierarchyImpl_CreateFrame (ID3DXAllocateHierarchy *iface, const char *name, D3DXFRAME **new_frame)
 
static HRESULT destroy_mesh_container (LPD3DXMESHCONTAINER mesh_container)
 
static HRESULT CALLBACK ID3DXAllocateHierarchyImpl_DestroyMeshContainer (ID3DXAllocateHierarchy *iface, LPD3DXMESHCONTAINER mesh_container)
 
static HRESULT CALLBACK ID3DXAllocateHierarchyImpl_CreateMeshContainer (ID3DXAllocateHierarchy *iface, const char *name, const D3DXMESHDATA *mesh_data, const D3DXMATERIAL *materials, const D3DXEFFECTINSTANCE *effects, DWORD num_materials, const DWORD *adjacency, ID3DXSkinInfo *skin_info, D3DXMESHCONTAINER **new_mesh_container)
 
static void test_LoadMeshFromX_ (int line, IDirect3DDevice9 *device, const char *xfile_str, size_t xfile_strlen, const void *vertices, DWORD num_vertices, DWORD fvf, const void *indices, DWORD num_indices, size_t index_size, const D3DXMATERIAL *expected_materials, DWORD expected_num_materials, BOOL check_adjacency)
 
static void D3DXLoadMeshTest (void)
 
static BOOL compute_box (struct mesh *mesh, float width, float height, float depth)
 
static void test_box (IDirect3DDevice9 *device, float width, float height, float depth)
 
static void D3DXCreateBoxTest (void)
 
static BOOL compute_polygon (struct mesh *mesh, float length, unsigned int sides)
 
static void test_polygon (IDirect3DDevice9 *device, float length, unsigned int sides)
 
static void D3DXCreatePolygonTest (void)
 
static void free_sincos_table (struct sincos_table *sincos_table)
 
static BOOL compute_sincos_table (struct sincos_table *sincos_table, float angle_start, float angle_step, int n)
 
static WORD vertex_index (UINT slices, int slice, int stack)
 
static BOOL compute_sphere (struct mesh *mesh, FLOAT radius, UINT slices, UINT stacks)
 
static void test_sphere (IDirect3DDevice9 *device, FLOAT radius, UINT slices, UINT stacks)
 
static void D3DXCreateSphereTest (void)
 
static BOOL compute_cylinder (struct mesh *mesh, FLOAT radius1, FLOAT radius2, FLOAT length, UINT slices, UINT stacks)
 
static void test_cylinder (IDirect3DDevice9 *device, FLOAT radius1, FLOAT radius2, FLOAT length, UINT slices, UINT stacks)
 
static void D3DXCreateCylinderTest (void)
 
static BOOL compute_torus (struct mesh *mesh, float innerradius, float outerradius, UINT sides, UINT rings)
 
static void test_torus (IDirect3DDevice9 *device, float innerradius, float outerradius, UINT sides, UINT rings)
 
static void D3DXCreateTorusTest (void)
 
static BOOL reserve (struct dynamic_array *array, int count, int itemsize)
 
static struct point2dadd_point (struct outline *array)
 
static struct outlineadd_outline (struct outline_array *array)
 
static D3DXVECTOR2convert_fixed_to_float (POINTFX *pt, int count, float emsquare)
 
static HRESULT add_bezier_points (struct outline *outline, const D3DXVECTOR2 *p1, const D3DXVECTOR2 *p2, const D3DXVECTOR2 *p3, float max_deviation)
 
static BOOL is_direction_similar (D3DXVECTOR2 *dir1, D3DXVECTOR2 *dir2, float cos_theta)
 
static D3DXVECTOR2unit_vec2 (D3DXVECTOR2 *dir, const D3DXVECTOR2 *pt1, const D3DXVECTOR2 *pt2)
 
static BOOL attempt_line_merge (struct outline *outline, int pt_index, const D3DXVECTOR2 *nextpt, BOOL to_curve)
 
static HRESULT create_outline (struct glyphinfo *glyph, void *raw_outline, int datasize, float max_deviation, float emsquare)
 
static void free_outline (struct outline *outline)
 
static void free_glyphinfo (struct glyphinfo *glyph)
 
static void compute_text_mesh (struct mesh *mesh, const char *text, float deviation, float extrusion, float otmEMSquare, const struct glyphinfo *glyphs)
 
static void compare_text_outline_mesh (const char *name, ID3DXMesh *d3dxmesh, struct mesh *mesh, size_t textlen, float extrusion, const struct glyphinfo *glyphs)
 
static void test_createtext (IDirect3DDevice9 *device, HDC hdc, const char *text, float deviation, float extrusion)
 
static void D3DXCreateTextTest (void)
 
static void test_get_decl_length (void)
 
static void test_get_decl_vertex_size (void)
 
static void D3DXGenerateAdjacencyTest (void)
 
static void test_update_semantics (void)
 
static void test_create_skin_info (void)
 
static void test_update_skinned_mesh (void)
 
static void test_convert_adjacency_to_point_reps (void)
 
static void test_convert_point_reps_to_adjacency (void)
 
static HRESULT init_test_mesh (const DWORD num_faces, const DWORD num_vertices, const DWORD options, const D3DVERTEXELEMENT9 *declaration, IDirect3DDevice9 *device, ID3DXMesh **mesh_ptr, const void *vertices, const DWORD vertex_size, const DWORD *indices, const DWORD *attributes)
 
static DWORD init_udec3_dword (UINT x, UINT y, UINT z, UINT w)
 
static DWORD init_dec3n_dword (INT x, INT y, INT z, INT w)
 
static struct udec3 dword_to_udec3 (DWORD d)
 
static struct dec3n dword_to_dec3n (DWORD d)
 
static void check_vertex_components (int line, int mesh_number, int vertex_number, BYTE *got_ptr, const BYTE *exp_ptr, D3DVERTEXELEMENT9 *declaration)
 
static void test_weld_vertices (void)
 
static void test_clone_mesh (void)
 
static void test_valid_mesh (void)
 
static void test_optimize_vertices (void)
 
static void test_optimize_faces (void)
 
static HRESULT clear_normals (ID3DXMesh *mesh)
 
static void compare_normals (unsigned int line, const char *test_name, ID3DXMesh *mesh, const D3DXVECTOR3 *normals, unsigned int num_normals)
 
static HRESULT compute_normals_D3DXComputeNormals (ID3DXMesh *mesh, const DWORD *adjacency)
 
static HRESULT compute_normals_D3DXComputeTangentFrameEx (ID3DXMesh *mesh, const DWORD *adjacency)
 
static void test_compute_normals (void)
 
static void D3DXCreateAnimationControllerTest (void)
 
static void D3DXCreateKeyframedAnimationSetTest (void)
 
static void test_D3DXFrameFind (void)
 
static ID3DXFileData * get_mesh_data (const void *memory, SIZE_T length)
 
static void test_load_skin_mesh_from_xof (void)
 
 START_TEST (mesh)
 

Variables

static ID3DXAllocateHierarchyVtbl ID3DXAllocateHierarchyImpl_Vtbl
 
static ID3DXAllocateHierarchy alloc_hier = { &ID3DXAllocateHierarchyImpl_Vtbl }
 

Macro Definition Documentation

◆ admitted_error

#define admitted_error   0.0001f

Definition at line 46 of file mesh.c.

◆ check_floats

#define check_floats (   got,
  exp,
  dim 
)    check_floats_(__LINE__, "", got, exp, dim)

Definition at line 74 of file mesh.c.

◆ check_generated_adjacency

#define check_generated_adjacency (   mesh,
  got,
  epsilon 
)    check_generated_adjacency_(__LINE__, mesh, got, epsilon)

Definition at line 1712 of file mesh.c.

◆ check_generated_effects

#define check_generated_effects (   materials,
  num_materials,
  effects 
)     check_generated_effects_(__LINE__, materials, num_materials, effects)

Definition at line 1742 of file mesh.c.

◆ check_index_buffer

#define check_index_buffer (   mesh,
  indices,
  num_indices,
  index_size 
)     check_index_buffer_(__LINE__, mesh, indices, num_indices, index_size)

Definition at line 1629 of file mesh.c.

◆ check_materials

#define check_materials (   got,
  got_count,
  expected,
  expected_count 
)     check_materials_(__LINE__, got, got_count, expected, expected_count)

Definition at line 1685 of file mesh.c.

◆ check_matrix

#define check_matrix (   got,
  expected 
)    check_matrix_(__LINE__, got, expected)

Definition at line 1665 of file mesh.c.

◆ check_vertex_buffer

#define check_vertex_buffer (   mesh,
  vertices,
  num_vertices,
  fvf 
)     check_vertex_buffer_(__LINE__, mesh, vertices, num_vertices, fvf)

Definition at line 1527 of file mesh.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 22 of file mesh.c.

◆ compare_float

#define compare_float (   got,
  exp 
)
Value:
do { \
float _got = (got); \
float _exp = (exp); \
ok(_got == _exp, "Expected: %g, Got: %g\n", _exp, _got); \
} while (0)
DWORD exp
Definition: msg.c:16058

Definition at line 52 of file mesh.c.

◆ compare_vertex_sizes

#define compare_vertex_sizes (   type,
  exp 
)
Value:
ok(got==exp, "Expected: %d, Got: %d\n", exp, got);
UINT WINAPI D3DXGetFVFVertexSize(DWORD FVF)
Definition: mesh.c:2289
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

Definition at line 48 of file mesh.c.

◆ EFFECT_TABLE_ENTRY

#define EFFECT_TABLE_ENTRY (   str,
  field 
)     {str, sizeof(str), sizeof(materials->MatD3D.field), offsetof(D3DXMATERIAL, MatD3D.field)}

◆ NAN

#define NAN   __port_nan()

Definition at line 39 of file mesh.c.

◆ test_LoadMeshFromX

#define test_LoadMeshFromX (   device,
  xfile_str,
  vertex_array,
  fvf,
  index_array,
  materials_array,
  check_adjacency 
)
Value:
test_LoadMeshFromX_(__LINE__, device, xfile_str, sizeof(xfile_str) - 1, vertex_array, ARRAY_SIZE(vertex_array), fvf, \
index_array, ARRAY_SIZE(index_array), sizeof(*index_array), materials_array, ARRAY_SIZE(materials_array), \
check_adjacency);
#define ARRAY_SIZE(A)
Definition: main.h:33
static void test_LoadMeshFromX_(int line, IDirect3DDevice9 *device, const char *xfile_str, size_t xfile_strlen, const void *vertices, DWORD num_vertices, DWORD fvf, const void *indices, DWORD num_indices, size_t index_size, const D3DXMATERIAL *expected_materials, DWORD expected_num_materials, BOOL check_adjacency)
Definition: mesh.c:2016
Definition: devices.h:37

Definition at line 2012 of file mesh.c.

◆ TRACECALLBACK

#define TRACECALLBACK   if(winetest_debug > 1) trace

Definition at line 44 of file mesh.c.

Typedef Documentation

◆ face

typedef WORD face[3]

Definition at line 103 of file mesh.c.

Enumeration Type Documentation

◆ pointtype

Enumerator
POINTTYPE_CURVE 
POINTTYPE_CORNER 
POINTTYPE_CURVE_START 
POINTTYPE_CURVE_END 
POINTTYPE_CURVE_MIDDLE 
POINTTYPE_CURVE 
POINTTYPE_CORNER 
POINTTYPE_CURVE_START 
POINTTYPE_CURVE_END 
POINTTYPE_CURVE_MIDDLE 

Definition at line 3496 of file mesh.c.

3496 {
3497 POINTTYPE_CURVE = 0,
3502};
@ POINTTYPE_CURVE_MIDDLE
Definition: mesh.c:5313
@ POINTTYPE_CORNER
Definition: mesh.c:5310
@ POINTTYPE_CURVE_END
Definition: mesh.c:5312
@ POINTTYPE_CURVE_START
Definition: mesh.c:5311
@ POINTTYPE_CURVE
Definition: mesh.c:5309

Function Documentation

◆ __port_nan()

static float __port_nan ( void  )
inlinestatic

Definition at line 34 of file mesh.c.

35{
36 static const unsigned __nan_bytes = 0x7fc00000;
37 return *(const float *)&__nan_bytes;
38}

◆ add_bezier_points()

static HRESULT add_bezier_points ( struct outline outline,
const D3DXVECTOR2 p1,
const D3DXVECTOR2 p2,
const D3DXVECTOR2 p3,
float  max_deviation 
)
static

Definition at line 3586 of file mesh.c.

3589{
3590 D3DXVECTOR2 split1 = {0, 0}, split2 = {0, 0}, middle, vec;
3591 float deviation;
3592
3593 D3DXVec2Scale(&split1, D3DXVec2Add(&split1, p1, p2), 0.5f);
3594 D3DXVec2Scale(&split2, D3DXVec2Add(&split2, p2, p3), 0.5f);
3595 D3DXVec2Scale(&middle, D3DXVec2Add(&middle, &split1, &split2), 0.5f);
3596
3597 deviation = D3DXVec2Length(D3DXVec2Subtract(&vec, &middle, p2));
3598 if (deviation < max_deviation) {
3599 struct point2d *pt = add_point(outline);
3600 if (!pt) return E_OUTOFMEMORY;
3601 pt->pos = *p2;
3602 pt->corner = POINTTYPE_CURVE;
3603 /* the end point is omitted because the end line merges into the next segment of
3604 * the split bezier curve, and the end of the split bezier curve is added outside
3605 * this recursive function. */
3606 } else {
3607 HRESULT hr = add_bezier_points(outline, p1, &split1, &middle, max_deviation);
3608 if (hr != S_OK) return hr;
3609 hr = add_bezier_points(outline, &middle, &split2, p3, max_deviation);
3610 if (hr != S_OK) return hr;
3611 }
3612
3613 return S_OK;
3614}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static HRESULT add_bezier_points(struct outline *outline, const D3DXVECTOR2 *p1, const D3DXVECTOR2 *p2, const D3DXVECTOR2 *p3, float max_deviation_sq)
Definition: mesh.c:5478
#define pt(x, y)
Definition: drawing.c:79
FT_Vector * vec
Definition: ftbbox.c:448
#define S_OK
Definition: intsafe.h:52
static struct point2d * add_point(struct outline *array)
Definition: mesh.c:3550
HRESULT hr
Definition: shlfolder.c:183
Definition: mesh.c:5330
Definition: mesh.c:5317

◆ add_outline()

static struct outline * add_outline ( struct outline_array array)
static

Definition at line 3562 of file mesh.c.

3563{
3564 struct outline *item;
3565
3566 if (!reserve((struct dynamic_array *)array, array->count + 1, sizeof(array->items[0])))
3567 return NULL;
3568
3569 item = &array->items[array->count++];
3570 ZeroMemory(item, sizeof(*item));
3571 return item;
3572}
#define NULL
Definition: types.h:112
static BOOL reserve(struct dynamic_array *array, int count, int itemsize)
Definition: mesh.c:5392
static ATOM item
Definition: dde.c:856
#define ZeroMemory
Definition: winbase.h:1670

◆ add_point()

static struct point2d * add_point ( struct outline array)
static

Definition at line 3550 of file mesh.c.

3551{
3552 struct point2d *item;
3553
3554 if (!reserve((struct dynamic_array *)array, array->count + 1, sizeof(array->items[0])))
3555 return NULL;
3556
3557 item = &array->items[array->count++];
3558 ZeroMemory(item, sizeof(*item));
3559 return item;
3560}

Referenced by add_bezier_points(), and create_outline().

◆ attempt_line_merge()

static BOOL attempt_line_merge ( struct outline outline,
int  pt_index,
const D3DXVECTOR2 nextpt,
BOOL  to_curve 
)
static

Definition at line 3627 of file mesh.c.

3631{
3632 D3DXVECTOR2 curdir, lastdir;
3633 struct point2d *prevpt, *pt;
3634 BOOL ret = FALSE;
3635 const float cos_half = cos(D3DXToRadian(0.5f));
3636
3637 pt = &outline->items[pt_index];
3638 pt_index = (pt_index - 1 + outline->count) % outline->count;
3639 prevpt = &outline->items[pt_index];
3640
3641 if (to_curve)
3643
3644 if (outline->count < 2)
3645 return FALSE;
3646
3647 /* remove last point if the next line continues the last line */
3648 unit_vec2(&lastdir, &prevpt->pos, &pt->pos);
3649 unit_vec2(&curdir, &pt->pos, nextpt);
3650 if (is_direction_similar(&lastdir, &curdir, cos_half))
3651 {
3652 outline->count--;
3653 if (pt->corner == POINTTYPE_CURVE_END)
3654 prevpt->corner = pt->corner;
3655 if (prevpt->corner == POINTTYPE_CURVE_END && to_curve)
3657 pt = prevpt;
3658
3659 ret = TRUE;
3660 if (outline->count < 2)
3661 return ret;
3662
3663 pt_index = (pt_index - 1 + outline->count) % outline->count;
3664 prevpt = &outline->items[pt_index];
3665 unit_vec2(&lastdir, &prevpt->pos, &pt->pos);
3666 unit_vec2(&curdir, &pt->pos, nextpt);
3667 }
3668 return ret;
3669}
_STLP_DECLSPEC complex< float > _STLP_CALL cos(const complex< float > &)
#define D3DXToRadian(degree)
Definition: d3dx9math.h:33
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static BOOL is_direction_similar(D3DXVECTOR2 *dir1, D3DXVECTOR2 *dir2, float cos_theta)
Definition: mesh.c:5508
static D3DXVECTOR2 * unit_vec2(D3DXVECTOR2 *dir, const D3DXVECTOR2 *pt1, const D3DXVECTOR2 *pt2)
Definition: mesh.c:5514
unsigned int BOOL
Definition: ntddk_ex.h:94
if(dx< 0)
Definition: linetemp.h:194
struct point2d * items
Definition: mesh.c:5332
int count
Definition: mesh.c:5331
D3DXVECTOR2 pos
Definition: mesh.c:5318
enum pointtype corner
Definition: mesh.c:5319
int ret

◆ check_colorvalue_()

static void check_colorvalue_ ( int  line,
const char prefix,
const D3DCOLORVALUE  got,
const D3DCOLORVALUE  expected 
)
static

Definition at line 1678 of file mesh.c.

1679{
1680 ok_(__FILE__,line)(expected.r == got.r && expected.g == got.g && expected.b == got.b && expected.a == got.a,
1681 "%sExpected (%g, %g, %g, %g), got (%g, %g, %g, %g)\n", prefix,
1682 expected.r, expected.g, expected.b, expected.a, got.r, got.g, got.b, got.a);
1683}
#define ok_(x1, x2)
Definition: atltest.h:61
BOOL expected
Definition: store.c:2063
Definition: parser.c:49

Referenced by check_materials_().

◆ check_floats_()

static void check_floats_ ( int  line,
const char prefix,
const float got,
const float exp,
int  dim 
)
static

Definition at line 75 of file mesh.c.

76{
77 int i;
78 char exp_buffer[256] = "";
79 char got_buffer[256] = "";
80 char *exp_buffer_ptr = exp_buffer;
81 char *got_buffer_ptr = got_buffer;
82 BOOL equal = TRUE;
83
84 for (i = 0; i < dim; i++) {
85 if (i) {
86 exp_buffer_ptr += sprintf(exp_buffer_ptr, ", ");
87 got_buffer_ptr += sprintf(got_buffer_ptr, ", ");
88 }
89 equal = equal && compare(*exp, *got);
90 exp_buffer_ptr += sprintf(exp_buffer_ptr, "%g", *exp);
91 got_buffer_ptr += sprintf(got_buffer_ptr, "%g", *got);
92 exp++; got++;
93 }
94 ok_(__FILE__,line)(equal, "%sExpected (%s), got (%s)", prefix, exp_buffer, got_buffer);
95}
#define compare
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
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define equal(x, y)
Definition: reader.cc:56

Referenced by check_vertex_buffer_().

◆ check_generated_adjacency_()

static void check_generated_adjacency_ ( int  line,
ID3DXMesh *  mesh,
const DWORD got,
FLOAT  epsilon 
)
static

Definition at line 1713 of file mesh.c.

1714{
1715 DWORD *expected;
1716 DWORD num_faces = mesh->lpVtbl->GetNumFaces(mesh);
1717 HRESULT hr;
1718
1719 expected = HeapAlloc(GetProcessHeap(), 0, num_faces * sizeof(DWORD) * 3);
1720 if (!expected) {
1721 skip_(__FILE__, line)("Out of memory\n");
1722 return;
1723 }
1724 hr = mesh->lpVtbl->GenerateAdjacency(mesh, epsilon, expected);
1725 ok_(__FILE__, line)(hr == D3D_OK, "Expected D3D_OK, got %#x\n", hr);
1726 if (SUCCEEDED(hr))
1727 {
1728 int i;
1729 for (i = 0; i < num_faces; i++)
1730 {
1731 ok_(__FILE__, line)(expected[i * 3] == got[i * 3] &&
1732 expected[i * 3 + 1] == got[i * 3 + 1] &&
1733 expected[i * 3 + 2] == got[i * 3 + 2],
1734 "Face %u adjacencies: Expected (%u, %u, %u), got (%u, %u, %u)\n", i,
1735 expected[i * 3], expected[i * 3 + 1], expected[i * 3 + 2],
1736 got[i * 3], got[i * 3 + 1], got[i * 3 + 2]);
1737 }
1738 }
1740}
#define D3D_OK
Definition: d3d.h:106
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define skip_(test, file, line,...)
Definition: kmt_test.h:224
Definition: mesh.c:198

Referenced by test_LoadMeshFromX_().

◆ check_generated_effects_()

static void check_generated_effects_ ( int  line,
const D3DXMATERIAL materials,
DWORD  num_materials,
const D3DXEFFECTINSTANCE effects 
)
static

Definition at line 1744 of file mesh.c.

1745{
1746 int i;
1747 static const struct {
1748 const char *name;
1749 DWORD name_size;
1750 DWORD num_bytes;
1751 DWORD value_offset;
1752 } params[] = {
1753#define EFFECT_TABLE_ENTRY(str, field) \
1754 {str, sizeof(str), sizeof(materials->MatD3D.field), offsetof(D3DXMATERIAL, MatD3D.field)}
1755 EFFECT_TABLE_ENTRY("Diffuse", Diffuse),
1756 EFFECT_TABLE_ENTRY("Power", Power),
1757 EFFECT_TABLE_ENTRY("Specular", Specular),
1758 EFFECT_TABLE_ENTRY("Emissive", Emissive),
1759 EFFECT_TABLE_ENTRY("Ambient", Ambient),
1760#undef EFFECT_TABLE_ENTRY
1761 };
1762
1763 if (!num_materials) {
1764 ok_(__FILE__, line)(effects == NULL, "Expected NULL effects, got %p\n", effects);
1765 return;
1766 }
1767 for (i = 0; i < num_materials; i++)
1768 {
1769 int j;
1770 DWORD expected_num_defaults = ARRAY_SIZE(params) + (materials[i].pTextureFilename ? 1 : 0);
1771
1772 ok_(__FILE__,line)(expected_num_defaults == effects[i].NumDefaults,
1773 "effect[%u] NumDefaults: Expected %u, got %u\n", i,
1774 expected_num_defaults, effects[i].NumDefaults);
1775 for (j = 0; j < min(ARRAY_SIZE(params), effects[i].NumDefaults); j++)
1776 {
1777 int k;
1778 D3DXEFFECTDEFAULT *got_param = &effects[i].pDefaults[j];
1779 ok_(__FILE__,line)(!strcmp(params[j].name, got_param->pParamName),
1780 "effect[%u].pDefaults[%u].pParamName: Expected '%s', got '%s'\n", i, j,
1781 params[j].name, got_param->pParamName);
1782 ok_(__FILE__,line)(D3DXEDT_FLOATS == got_param->Type,
1783 "effect[%u].pDefaults[%u].Type: Expected %u, got %u\n", i, j,
1784 D3DXEDT_FLOATS, got_param->Type);
1785 ok_(__FILE__,line)(params[j].num_bytes == got_param->NumBytes,
1786 "effect[%u].pDefaults[%u].NumBytes: Expected %u, got %u\n", i, j,
1787 params[j].num_bytes, got_param->NumBytes);
1788 for (k = 0; k < min(params[j].num_bytes, got_param->NumBytes) / 4; k++)
1789 {
1790 FLOAT expected = ((FLOAT*)((BYTE*)&materials[i] + params[j].value_offset))[k];
1791 FLOAT got = ((FLOAT*)got_param->pValue)[k];
1792 ok_(__FILE__,line)(compare(expected, got),
1793 "effect[%u].pDefaults[%u] float value %u: Expected %g, got %g\n", i, j, k, expected, got);
1794 }
1795 }
1796 if (effects[i].NumDefaults > ARRAY_SIZE(params)) {
1797 D3DXEFFECTDEFAULT *got_param = &effects[i].pDefaults[j];
1798 static const char *expected_name = "Texture0@Name";
1799
1800 ok_(__FILE__,line)(!strcmp(expected_name, got_param->pParamName),
1801 "effect[%u].pDefaults[%u].pParamName: Expected '%s', got '%s'\n", i, j,
1802 expected_name, got_param->pParamName);
1803 ok_(__FILE__,line)(D3DXEDT_STRING == got_param->Type,
1804 "effect[%u].pDefaults[%u].Type: Expected %u, got %u\n", i, j,
1805 D3DXEDT_STRING, got_param->Type);
1806 if (materials[i].pTextureFilename) {
1807 ok_(__FILE__,line)(strlen(materials[i].pTextureFilename) + 1 == got_param->NumBytes,
1808 "effect[%u] texture filename length: Expected %u, got %u\n", i,
1809 (DWORD)strlen(materials[i].pTextureFilename) + 1, got_param->NumBytes);
1810 ok_(__FILE__,line)(!strcmp(materials[i].pTextureFilename, got_param->pValue),
1811 "effect[%u] texture filename: Expected '%s', got '%s'\n", i,
1812 materials[i].pTextureFilename, (char*)got_param->pValue);
1813 }
1814 }
1815 }
1816}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
@ D3DXEDT_FLOATS
Definition: d3dx9mesh.h:142
@ D3DXEDT_STRING
Definition: d3dx9mesh.h:141
#define EFFECT_TABLE_ENTRY(str, field)
GLenum const GLfloat * params
Definition: glext.h:5645
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 min(a, b)
Definition: monoChain.cc:55
int k
Definition: mpi.c:3369
#define DWORD
Definition: nt_native.h:44
D3DXEFFECTDEFAULTTYPE Type
Definition: d3dx9mesh.h:202
LPD3DXEFFECTDEFAULT pDefaults
Definition: d3dx9mesh.h:211
char * pTextureFilename
Definition: d3dx9mesh.h:196
Definition: name.c:39
float FLOAT
Definition: typedefs.h:69
unsigned char BYTE
Definition: xxhash.c:193

Referenced by test_LoadMeshFromX_().

◆ check_index_buffer_()

static void check_index_buffer_ ( int  line,
ID3DXMesh *  mesh,
const void indices,
DWORD  num_indices,
DWORD  index_size 
)
static

Definition at line 1631 of file mesh.c.

1632{
1633 DWORD mesh_index_size = (mesh->lpVtbl->GetOptions(mesh) & D3DXMESH_32BIT) ? 4 : 2;
1634 DWORD mesh_num_indices = mesh->lpVtbl->GetNumFaces(mesh) * 3;
1635 const void *mesh_indices;
1636 HRESULT hr;
1637 DWORD i;
1638
1639 ok_(__FILE__,line)(index_size == mesh_index_size,
1640 "Expected index size %u, got %u\n", index_size, mesh_index_size);
1641 ok_(__FILE__,line)(num_indices == mesh_num_indices,
1642 "Expected %u indices, got %u\n", num_indices, mesh_num_indices);
1643
1644 hr = mesh->lpVtbl->LockIndexBuffer(mesh, D3DLOCK_READONLY, (void**)&mesh_indices);
1645 ok_(__FILE__,line)(hr == D3D_OK, "LockIndexBuffer returned %x, expected %x (D3D_OK)\n", hr, D3D_OK);
1646 if (FAILED(hr))
1647 return;
1648
1649 if (mesh_index_size == index_size) {
1650 for (i = 0; i < min(num_indices, mesh_num_indices); i++)
1651 {
1652 if (index_size == 4)
1653 ok_(__FILE__,line)(*(DWORD*)indices == *(DWORD*)mesh_indices,
1654 "Index[%u]: expected %u, got %u\n", i, *(DWORD*)indices, *(DWORD*)mesh_indices);
1655 else
1656 ok_(__FILE__,line)(*(WORD*)indices == *(WORD*)mesh_indices,
1657 "Index[%u]: expected %u, got %u\n", i, *(WORD*)indices, *(WORD*)mesh_indices);
1658 indices = (BYTE*)indices + index_size;
1659 mesh_indices = (BYTE*)mesh_indices + index_size;
1660 }
1661 }
1662 mesh->lpVtbl->UnlockIndexBuffer(mesh);
1663}
#define D3DLOCK_READONLY
Definition: d3d8types.h:69
@ D3DXMESH_32BIT
Definition: d3dx9mesh.h:46
unsigned short WORD
Definition: ntddk_ex.h:93
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: gl.h:1545
#define FAILED(hr)
Definition: intsafe.h:51

Referenced by test_LoadMeshFromX_().

◆ check_materials_()

static void check_materials_ ( int  line,
const D3DXMATERIAL got,
DWORD  got_count,
const D3DXMATERIAL expected,
DWORD  expected_count 
)
static

Definition at line 1687 of file mesh.c.

1688{
1689 int i;
1690 ok_(__FILE__,line)(expected_count == got_count, "Expected %u materials, got %u\n", expected_count, got_count);
1691 if (!expected) {
1692 ok_(__FILE__,line)(got == NULL, "Expected NULL material ptr, got %p\n", got);
1693 return;
1694 }
1695 for (i = 0; i < min(expected_count, got_count); i++)
1696 {
1697 if (!expected[i].pTextureFilename)
1698 ok_(__FILE__,line)(got[i].pTextureFilename == NULL,
1699 "Expected NULL pTextureFilename, got %p\n", got[i].pTextureFilename);
1700 else
1701 ok_(__FILE__,line)(!strcmp(expected[i].pTextureFilename, got[i].pTextureFilename),
1702 "Expected '%s' for pTextureFilename, got '%s'\n", expected[i].pTextureFilename, got[i].pTextureFilename);
1703 check_colorvalue_(line, "Diffuse: ", got[i].MatD3D.Diffuse, expected[i].MatD3D.Diffuse);
1704 check_colorvalue_(line, "Ambient: ", got[i].MatD3D.Ambient, expected[i].MatD3D.Ambient);
1705 check_colorvalue_(line, "Specular: ", got[i].MatD3D.Specular, expected[i].MatD3D.Specular);
1706 check_colorvalue_(line, "Emissive: ", got[i].MatD3D.Emissive, expected[i].MatD3D.Emissive);
1707 ok_(__FILE__,line)(expected[i].MatD3D.Power == got[i].MatD3D.Power,
1708 "Power: Expected %g, got %g\n", expected[i].MatD3D.Power, got[i].MatD3D.Power);
1709 }
1710}
static void check_colorvalue_(int line, const char *prefix, const D3DCOLORVALUE got, const D3DCOLORVALUE expected)
Definition: mesh.c:1678
static int expected_count(int *sink)
D3DMATERIAL9 MatD3D
Definition: d3dx9mesh.h:195

Referenced by test_LoadMeshFromX_().

◆ check_matrix_()

static void check_matrix_ ( int  line,
const D3DXMATRIX got,
const D3DXMATRIX expected 
)
static

Definition at line 1666 of file mesh.c.

1667{
1668 int i, j;
1669 for (i = 0; i < 4; i++) {
1670 for (j = 0; j < 4; j++) {
1671 ok_(__FILE__,line)(compare(U(*expected).m[i][j], U(*got).m[i][j]),
1672 "matrix[%u][%u]: expected %g, got %g\n",
1673 i, j, U(*expected).m[i][j], U(*got).m[i][j]);
1674 }
1675 }
1676}
#define U(x)
Definition: wordpad.c:45

◆ check_vertex_buffer_()

static void check_vertex_buffer_ ( int  line,
ID3DXMesh *  mesh,
const void vertices,
DWORD  num_vertices,
DWORD  fvf 
)
static

Definition at line 1529 of file mesh.c.

1530{
1531 DWORD mesh_num_vertices = mesh->lpVtbl->GetNumVertices(mesh);
1532 DWORD mesh_fvf = mesh->lpVtbl->GetFVF(mesh);
1533 const void *mesh_vertices;
1534 HRESULT hr;
1535
1536 ok_(__FILE__,line)(fvf == mesh_fvf, "expected FVF %x, got %x\n", fvf, mesh_fvf);
1537 ok_(__FILE__,line)(num_vertices == mesh_num_vertices,
1538 "Expected %u vertices, got %u\n", num_vertices, mesh_num_vertices);
1539
1540 hr = mesh->lpVtbl->LockVertexBuffer(mesh, D3DLOCK_READONLY, (void**)&mesh_vertices);
1541 ok_(__FILE__,line)(hr == D3D_OK, "LockVertexBuffer returned %x, expected %x (D3D_OK)\n", hr, D3D_OK);
1542 if (FAILED(hr))
1543 return;
1544
1545 if (mesh_fvf == fvf) {
1546 DWORD vertex_size = D3DXGetFVFVertexSize(fvf), i;
1547
1548 for (i = 0; i < min(num_vertices, mesh_num_vertices); i++)
1549 {
1550 const FLOAT *exp_float = vertices;
1551 const FLOAT *got_float = mesh_vertices;
1552 DWORD texcount;
1553 DWORD pos_dim = 0;
1554 int j;
1555 BOOL last_beta_dword = FALSE;
1556 char prefix[128];
1557
1558 switch (fvf & D3DFVF_POSITION_MASK) {
1559 case D3DFVF_XYZ: pos_dim = 3; break;
1560 case D3DFVF_XYZRHW: pos_dim = 4; break;
1561 case D3DFVF_XYZB1:
1562 case D3DFVF_XYZB2:
1563 case D3DFVF_XYZB3:
1564 case D3DFVF_XYZB4:
1565 case D3DFVF_XYZB5:
1566 pos_dim = (fvf & D3DFVF_POSITION_MASK) - D3DFVF_XYZB1 + 1;
1568 {
1569 pos_dim--;
1570 last_beta_dword = TRUE;
1571 }
1572 break;
1573 case D3DFVF_XYZW: pos_dim = 4; break;
1574 }
1575 sprintf(prefix, "vertex[%u] position, ", i);
1576 check_floats_(line, prefix, got_float, exp_float, pos_dim);
1577 exp_float += pos_dim;
1578 got_float += pos_dim;
1579
1580 if (last_beta_dword) {
1581 ok_(__FILE__,line)(*(DWORD*)exp_float == *(DWORD*)got_float,
1582 "Vertex[%u]: Expected last beta %08x, got %08x\n", i, *(DWORD*)exp_float, *(DWORD*)got_float);
1583 exp_float++;
1584 got_float++;
1585 }
1586
1587 if (fvf & D3DFVF_NORMAL) {
1588 sprintf(prefix, "vertex[%u] normal, ", i);
1589 check_floats_(line, prefix, got_float, exp_float, 3);
1590 exp_float += 3;
1591 got_float += 3;
1592 }
1593 if (fvf & D3DFVF_PSIZE) {
1594 ok_(__FILE__,line)(compare(*exp_float, *got_float),
1595 "Vertex[%u]: Expected psize %g, got %g\n", i, *exp_float, *got_float);
1596 exp_float++;
1597 got_float++;
1598 }
1599 if (fvf & D3DFVF_DIFFUSE) {
1600 ok_(__FILE__,line)(*(DWORD*)exp_float == *(DWORD*)got_float,
1601 "Vertex[%u]: Expected diffuse %08x, got %08x\n", i, *(DWORD*)exp_float, *(DWORD*)got_float);
1602 exp_float++;
1603 got_float++;
1604 }
1605 if (fvf & D3DFVF_SPECULAR) {
1606 ok_(__FILE__,line)(*(DWORD*)exp_float == *(DWORD*)got_float,
1607 "Vertex[%u]: Expected specular %08x, got %08x\n", i, *(DWORD*)exp_float, *(DWORD*)got_float);
1608 exp_float++;
1609 got_float++;
1610 }
1611
1612 texcount = (fvf & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
1613 for (j = 0; j < texcount; j++) {
1614 DWORD dim = (((fvf >> (16 + 2 * j)) + 1) & 0x03) + 1;
1615 sprintf(prefix, "vertex[%u] texture, ", i);
1616 check_floats_(line, prefix, got_float, exp_float, dim);
1617 exp_float += dim;
1618 got_float += dim;
1619 }
1620
1621 vertices = (BYTE*)vertices + vertex_size;
1622 mesh_vertices = (BYTE*)mesh_vertices + vertex_size;
1623 }
1624 }
1625
1626 mesh->lpVtbl->UnlockVertexBuffer(mesh);
1627}
#define D3DFVF_DIFFUSE
Definition: d3d8types.h:122
#define D3DFVF_XYZ
Definition: d3d8types.h:113
#define D3DFVF_TEXCOUNT_SHIFT
Definition: d3d8types.h:125
#define D3DFVF_XYZB1
Definition: d3d8types.h:115
#define D3DFVF_LASTBETA_UBYTE4
Definition: d3d8types.h:135
#define D3DFVF_XYZB5
Definition: d3d8types.h:119
#define D3DFVF_XYZRHW
Definition: d3d8types.h:114
#define D3DFVF_XYZB4
Definition: d3d8types.h:118
#define D3DFVF_NORMAL
Definition: d3d8types.h:120
#define D3DFVF_XYZB3
Definition: d3d8types.h:117
#define D3DFVF_XYZB2
Definition: d3d8types.h:116
#define D3DFVF_TEXCOUNT_MASK
Definition: d3d8types.h:124
#define D3DFVF_PSIZE
Definition: d3d8types.h:121
#define D3DFVF_SPECULAR
Definition: d3d8types.h:123
#define D3DFVF_POSITION_MASK
Definition: d3d8types.h:112
#define D3DFVF_LASTBETA_D3DCOLOR
Definition: d3d9types.h:160
#define D3DFVF_XYZW
Definition: d3d9types.h:143
static void check_floats_(int line, const char *prefix, const float *got, const float *exp, int dim)
Definition: mesh.c:75

Referenced by test_LoadMeshFromX_().

◆ check_vertex_components()

static void check_vertex_components ( int  line,
int  mesh_number,
int  vertex_number,
BYTE got_ptr,
const BYTE exp_ptr,
D3DVERTEXELEMENT9 declaration 
)
static

Definition at line 6592 of file mesh.c.

6593{
6594 const char *usage_strings[] =
6595 {
6596 "position",
6597 "blend weight",
6598 "blend indices",
6599 "normal",
6600 "point size",
6601 "texture coordinates",
6602 "tangent",
6603 "binormal",
6604 "tessellation factor",
6605 "position transformed",
6606 "color",
6607 "fog",
6608 "depth",
6609 "sample"
6610 };
6611 D3DVERTEXELEMENT9 *decl_ptr;
6612 const float PRECISION = 1e-5f;
6613
6614 for (decl_ptr = declaration; decl_ptr->Stream != 0xFF; decl_ptr++)
6615 {
6616 switch (decl_ptr->Type)
6617 {
6618 case D3DDECLTYPE_FLOAT1:
6619 {
6620 FLOAT *got = (FLOAT*)(got_ptr + decl_ptr->Offset);
6621 FLOAT *exp = (FLOAT*)(exp_ptr + decl_ptr->Offset);
6622 FLOAT diff = fabsf(*got - *exp);
6623 ok_(__FILE__,line)(diff <= PRECISION, "Mesh %d: Got %f for vertex %d %s, expected %f.\n",
6624 mesh_number, *got, vertex_number, usage_strings[decl_ptr->Usage], *exp);
6625 break;
6626 }
6627 case D3DDECLTYPE_FLOAT2:
6628 {
6629 D3DXVECTOR2 *got = (D3DXVECTOR2*)(got_ptr + decl_ptr->Offset);
6630 D3DXVECTOR2 *exp = (D3DXVECTOR2*)(exp_ptr + decl_ptr->Offset);
6631 FLOAT diff = max(fabsf(got->x - exp->x), fabsf(got->y - exp->y));
6632 ok_(__FILE__,line)(diff <= PRECISION, "Mesh %d: Got (%f, %f) for vertex %d %s, expected (%f, %f).\n",
6633 mesh_number, got->x, got->y, vertex_number, usage_strings[decl_ptr->Usage], exp->x, exp->y);
6634 break;
6635 }
6636 case D3DDECLTYPE_FLOAT3:
6637 {
6638 D3DXVECTOR3 *got = (D3DXVECTOR3*)(got_ptr + decl_ptr->Offset);
6639 D3DXVECTOR3 *exp = (D3DXVECTOR3*)(exp_ptr + decl_ptr->Offset);
6640 FLOAT diff = max(fabsf(got->x - exp->x), fabsf(got->y - exp->y));
6641 diff = max(diff, fabsf(got->z - exp->z));
6642 ok_(__FILE__,line)(diff <= PRECISION, "Mesh %d: Got (%f, %f, %f) for vertex %d %s, expected (%f, %f, %f).\n",
6643 mesh_number, got->x, got->y, got->z, vertex_number, usage_strings[decl_ptr->Usage], exp->x, exp->y, exp->z);
6644 break;
6645 }
6646 case D3DDECLTYPE_FLOAT4:
6647 {
6648 D3DXVECTOR4 *got = (D3DXVECTOR4*)(got_ptr + decl_ptr->Offset);
6649 D3DXVECTOR4 *exp = (D3DXVECTOR4*)(exp_ptr + decl_ptr->Offset);
6650 FLOAT diff = max(fabsf(got->x - exp->x), fabsf(got->y - exp->y));
6651 diff = max(diff, fabsf(got->z - exp->z));
6652 diff = max(diff, fabsf(got->w - exp->w));
6653 ok_(__FILE__,line)(diff <= PRECISION, "Mesh %d: Got (%f, %f, %f, %f) for vertex %d %s, expected (%f, %f, %f, %f).\n",
6654 mesh_number, got->x, got->y, got->z, got->w, vertex_number, usage_strings[decl_ptr->Usage], exp->x, exp->y, exp->z, got->w);
6655 break;
6656 }
6658 {
6659 BYTE *got = got_ptr + decl_ptr->Offset;
6660 const BYTE *exp = exp_ptr + decl_ptr->Offset;
6661 BOOL same_color = got[0] == exp[0] && got[1] == exp[1]
6662 && got[2] == exp[2] && got[3] == exp[3];
6663 const char *color_types[] = {"diffuse", "specular", "undefined color"};
6664 BYTE usage_index = decl_ptr->UsageIndex;
6665 if (usage_index > 1) usage_index = 2;
6666 ok_(__FILE__,line)(same_color, "Mesh %d: Got (%u, %u, %u, %u) for vertex %d %s, expected (%u, %u, %u, %u).\n",
6667 mesh_number, got[0], got[1], got[2], got[3], vertex_number, color_types[usage_index], exp[0], exp[1], exp[2], exp[3]);
6668 break;
6669 }
6670 case D3DDECLTYPE_UBYTE4:
6672 {
6673 BYTE *got = got_ptr + decl_ptr->Offset;
6674 const BYTE *exp = exp_ptr + decl_ptr->Offset;
6675 BOOL same = got[0] == exp[0] && got[1] == exp[1]
6676 && got[2] == exp[2] && got[3] == exp[3];
6677 ok_(__FILE__,line)(same, "Mesh %d: Got (%u, %u, %u, %u) for vertex %d %s, expected (%u, %u, %u, %u).\n",
6678 mesh_number, got[0], got[1], got[2], got[3], vertex_number, usage_strings[decl_ptr->Usage], exp[0], exp[1], exp[2], exp[3]);
6679 break;
6680 }
6681 case D3DDECLTYPE_SHORT2:
6683 {
6684 SHORT *got = (SHORT*)(got_ptr + decl_ptr->Offset);
6685 SHORT *exp = (SHORT*)(exp_ptr + decl_ptr->Offset);
6686 BOOL same = got[0] == exp[0] && got[1] == exp[1];
6687 ok_(__FILE__,line)(same, "Mesh %d: Got (%hd, %hd) for vertex %d %s, expected (%hd, %hd).\n",
6688 mesh_number, got[0], got[1], vertex_number, usage_strings[decl_ptr->Usage], exp[0], exp[1]);
6689 break;
6690 }
6691 case D3DDECLTYPE_SHORT4:
6693 {
6694 SHORT *got = (SHORT*)(got_ptr + decl_ptr->Offset);
6695 SHORT *exp = (SHORT*)(exp_ptr + decl_ptr->Offset);
6696 BOOL same = got[0] == exp[0] && got[1] == exp[1]
6697 && got[2] == exp[2] && got[3] == exp[3];
6698 ok_(__FILE__,line)(same, "Mesh %d: Got (%hd, %hd, %hd, %hd) for vertex %d %s, expected (%hd, %hd, %hd, %hd).\n",
6699 mesh_number, got[0], got[1], got[2], got[3], vertex_number, usage_strings[decl_ptr->Usage], exp[0], exp[1], exp[2], exp[3]);
6700 break;
6701 }
6703 {
6704 USHORT *got = (USHORT*)(got_ptr + decl_ptr->Offset);
6705 USHORT *exp = (USHORT*)(exp_ptr + decl_ptr->Offset);
6706 BOOL same = got[0] == exp[0] && got[1] == exp[1];
6707 ok_(__FILE__,line)(same, "Mesh %d: Got (%hu, %hu) for vertex %d %s, expected (%hu, %hu).\n",
6708 mesh_number, got[0], got[1], vertex_number, usage_strings[decl_ptr->Usage], exp[0], exp[1]);
6709 break;
6710 }
6712 {
6713 USHORT *got = (USHORT*)(got_ptr + decl_ptr->Offset);
6714 USHORT *exp = (USHORT*)(exp_ptr + decl_ptr->Offset);
6715 BOOL same = got[0] == exp[0] && got[1] == exp[1]
6716 && got[2] == exp[2] && got[3] == exp[3];
6717 ok_(__FILE__,line)(same, "Mesh %d: Got (%hu, %hu, %hu, %hu) for vertex %d %s, expected (%hu, %hu, %hu, %hu).\n",
6718 mesh_number, got[0], got[1], got[2], got[3], vertex_number, usage_strings[decl_ptr->Usage], exp[0], exp[1], exp[2], exp[3]);
6719 break;
6720 }
6721 case D3DDECLTYPE_UDEC3:
6722 {
6723 DWORD *got = (DWORD*)(got_ptr + decl_ptr->Offset);
6724 DWORD *exp = (DWORD*)(exp_ptr + decl_ptr->Offset);
6725 BOOL same = memcmp(got, exp, sizeof(*got)) == 0;
6726 struct udec3 got_udec3 = dword_to_udec3(*got);
6727 struct udec3 exp_udec3 = dword_to_udec3(*exp);
6728 ok_(__FILE__,line)(same, "Mesh %d: Got (%u, %u, %u, %u) for vertex %d %s, expected (%u, %u, %u, %u).\n",
6729 mesh_number, got_udec3.x, got_udec3.y, got_udec3.z, got_udec3.w, vertex_number, usage_strings[decl_ptr->Usage], exp_udec3.x, exp_udec3.y, exp_udec3.z, exp_udec3.w);
6730
6731 break;
6732 }
6733 case D3DDECLTYPE_DEC3N:
6734 {
6735 DWORD *got = (DWORD*)(got_ptr + decl_ptr->Offset);
6736 DWORD *exp = (DWORD*)(exp_ptr + decl_ptr->Offset);
6737 BOOL same = memcmp(got, exp, sizeof(*got)) == 0;
6738 struct dec3n got_dec3n = dword_to_dec3n(*got);
6739 struct dec3n exp_dec3n = dword_to_dec3n(*exp);
6740 ok_(__FILE__,line)(same, "Mesh %d: Got (%d, %d, %d, %d) for vertex %d %s, expected (%d, %d, %d, %d).\n",
6741 mesh_number, got_dec3n.x, got_dec3n.y, got_dec3n.z, got_dec3n.w, vertex_number, usage_strings[decl_ptr->Usage], exp_dec3n.x, exp_dec3n.y, exp_dec3n.z, exp_dec3n.w);
6742 break;
6743 }
6745 {
6746 WORD *got = (WORD*)(got_ptr + decl_ptr->Offset);
6747 WORD *exp = (WORD*)(exp_ptr + decl_ptr->Offset);
6748 BOOL same = got[0] == exp[0] && got[1] == exp[1];
6749 ok_(__FILE__,line)(same, "Mesh %d: Got (%hx, %hx) for vertex %d %s, expected (%hx, %hx).\n",
6750 mesh_number, got[0], got[1], vertex_number, usage_strings[decl_ptr->Usage], exp[0], exp[1]);
6751 break;
6752 }
6754 {
6755 WORD *got = (WORD*)(got_ptr + decl_ptr->Offset);
6756 WORD *exp = (WORD*)(exp_ptr + decl_ptr->Offset);
6757 BOOL same = got[0] == exp[0] && got[1] == exp[1]
6758 && got[2] == exp[2] && got[3] == exp[3];
6759 ok_(__FILE__,line)(same, "Mesh %d: Got (%hx, %hx, %hx, %hx) for vertex %d %s, expected (%hx, %hx, %hx, %hx).\n",
6760 mesh_number, got[0], got[1], got[2], got[3], vertex_number, usage_strings[decl_ptr->Usage], exp[0], exp[1], exp[3], exp[4]);
6761 break;
6762 }
6763 default:
6764 break;
6765 }
6766 }
6767}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
@ D3DDECLTYPE_UBYTE4
Definition: d3d9types.h:260
@ D3DDECLTYPE_SHORT2
Definition: d3d9types.h:261
@ D3DDECLTYPE_FLOAT3
Definition: d3d9types.h:257
@ D3DDECLTYPE_FLOAT1
Definition: d3d9types.h:255
@ D3DDECLTYPE_SHORT2N
Definition: d3d9types.h:265
@ D3DDECLTYPE_FLOAT16_4
Definition: d3d9types.h:272
@ D3DDECLTYPE_FLOAT16_2
Definition: d3d9types.h:271
@ D3DDECLTYPE_D3DCOLOR
Definition: d3d9types.h:259
@ D3DDECLTYPE_UDEC3
Definition: d3d9types.h:269
@ D3DDECLTYPE_SHORT4
Definition: d3d9types.h:262
@ D3DDECLTYPE_UBYTE4N
Definition: d3d9types.h:264
@ D3DDECLTYPE_USHORT4N
Definition: d3d9types.h:268
@ D3DDECLTYPE_DEC3N
Definition: d3d9types.h:270
@ D3DDECLTYPE_SHORT4N
Definition: d3d9types.h:266
@ D3DDECLTYPE_FLOAT2
Definition: d3d9types.h:256
@ D3DDECLTYPE_FLOAT4
Definition: d3d9types.h:258
@ D3DDECLTYPE_USHORT2N
Definition: d3d9types.h:267
static struct udec3 dword_to_udec3(DWORD d)
Definition: mesh.c:6650
static struct dec3n dword_to_dec3n(DWORD d)
Definition: mesh.c:6695
_Check_return_ __CRT_INLINE float __CRTDECL fabsf(_In_ float x)
Definition: math.h:179
#define PRECISION
Definition: pchw.c:28
short SHORT
Definition: pedump.c:59
unsigned short USHORT
Definition: pedump.c:61
FLOAT x
Definition: d3dx9math.h:64
FLOAT y
Definition: d3dx9math.h:64
Definition: mesh.c:6688
INT w
Definition: mesh.c:6692
INT y
Definition: mesh.c:6690
INT z
Definition: mesh.c:6691
INT x
Definition: mesh.c:6689
Definition: mesh.c:6643
UINT w
Definition: mesh.c:6647
UINT x
Definition: mesh.c:6644
UINT y
Definition: mesh.c:6645
UINT z
Definition: mesh.c:6646
#define max(a, b)
Definition: svc.c:63

Referenced by test_clone_mesh(), and test_weld_vertices().

◆ clear_normals()

static HRESULT clear_normals ( ID3DXMesh *  mesh)
static

Definition at line 10693 of file mesh.c.

10694{
10695 HRESULT hr;
10696 BYTE *vertices;
10697 size_t normal_size;
10698 DWORD i, num_vertices, vertex_stride;
10699 const D3DXVECTOR4 normal = {NAN, NAN, NAN, NAN};
10700 D3DVERTEXELEMENT9 *normal_declaration = NULL;
10702
10703 if (FAILED(hr = mesh->lpVtbl->GetDeclaration(mesh, declaration)))
10704 return hr;
10705
10706 for (i = 0; declaration[i].Stream != 0xff; i++)
10707 {
10708 if (declaration[i].Usage == D3DDECLUSAGE_NORMAL && !declaration[i].UsageIndex)
10709 {
10710 normal_declaration = &declaration[i];
10711 break;
10712 }
10713 }
10714
10715 if (!normal_declaration)
10716 return D3DERR_INVALIDCALL;
10717
10718 if (normal_declaration->Type == D3DDECLTYPE_FLOAT3)
10719 {
10720 normal_size = sizeof(D3DXVECTOR3);
10721 }
10722 else if (normal_declaration->Type == D3DDECLTYPE_FLOAT4)
10723 {
10724 normal_size = sizeof(D3DXVECTOR4);
10725 }
10726 else
10727 {
10728 trace("Cannot clear normals\n");
10729 return E_NOTIMPL;
10730 }
10731
10732 num_vertices = mesh->lpVtbl->GetNumVertices(mesh);
10733 vertex_stride = mesh->lpVtbl->GetNumBytesPerVertex(mesh);
10734
10735 if (FAILED(hr = mesh->lpVtbl->LockVertexBuffer(mesh, 0, (void **)&vertices)))
10736 return hr;
10737
10738 vertices += normal_declaration->Offset;
10739
10740 for (i = 0; i < num_vertices; i++, vertices += vertex_stride)
10741 memcpy(vertices, &normal, normal_size);
10742
10743 return mesh->lpVtbl->UnlockVertexBuffer(mesh);
10744}
#define trace
Definition: atltest.h:70
@ D3DDECLUSAGE_NORMAL
Definition: d3d9types.h:223
#define D3DDECL_END()
Definition: d3d9types.h:311
#define D3DERR_INVALIDCALL
struct _D3DVECTOR D3DXVECTOR3
Definition: d3dx9math.h:97
@ MAX_FVF_DECL_SIZE
Definition: d3dx9mesh.h:41
#define E_NOTIMPL
Definition: ddrawi.h:99
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:384
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define NAN
Definition: mesh.c:39
@ normal
Definition: optimize.h:166

Referenced by test_compute_normals().

◆ compare()

static BOOL compare ( FLOAT  u,
FLOAT  v 
)
static

Definition at line 59 of file mesh.c.

60{
61 return (fabs(u-v) < admitted_error);
62}
const GLdouble * v
Definition: gl.h:2040
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 * u
Definition: glfuncs.h:240
_Check_return_ _CRT_JIT_INTRINSIC double __cdecl fabs(_In_ double x)
Definition: fabs.c:17
#define admitted_error
Definition: mesh.c:46

◆ compare_elements()

static void compare_elements ( const D3DVERTEXELEMENT9 elements,
const D3DVERTEXELEMENT9 expected_elements,
unsigned int  line,
unsigned int  test_id 
)
static

Definition at line 610 of file mesh.c.

612{
614 unsigned int i;
615
616 for (i = 0; i < MAX_FVF_DECL_SIZE; i++)
617 {
618 int end1 = memcmp(&elements[i], &last, sizeof(last));
619 int end2 = memcmp(&expected_elements[i], &last, sizeof(last));
620 int status;
621
622 if (!end1 && !end2) break;
623
624 status = !end1 ^ !end2;
625 ok(!status, "Line %u, test %u: Mismatch in size, test declaration is %s than expected.\n",
626 line, test_id, end1 ? "shorter" : "longer");
627 if (status)
628 {
629 print_elements(elements);
630 break;
631 }
632
633 status = memcmp(&elements[i], &expected_elements[i], sizeof(D3DVERTEXELEMENT9));
634 ok(!status, "Line %u, test %u: Mismatch in element %u.\n", line, test_id, i);
635 if (status)
636 {
637 print_elements(elements);
638 break;
639 }
640 }
641}
#define ok(value,...)
Definition: atltest.h:57
POINT last
Definition: font.c:46
static void print_elements(const D3DVERTEXELEMENT9 *elements)
Definition: mesh.c:594
Definition: ps.c:97

Referenced by test_create_skin_info(), test_fvf_to_decl(), and test_load_skin_mesh_from_xof().

◆ compare_face()

static BOOL compare_face ( face  a,
face  b 
)
static

Definition at line 105 of file mesh.c.

106{
107 return (a[0]==b[0] && a[1] == b[1] && a[2] == b[2]);
108}
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by compare_mesh().

◆ compare_mesh()

static void compare_mesh ( const char name,
ID3DXMesh *  d3dxmesh,
struct mesh mesh 
)
static

Definition at line 235 of file mesh.c.

236{
237 HRESULT hr;
238 DWORD number_of_vertices, number_of_faces;
239 IDirect3DVertexBuffer9 *vertex_buffer;
240 IDirect3DIndexBuffer9 *index_buffer;
241 D3DVERTEXBUFFER_DESC vertex_buffer_description;
242 D3DINDEXBUFFER_DESC index_buffer_description;
243 struct vertex *vertices;
244 face *faces;
245 int expected, i;
246
247 number_of_vertices = d3dxmesh->lpVtbl->GetNumVertices(d3dxmesh);
248 ok(number_of_vertices == mesh->number_of_vertices, "Test %s, result %u, expected %d\n",
249 name, number_of_vertices, mesh->number_of_vertices);
250
251 number_of_faces = d3dxmesh->lpVtbl->GetNumFaces(d3dxmesh);
252 ok(number_of_faces == mesh->number_of_faces, "Test %s, result %u, expected %d\n",
253 name, number_of_faces, mesh->number_of_faces);
254
255 /* vertex buffer */
256 hr = d3dxmesh->lpVtbl->GetVertexBuffer(d3dxmesh, &vertex_buffer);
257 ok(hr == D3D_OK, "Test %s, result %x, expected 0 (D3D_OK)\n", name, hr);
258
259 if (hr != D3D_OK)
260 {
261 skip("Couldn't get vertex buffer\n");
262 }
263 else
264 {
265 hr = IDirect3DVertexBuffer9_GetDesc(vertex_buffer, &vertex_buffer_description);
266 ok(hr == D3D_OK, "Test %s, result %x, expected 0 (D3D_OK)\n", name, hr);
267
268 if (hr != D3D_OK)
269 {
270 skip("Couldn't get vertex buffer description\n");
271 }
272 else
273 {
274 ok(vertex_buffer_description.Format == D3DFMT_VERTEXDATA, "Test %s, result %x, expected %x (D3DFMT_VERTEXDATA)\n",
275 name, vertex_buffer_description.Format, D3DFMT_VERTEXDATA);
276 ok(vertex_buffer_description.Type == D3DRTYPE_VERTEXBUFFER, "Test %s, result %x, expected %x (D3DRTYPE_VERTEXBUFFER)\n",
277 name, vertex_buffer_description.Type, D3DRTYPE_VERTEXBUFFER);
278 ok(vertex_buffer_description.Usage == 0, "Test %s, result %x, expected %x\n", name, vertex_buffer_description.Usage, 0);
279 ok(vertex_buffer_description.Pool == D3DPOOL_MANAGED, "Test %s, result %x, expected %x (D3DPOOL_MANAGED)\n",
280 name, vertex_buffer_description.Pool, D3DPOOL_MANAGED);
281 ok(vertex_buffer_description.FVF == mesh->fvf, "Test %s, result %x, expected %x\n",
282 name, vertex_buffer_description.FVF, mesh->fvf);
283 if (mesh->fvf == 0)
284 {
285 expected = number_of_vertices * mesh->vertex_size;
286 }
287 else
288 {
289 expected = number_of_vertices * D3DXGetFVFVertexSize(mesh->fvf);
290 }
291 ok(vertex_buffer_description.Size == expected, "Test %s, result %x, expected %x\n",
292 name, vertex_buffer_description.Size, expected);
293 }
294
295 /* specify offset and size to avoid potential overruns */
296 hr = IDirect3DVertexBuffer9_Lock(vertex_buffer, 0, number_of_vertices * sizeof(D3DXVECTOR3) * 2,
297 (void **)&vertices, D3DLOCK_DISCARD);
298 ok(hr == D3D_OK, "Test %s, result %x, expected 0 (D3D_OK)\n", name, hr);
299
300 if (hr != D3D_OK)
301 {
302 skip("Couldn't lock vertex buffer\n");
303 }
304 else
305 {
306 for (i = 0; i < number_of_vertices; i++)
307 {
308 ok(compare_vec3(vertices[i].position, mesh->vertices[i].position),
309 "Test %s, vertex position %d, result (%g, %g, %g), expected (%g, %g, %g)\n", name, i,
310 vertices[i].position.x, vertices[i].position.y, vertices[i].position.z,
311 mesh->vertices[i].position.x, mesh->vertices[i].position.y, mesh->vertices[i].position.z);
312 ok(compare_vec3(vertices[i].normal, mesh->vertices[i].normal),
313 "Test %s, vertex normal %d, result (%g, %g, %g), expected (%g, %g, %g)\n", name, i,
314 vertices[i].normal.x, vertices[i].normal.y, vertices[i].normal.z,
315 mesh->vertices[i].normal.x, mesh->vertices[i].normal.y, mesh->vertices[i].normal.z);
316 }
317
319 }
320
322 }
323
324 /* index buffer */
325 hr = d3dxmesh->lpVtbl->GetIndexBuffer(d3dxmesh, &index_buffer);
326 ok(hr == D3D_OK, "Test %s, result %x, expected 0 (D3D_OK)\n", name, hr);
327
328 if (!index_buffer)
329 {
330 skip("Couldn't get index buffer\n");
331 }
332 else
333 {
334 hr = IDirect3DIndexBuffer9_GetDesc(index_buffer, &index_buffer_description);
335 ok(hr == D3D_OK, "Test %s, result %x, expected 0 (D3D_OK)\n", name, hr);
336
337 if (hr != D3D_OK)
338 {
339 skip("Couldn't get index buffer description\n");
340 }
341 else
342 {
343 ok(index_buffer_description.Format == D3DFMT_INDEX16, "Test %s, result %x, expected %x (D3DFMT_INDEX16)\n",
344 name, index_buffer_description.Format, D3DFMT_INDEX16);
345 ok(index_buffer_description.Type == D3DRTYPE_INDEXBUFFER, "Test %s, result %x, expected %x (D3DRTYPE_INDEXBUFFER)\n",
346 name, index_buffer_description.Type, D3DRTYPE_INDEXBUFFER);
347 ok(index_buffer_description.Usage == 0, "Test %s, result %#x, expected %#x.\n",
348 name, index_buffer_description.Usage, 0);
349 ok(index_buffer_description.Pool == D3DPOOL_MANAGED, "Test %s, result %x, expected %x (D3DPOOL_MANAGED)\n",
350 name, index_buffer_description.Pool, D3DPOOL_MANAGED);
351 expected = number_of_faces * sizeof(WORD) * 3;
352 ok(index_buffer_description.Size == expected, "Test %s, result %x, expected %x\n",
353 name, index_buffer_description.Size, expected);
354 }
355
356 /* specify offset and size to avoid potential overruns */
357 hr = IDirect3DIndexBuffer9_Lock(index_buffer, 0, number_of_faces * sizeof(WORD) * 3,
358 (void **)&faces, D3DLOCK_DISCARD);
359 ok(hr == D3D_OK, "Test %s, result %x, expected 0 (D3D_OK)\n", name, hr);
360
361 if (hr != D3D_OK)
362 {
363 skip("Couldn't lock index buffer\n");
364 }
365 else
366 {
367 for (i = 0; i < number_of_faces; i++)
368 {
369 ok(compare_face(faces[i], mesh->faces[i]),
370 "Test %s, face %d, result (%u, %u, %u), expected (%u, %u, %u)\n", name, i,
371 faces[i][0], faces[i][1], faces[i][2],
372 mesh->faces[i][0], mesh->faces[i][1], mesh->faces[i][2]);
373 }
374
375 IDirect3DIndexBuffer9_Unlock(index_buffer);
376 }
377
378 IDirect3DIndexBuffer9_Release(index_buffer);
379 }
380}
#define skip(...)
Definition: atltest.h:64
#define D3DLOCK_DISCARD
Definition: d3d8types.h:72
@ D3DFMT_VERTEXDATA
Definition: d3d8types.h:648
@ D3DFMT_INDEX16
Definition: d3d8types.h:649
@ D3DRTYPE_INDEXBUFFER
Definition: d3d8types.h:816
@ D3DRTYPE_VERTEXBUFFER
Definition: d3d8types.h:815
@ D3DPOOL_MANAGED
Definition: d3d8types.h:710
#define IDirect3DIndexBuffer9_Unlock(p)
Definition: d3d9.h:776
#define IDirect3DVertexBuffer9_Unlock(p)
Definition: d3d9.h:708
#define IDirect3DVertexBuffer9_Release(p)
Definition: d3d9.h:696
#define IDirect3DVertexBuffer9_Lock(p, a, b, c, d)
Definition: d3d9.h:707
#define IDirect3DVertexBuffer9_GetDesc(p, a)
Definition: d3d9.h:709
#define IDirect3DIndexBuffer9_GetDesc(p, a)
Definition: d3d9.h:777
#define IDirect3DIndexBuffer9_Lock(p, a, b, c, d)
Definition: d3d9.h:775
#define IDirect3DIndexBuffer9_Release(p)
Definition: d3d9.h:764
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
static BOOL compare_face(face a, face b)
Definition: mesh.c:105
static BOOL compare_vec3(D3DXVECTOR3 u, D3DXVECTOR3 v)
Definition: mesh.c:64
D3DRESOURCETYPE Type
Definition: d3d8types.h:1053
D3DRESOURCETYPE Type
Definition: d3d8types.h:1189
DWORD number_of_vertices
Definition: mesh.c:199
struct vertex * vertices
Definition: mesh.c:200
DWORD fvf
Definition: mesh.c:205
DWORD number_of_faces
Definition: mesh.c:202
face * faces
Definition: mesh.c:203
UINT vertex_size
Definition: mesh.c:206
Definition: mesh.c:4558
D3DXVECTOR3 position
Definition: mesh.c:4559

Referenced by D3DXCreateMeshFVFTest(), D3DXCreateMeshTest(), test_box(), test_cylinder(), test_polygon(), test_sphere(), and test_torus().

◆ compare_normals()

static void compare_normals ( unsigned int  line,
const char test_name,
ID3DXMesh *  mesh,
const D3DXVECTOR3 normals,
unsigned int  num_normals 
)
static

Definition at line 10746 of file mesh.c.

10748{
10749 unsigned int i;
10750 BYTE *vertices;
10751 DWORD num_vertices, vertex_stride;
10752 D3DVERTEXELEMENT9 *normal_declaration = NULL;
10754
10755 if (FAILED(mesh->lpVtbl->GetDeclaration(mesh, declaration)))
10756 {
10757 ok_(__FILE__, line)(0, "%s: Failed to get declaration\n", test_name);
10758 return;
10759 }
10760
10761 for (i = 0; declaration[i].Stream != 0xff; i++)
10762 {
10763 if (declaration[i].Usage == D3DDECLUSAGE_NORMAL && !declaration[i].UsageIndex)
10764 {
10765 normal_declaration = &declaration[i];
10766 break;
10767 }
10768 }
10769
10770 if (!normal_declaration)
10771 {
10772 ok_(__FILE__, line)(0, "%s: Mesh has no normals\n", test_name);
10773 return;
10774 }
10775
10776 if (normal_declaration->Type != D3DDECLTYPE_FLOAT3 && normal_declaration->Type != D3DDECLTYPE_FLOAT4)
10777 {
10778 ok_(__FILE__, line)(0, "%s: Mesh has invalid normals type\n", test_name);
10779 return;
10780 }
10781
10782 num_vertices = mesh->lpVtbl->GetNumVertices(mesh);
10783 vertex_stride = mesh->lpVtbl->GetNumBytesPerVertex(mesh);
10784
10785 ok_(__FILE__, line)(num_vertices == num_normals, "%s: Expected %u vertices, got %u\n", test_name,
10786 num_normals, num_vertices);
10787
10788 if (FAILED(mesh->lpVtbl->LockVertexBuffer(mesh, 0, (void **)&vertices)))
10789 {
10790 ok_(__FILE__, line)(0, "%s: Failed to compare normals\n", test_name);
10791 return;
10792 }
10793
10794 vertices += normal_declaration->Offset;
10795
10796 for (i = 0; i < min(num_vertices, num_normals); i++, vertices += vertex_stride)
10797 {
10798 if (normal_declaration->Type == D3DDECLTYPE_FLOAT3)
10799 {
10800 const D3DXVECTOR3 *n = (D3DXVECTOR3 *)vertices;
10801 ok_(__FILE__, line)(compare_vec3(*n, normals[i]),
10802 "%s: normal %2u, expected (%f, %f, %f), got (%f, %f, %f)\n",
10803 test_name, i, normals[i].x, normals[i].y, normals[i].z, n->x, n->y, n->z);
10804 }
10805 else
10806 {
10807 const D3DXVECTOR4 *n = (D3DXVECTOR4 *)vertices;
10808 const D3DXVECTOR4 normal = {normals[i].x, normals[i].y, normals[i].z, 1.0f};
10809 ok_(__FILE__, line)(compare_vec4(*n, normal),
10810 "%s: normal %2u, expected (%f, %f, %f, %f), got (%f, %f, %f, %f)\n",
10811 test_name, i, normals[i].x, normals[i].y, normals[i].z, 1.0f,
10812 n->x, n->y, n->z, n->w);
10813 }
10814 }
10815
10816 mesh->lpVtbl->UnlockVertexBuffer(mesh);
10817}
GLdouble n
Definition: glext.h:7729
static BOOL compare_vec4(D3DXVECTOR4 u, D3DXVECTOR4 v)
Definition: mesh.c:69
static const char * test_name
Definition: run.c:177

Referenced by test_compute_normals().

◆ compare_text_outline_mesh()

static void compare_text_outline_mesh ( const char name,
ID3DXMesh *  d3dxmesh,
struct mesh mesh,
size_t  textlen,
float  extrusion,
const struct glyphinfo glyphs 
)
static

Definition at line 3977 of file mesh.c.

3979{
3980 HRESULT hr;
3981 DWORD number_of_vertices, number_of_faces;
3982 IDirect3DVertexBuffer9 *vertex_buffer = NULL;
3983 IDirect3DIndexBuffer9 *index_buffer = NULL;
3984 D3DVERTEXBUFFER_DESC vertex_buffer_description;
3985 D3DINDEXBUFFER_DESC index_buffer_description;
3986 struct vertex *vertices = NULL;
3987 face *faces = NULL;
3988 int expected, i;
3989 int vtx_idx1, face_idx1, vtx_idx2, face_idx2;
3990
3991 number_of_vertices = d3dxmesh->lpVtbl->GetNumVertices(d3dxmesh);
3992 number_of_faces = d3dxmesh->lpVtbl->GetNumFaces(d3dxmesh);
3993
3994 hr = d3dxmesh->lpVtbl->GetVertexBuffer(d3dxmesh, &vertex_buffer);
3995 ok(hr == D3D_OK, "Test %s, unexpected hr %#x.\n", name, hr);
3996 hr = IDirect3DVertexBuffer9_GetDesc(vertex_buffer, &vertex_buffer_description);
3997 ok(hr == D3D_OK, "Test %s, unexpected hr %#x.\n", name, hr);
3998 ok(vertex_buffer_description.Format == D3DFMT_VERTEXDATA, "Test %s, unexpected format %u.\n",
3999 name, vertex_buffer_description.Format);
4000 ok(vertex_buffer_description.Type == D3DRTYPE_VERTEXBUFFER, "Test %s, unexpected resource type %u.\n",
4001 name, vertex_buffer_description.Type);
4002 ok(!vertex_buffer_description.Usage, "Test %s, unexpected usage %#x.\n", name, vertex_buffer_description.Usage);
4003 ok(vertex_buffer_description.Pool == D3DPOOL_MANAGED, "Test %s, unexpected pool %u.\n",
4004 name, vertex_buffer_description.Pool);
4005 ok(vertex_buffer_description.FVF == mesh->fvf, "Test %s, unexpected FVF %#x (expected %#x).\n",
4006 name, vertex_buffer_description.FVF, mesh->fvf);
4007 if (!mesh->fvf)
4008 expected = number_of_vertices * mesh->vertex_size;
4009 else
4010 expected = number_of_vertices * D3DXGetFVFVertexSize(mesh->fvf);
4011 ok(vertex_buffer_description.Size == expected, "Test %s, unexpected size %u (expected %u).\n",
4012 name, vertex_buffer_description.Size, expected);
4013
4014 hr = d3dxmesh->lpVtbl->GetIndexBuffer(d3dxmesh, &index_buffer);
4015 ok(hr == D3D_OK, "Test %s, unexpected hr %#x.\n", name, hr);
4016 hr = IDirect3DIndexBuffer9_GetDesc(index_buffer, &index_buffer_description);
4017 ok(hr == D3D_OK, "Test %s, unexpected hr %#x.\n", name, hr);
4018 ok(index_buffer_description.Format == D3DFMT_INDEX16, "Test %s, unexpected format %u.\n",
4019 name, index_buffer_description.Format);
4020 ok(index_buffer_description.Type == D3DRTYPE_INDEXBUFFER, "Test %s, unexpected resource type %u.\n",
4021 name, index_buffer_description.Type);
4022 ok(!index_buffer_description.Usage, "Test %s, unexpected usage %#x.\n",
4023 name, index_buffer_description.Usage);
4024 ok(index_buffer_description.Pool == D3DPOOL_MANAGED, "Test %s, unexpected pool %u.\n",
4025 name, index_buffer_description.Pool);
4026 expected = number_of_faces * sizeof(WORD) * 3;
4027 ok(index_buffer_description.Size == expected, "Test %s, unexpected size %u.\n",
4028 name, index_buffer_description.Size);
4029
4030 hr = IDirect3DVertexBuffer9_Lock(vertex_buffer, 0, number_of_vertices * sizeof(D3DXVECTOR3) * 2,
4031 (void **)&vertices, D3DLOCK_DISCARD);
4032 ok(hr == D3D_OK, "Test %s, unexpected hr %#x.\n", name, hr);
4033 hr = IDirect3DIndexBuffer9_Lock(index_buffer, 0, number_of_faces * sizeof(WORD) * 3,
4034 (void **)&faces, D3DLOCK_DISCARD);
4035 ok(hr == D3D_OK, "Test %s, unexpected hr %#x.\n", name, hr);
4036 face_idx1 = 0;
4037 vtx_idx2 = 0;
4038 face_idx2 = 0;
4039 vtx_idx1 = 0;
4040 for (i = 0; i < textlen; i++)
4041 {
4042 int nb_outline_vertices1, nb_outline_faces1;
4043 int nb_outline_vertices2, nb_outline_faces2;
4044 int nb_back_vertices, nb_back_faces;
4045 int first_vtx1, first_vtx2;
4046 int first_face1, first_face2;
4047 int j;
4048
4049 first_vtx1 = vtx_idx1;
4050 first_vtx2 = vtx_idx2;
4051 /* Glyphs without outlines do not generate any vertices. */
4052 if (glyphs[i].outlines.count > 0)
4053 {
4054 for (; vtx_idx1 < number_of_vertices; vtx_idx1++)
4055 {
4056 if (vertices[vtx_idx1].normal.z != 0)
4057 break;
4058 }
4059
4060 for (; vtx_idx2 < mesh->number_of_vertices; vtx_idx2++)
4061 {
4062 if (mesh->vertices[vtx_idx2].normal.z != 0)
4063 break;
4064 }
4065 }
4066 nb_outline_vertices1 = vtx_idx1 - first_vtx1;
4067 nb_outline_vertices2 = vtx_idx2 - first_vtx2;
4068 ok(nb_outline_vertices1 == nb_outline_vertices2,
4069 "Test %s, glyph %d, outline vertex count result %d, expected %d\n", name, i,
4070 nb_outline_vertices1, nb_outline_vertices2);
4071
4072 for (j = 0; j < min(nb_outline_vertices1, nb_outline_vertices2); j++)
4073 {
4074 vtx_idx1 = first_vtx1 + j;
4075 vtx_idx2 = first_vtx2 + j;
4076 ok(compare_vec3(vertices[vtx_idx1].position, mesh->vertices[vtx_idx2].position),
4077 "Test %s, glyph %d, vertex position %d, result (%g, %g, %g), expected (%g, %g, %g)\n", name, i, vtx_idx1,
4078 vertices[vtx_idx1].position.x, vertices[vtx_idx1].position.y, vertices[vtx_idx1].position.z,
4079 mesh->vertices[vtx_idx2].position.x, mesh->vertices[vtx_idx2].position.y, mesh->vertices[vtx_idx2].position.z);
4080 ok(compare_vec3(vertices[vtx_idx1].normal, mesh->vertices[first_vtx2 + j].normal),
4081 "Test %s, glyph %d, vertex normal %d, result (%g, %g, %g), expected (%g, %g, %g)\n", name, i, vtx_idx1,
4082 vertices[vtx_idx1].normal.x, vertices[vtx_idx1].normal.y, vertices[vtx_idx1].normal.z,
4083 mesh->vertices[vtx_idx2].normal.x, mesh->vertices[vtx_idx2].normal.y, mesh->vertices[vtx_idx2].normal.z);
4084 }
4085 vtx_idx1 = first_vtx1 + nb_outline_vertices1;
4086 vtx_idx2 = first_vtx2 + nb_outline_vertices2;
4087
4088 first_face1 = face_idx1;
4089 first_face2 = face_idx2;
4090 for (; face_idx1 < number_of_faces; face_idx1++)
4091 {
4092 if (faces[face_idx1][0] >= vtx_idx1 ||
4093 faces[face_idx1][1] >= vtx_idx1 ||
4094 faces[face_idx1][2] >= vtx_idx1)
4095 break;
4096 }
4097 for (; face_idx2 < mesh->number_of_faces; face_idx2++)
4098 {
4099 if (mesh->faces[face_idx2][0] >= vtx_idx2 ||
4100 mesh->faces[face_idx2][1] >= vtx_idx2 ||
4101 mesh->faces[face_idx2][2] >= vtx_idx2)
4102 break;
4103 }
4104 nb_outline_faces1 = face_idx1 - first_face1;
4105 nb_outline_faces2 = face_idx2 - first_face2;
4106 ok(nb_outline_faces1 == nb_outline_faces2,
4107 "Test %s, glyph %d, outline face count result %d, expected %d\n", name, i,
4108 nb_outline_faces1, nb_outline_faces2);
4109
4110 for (j = 0; j < min(nb_outline_faces1, nb_outline_faces2); j++)
4111 {
4112 face_idx1 = first_face1 + j;
4113 face_idx2 = first_face2 + j;
4114 ok(faces[face_idx1][0] - first_vtx1 == mesh->faces[face_idx2][0] - first_vtx2 &&
4115 faces[face_idx1][1] - first_vtx1 == mesh->faces[face_idx2][1] - first_vtx2 &&
4116 faces[face_idx1][2] - first_vtx1 == mesh->faces[face_idx2][2] - first_vtx2,
4117 "Test %s, glyph %d, face %d, result (%d, %d, %d), expected (%d, %d, %d)\n", name, i, face_idx1,
4118 faces[face_idx1][0], faces[face_idx1][1], faces[face_idx1][2],
4119 mesh->faces[face_idx2][0] - first_vtx2 + first_vtx1,
4120 mesh->faces[face_idx2][1] - first_vtx2 + first_vtx1,
4121 mesh->faces[face_idx2][2] - first_vtx2 + first_vtx1);
4122 }
4123 face_idx1 = first_face1 + nb_outline_faces1;
4124 face_idx2 = first_face2 + nb_outline_faces2;
4125
4126 /* partial test on back vertices and faces */
4127 first_vtx1 = vtx_idx1;
4128 for (; vtx_idx1 < number_of_vertices; vtx_idx1++) {
4129 struct vertex vtx;
4130
4131 if (vertices[vtx_idx1].normal.z != 1.0f)
4132 break;
4133
4134 vtx.position.z = 0.0f;
4135 vtx.normal.x = 0.0f;
4136 vtx.normal.y = 0.0f;
4137 vtx.normal.z = 1.0f;
4138 ok(compare(vertices[vtx_idx1].position.z, vtx.position.z),
4139 "Test %s, glyph %d, vertex position.z %d, result %g, expected %g\n", name, i, vtx_idx1,
4140 vertices[vtx_idx1].position.z, vtx.position.z);
4141 ok(compare_vec3(vertices[vtx_idx1].normal, vtx.normal),
4142 "Test %s, glyph %d, vertex normal %d, result (%g, %g, %g), expected (%g, %g, %g)\n", name, i, vtx_idx1,
4143 vertices[vtx_idx1].normal.x, vertices[vtx_idx1].normal.y, vertices[vtx_idx1].normal.z,
4144 vtx.normal.x, vtx.normal.y, vtx.normal.z);
4145 }
4146 nb_back_vertices = vtx_idx1 - first_vtx1;
4147 first_face1 = face_idx1;
4148 for (; face_idx1 < number_of_faces; face_idx1++)
4149 {
4150 const D3DXVECTOR3 *vtx1, *vtx2, *vtx3;
4152 D3DXVECTOR3 v1 = {0, 0, 0};
4153 D3DXVECTOR3 v2 = {0, 0, 0};
4154 D3DXVECTOR3 forward = {0.0f, 0.0f, 1.0f};
4155
4156 if (faces[face_idx1][0] >= vtx_idx1 ||
4157 faces[face_idx1][1] >= vtx_idx1 ||
4158 faces[face_idx1][2] >= vtx_idx1)
4159 break;
4160
4161 vtx1 = &vertices[faces[face_idx1][0]].position;
4162 vtx2 = &vertices[faces[face_idx1][1]].position;
4163 vtx3 = &vertices[faces[face_idx1][2]].position;
4164
4165 D3DXVec3Subtract(&v1, vtx2, vtx1);
4166 D3DXVec3Subtract(&v2, vtx3, vtx2);
4167 D3DXVec3Cross(&normal, &v1, &v2);
4169 ok(!D3DXVec3Length(&normal) || compare_vec3(normal, forward),
4170 "Test %s, glyph %d, face %d normal, result (%g, %g, %g), expected (%g, %g, %g)\n", name, i, face_idx1,
4171 normal.x, normal.y, normal.z, forward.x, forward.y, forward.z);
4172 }
4173 nb_back_faces = face_idx1 - first_face1;
4174
4175 /* compare front and back faces & vertices */
4176 if (extrusion == 0.0f) {
4177 /* Oddly there are only back faces in this case */
4178 nb_back_vertices /= 2;
4179 nb_back_faces /= 2;
4180 face_idx1 -= nb_back_faces;
4181 vtx_idx1 -= nb_back_vertices;
4182 }
4183 for (j = 0; j < nb_back_vertices; j++)
4184 {
4185 struct vertex vtx = vertices[first_vtx1];
4186 vtx.position.z = -extrusion;
4187 vtx.normal.x = 0.0f;
4188 vtx.normal.y = 0.0f;
4189 vtx.normal.z = extrusion == 0.0f ? 1.0f : -1.0f;
4190 ok(compare_vec3(vertices[vtx_idx1].position, vtx.position),
4191 "Test %s, glyph %d, vertex position %d, result (%g, %g, %g), expected (%g, %g, %g)\n", name, i, vtx_idx1,
4192 vertices[vtx_idx1].position.x, vertices[vtx_idx1].position.y, vertices[vtx_idx1].position.z,
4193 vtx.position.x, vtx.position.y, vtx.position.z);
4194 ok(compare_vec3(vertices[vtx_idx1].normal, vtx.normal),
4195 "Test %s, glyph %d, vertex normal %d, result (%g, %g, %g), expected (%g, %g, %g)\n", name, i, vtx_idx1,
4196 vertices[vtx_idx1].normal.x, vertices[vtx_idx1].normal.y, vertices[vtx_idx1].normal.z,
4197 vtx.normal.x, vtx.normal.y, vtx.normal.z);
4198 vtx_idx1++;
4199 first_vtx1++;
4200 }
4201 for (j = 0; j < nb_back_faces; j++)
4202 {
4203 int f1, f2;
4204 if (extrusion == 0.0f) {
4205 f1 = 1;
4206 f2 = 2;
4207 } else {
4208 f1 = 2;
4209 f2 = 1;
4210 }
4211 ok(faces[face_idx1][0] == faces[first_face1][0] + nb_back_vertices &&
4212 faces[face_idx1][1] == faces[first_face1][f1] + nb_back_vertices &&
4213 faces[face_idx1][2] == faces[first_face1][f2] + nb_back_vertices,
4214 "Test %s, glyph %d, face %d, result (%d, %d, %d), expected (%d, %d, %d)\n", name, i, face_idx1,
4215 faces[face_idx1][0], faces[face_idx1][1], faces[face_idx1][2],
4216 faces[first_face1][0] - nb_back_faces,
4217 faces[first_face1][f1] - nb_back_faces,
4218 faces[first_face1][f2] - nb_back_faces);
4219 first_face1++;
4220 face_idx1++;
4221 }
4222
4223 /* skip to the outline for the next glyph */
4224 for (; vtx_idx2 < mesh->number_of_vertices; vtx_idx2++) {
4225 if (mesh->vertices[vtx_idx2].normal.z == 0)
4226 break;
4227 }
4228 for (; face_idx2 < mesh->number_of_faces; face_idx2++)
4229 {
4230 if (mesh->faces[face_idx2][0] >= vtx_idx2 ||
4231 mesh->faces[face_idx2][1] >= vtx_idx2 ||
4232 mesh->faces[face_idx2][2] >= vtx_idx2) break;
4233 }
4234 }
4235
4236 IDirect3DIndexBuffer9_Unlock(index_buffer);
4238 IDirect3DIndexBuffer9_Release(index_buffer);
4240}
D3DXVECTOR3 *WINAPI D3DXVec3Normalize(D3DXVECTOR3 *pout, const D3DXVECTOR3 *pv)
Definition: math.c:1805
GLfloat GLfloat v1
Definition: glext.h:6062
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
static UINT UINT LPWORD glyphs
Definition: font.c:44
#define f2(x, y, z)
Definition: sha1.c:31
#define f1(x, y, z)
Definition: sha1.c:30
D3DXVECTOR3 normal
Definition: mesh.c:4560

Referenced by test_createtext().

◆ compare_vec3()

static BOOL compare_vec3 ( D3DXVECTOR3  u,
D3DXVECTOR3  v 
)
static

Definition at line 64 of file mesh.c.

65{
66 return ( compare(u.x, v.x) && compare(u.y, v.y) && compare(u.z, v.z) );
67}
Definition: bug.cpp:8

Referenced by compare_mesh(), compare_normals(), compare_text_outline_mesh(), D3DXComputeBoundingBoxTest(), and D3DXComputeBoundingSphereTest().

◆ compare_vec4()

static BOOL compare_vec4 ( D3DXVECTOR4  u,
D3DXVECTOR4  v 
)
static

Definition at line 69 of file mesh.c.

70{
71 return compare(u.x, v.x) && compare(u.y, v.y) && compare(u.z, v.z) && compare(u.w, v.w);
72}

Referenced by compare_normals().

◆ compute_box()

static BOOL compute_box ( struct mesh mesh,
float  width,
float  height,
float  depth 
)
static

Definition at line 2574 of file mesh.c.

2575{
2576 unsigned int i, face;
2577 static const D3DXVECTOR3 unit_box[] =
2578 {
2579 {-1.0f, -1.0f, -1.0f}, {-1.0f, -1.0f, 1.0f}, {-1.0f, 1.0f, 1.0f}, {-1.0f, 1.0f, -1.0f},
2580 {-1.0f, 1.0f, -1.0f}, {-1.0f, 1.0f, 1.0f}, { 1.0f, 1.0f, 1.0f}, { 1.0f, 1.0f, -1.0f},
2581 { 1.0f, 1.0f, -1.0f}, { 1.0f, 1.0f, 1.0f}, { 1.0f, -1.0f, 1.0f}, { 1.0f, -1.0f, -1.0f},
2582 {-1.0f, -1.0f, 1.0f}, {-1.0f, -1.0f, -1.0f}, { 1.0f, -1.0f, -1.0f}, { 1.0f, -1.0f, 1.0f},
2583 {-1.0f, -1.0f, 1.0f}, { 1.0f, -1.0f, 1.0f}, { 1.0f, 1.0f, 1.0f}, {-1.0f, 1.0f, 1.0f},
2584 {-1.0f, -1.0f, -1.0f}, {-1.0f, 1.0f, -1.0f}, { 1.0f, 1.0f, -1.0f}, { 1.0f, -1.0f, -1.0f}
2585 };
2586 static const D3DXVECTOR3 normals[] =
2587 {
2588 {-1.0f, 0.0f, 0.0f}, { 0.0f, 1.0f, 0.0f}, { 1.0f, 0.0f, 0.0f},
2589 { 0.0f, -1.0f, 0.0f}, { 0.0f, 0.0f, 1.0f}, { 0.0f, 0.0f, -1.0f}
2590 };
2591
2592 if (!new_mesh(mesh, 24, 12))
2593 {
2594 return FALSE;
2595 }
2596
2597 width /= 2.0f;
2598 height /= 2.0f;
2599 depth /= 2.0f;
2600
2601 for (i = 0; i < 24; i++)
2602 {
2603 mesh->vertices[i].position.x = width * unit_box[i].x;
2604 mesh->vertices[i].position.y = height * unit_box[i].y;
2605 mesh->vertices[i].position.z = depth * unit_box[i].z;
2606 mesh->vertices[i].normal.x = normals[i / 4].x;
2607 mesh->vertices[i].normal.y = normals[i / 4].y;
2608 mesh->vertices[i].normal.z = normals[i / 4].z;
2609 }
2610
2611 face = 0;
2612 for (i = 0; i < 12; i++)
2613 {
2614 mesh->faces[i][0] = face++;
2615 mesh->faces[i][1] = face++;
2616 mesh->faces[i][2] = (i % 2) ? face - 4 : face;
2617 }
2618
2619 return TRUE;
2620}
WORD face[3]
Definition: mesh.c:4747
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
static BOOL new_mesh(struct mesh *mesh, DWORD number_of_vertices, DWORD number_of_faces)
Definition: mesh.c:215

Referenced by test_box().

◆ compute_cylinder()

static BOOL compute_cylinder ( struct mesh mesh,
FLOAT  radius1,
FLOAT  radius2,
FLOAT  length,
UINT  slices,
UINT  stacks 
)
static

Definition at line 3104 of file mesh.c.

3105{
3106 float theta_step, theta_start;
3107 struct sincos_table theta;
3108 FLOAT delta_radius, radius, radius_step;
3109 FLOAT z, z_step, z_normal;
3110 DWORD number_of_vertices, number_of_faces;
3111 DWORD vertex, face;
3112 int slice, stack;
3113
3114 /* theta = angle on xy plane wrt x axis */
3115 theta_step = -2 * D3DX_PI / slices;
3116 theta_start = D3DX_PI / 2;
3117
3118 if (!compute_sincos_table(&theta, theta_start, theta_step, slices))
3119 {
3120 return FALSE;
3121 }
3122
3123 number_of_vertices = 2 + (slices * (3 + stacks));
3124 number_of_faces = 2 * slices + stacks * (2 * slices);
3125
3126 if (!new_mesh(mesh, number_of_vertices, number_of_faces))
3127 {
3128 free_sincos_table(&theta);
3129 return FALSE;
3130 }
3131
3132 vertex = 0;
3133 face = 0;
3134
3135 delta_radius = radius1 - radius2;
3136 radius = radius1;
3137 radius_step = delta_radius / stacks;
3138
3139 z = -length / 2;
3140 z_step = length / stacks;
3141 z_normal = delta_radius / length;
3142 if (isnan(z_normal))
3143 {
3144 z_normal = 0.0f;
3145 }
3146
3147 mesh->vertices[vertex].normal.x = 0.0f;
3148 mesh->vertices[vertex].normal.y = 0.0f;
3149 mesh->vertices[vertex].normal.z = -1.0f;
3150 mesh->vertices[vertex].position.x = 0.0f;
3151 mesh->vertices[vertex].position.y = 0.0f;
3152 mesh->vertices[vertex++].position.z = z;
3153
3154 for (slice = 0; slice < slices; slice++, vertex++)
3155 {
3156 mesh->vertices[vertex].normal.x = 0.0f;
3157 mesh->vertices[vertex].normal.y = 0.0f;
3158 mesh->vertices[vertex].normal.z = -1.0f;
3159 mesh->vertices[vertex].position.x = radius * theta.cos[slice];
3160 mesh->vertices[vertex].position.y = radius * theta.sin[slice];
3161 mesh->vertices[vertex].position.z = z;
3162
3163 if (slice > 0)
3164 {
3165 mesh->faces[face][0] = 0;
3166 mesh->faces[face][1] = slice;
3167 mesh->faces[face++][2] = slice + 1;
3168 }
3169 }
3170
3171 mesh->faces[face][0] = 0;
3172 mesh->faces[face][1] = slice;
3173 mesh->faces[face++][2] = 1;
3174
3175 for (stack = 1; stack <= stacks+1; stack++)
3176 {
3177 for (slice = 0; slice < slices; slice++, vertex++)
3178 {
3179 mesh->vertices[vertex].normal.x = theta.cos[slice];
3180 mesh->vertices[vertex].normal.y = theta.sin[slice];
3181 mesh->vertices[vertex].normal.z = z_normal;
3183 mesh->vertices[vertex].position.x = radius * theta.cos[slice];
3184 mesh->vertices[vertex].position.y = radius * theta.sin[slice];
3185 mesh->vertices[vertex].position.z = z;
3186
3187 if (stack > 1 && slice > 0)
3188 {
3189 mesh->faces[face][0] = vertex_index(slices, slice-1, stack-1);
3190 mesh->faces[face][1] = vertex_index(slices, slice-1, stack);
3191 mesh->faces[face++][2] = vertex_index(slices, slice, stack-1);
3192
3193 mesh->faces[face][0] = vertex_index(slices, slice, stack-1);
3194 mesh->faces[face][1] = vertex_index(slices, slice-1, stack);
3195 mesh->faces[face++][2] = vertex_index(slices, slice, stack);
3196 }
3197 }
3198
3199 if (stack > 1)
3200 {
3201 mesh->faces[face][0] = vertex_index(slices, slice-1, stack-1);
3202 mesh->faces[face][1] = vertex_index(slices, slice-1, stack);
3203 mesh->faces[face++][2] = vertex_index(slices, 0, stack-1);
3204
3205 mesh->faces[face][0] = vertex_index(slices, 0, stack-1);
3206 mesh->faces[face][1] = vertex_index(slices, slice-1, stack);
3207 mesh->faces[face++][2] = vertex_index(slices, 0, stack);
3208 }
3209
3210 if (stack < stacks + 1)
3211 {
3212 z += z_step;
3213 radius -= radius_step;
3214 }
3215 }
3216
3217 for (slice = 0; slice < slices; slice++, vertex++)
3218 {
3219 mesh->vertices[vertex].normal.x = 0.0f;
3220 mesh->vertices[vertex].normal.y = 0.0f;
3221 mesh->vertices[vertex].normal.z = 1.0f;
3222 mesh->vertices[vertex].position.x = radius * theta.cos[slice];
3223 mesh->vertices[vertex].position.y = radius * theta.sin[slice];
3224 mesh->vertices[vertex].position.z = z;
3225
3226 if (slice > 0)
3227 {
3228 mesh->faces[face][0] = vertex_index(slices, slice-1, stack);
3229 mesh->faces[face][1] = number_of_vertices - 1;
3230 mesh->faces[face++][2] = vertex_index(slices, slice, stack);
3231 }
3232 }
3233
3234 mesh->vertices[vertex].position.x = 0.0f;
3235 mesh->vertices[vertex].position.y = 0.0f;
3236 mesh->vertices[vertex].position.z = z;
3237 mesh->vertices[vertex].normal.x = 0.0f;
3238 mesh->vertices[vertex].normal.y = 0.0f;
3239 mesh->vertices[vertex].normal.z = 1.0f;
3240
3241 mesh->faces[face][0] = vertex_index(slices, slice-1, stack);
3242 mesh->faces[face][1] = number_of_vertices - 1;
3243 mesh->faces[face][2] = vertex_index(slices, 0, stack);
3244
3245 free_sincos_table(&theta);
3246
3247 return TRUE;
3248}
Definition: _stack.h:55
#define D3DX_PI
Definition: d3dx9math.h:27
static void free_sincos_table(struct sincos_table *sincos_table)
Definition: mesh.c:4755
static BOOL compute_sincos_table(struct sincos_table *sincos_table, float angle_start, float angle_step, int n)
Definition: mesh.c:4762
static WORD vertex_index(UINT slices, int slice, int stack)
Definition: mesh.c:4790
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLdouble GLdouble z
Definition: glext.h:5874
#define isnan(x)
Definition: mingw_math.h:133

Referenced by test_cylinder().

◆ compute_normals_D3DXComputeNormals()

static HRESULT compute_normals_D3DXComputeNormals ( ID3DXMesh *  mesh,
const DWORD adjacency 
)
static

Definition at line 10819 of file mesh.c.

10820{
10821 return D3DXComputeNormals((ID3DXBaseMesh *)mesh, adjacency);
10822}
HRESULT WINAPI D3DXComputeNormals(struct ID3DXBaseMesh *mesh, const DWORD *adjacency)
Definition: mesh.c:7563

Referenced by test_compute_normals().

◆ compute_normals_D3DXComputeTangentFrameEx()

static HRESULT compute_normals_D3DXComputeTangentFrameEx ( ID3DXMesh *  mesh,
const DWORD adjacency 
)
static

Definition at line 10824 of file mesh.c.

10825{
10828 adjacency, -1.01f, -0.01f, -1.01f, NULL, NULL);
10829}
#define D3DX_DEFAULT
Definition: d3dx9.h:24
@ D3DXTANGENT_CALCULATE_NORMALS
Definition: d3dx9mesh.h:121
@ D3DXTANGENT_GENERATE_IN_PLACE
Definition: d3dx9mesh.h:122
HRESULT WINAPI D3DXComputeTangentFrameEx(ID3DXMesh *mesh, DWORD texture_in_semantic, DWORD texture_in_index, DWORD u_partial_out_semantic, DWORD u_partial_out_index, DWORD v_partial_out_semantic, DWORD v_partial_out_index, DWORD normal_out_semantic, DWORD normal_out_index, DWORD options, const DWORD *adjacency, float partial_edge_threshold, float singular_point_threshold, float normal_edge_threshold, ID3DXMesh **mesh_out, ID3DXBuffer **vertex_mapping)
Definition: mesh.c:7320

Referenced by test_compute_normals().

◆ compute_polygon()

static BOOL compute_polygon ( struct mesh mesh,
float  length,
unsigned int  sides 
)
static

Definition at line 2708 of file mesh.c.

2709{
2710 unsigned int i;
2711 float angle, scale;
2712
2713 if (!new_mesh(mesh, sides + 1, sides))
2714 return FALSE;
2715
2716 angle = D3DX_PI / sides;
2717 scale = 0.5f * length / sinf(angle);
2718 angle *= 2.0f;
2719
2720 mesh->vertices[0].position.x = 0.0f;
2721 mesh->vertices[0].position.y = 0.0f;
2722 mesh->vertices[0].position.z = 0.0f;
2723 mesh->vertices[0].normal.x = 0.0f;
2724 mesh->vertices[0].normal.y = 0.0f;
2725 mesh->vertices[0].normal.z = 1.0f;
2726
2727 for (i = 0; i < sides; ++i)
2728 {
2729 mesh->vertices[i + 1].position.x = cosf(angle * i) * scale;
2730 mesh->vertices[i + 1].position.y = sinf(angle * i) * scale;
2731 mesh->vertices[i + 1].position.z = 0.0f;
2732 mesh->vertices[i + 1].normal.x = 0.0f;
2733 mesh->vertices[i + 1].normal.y = 0.0f;
2734 mesh->vertices[i + 1].normal.z = 1.0f;
2735
2736 mesh->faces[i][0] = 0;
2737 mesh->faces[i][1] = i + 1;
2738 mesh->faces[i][2] = i + 2;
2739 }
2740
2741 mesh->faces[sides - 1][2] = 1;
2742
2743 return TRUE;
2744}
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9032
GLfloat angle
Definition: glext.h:10853
_Check_return_ float __cdecl cosf(_In_ float x)
Definition: math.h:224
_Check_return_ float __cdecl sinf(_In_ float x)
Definition: math.h:233

Referenced by test_polygon().

◆ compute_sincos_table()

static BOOL compute_sincos_table ( struct sincos_table sincos_table,
float  angle_start,
float  angle_step,
int  n 
)
static

Definition at line 2855 of file mesh.c.

2856{
2857 float angle;
2858 int i;
2859
2861 if (!sincos_table->sin)
2862 {
2863 return FALSE;
2864 }
2866 if (!sincos_table->cos)
2867 {
2869 return FALSE;
2870 }
2871
2872 angle = angle_start;
2873 for (i = 0; i < n; i++)
2874 {
2875 sincos_table->sin[i] = sin(angle);
2876 sincos_table->cos[i] = cos(angle);
2877 angle += angle_step;
2878 }
2879
2880 return TRUE;
2881}
_STLP_DECLSPEC complex< float > _STLP_CALL sin(const complex< float > &)
float * sin
Definition: mesh.c:4751
float * cos
Definition: mesh.c:4752

◆ compute_sphere()

static BOOL compute_sphere ( struct mesh mesh,
FLOAT  radius,
UINT  slices,
UINT  stacks 
)
static

Definition at line 2889 of file mesh.c.

2890{
2891 float theta_step, theta_start;
2892 struct sincos_table theta;
2893 float phi_step, phi_start;
2894 struct sincos_table phi;
2895 DWORD number_of_vertices, number_of_faces;
2896 DWORD vertex, face;
2897 int slice, stack;
2898
2899 /* theta = angle on xy plane wrt x axis */
2900 theta_step = D3DX_PI / stacks;
2901 theta_start = theta_step;
2902
2903 /* phi = angle on xz plane wrt z axis */
2904 phi_step = -2 * D3DX_PI / slices;
2905 phi_start = D3DX_PI / 2;
2906
2907 if (!compute_sincos_table(&theta, theta_start, theta_step, stacks))
2908 {
2909 return FALSE;
2910 }
2911 if (!compute_sincos_table(&phi, phi_start, phi_step, slices))
2912 {
2913 free_sincos_table(&theta);
2914 return FALSE;
2915 }
2916
2917 number_of_vertices = 2 + slices * (stacks-1);
2918 number_of_faces = 2 * slices + (stacks - 2) * (2 * slices);
2919
2920 if (!new_mesh(mesh, number_of_vertices, number_of_faces))
2921 {
2922 free_sincos_table(&phi);
2923 free_sincos_table(&theta);
2924 return FALSE;
2925 }
2926
2927 vertex = 0;
2928 face = 0;
2929
2930 mesh->vertices[vertex].normal.x = 0.0f;
2931 mesh->vertices[vertex].normal.y = 0.0f;
2932 mesh->vertices[vertex].normal.z = 1.0f;
2933 mesh->vertices[vertex].position.x = 0.0f;
2934 mesh->vertices[vertex].position.y = 0.0f;
2935 mesh->vertices[vertex].position.z = radius;
2936 vertex++;
2937
2938 for (stack = 0; stack < stacks - 1; stack++)
2939 {
2940 for (slice = 0; slice < slices; slice++)
2941 {
2942 mesh->vertices[vertex].normal.x = theta.sin[stack] * phi.cos[slice];
2943 mesh->vertices[vertex].normal.y = theta.sin[stack] * phi.sin[slice];
2944 mesh->vertices[vertex].normal.z = theta.cos[stack];
2945 mesh->vertices[vertex].position.x = radius * theta.sin[stack] * phi.cos[slice];
2946 mesh->vertices[vertex].position.y = radius * theta.sin[stack] * phi.sin[slice];
2947 mesh->vertices[vertex].position.z = radius * theta.cos[stack];
2948 vertex++;
2949
2950 if (slice > 0)
2951 {
2952 if (stack == 0)
2953 {
2954 /* top stack is triangle fan */
2955 mesh->faces[face][0] = 0;
2956 mesh->faces[face][1] = slice + 1;
2957 mesh->faces[face][2] = slice;
2958 face++;
2959 }
2960 else
2961 {
2962 /* stacks in between top and bottom are quad strips */
2963 mesh->faces[face][0] = vertex_index(slices, slice-1, stack-1);
2964 mesh->faces[face][1] = vertex_index(slices, slice, stack-1);
2965 mesh->faces[face][2] = vertex_index(slices, slice-1, stack);
2966 face++;
2967
2968 mesh->faces[face][0] = vertex_index(slices, slice, stack-1);
2969 mesh->faces[face][1] = vertex_index(slices, slice, stack);
2970 mesh->faces[face][2] = vertex_index(slices, slice-1, stack);
2971 face++;
2972 }
2973 }
2974 }
2975
2976 if (stack == 0)
2977 {
2978 mesh->faces[face][0] = 0;
2979 mesh->faces[face][1] = 1;
2980 mesh->faces[face][2] = slice;
2981 face++;
2982 }
2983 else
2984 {
2985 mesh->faces[face][0] = vertex_index(slices, slice-1, stack-1);
2986 mesh->faces[face][1] = vertex_index(slices, 0, stack-1);
2987 mesh->faces[face][2] = vertex_index(slices, slice-1, stack);
2988 face++;
2989
2990 mesh->faces[face][0] = vertex_index(slices, 0, stack-1);
2991 mesh->faces[face][1] = vertex_index(slices, 0, stack);
2992 mesh->faces[face][2] = vertex_index(slices, slice-1, stack);
2993 face++;
2994 }
2995 }
2996
2997 mesh->vertices[vertex].position.x = 0.0f;
2998 mesh->vertices[vertex].position.y = 0.0f;
2999 mesh->vertices[vertex].position.z = -radius;
3000 mesh->vertices[vertex].normal.x = 0.0f;
3001 mesh->vertices[vertex].normal.y = 0.0f;
3002 mesh->vertices[vertex].normal.z = -1.0f;
3003
3004 /* bottom stack is triangle fan */
3005 for (slice = 1; slice < slices; slice++)
3006 {
3007 mesh->faces[face][0] = vertex_index(slices, slice-1, stack-1);
3008 mesh->faces[face][1] = vertex_index(slices, slice, stack-1);
3009 mesh->faces[face][2] = vertex;
3010 face++;
3011 }
3012
3013 mesh->faces[face][0] = vertex_index(slices, slice-1, stack-1);
3014 mesh->faces[face][1] = vertex_index(slices, 0, stack-1);
3015 mesh->faces[face][2] = vertex;
3016
3017 free_sincos_table(&phi);
3018 free_sincos_table(&theta);
3019
3020 return TRUE;
3021}

Referenced by test_sphere().

◆ compute_text_mesh()

static void compute_text_mesh ( struct mesh mesh,
const char text,
float  deviation,
float  extrusion,
float  otmEMSquare,
const struct glyphinfo glyphs 
)
static

Definition at line 3833 of file mesh.c.

3835{
3836 DWORD nb_vertices, nb_faces;
3837 DWORD nb_corners, nb_outline_points;
3838 int textlen = 0;
3839 int i;
3840 struct vertex *vertex_ptr;
3841 face *face_ptr;
3842
3843 textlen = strlen(text);
3844
3845 /* corner points need an extra vertex for the different side faces normals */
3846 nb_corners = 0;
3847 nb_outline_points = 0;
3848 for (i = 0; i < textlen; i++)
3849 {
3850 int j;
3851 for (j = 0; j < glyphs[i].outlines.count; j++)
3852 {
3853 int k;
3854 struct outline *outline = &glyphs[i].outlines.items[j];
3855 nb_outline_points += outline->count;
3856 nb_corners++; /* first outline point always repeated as a corner */
3857 for (k = 1; k < outline->count; k++)
3858 if (outline->items[k].corner)
3859 nb_corners++;
3860 }
3861 }
3862
3863 nb_vertices = (nb_outline_points + nb_corners) * 2 + textlen;
3864 nb_faces = nb_outline_points * 2;
3865
3866 ok(new_mesh(mesh, nb_vertices, nb_faces), "Failed to create reference text mesh.\n");
3867
3868 /* convert 2D vertices and faces into 3D mesh */
3869 vertex_ptr = mesh->vertices;
3870 face_ptr = mesh->faces;
3871 for (i = 0; i < textlen; i++)
3872 {
3873 int j;
3874
3875 /* side vertices and faces */
3876 for (j = 0; j < glyphs[i].outlines.count; j++)
3877 {
3878 struct vertex *outline_vertices = vertex_ptr;
3879 struct outline *outline = &glyphs[i].outlines.items[j];
3880 int k;
3881 struct point2d *prevpt = &outline->items[outline->count - 1];
3882 struct point2d *pt = &outline->items[0];
3883
3884 for (k = 1; k <= outline->count; k++)
3885 {
3886 struct vertex vtx;
3887 struct point2d *nextpt = &outline->items[k % outline->count];
3888 WORD vtx_idx = vertex_ptr - mesh->vertices;
3890
3891 if (pt->corner == POINTTYPE_CURVE_START)
3892 D3DXVec2Subtract(&vec, &pt->pos, &prevpt->pos);
3893 else if (pt->corner)
3894 D3DXVec2Subtract(&vec, &nextpt->pos, &pt->pos);
3895 else
3896 D3DXVec2Subtract(&vec, &nextpt->pos, &prevpt->pos);
3898 vtx.normal.x = -vec.y;
3899 vtx.normal.y = vec.x;
3900 vtx.normal.z = 0;
3901
3902 vtx.position.x = pt->pos.x + glyphs[i].offset_x;
3903 vtx.position.y = pt->pos.y;
3904 vtx.position.z = 0;
3905 *vertex_ptr++ = vtx;
3906
3907 vtx.position.z = -extrusion;
3908 *vertex_ptr++ = vtx;
3909
3910 vtx.position.x = nextpt->pos.x + glyphs[i].offset_x;
3911 vtx.position.y = nextpt->pos.y;
3912 if (pt->corner && nextpt->corner && nextpt->corner != POINTTYPE_CURVE_END) {
3913 vtx.position.z = -extrusion;
3914 *vertex_ptr++ = vtx;
3915 vtx.position.z = 0;
3916 *vertex_ptr++ = vtx;
3917
3918 (*face_ptr)[0] = vtx_idx;
3919 (*face_ptr)[1] = vtx_idx + 2;
3920 (*face_ptr)[2] = vtx_idx + 1;
3921 face_ptr++;
3922
3923 (*face_ptr)[0] = vtx_idx;
3924 (*face_ptr)[1] = vtx_idx + 3;
3925 (*face_ptr)[2] = vtx_idx + 2;
3926 face_ptr++;
3927 } else {
3928 if (nextpt->corner) {
3929 if (nextpt->corner == POINTTYPE_CURVE_END) {
3930 struct point2d *nextpt2 = &outline->items[(k + 1) % outline->count];
3931 D3DXVec2Subtract(&vec, &nextpt2->pos, &nextpt->pos);
3932 } else {
3933 D3DXVec2Subtract(&vec, &nextpt->pos, &pt->pos);
3934 }
3936 vtx.normal.x = -vec.y;
3937 vtx.normal.y = vec.x;
3938
3939 vtx.position.z = 0;
3940 *vertex_ptr++ = vtx;
3941 vtx.position.z = -extrusion;
3942 *vertex_ptr++ = vtx;
3943 }
3944
3945 (*face_ptr)[0] = vtx_idx;
3946 (*face_ptr)[1] = vtx_idx + 3;
3947 (*face_ptr)[2] = vtx_idx + 1;
3948 face_ptr++;
3949
3950 (*face_ptr)[0] = vtx_idx;
3951 (*face_ptr)[1] = vtx_idx + 2;
3952 (*face_ptr)[2] = vtx_idx + 3;
3953 face_ptr++;
3954 }
3955
3956 prevpt = pt;
3957 pt = nextpt;
3958 }
3959 if (!pt->corner) {
3960 *vertex_ptr++ = *outline_vertices++;
3961 *vertex_ptr++ = *outline_vertices++;
3962 }
3963 }
3964
3965 /* FIXME: compute expected faces */
3966 /* Add placeholder to separate glyph outlines */
3967 vertex_ptr->position.x = 0;
3968 vertex_ptr->position.y = 0;
3969 vertex_ptr->position.z = 0;
3970 vertex_ptr->normal.x = 0;
3971 vertex_ptr->normal.y = 0;
3972 vertex_ptr->normal.z = 1;
3973 vertex_ptr++;
3974 }
3975}
D3DXVECTOR2 *WINAPI D3DXVec2Normalize(D3DXVECTOR2 *pout, const D3DXVECTOR2 *pv)
Definition: math.c:1659
const WCHAR * text
Definition: package.c:1799
FT_Pos x
Definition: ftimage.h:76
FT_Pos y
Definition: ftimage.h:77

Referenced by test_createtext().

◆ compute_torus()

static BOOL compute_torus ( struct mesh mesh,
float  innerradius,
float  outerradius,
UINT  sides,
UINT  rings 
)
static

Definition at line 3355 of file mesh.c.

3356{
3357 float phi, phi_step, sin_phi, cos_phi;
3358 float theta, theta_step, sin_theta, cos_theta;
3359 unsigned int numvert, numfaces, i, j;
3360
3361 numvert = sides * rings;
3362 numfaces = numvert * 2;
3363
3364 if (!new_mesh(mesh, numvert, numfaces))
3365 return FALSE;
3366
3367 phi_step = D3DX_PI / sides * 2.0f;
3368 theta_step = D3DX_PI / rings * -2.0f;
3369
3370 theta = 0.0f;
3371
3372 for (i = 0; i < rings; ++i)
3373 {
3374 phi = 0.0f;
3375
3376 cos_theta = cosf(theta);
3377 sin_theta = sinf(theta);
3378
3379 for (j = 0; j < sides; ++j)
3380 {
3381 sin_phi = sinf(phi);
3382 cos_phi = cosf(phi);
3383
3384 mesh->vertices[i * sides + j].position.x = (innerradius * cos_phi + outerradius) * cos_theta;
3385 mesh->vertices[i * sides + j].position.y = (innerradius * cos_phi + outerradius) * sin_theta;
3386 mesh->vertices[i * sides + j].position.z = innerradius * sin_phi;
3387 mesh->vertices[i * sides + j].normal.x = cos_phi * cos_theta;
3388 mesh->vertices[i * sides + j].normal.y = cos_phi * sin_theta;
3389 mesh->vertices[i * sides + j].normal.z = sin_phi;
3390
3391 phi += phi_step;
3392 }
3393
3394 theta += theta_step;
3395 }
3396
3397 for (i = 0; i < numfaces - sides * 2; ++i)
3398 {
3399 mesh->faces[i][0] = i % 2 ? i / 2 + sides : i / 2;
3400 mesh->faces[i][1] = (i / 2 + 1) % sides ? i / 2 + 1 : i / 2 + 1 - sides;
3401 mesh->faces[i][2] = (i + 1) % (sides * 2) ? (i + 1) / 2 + sides : (i + 1) / 2;
3402 }
3403
3404 for (j = 0; i < numfaces; ++i, ++j)
3405 {
3406 mesh->faces[i][0] = i % 2 ? j / 2 : i / 2;
3407 mesh->faces[i][1] = (i / 2 + 1) % sides ? i / 2 + 1 : i / 2 + 1 - sides;
3408 mesh->faces[i][2] = i == numfaces - 1 ? 0 : (j + 1) / 2;
3409 }
3410
3411 return TRUE;
3412}

Referenced by test_torus().

◆ convert_fixed_to_float()

static D3DXVECTOR2 * convert_fixed_to_float ( POINTFX pt,
int  count,
float  emsquare 
)
inlinestatic

Definition at line 3574 of file mesh.c.

3575{
3577 while (count--) {
3578 D3DXVECTOR2 *pt_flt = (D3DXVECTOR2*)pt;
3579 pt_flt->x = (pt->x.value + pt->x.fract / (float)0x10000) / emsquare;
3580 pt_flt->y = (pt->y.value + pt->y.fract / (float)0x10000) / emsquare;
3581 pt++;
3582 }
3583 return ret;
3584}
GLuint GLuint GLsizei count
Definition: gl.h:1545
static float(__cdecl *square_half_float)(float x
char * value
Definition: compiler.c:67

◆ create_outline()

static HRESULT create_outline ( struct glyphinfo glyph,
void raw_outline,
int  datasize,
float  max_deviation,
float  emsquare 
)
static

Definition at line 3671 of file mesh.c.

3673{
3674 const float cos_45 = cos(D3DXToRadian(45.0f));
3675 const float cos_90 = cos(D3DXToRadian(90.0f));
3676 TTPOLYGONHEADER *header = (TTPOLYGONHEADER *)raw_outline;
3677
3678 while ((char *)header < (char *)raw_outline + datasize)
3679 {
3680 TTPOLYCURVE *curve = (TTPOLYCURVE *)(header + 1);
3681 struct point2d *lastpt, *pt;
3682 D3DXVECTOR2 lastdir;
3683 D3DXVECTOR2 *pt_flt;
3684 int j;
3685 struct outline *outline = add_outline(&glyph->outlines);
3686
3687 if (!outline)
3688 return E_OUTOFMEMORY;
3689
3690 pt = add_point(outline);
3691 if (!pt)
3692 return E_OUTOFMEMORY;
3693 pt_flt = convert_fixed_to_float(&header->pfxStart, 1, emsquare);
3694 pt->pos = *pt_flt;
3695 pt->corner = POINTTYPE_CORNER;
3696
3697 if (header->dwType != TT_POLYGON_TYPE)
3698 trace("Unknown header type %d\n", header->dwType);
3699
3700 while ((char *)curve < (char *)header + header->cb)
3701 {
3702 D3DXVECTOR2 bezier_start = outline->items[outline->count - 1].pos;
3703 BOOL to_curve = curve->wType != TT_PRIM_LINE && curve->cpfx > 1;
3704
3705 if (!curve->cpfx) {
3706 curve = (TTPOLYCURVE *)&curve->apfx[curve->cpfx];
3707 continue;
3708 }
3709
3710 pt_flt = convert_fixed_to_float(curve->apfx, curve->cpfx, emsquare);
3711
3712 attempt_line_merge(outline, outline->count - 1, &pt_flt[0], to_curve);
3713
3714 if (to_curve)
3715 {
3716 HRESULT hr;
3717 int count = curve->cpfx;
3718 j = 0;
3719
3720 while (count > 2)
3721 {
3722 D3DXVECTOR2 bezier_end;
3723
3724 D3DXVec2Scale(&bezier_end, D3DXVec2Add(&bezier_end, &pt_flt[j], &pt_flt[j+1]), 0.5f);
3725 hr = add_bezier_points(outline, &bezier_start, &pt_flt[j], &bezier_end, max_deviation);
3726 if (hr != S_OK)
3727 return hr;
3728 bezier_start = bezier_end;
3729 count--;
3730 j++;
3731 }
3732 hr = add_bezier_points(outline, &bezier_start, &pt_flt[j], &pt_flt[j+1], max_deviation);
3733 if (hr != S_OK)
3734 return hr;
3735
3736 pt = add_point(outline);
3737 if (!pt)
3738 return E_OUTOFMEMORY;
3739 j++;
3740 pt->pos = pt_flt[j];
3741 pt->corner = POINTTYPE_CURVE_END;
3742 } else {
3743 for (j = 0; j < curve->cpfx; j++)
3744 {
3745 pt = add_point(outline);
3746 if (!pt)
3747 return E_OUTOFMEMORY;
3748 pt->pos = pt_flt[j];
3749 pt->corner = POINTTYPE_CORNER;
3750 }
3751 }
3752
3753 curve = (TTPOLYCURVE *)&curve->apfx[curve->cpfx];
3754 }
3755
3756 /* remove last point if the next line continues the last line */
3757 if (outline->count >= 3) {
3758 BOOL to_curve;
3759
3760 lastpt = &outline->items[outline->count - 1];
3761 pt = &outline->items[0];
3762 if (pt->pos.x == lastpt->pos.x && pt->pos.y == lastpt->pos.y) {
3763 if (lastpt->corner == POINTTYPE_CURVE_END)
3764 {
3765 if (pt->corner == POINTTYPE_CURVE_START)
3766 pt->corner = POINTTYPE_CURVE_MIDDLE;
3767 else
3768 pt->corner = POINTTYPE_CURVE_END;
3769 }
3770 outline->count--;
3771 } else {
3772 /* outline closed with a line from end to start point */
3774 }
3775 lastpt = &outline->items[0];
3776 to_curve = lastpt->corner != POINTTYPE_CORNER && lastpt->corner != POINTTYPE_CURVE_END;
3777 if (lastpt->corner == POINTTYPE_CURVE_START)
3778 lastpt->corner = POINTTYPE_CORNER;
3779 pt = &outline->items[1];
3780 if (attempt_line_merge(outline, 0, &pt->pos, to_curve))
3781 *lastpt = outline->items[outline->count];
3782 }
3783
3784 lastpt = &outline->items[outline->count - 1];
3785 pt = &outline->items[0];
3786 unit_vec2(&lastdir, &lastpt->pos, &pt->pos);
3787 for (j = 0; j < outline->count; j++)
3788 {
3789 D3DXVECTOR2 curdir;
3790
3791 lastpt = pt;
3792 pt = &outline->items[(j + 1) % outline->count];
3793 unit_vec2(&curdir, &lastpt->pos, &pt->pos);
3794
3795 switch (lastpt->corner)
3796 {
3799 if (!is_direction_similar(&lastdir, &curdir, cos_45))
3800 lastpt->corner = POINTTYPE_CORNER;
3801 break;
3803 if (!is_direction_similar(&lastdir, &curdir, cos_90))
3804 lastpt->corner = POINTTYPE_CORNER;
3805 else
3806 lastpt->corner = POINTTYPE_CURVE;
3807 break;
3808 default:
3809 break;
3810 }
3811 lastdir = curdir;
3812 }
3813
3814 header = (TTPOLYGONHEADER *)((char *)header + header->cb);
3815 }
3816 return S_OK;
3817}
static SIZE_T datasize
Definition: asm.c:30
static D3DXVECTOR2 * convert_fixed_to_float(POINTFX *pt, int count, unsigned int emsquare)
Definition: mesh.c:5466
static struct outline * add_outline(struct outline_array *array)
Definition: mesh.c:5424
static BOOL attempt_line_merge(struct outline *outline, int pt_index, const D3DXVECTOR2 *nextpt, BOOL to_curve, const struct cos_table *table)
Definition: mesh.c:5526
struct outline_array outlines
Definition: mesh.c:5362
POINTFX apfx[1]
Definition: wingdi.h:2714
#define TT_POLYGON_TYPE
Definition: wingdi.h:1318
#define TT_PRIM_LINE
Definition: wingdi.h:1319

◆ D3DXBoundProbeTest()

static void D3DXBoundProbeTest ( void  )
static

Definition at line 382 of file mesh.c.

383{
384 BOOL result;
385 D3DXVECTOR3 bottom_point, center, top_point, raydirection, rayposition;
386 FLOAT radius;
387
388/*____________Test the Box case___________________________*/
389 bottom_point.x = -3.0f; bottom_point.y = -2.0f; bottom_point.z = -1.0f;
390 top_point.x = 7.0f; top_point.y = 8.0f; top_point.z = 9.0f;
391
392 raydirection.x = -4.0f; raydirection.y = -5.0f; raydirection.z = -6.0f;
393 rayposition.x = 5.0f; rayposition.y = 5.0f; rayposition.z = 11.0f;
394 result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
395 ok(result == TRUE, "expected TRUE, received FALSE\n");
396
397 raydirection.x = 4.0f; raydirection.y = 5.0f; raydirection.z = 6.0f;
398 rayposition.x = 5.0f; rayposition.y = 5.0f; rayposition.z = 11.0f;
399 result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
400 ok(result == FALSE, "expected FALSE, received TRUE\n");
401
402 rayposition.x = -4.0f; rayposition.y = 1.0f; rayposition.z = -2.0f;
403 result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
404 ok(result == TRUE, "expected TRUE, received FALSE\n");
405
406 bottom_point.x = 1.0f; bottom_point.y = 0.0f; bottom_point.z = 0.0f;
407 top_point.x = 1.0f; top_point.y = 0.0f; top_point.z = 0.0f;
408 rayposition.x = 0.0f; rayposition.y = 1.0f; rayposition.z = 0.0f;
409 raydirection.x = 0.0f; raydirection.y = 3.0f; raydirection.z = 0.0f;
410 result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
411 ok(result == FALSE, "expected FALSE, received TRUE\n");
412
413 bottom_point.x = 1.0f; bottom_point.y = 2.0f; bottom_point.z = 3.0f;
414 top_point.x = 10.0f; top_point.y = 15.0f; top_point.z = 20.0f;
415
416 raydirection.x = 7.0f; raydirection.y = 8.0f; raydirection.z = 9.0f;
417 rayposition.x = 3.0f; rayposition.y = 7.0f; rayposition.z = -6.0f;
418 result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
419 ok(result == TRUE, "expected TRUE, received FALSE\n");
420
421 bottom_point.x = 0.0f; bottom_point.y = 0.0f; bottom_point.z = 0.0f;
422 top_point.x = 1.0f; top_point.y = 1.0f; top_point.z = 1.0f;
423
424 raydirection.x = 0.0f; raydirection.y = 1.0f; raydirection.z = .0f;
425 rayposition.x = -3.0f; rayposition.y = 0.0f; rayposition.z = 0.0f;
426 result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
427 ok(result == FALSE, "expected FALSE, received TRUE\n");
428
429 raydirection.x = 1.0f; raydirection.y = 0.0f; raydirection.z = .0f;
430 rayposition.x = -3.0f; rayposition.y = 0.0f; rayposition.z = 0.0f;
431 result = D3DXBoxBoundProbe(&bottom_point, &top_point, &rayposition, &raydirection);
432 ok(result == TRUE, "expected TRUE, received FALSE\n");
433
434/*____________Test the Sphere case________________________*/
435 radius = sqrt(77.0f);
436 center.x = 1.0f; center.y = 2.0f; center.z = 3.0f;
437 raydirection.x = 2.0f; raydirection.y = -4.0f; raydirection.z = 2.0f;
438 rayposition.x = 5.0f; rayposition.y = 5.0f; rayposition.z = 9.0f;
439 result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
440 ok(result == TRUE, "Got unexpected result %#x.\n", result);
441
442 rayposition.x = 45.0f; rayposition.y = -75.0f; rayposition.z = 49.0f;
443 result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
444 ok(result == FALSE, "Got unexpected result %#x.\n", result);
445
446 raydirection.x = -2.0f; raydirection.y = 4.0f; raydirection.z = -2.0f;
447 result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
448 ok(result == TRUE, "Got unexpected result %#x.\n", result);
449
450 rayposition.x = 5.0f; rayposition.y = 11.0f; rayposition.z = 9.0f;
451 result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
452 ok(result == FALSE, "Got unexpected result %#x.\n", result);
453
454 raydirection.x = 2.0f; raydirection.y = -4.0f; raydirection.z = 2.0f;
455 result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
456 ok(result == FALSE, "Got unexpected result %#x.\n", result);
457
458 radius = 1.0f;
459 rayposition.x = 2.0f; rayposition.y = 2.0f; rayposition.z = 3.0f;
460 result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
461 ok(result == FALSE, "Got unexpected result %#x.\n", result);
462
463 raydirection.x = 0.0f; raydirection.y = 0.0f; raydirection.z = 1.0f;
464 result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
465 ok(result == TRUE, "Got unexpected result %#x.\n", result);
466
467 if (0)
468 {
469 /* All these crash on native. */
470 D3DXSphereBoundProbe(&center, radius, &rayposition, NULL);
471 D3DXSphereBoundProbe(&center, radius, NULL, &raydirection);
472 D3DXSphereBoundProbe(NULL, radius, &rayposition, &raydirection);
473 }
474}
_STLP_DECLSPEC complex< float > _STLP_CALL sqrt(const complex< float > &)
Definition: complex.cpp:188
BOOL WINAPI D3DXSphereBoundProbe(const D3DXVECTOR3 *center, float radius, const D3DXVECTOR3 *ray_position, const D3DXVECTOR3 *ray_direction)
Definition: mesh.c:2413
BOOL WINAPI D3DXBoxBoundProbe(const D3DXVECTOR3 *pmin, const D3DXVECTOR3 *pmax, const D3DXVECTOR3 *prayposition, const D3DXVECTOR3 *praydirection)
Definition: mesh.c:1911
GLuint64EXT * result
Definition: glext.h:11304

Referenced by START_TEST().

◆ D3DXComputeBoundingBoxTest()

static void D3DXComputeBoundingBoxTest ( void  )
static

Definition at line 476 of file mesh.c.

477{
478 D3DXVECTOR3 exp_max, exp_min, got_max, got_min, vertex[5];
479 HRESULT hr;
480
481 vertex[0].x = 1.0f; vertex[0].y = 1.0f; vertex[0].z = 1.0f;
482 vertex[1].x = 1.0f; vertex[1].y = 1.0f; vertex[1].z = 1.0f;
483 vertex[2].x = 1.0f; vertex[2].y = 1.0f; vertex[2].z = 1.0f;
484 vertex[3].x = 1.0f; vertex[3].y = 1.0f; vertex[3].z = 1.0f;
485 vertex[4].x = 9.0f; vertex[4].y = 9.0f; vertex[4].z = 9.0f;
486
487 exp_min.x = 1.0f; exp_min.y = 1.0f; exp_min.z = 1.0f;
488 exp_max.x = 9.0f; exp_max.y = 9.0f; exp_max.z = 9.0f;
489
491
492 ok( hr == D3D_OK, "Expected D3D_OK, got %#x\n", hr);
493 ok( compare_vec3(exp_min,got_min), "Expected min: (%f, %f, %f), got: (%f, %f, %f)\n", exp_min.x,exp_min.y,exp_min.z,got_min.x,got_min.y,got_min.z);
494 ok( compare_vec3(exp_max,got_max), "Expected max: (%f, %f, %f), got: (%f, %f, %f)\n", exp_max.x,exp_max.y,exp_max.z,got_max.x,got_max.y,got_max.z);
495
496/*________________________*/
497
498 vertex[0].x = 2.0f; vertex[0].y = 5.9f; vertex[0].z = -1.2f;
499 vertex[1].x = -1.87f; vertex[1].y = 7.9f; vertex[1].z = 7.4f;
500 vertex[2].x = 7.43f; vertex[2].y = -0.9f; vertex[2].z = 11.9f;
501 vertex[3].x = -6.92f; vertex[3].y = 6.3f; vertex[3].z = -3.8f;
502 vertex[4].x = 11.4f; vertex[4].y = -8.1f; vertex[4].z = 4.5f;
503
504 exp_min.x = -6.92f; exp_min.y = -8.1f; exp_min.z = -3.80f;
505 exp_max.x = 11.4f; exp_max.y = 7.90f; exp_max.z = 11.9f;
506
508
509 ok( hr == D3D_OK, "Expected D3D_OK, got %#x\n", hr);
510 ok( compare_vec3(exp_min,got_min), "Expected min: (%f, %f, %f), got: (%f, %f, %f)\n", exp_min.x,exp_min.y,exp_min.z,got_min.x,got_min.y,got_min.z);
511 ok( compare_vec3(exp_max,got_max), "Expected max: (%f, %f, %f), got: (%f, %f, %f)\n", exp_max.x,exp_max.y,exp_max.z,got_max.x,got_max.y,got_max.z);
512
513/*________________________*/
514
515 vertex[0].x = 2.0f; vertex[0].y = 5.9f; vertex[0].z = -1.2f;
516 vertex[1].x = -1.87f; vertex[1].y = 7.9f; vertex[1].z = 7.4f;
517 vertex[2].x = 7.43f; vertex[2].y = -0.9f; vertex[2].z = 11.9f;
518 vertex[3].x = -6.92f; vertex[3].y = 6.3f; vertex[3].z = -3.8f;
519 vertex[4].x = 11.4f; vertex[4].y = -8.1f; vertex[4].z = 4.5f;
520
521 exp_min.x = -6.92f; exp_min.y = -0.9f; exp_min.z = -3.8f;
522 exp_max.x = 7.43f; exp_max.y = 7.90f; exp_max.z = 11.9f;
523
525
526 ok( hr == D3D_OK, "Expected D3D_OK, got %#x\n", hr);
527 ok( compare_vec3(exp_min,got_min), "Expected min: (%f, %f, %f), got: (%f, %f, %f)\n", exp_min.x,exp_min.y,exp_min.z,got_min.x,got_min.y,got_min.z);
528 ok( compare_vec3(exp_max,got_max), "Expected max: (%f, %f, %f), got: (%f, %f, %f)\n", exp_max.x,exp_max.y,exp_max.z,got_max.x,got_max.y,got_max.z);
529
530/*________________________*/
532 ok( hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#x\n", hr);
533
534/*________________________*/
536 ok( hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#x\n", hr);
537
538/*________________________*/
540 ok( hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#x\n", hr);
541}
HRESULT WINAPI D3DXComputeBoundingBox(const D3DXVECTOR3 *pfirstposition, DWORD numvertices, DWORD dwstride, D3DXVECTOR3 *pmin, D3DXVECTOR3 *pmax)
Definition: mesh.c:1964
float x
Definition: hlsl.c:29
float y
Definition: hlsl.c:29
float z
Definition: hlsl.c:29

Referenced by START_TEST().

◆ D3DXComputeBoundingSphereTest()

static void D3DXComputeBoundingSphereTest ( void  )
static

Definition at line 543 of file mesh.c.

544{
545 D3DXVECTOR3 exp_cen, got_cen, vertex[5];
546 FLOAT exp_rad, got_rad;
547 HRESULT hr;
548
549 vertex[0].x = 1.0f; vertex[0].y = 1.0f; vertex[0].z = 1.0f;
550 vertex[1].x = 1.0f; vertex[1].y = 1.0f; vertex[1].z = 1.0f;
551 vertex[2].x = 1.0f; vertex[2].y = 1.0f; vertex[2].z = 1.0f;
552 vertex[3].x = 1.0f; vertex[3].y = 1.0f; vertex[3].z = 1.0f;
553 vertex[4].x = 9.0f; vertex[4].y = 9.0f; vertex[4].z = 9.0f;
554
555 exp_rad = 6.928203f;
556 exp_cen.x = 5.0; exp_cen.y = 5.0; exp_cen.z = 5.0;
557
559
560 ok( hr == D3D_OK, "Expected D3D_OK, got %#x\n", hr);
561 ok( compare(exp_rad, got_rad), "Expected radius: %f, got radius: %f\n", exp_rad, got_rad);
562 ok( compare_vec3(exp_cen,got_cen), "Expected center: (%f, %f, %f), got center: (%f, %f, %f)\n", exp_cen.x,exp_cen.y,exp_cen.z,got_cen.x,got_cen.y,got_cen.z);
563
564/*________________________*/
565
566 vertex[0].x = 2.0f; vertex[0].y = 5.9f; vertex[0].z = -1.2f;
567 vertex[1].x = -1.87f; vertex[1].y = 7.9f; vertex[1].z = 7.4f;
568 vertex[2].x = 7.43f; vertex[2].y = -0.9f; vertex[2].z = 11.9f;
569 vertex[3].x = -6.92f; vertex[3].y = 6.3f; vertex[3].z = -3.8f;
570 vertex[4].x = 11.4f; vertex[4].y = -8.1f; vertex[4].z = 4.5f;
571
572 exp_rad = 13.707883f;
573 exp_cen.x = 2.408f; exp_cen.y = 2.22f; exp_cen.z = 3.76f;
574
576
577 ok( hr == D3D_OK, "Expected D3D_OK, got %#x\n", hr);
578 ok( compare(exp_rad, got_rad), "Expected radius: %f, got radius: %f\n", exp_rad, got_rad);
579 ok( compare_vec3(exp_cen,got_cen), "Expected center: (%f, %f, %f), got center: (%f, %f, %f)\n", exp_cen.x,exp_cen.y,exp_cen.z,got_cen.x,got_cen.y,got_cen.z);
580
581/*________________________*/
583 ok( hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#x\n", hr);
584
585/*________________________*/
587 ok( hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#x\n", hr);
588
589/*________________________*/
591 ok( hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %#x\n", hr);
592}
HRESULT WINAPI D3DXComputeBoundingSphere(const D3DXVECTOR3 *pfirstposition, DWORD numvertices, DWORD dwstride, D3DXVECTOR3 *pcenter, float *pradius)
Definition: mesh.c:1992

Referenced by START_TEST().

◆ D3DXCreateAnimationControllerTest()

static void D3DXCreateAnimationControllerTest ( void  )
static

Definition at line 11260 of file mesh.c.

11261{
11262 HRESULT hr;
11263 ID3DXAnimationController *animation;
11264 UINT value;
11265
11266 hr = D3DXCreateAnimationController(0, 0, 0, 0, NULL);
11267 ok(hr == D3D_OK, "Got unexpected hr returned %#x.\n", hr);
11268
11269 animation = (void*)0xdeadbeef;
11270 hr = D3DXCreateAnimationController(0, 1, 1, 1, &animation);
11271 ok(hr == D3D_OK, "Got unexpected hr returned %#x.\n", hr);
11272 ok(animation == (void*)0xdeadbeef, "Got unexpected animation %p.\n", animation);
11273
11274 animation = (void*)0xdeadbeef;
11275 hr = D3DXCreateAnimationController(1, 0, 1, 1, &animation);
11276 ok(hr == D3D_OK, "Got unexpected hr returned %#x.\n", hr);
11277 ok(animation == (void*)0xdeadbeef, "Got unexpected animation %p.\n", animation);
11278
11279 animation = (void*)0xdeadbeef;
11280 hr = D3DXCreateAnimationController(1, 1, 0, 1, &animation);
11281 ok(hr == D3D_OK, "Got unexpected hr returned %#x.\n", hr);
11282 ok(animation == (void*)0xdeadbeef, "Got unexpected animation %p.\n", animation);
11283
11284 animation = (void*)0xdeadbeef;
11285 hr = D3DXCreateAnimationController(1, 1, 1, 0, &animation);
11286 ok(hr == D3D_OK, "Got unexpected hr returned %#x.\n", hr);
11287 ok(animation == (void*)0xdeadbeef, "Got unexpected animation %p.\n", animation);
11288
11289 hr = D3DXCreateAnimationController(1, 1, 1, 1, &animation);
11290 ok(hr == D3D_OK, "Got unexpected hr returned %#x.\n", hr);
11291
11292 value = animation->lpVtbl->GetMaxNumAnimationOutputs(animation);
11293 ok(value == 1, "Got unexpected value %u.\n", value);
11294
11295 value = animation->lpVtbl->GetMaxNumAnimationSets(animation);
11296 ok(value == 1, "Got unexpected value %u.\n", value);
11297
11298 value = animation->lpVtbl->GetMaxNumTracks(animation);
11299 ok(value == 1, "Got unexpected value %u.\n", value);
11300
11301 value = animation->lpVtbl->GetMaxNumEvents(animation);
11302 ok(value == 1, "Got unexpected value %u.\n", value);
11303
11304 animation->lpVtbl->Release(animation);
11305
11306 hr = D3DXCreateAnimationController(100, 101, 102, 103, &animation);
11307 ok(hr == D3D_OK, "Got unexpected hr returned %#x.\n", hr);
11308
11309 value = animation->lpVtbl->GetMaxNumAnimationOutputs(animation);
11310 ok(value == 100, "Got unexpected value %u.\n", value);
11311
11312 value = animation->lpVtbl->GetMaxNumAnimationSets(animation);
11313 ok(value == 101, "Got unexpected value %u.\n", value);
11314
11315 value = animation->lpVtbl->GetMaxNumTracks(animation);
11316 ok(value == 102, "Got unexpected value %u.\n", value);
11317
11318 value = animation->lpVtbl->GetMaxNumEvents(animation);
11319 ok(value == 103, "Got unexpected value %u.\n", value);
11320
11321 animation->lpVtbl->Release(animation);
11322}
HRESULT WINAPI D3DXCreateAnimationController(UINT max_outputs, UINT max_sets, UINT max_tracks, UINT max_events, ID3DXAnimationController **controller)
Definition: animation.c:448
unsigned int UINT
Definition: ndis.h:50
Definition: pdh_main.c:94

Referenced by START_TEST().

◆ D3DXCreateBoxTest()

static void D3DXCreateBoxTest ( void  )
static

Definition at line 2653 of file mesh.c.

2654{
2655 HRESULT hr;
2656 IDirect3DDevice9* device;
2657 ID3DXMesh* box;
2658 ID3DXBuffer* ppBuffer;
2659 DWORD *buffer;
2660 static const DWORD adjacency[36]=
2661 {6, 9, 1, 2, 10, 0,
2662 1, 9, 3, 4, 10, 2,
2663 3, 8, 5, 7, 11, 4,
2664 0, 11, 7, 5, 8, 6,
2665 7, 4, 9, 2, 0, 8,
2666 1, 3, 11, 5, 6, 10};
2667 unsigned int i;
2668 struct test_context *test_context;
2669
2670 if (!(test_context = new_test_context()))
2671 {
2672 skip("Couldn't create test context\n");
2673 return;
2674 }
2676
2677 hr = D3DXCreateBox(device,2.0f,20.0f,4.9f,NULL, &ppBuffer);
2678 ok(hr==D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, received %#x\n", hr);
2679
2680 hr = D3DXCreateBox(NULL,22.0f,20.0f,4.9f,&box, &ppBuffer);
2681 ok(hr==D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, received %#x\n", hr);
2682
2683 hr = D3DXCreateBox(device,-2.0f,20.0f,4.9f,&box, &ppBuffer);
2684 ok(hr==D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, received %#x\n", hr);
2685
2686 hr = D3DXCreateBox(device,22.0f,-20.0f,4.9f,&box, &ppBuffer);
2687 ok(hr==D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, received %#x\n", hr);
2688
2689 hr = D3DXCreateBox(device,22.0f,20.0f,-4.9f,&box, &ppBuffer);
2690 ok(hr==D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, received %#x\n", hr);
2691
2692 ppBuffer = NULL;
2693 hr = D3DXCreateBox(device,10.9f,20.0f,4.9f,&box, &ppBuffer);
2694 ok(hr==D3D_OK, "Expected D3D_OK, received %#x\n", hr);
2695
2697 for(i=0; i<36; i++)
2698 ok(adjacency[i]==buffer[i], "expected adjacency %d: %#x, received %#x\n",i,adjacency[i], buffer[i]);
2699
2700 box->lpVtbl->Release(box);
2701 ID3DXBuffer_Release(ppBuffer);
2702
2703 test_box(device, 10.9f, 20.0f, 4.9f);
2704
2706}
struct ID3DXBuffer ID3DXBuffer
Definition: d3dx8core.h:51
#define ID3DXBuffer_GetBufferPointer(p)
Definition: d3dx9core.h:85
#define ID3DXBuffer_Release(p)
Definition: d3dx9core.h:83
HRESULT WINAPI D3DXCreateBox(struct IDirect3DDevice9 *device, float width, float height, float depth, struct ID3DXMesh **mesh, struct ID3DXBuffer **adjacency)
Definition: mesh.c:4653
GLuint buffer
Definition: glext.h:5915
static struct test_context * new_test_context(void)
Definition: mesh.c:121
static void test_box(IDirect3DDevice9 *device, float width, float height, float depth)
Definition: mesh.c:2622
static void free_test_context(struct test_context *test_context)
Definition: mesh.c:180
Definition: palette.c:468
IDirect3DDevice9 * device
Definition: mesh.c:114

Referenced by START_TEST().

◆ D3DXCreateCylinderTest()

static void D3DXCreateCylinderTest ( void  )
static

Definition at line 3282 of file mesh.c.

3283{
3284 HRESULT hr;
3285 IDirect3DDevice9* device;
3286 ID3DXMesh* cylinder = NULL;
3287 struct test_context *test_context;
3288
3289 hr = D3DXCreateCylinder(NULL, 0.0f, 0.0f, 0.0f, 0, 0, NULL, NULL);
3290 ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n",hr,D3DERR_INVALIDCALL);
3291
3292 hr = D3DXCreateCylinder(NULL, 1.0f, 1.0f, 1.0f, 2, 1, &cylinder, NULL);
3293 ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n",hr,D3DERR_INVALIDCALL);
3294
3295 if (!(test_context = new_test_context()))
3296 {
3297 skip("Couldn't create test context\n");
3298 return;
3299 }
3301
3302 hr = D3DXCreateCylinder(device, -0.1f, 1.0f, 1.0f, 2, 1, &cylinder, NULL);
3303 ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n",hr,D3DERR_INVALIDCALL);
3304
3305 hr = D3DXCreateCylinder(device, 0.0f, 1.0f, 1.0f, 2, 1, &cylinder, NULL);
3306 ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n",hr);
3307
3308 if (SUCCEEDED(hr) && cylinder)
3309 {
3310 cylinder->lpVtbl->Release(cylinder);
3311 }
3312
3313 hr = D3DXCreateCylinder(device, 1.0f, -0.1f, 1.0f, 2, 1, &cylinder, NULL);
3314 ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n",hr,D3DERR_INVALIDCALL);
3315
3316 hr = D3DXCreateCylinder(device, 1.0f, 0.0f, 1.0f, 2, 1, &cylinder, NULL);
3317 ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n",hr);
3318
3319 if (SUCCEEDED(hr) && cylinder)
3320 {
3321 cylinder->lpVtbl->Release(cylinder);
3322 }
3323
3324 hr = D3DXCreateCylinder(device, 1.0f, 1.0f, -0.1f, 2, 1, &cylinder, NULL);
3325 ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n",hr,D3DERR_INVALIDCALL);
3326
3327 /* Test with length == 0.0f succeeds */
3328 hr = D3DXCreateCylinder(device, 1.0f, 1.0f, 0.0f, 2, 1, &cylinder, NULL);
3329 ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n",hr);
3330
3331 if (SUCCEEDED(hr) && cylinder)
3332 {
3333 cylinder->lpVtbl->Release(cylinder);
3334 }
3335
3336 hr = D3DXCreateCylinder(device, 1.0f, 1.0f, 1.0f, 1, 1, &cylinder, NULL);
3337 ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n",hr,D3DERR_INVALIDCALL);
3338
3339 hr = D3DXCreateCylinder(device, 1.0f, 1.0f, 1.0f, 2, 0, &cylinder, NULL);
3340 ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n",hr,D3DERR_INVALIDCALL);
3341
3342 hr = D3DXCreateCylinder(device, 1.0f, 1.0f, 1.0f, 2, 1, NULL, NULL);
3343 ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n",hr,D3DERR_INVALIDCALL);
3344
3345 test_cylinder(device, 0.0f, 0.0f, 0.0f, 2, 1);
3346 test_cylinder(device, 1.0f, 1.0f, 1.0f, 2, 1);
3347 test_cylinder(device, 1.0f, 1.0f, 2.0f, 3, 4);
3348 test_cylinder(device, 3.0f, 2.0f, 4.0f, 3, 4);
3349 test_cylinder(device, 2.0f, 3.0f, 4.0f, 3, 4);
3350 test_cylinder(device, 3.0f, 4.0f, 5.0f, 11, 20);
3351
3353}
GLUquadricObj * cylinder
Definition: cylfrac.c:44
HRESULT WINAPI D3DXCreateCylinder(struct IDirect3DDevice9 *device, float radius1, float radius2, float length, UINT slices, UINT stacks, struct ID3DXMesh **mesh, struct ID3DXBuffer **adjacency)
Definition: mesh.c:4975
static void test_cylinder(IDirect3DDevice9 *device, FLOAT radius1, FLOAT radius2, FLOAT length, UINT slices, UINT stacks)
Definition: mesh.c:3250

Referenced by START_TEST().

◆ D3DXCreateKeyframedAnimationSetTest()

static void D3DXCreateKeyframedAnimationSetTest ( void  )
static

Definition at line 11324 of file mesh.c.

11325{
11326 ID3DXKeyframedAnimationSet *set;
11328 unsigned int count;
11329 const char *name;
11330 HRESULT hr;
11331
11332 hr = D3DXCreateKeyframedAnimationSet("wine_bottle", 5.0, D3DXPLAY_LOOP, 0, 0, NULL, &set);
11333 ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
11334
11335 hr = D3DXCreateKeyframedAnimationSet("wine_bottle", 5.0, D3DXPLAY_LOOP, 10, 0, NULL, &set);
11336 ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
11337
11338 name = set->lpVtbl->GetName(set);
11339 ok(!strcmp(name, "wine_bottle"), "Got unexpected name %s.\n", debugstr_a(name));
11340
11341 type = set->lpVtbl->GetPlaybackType(set);
11342 ok(type == D3DXPLAY_LOOP, "Got unexpected value %u.\n", type);
11343
11344 count = set->lpVtbl->GetNumAnimations(set);
11345 ok(!count, "Got unexpected value %u.\n", count);
11346
11347 set->lpVtbl->Release(set);
11348}
HRESULT WINAPI D3DXCreateKeyframedAnimationSet(const char *name, double ticks_per_second, D3DXPLAYBACK_TYPE playback_type, UINT animation_count, UINT callback_key_count, const D3DXKEY_CALLBACK *callback_keys, ID3DXKeyframedAnimationSet **animation_set)
Definition: animation.c:862
Definition: _set.h:50
enum _D3DXPLAYBACK_TYPE D3DXPLAYBACK_TYPE
@ D3DXPLAY_LOOP
Definition: d3dx9anim.h:44
#define debugstr_a
Definition: kernel32.h:31

Referenced by START_TEST().

◆ D3DXCreateMeshFVFTest()

static void D3DXCreateMeshFVFTest ( void  )
static

Definition at line 1408 of file mesh.c.

1409{
1410 HRESULT hr;
1411 IDirect3DDevice9 *device, *test_device;
1412 ID3DXMesh *d3dxmesh;
1413 int i, size;
1415 DWORD options;
1416 struct mesh mesh;
1417 struct test_context *test_context;
1418
1419 static const D3DVERTEXELEMENT9 decl[] =
1420 {
1423 D3DDECL_END(),
1424 };
1425
1426 hr = D3DXCreateMeshFVF(0, 0, 0, 0, NULL, NULL);
1427 ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1428
1430 ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1431
1433 if (!test_context)
1434 {
1435 skip("Couldn't create test context\n");
1436 return;
1437 }
1439
1441 ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1442
1444 ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1445
1446 hr = D3DXCreateMeshFVF(1, 3, 0, D3DFVF_XYZ | D3DFVF_NORMAL, device, &d3dxmesh);
1447 ok(hr == D3D_OK, "Got result %x, expected %x (D3D_OK)\n", hr, D3D_OK);
1448
1449 if (hr == D3D_OK)
1450 {
1451 d3dxmesh->lpVtbl->Release(d3dxmesh);
1452 }
1453
1454 hr = D3DXCreateMeshFVF(1, 3, D3DXMESH_MANAGED, 0xdeadbeef, device, &d3dxmesh);
1455 ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1456
1458 ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1459
1461 ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
1462
1463 if (hr == D3D_OK)
1464 {
1465 /* device */
1466 hr = d3dxmesh->lpVtbl->GetDevice(d3dxmesh, NULL);
1467 ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1468
1469 hr = d3dxmesh->lpVtbl->GetDevice(d3dxmesh, &test_device);
1470 ok(hr == D3D_OK, "Got result %x, expected %x (D3D_OK)\n", hr, D3D_OK);
1471 ok(test_device == device, "Got result %p, expected %p\n", test_device, device);
1472
1473 if (hr == D3D_OK)
1474 {
1476 }
1477
1478 /* declaration */
1479 hr = d3dxmesh->lpVtbl->GetDeclaration(d3dxmesh, NULL);
1480 ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
1481
1482 hr = d3dxmesh->lpVtbl->GetDeclaration(d3dxmesh, test_decl);
1483 ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
1484
1485 if (hr == D3D_OK)
1486 {
1487 size = ARRAY_SIZE(decl);
1488 for (i = 0; i < size - 1; i++)
1489 {
1490 ok(test_decl[i].Stream == decl[i].Stream, "Returned stream %d, expected %d\n", test_decl[i].Stream, decl[i].Stream);
1491 ok(test_decl[i].Type == decl[i].Type, "Returned type %d, expected %d\n", test_decl[i].Type, decl[i].Type);
1492 ok(test_decl[i].Method == decl[i].Method, "Returned method %d, expected %d\n", test_decl[i].Method, decl[i].Method);
1493 ok(test_decl[i].Usage == decl[i].Usage, "Returned usage %d, expected %d\n", test_decl[i].Usage, decl[i].Usage);
1494 ok(test_decl[i].UsageIndex == decl[i].UsageIndex, "Returned usage index %d, expected %d\n",
1495 test_decl[i].UsageIndex, decl[i].UsageIndex);
1496 ok(test_decl[i].Offset == decl[i].Offset, "Returned offset %d, expected %d\n", test_decl[i].Offset, decl[i].Offset);
1497 }
1498 ok(decl[size-1].Stream == 0xFF, "Returned too long vertex declaration\n"); /* end element */
1499 }
1500
1501 /* options */
1502 options = d3dxmesh->lpVtbl->GetOptions(d3dxmesh);
1503 ok(options == D3DXMESH_MANAGED, "Got result %x, expected %x (D3DXMESH_MANAGED)\n", options, D3DXMESH_MANAGED);
1504
1505 /* rest */
1506 if (!new_mesh(&mesh, 3, 1))
1507 {
1508 skip("Couldn't create mesh\n");
1509 }
1510 else
1511 {
1513 memset(mesh.faces, 0, mesh.number_of_faces * sizeof(*mesh.faces));
1515
1516 compare_mesh("createmeshfvf", d3dxmesh, &mesh);
1517
1518