ReactOS  0.4.15-dev-2352-g3fa57b8
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:16033

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
DWORD exp
Definition: msg.c:16033
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);
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
#define ARRAY_SIZE(a)
Definition: main.h:24

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.

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 }
HRESULT hr
Definition: shlfolder.c:183
#define pt(x, y)
Definition: drawing.c:79
static struct point2d * add_point(struct outline *array)
Definition: mesh.c:3550
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
GLfloat f
Definition: glext.h:7540
LONG HRESULT
Definition: typedefs.h:79
Definition: mesh.c:5316
FT_Vector * vec
Definition: ftbbox.c:448
Definition: mesh.c:5329
#define S_OK
Definition: intsafe.h:51
static HRESULT add_bezier_points(struct outline *outline, const D3DXVECTOR2 *p1, const D3DXVECTOR2 *p2, const D3DXVECTOR2 *p3, float max_deviation)
Definition: mesh.c:3586

Referenced by create_outline().

◆ 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 ZeroMemory
Definition: winbase.h:1664
static BOOL reserve(struct dynamic_array *array, int count, int itemsize)
Definition: mesh.c:3530
Definition: mesh.c:5329
static ATOM item
Definition: dde.c:856
#define NULL
Definition: types.h:112

Referenced by create_outline().

◆ 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 }
#define ZeroMemory
Definition: winbase.h:1664
static BOOL reserve(struct dynamic_array *array, int count, int itemsize)
Definition: mesh.c:3530
Definition: mesh.c:5316
static ATOM item
Definition: dde.c:856
#define NULL
Definition: types.h:112

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)
3656  prevpt->corner = POINTTYPE_CURVE_MIDDLE;
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 }
int count
Definition: mesh.c:5331
#define pt(x, y)
Definition: drawing.c:79
if(dx==0 &&dy==0)
Definition: linetemp.h:174
enum pointtype corner
Definition: mesh.c:5319
D3DXVECTOR2 pos
Definition: mesh.c:5318
unsigned int BOOL
Definition: ntddk_ex.h:94
_STLP_DECLSPEC complex< float > _STLP_CALL cos(const complex< float > &)
#define D3DXToRadian(degree)
Definition: d3dx9math.h:33
static BOOL is_direction_similar(D3DXVECTOR2 *dir1, D3DXVECTOR2 *dir2, float cos_theta)
Definition: mesh.c:3616
GLfloat f
Definition: glext.h:7540
Definition: mesh.c:5316
#define FALSE
Definition: mesh.c:45
int ret
static D3DXVECTOR2 * unit_vec2(D3DXVECTOR2 *dir, const D3DXVECTOR2 *pt1, const D3DXVECTOR2 *pt2)
Definition: mesh.c:3622
Definition: mesh.c:5329
struct point2d * items
Definition: mesh.c:5332
#define TRUE
Definition: mesh.c:42

Referenced by create_outline().

◆ 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 }
Definition: parser.c:48
BOOL expected
Definition: store.c:2063
#define ok_(x1, x2)
Definition: atltest.h:61

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 equal(x, y)
Definition: reader.cc:56
static BOOL compare(FLOAT u, FLOAT v)
Definition: mesh.c:59
#define sprintf(buf, format,...)
Definition: sprintf.c:55
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: parser.c:48
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
DWORD exp
Definition: msg.c:16033
#define TRUE
Definition: mesh.c:42
#define ok_(x1, x2)
Definition: atltest.h:61

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 }
HRESULT hr
Definition: shlfolder.c:183
Definition: mesh.c:197
if SUCCEEDED(hr)
Definition: parser.c:48
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
#define D3D_OK
Definition: d3d.h:106
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 skip_(test, file, line,...)
Definition: kmt_test.h:222
#define HeapFree(x, y, z)
Definition: compat.h:594
BOOL expected
Definition: store.c:2063
#define ok_(x1, x2)
Definition: atltest.h:61

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 }
#define EFFECT_TABLE_ENTRY(str, field)
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static BOOL compare(FLOAT u, FLOAT v)
Definition: mesh.c:59
#define DWORD
Definition: nt_native.h:44
LPD3DXEFFECTDEFAULT pDefaults
Definition: d3dx9mesh.h:211
GLenum const GLfloat * params
Definition: glext.h:5645
Definition: parser.c:48
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
ed2 num_bytes
Definition: write.c:2832
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned char BYTE
Definition: xxhash.c:193
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 ARRAY_SIZE(a)
Definition: main.h:24
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
Definition: name.c:38
float FLOAT
Definition: typedefs.h:69
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
D3DXEFFECTDEFAULTTYPE Type
Definition: d3dx9mesh.h:202
int k
Definition: mpi.c:3369
BOOL expected
Definition: store.c:2063
char * pTextureFilename
Definition: d3dx9mesh.h:196
#define ok_(x1, x2)
Definition: atltest.h:61
GLuint const GLchar * name
Definition: glext.h:6031

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 }
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: gl.h:1545
HRESULT hr
Definition: shlfolder.c:183
Definition: mesh.c:197
Definition: parser.c:48
LONG HRESULT
Definition: typedefs.h:79
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned char BYTE
Definition: xxhash.c:193
#define D3D_OK
Definition: d3d.h:106
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 min(a, b)
Definition: monoChain.cc:55
#define D3DLOCK_READONLY
Definition: d3d8types.h:69
#define ok_(x1, x2)
Definition: atltest.h:61

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 }
D3DMATERIAL9 MatD3D
Definition: d3dx9mesh.h:195
static void check_colorvalue_(int line, const char *prefix, const D3DCOLORVALUE got, const D3DCOLORVALUE expected)
Definition: mesh.c:1678
Definition: parser.c:48
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 min(a, b)
Definition: monoChain.cc:55
static int expected_count(int *sink)
#define NULL
Definition: types.h:112
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
BOOL expected
Definition: store.c:2063
char * pTextureFilename
Definition: d3dx9mesh.h:196
#define ok_(x1, x2)
Definition: atltest.h:61

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
static BOOL compare(FLOAT u, FLOAT v)
Definition: mesh.c:59
Definition: parser.c:48
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
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 ok_(x1, x2)
Definition: atltest.h:61

◆ 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_XYZB1
Definition: d3d8types.h:115
#define D3DFVF_LASTBETA_UBYTE4
Definition: d3d8types.h:135
#define D3DFVF_XYZRHW
Definition: d3d8types.h:114
HRESULT hr
Definition: shlfolder.c:183
#define D3DFVF_PSIZE
Definition: d3d8types.h:121
static void check_floats_(int line, const char *prefix, const float *got, const float *exp, int dim)
Definition: mesh.c:75
#define D3DFVF_NORMAL
Definition: d3d8types.h:120
static BOOL compare(FLOAT u, FLOAT v)
Definition: mesh.c:59
Definition: mesh.c:197
UINT WINAPI D3DXGetFVFVertexSize(DWORD FVF)
Definition: mesh.c:2289
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define D3DFVF_TEXCOUNT_MASK
Definition: d3d8types.h:124
unsigned int BOOL
Definition: ntddk_ex.h:94
#define D3DFVF_POSITION_MASK
Definition: d3d8types.h:112
#define D3DFVF_SPECULAR
Definition: d3d8types.h:123
Definition: parser.c:48
#define D3DFVF_XYZB2
Definition: d3d8types.h:116
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
LONG HRESULT
Definition: typedefs.h:79
#define D3DFVF_XYZB5
Definition: d3d8types.h:119
#define D3DFVF_XYZ
Definition: d3d8types.h:113
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FALSE
Definition: mesh.c:45
#define D3DFVF_XYZB3
Definition: d3d8types.h:117
unsigned char BYTE
Definition: xxhash.c:193
#define D3DFVF_XYZB4
Definition: d3d8types.h:118
#define D3D_OK
Definition: d3d.h:106
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 D3DFVF_TEXCOUNT_SHIFT
Definition: d3d8types.h:125
#define min(a, b)
Definition: monoChain.cc:55
#define D3DFVF_DIFFUSE
Definition: d3d8types.h:122
float FLOAT
Definition: typedefs.h:69
#define D3DFVF_XYZW
Definition: d3d9types.h:143
#define TRUE
Definition: mesh.c:42
#define D3DLOCK_READONLY
Definition: d3d8types.h:69
#define D3DFVF_LASTBETA_D3DCOLOR
Definition: d3d9types.h:160
#define ok_(x1, x2)
Definition: atltest.h:61

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  }
6657  case D3DDECLTYPE_D3DCOLOR:
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:
6671  case D3DDECLTYPE_UBYTE4N:
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:
6682  case D3DDECLTYPE_SHORT2N:
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:
6692  case D3DDECLTYPE_SHORT4N:
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  }
6702  case D3DDECLTYPE_USHORT2N:
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  }
6711  case D3DDECLTYPE_USHORT4N:
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  }
6744  case D3DDECLTYPE_FLOAT16_2:
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  }
6753  case D3DDECLTYPE_FLOAT16_4:
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 }
#define max(a, b)
Definition: svc.c:63
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
FLOAT y
Definition: d3dx9math.h:64
UINT w
Definition: mesh.c:6647
Definition: mesh.c:6687
unsigned int BOOL
Definition: ntddk_ex.h:94
#define e
Definition: ke_i.h:82
short SHORT
Definition: pedump.c:59
Definition: parser.c:48
UINT x
Definition: mesh.c:6644
Definition: mesh.c:6642
UINT z
Definition: mesh.c:6646
FLOAT x
Definition: d3dx9math.h:64
INT y
Definition: mesh.c:6690
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
static struct dec3n dword_to_dec3n(DWORD d)
Definition: mesh.c:6580
static struct udec3 dword_to_udec3(DWORD d)
Definition: mesh.c:6568
unsigned char BYTE
Definition: xxhash.c:193
#define PRECISION
Definition: pchw.c:28
INT w
Definition: mesh.c:6692
INT x
Definition: mesh.c:6689
unsigned short USHORT
Definition: pedump.c:61
#define f
Definition: ke_i.h:83
INT z
Definition: mesh.c:6691
DWORD exp
Definition: msg.c:16033
UINT y
Definition: mesh.c:6645
float FLOAT
Definition: typedefs.h:69
_Check_return_ __CRT_INLINE float __CRTDECL fabsf(_In_ float x)
Definition: math.h:164
#define ok_(x1, x2)
Definition: atltest.h:61

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 }
struct D3DXVECTOR4 D3DXVECTOR4
HRESULT hr
Definition: shlfolder.c:183
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:382
#define D3DERR_INVALIDCALL
Definition: mesh.c:197
#define NAN
Definition: mesh.c:39
#define trace
Definition: atltest.h:70
LONG HRESULT
Definition: typedefs.h:79
struct _D3DVECTOR D3DXVECTOR3
Definition: d3dx9math.h:97
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define D3DDECL_END()
Definition: d3d9types.h:311
unsigned char BYTE
Definition: xxhash.c:193
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 E_NOTIMPL
Definition: ddrawi.h:99
#define NULL
Definition: types.h:112

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 }
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)
const GLdouble * v
Definition: gl.h:2040
#define admitted_error
Definition: mesh.c:46

Referenced by check_floats_(), check_generated_effects_(), check_matrix_(), check_vertex_buffer_(), compare_text_outline_mesh(), compare_vec3(), compare_vec4(), D3DXComputeBoundingSphereTest(), D3DXIntersectTriTest(), and test_update_skinned_mesh().

◆ 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 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
POINT last
Definition: font.c:46
Definition: parser.c:48
#define D3DDECL_END()
Definition: d3d9types.h:311
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 ok(value,...)
Definition: atltest.h:57
static void print_elements(const D3DVERTEXELEMENT9 *elements)
Definition: mesh.c:594
static SERVICE_STATUS status
Definition: service.c:31
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 }
Definition: mesh.c:4557
HRESULT hr
Definition: shlfolder.c:183
#define IDirect3DVertexBuffer9_Unlock(p)
Definition: d3d9.h:708
#define D3DLOCK_DISCARD
Definition: d3d8types.h:72
D3DRESOURCETYPE Type
Definition: d3d8types.h:1189
#define IDirect3DVertexBuffer9_GetDesc(p, a)
Definition: d3d9.h:709
D3DRESOURCETYPE Type
Definition: d3d8types.h:1053
Definition: mesh.c:197
UINT WINAPI D3DXGetFVFVertexSize(DWORD FVF)
Definition: mesh.c:2289
D3DXVECTOR3 position
Definition: mesh.c:4559
UINT vertex_size
Definition: mesh.c:206
#define IDirect3DIndexBuffer9_GetDesc(p, a)
Definition: d3d9.h:777
DWORD number_of_faces
Definition: mesh.c:202
static BOOL compare_vec3(D3DXVECTOR3 u, D3DXVECTOR3 v)
Definition: mesh.c:64
#define IDirect3DIndexBuffer9_Lock(p, a, b, c, d)
Definition: d3d9.h:775
static BOOL compare_face(face a, face b)
Definition: mesh.c:105
LONG HRESULT
Definition: typedefs.h:79
struct vertex * vertices
Definition: mesh.c:200
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDirect3DVertexBuffer9_Lock(p, a, b, c, d)
Definition: d3d9.h:707
#define IDirect3DVertexBuffer9_Release(p)
Definition: d3d9.h:696
DWORD number_of_vertices
Definition: mesh.c:199
#define D3D_OK
Definition: d3d.h:106
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 IDirect3DIndexBuffer9_Release(p)
Definition: d3d9.h:764
#define ok(value,...)
Definition: atltest.h:57
face * faces
Definition: mesh.c:203
#define skip(...)
Definition: atltest.h:64
Definition: name.c:38
#define IDirect3DIndexBuffer9_Unlock(p)
Definition: d3d9.h:776
DWORD fvf
Definition: mesh.c:205
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
BOOL expected
Definition: store.c:2063

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 }
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:382
GLdouble n
Definition: glext.h:7729
Definition: mesh.c:197
Definition: parser.c:48
static BOOL compare_vec3(D3DXVECTOR3 u, D3DXVECTOR3 v)
Definition: mesh.c:64
unsigned long DWORD
Definition: ntddk_ex.h:95
static BOOL compare_vec4(D3DXVECTOR4 u, D3DXVECTOR4 v)
Definition: mesh.c:69
#define D3DDECL_END()
Definition: d3d9types.h:311
unsigned char BYTE
Definition: xxhash.c:193
static const char * test_name
Definition: run.c:177
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 min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
#define ok_(x1, x2)
Definition: atltest.h:61

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 }
Definition: mesh.c:4557
HRESULT hr
Definition: shlfolder.c:183
#define IDirect3DVertexBuffer9_Unlock(p)
Definition: d3d9.h:708
#define D3DLOCK_DISCARD
Definition: d3d8types.h:72
D3DRESOURCETYPE Type
Definition: d3d8types.h:1189
#define IDirect3DVertexBuffer9_GetDesc(p, a)
Definition: d3d9.h:709
static BOOL compare(FLOAT u, FLOAT v)
Definition: mesh.c:59
D3DRESOURCETYPE Type
Definition: d3d8types.h:1053
Definition: mesh.c:197
static UINT UINT LPWORD glyphs
Definition: font.c:44
UINT WINAPI D3DXGetFVFVertexSize(DWORD FVF)
Definition: mesh.c:2289
D3DXVECTOR3 normal
Definition: mesh.c:4560
D3DXVECTOR3 position
Definition: mesh.c:4559
UINT vertex_size
Definition: mesh.c:206
#define IDirect3DIndexBuffer9_GetDesc(p, a)
Definition: d3d9.h:777
DWORD number_of_faces
Definition: mesh.c:202
static BOOL compare_vec3(D3DXVECTOR3 u, D3DXVECTOR3 v)
Definition: mesh.c:64
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 IDirect3DIndexBuffer9_Lock(p, a, b, c, d)
Definition: d3d9.h:775
GLfloat f
Definition: glext.h:7540
LONG HRESULT
Definition: typedefs.h:79
struct vertex * vertices
Definition: mesh.c:200
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDirect3DVertexBuffer9_Lock(p, a, b, c, d)
Definition: d3d9.h:707
#define IDirect3DVertexBuffer9_Release(p)
Definition: d3d9.h:696
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
DWORD number_of_vertices
Definition: mesh.c:199
#define f1(x, y, z)
Definition: sha1.c:30
#define D3D_OK
Definition: d3d.h:106
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 IDirect3DIndexBuffer9_Release(p)
Definition: d3d9.h:764
#define ok(value,...)
Definition: atltest.h:57
face * faces
Definition: mesh.c:203
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
Definition: name.c:38
#define IDirect3DIndexBuffer9_Unlock(p)
Definition: d3d9.h:776
D3DXVECTOR3 *WINAPI D3DXVec3Normalize(D3DXVECTOR3 *pout, const D3DXVECTOR3 *pv)
Definition: math.c:1805
int f2(S1 &, S2 &)
GLfloat GLfloat v1
Definition: glext.h:6062
DWORD fvf
Definition: mesh.c:205
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
BOOL expected
Definition: store.c:2063

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 }
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
Definition: bug.cpp:7
static BOOL compare(FLOAT u, FLOAT v)
Definition: mesh.c:59
const GLdouble * v
Definition: gl.h:2040

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 }
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
static BOOL compare(FLOAT u, FLOAT v)
Definition: mesh.c:59
const GLdouble * v
Definition: gl.h:2040

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 }
GLint GLint GLsizei width
Definition: gl.h:1546
Definition: mesh.c:197
static BOOL new_mesh(struct mesh *mesh, DWORD number_of_vertices, DWORD number_of_faces)
Definition: mesh.c:215
struct vertex * vertices
Definition: mesh.c:200
WORD face[3]
Definition: mesh.c:4747
#define FALSE
Definition: mesh.c:45
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
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
face * faces
Definition: mesh.c:203
#define TRUE
Definition: mesh.c:42
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

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;
3182  D3DXVec3Normalize(&mesh->vertices[vertex].normal, &mesh->vertices[vertex].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: mesh.c:4557
static stack_node_t * stack
Definition: rpn_ieee.c:37
Definition: mesh.c:197
static void free_sincos_table(struct sincos_table *sincos_table)
Definition: mesh.c:2848
static BOOL new_mesh(struct mesh *mesh, DWORD number_of_vertices, DWORD number_of_faces)
Definition: mesh.c:215
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
GLdouble GLdouble z
Definition: glext.h:5874
Definition: _stack.h:47
static BOOL compute_sincos_table(struct sincos_table *sincos_table, float angle_start, float angle_step, int n)
Definition: mesh.c:2855
struct vertex * vertices
Definition: mesh.c:200
unsigned long DWORD
Definition: ntddk_ex.h:95
WORD face[3]
Definition: mesh.c:4747
static WORD vertex_index(UINT slices, int slice, int stack)
Definition: mesh.c:2883
#define FALSE
Definition: mesh.c:45
int isnan(double x)
face * faces
Definition: mesh.c:203
float FLOAT
Definition: typedefs.h:69
#define D3DX_PI
Definition: d3dx9math.h:27
#define TRUE
Definition: mesh.c:42
D3DXVECTOR3 *WINAPI D3DXVec3Normalize(D3DXVECTOR3 *pout, const D3DXVECTOR3 *pv)
Definition: math.c:1805
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

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
Definition: mesh.c:197

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 }
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
Definition: mesh.c:197
#define D3DX_DEFAULT
Definition: d3dx9.h:24
GLfloat f
Definition: glext.h:7540
#define NULL
Definition: types.h:112

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
Definition: mesh.c:197
#define cosf
Definition: cosf.c:6
static BOOL new_mesh(struct mesh *mesh, DWORD number_of_vertices, DWORD number_of_faces)
Definition: mesh.c:215
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
struct vertex * vertices
Definition: mesh.c:200
#define FALSE
Definition: mesh.c:45
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
face * faces
Definition: mesh.c:203
#define D3DX_PI
Definition: d3dx9math.h:27
#define sinf
Definition: sinf.c:6
#define TRUE
Definition: mesh.c:42

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 
2860  sincos_table->sin = HeapAlloc(GetProcessHeap(), 0, n * sizeof(*sincos_table->sin));
2861  if (!sincos_table->sin)
2862  {
2863  return FALSE;
2864  }
2865  sincos_table->cos = HeapAlloc(GetProcessHeap(), 0, n * sizeof(*sincos_table->cos));
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 }
GLdouble n
Definition: glext.h:7729
float * cos
Definition: mesh.c:4752
GLfloat angle
Definition: glext.h:10853
_STLP_DECLSPEC complex< float > _STLP_CALL cos(const complex< float > &)
float * sin
Definition: mesh.c:4751
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define FALSE
Definition: mesh.c:45
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
_STLP_DECLSPEC complex< float > _STLP_CALL sin(const complex< float > &)
#define TRUE
Definition: mesh.c:42
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by compute_cylinder(), and compute_sphere().

◆ 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 }
Definition: mesh.c:4557
static stack_node_t * stack
Definition: rpn_ieee.c:37
Definition: mesh.c:197
static void free_sincos_table(struct sincos_table *sincos_table)
Definition: mesh.c:2848
static BOOL new_mesh(struct mesh *mesh, DWORD number_of_vertices, DWORD number_of_faces)
Definition: mesh.c:215
Definition: _stack.h:47
static BOOL compute_sincos_table(struct sincos_table *sincos_table, float angle_start, float angle_step, int n)
Definition: mesh.c:2855
struct vertex * vertices
Definition: mesh.c:200
unsigned long DWORD
Definition: ntddk_ex.h:95
WORD face[3]
Definition: mesh.c:4747
static WORD vertex_index(UINT slices, int slice, int stack)
Definition: mesh.c:2883
#define FALSE
Definition: mesh.c:45
face * faces
Definition: mesh.c:203
#define D3DX_PI
Definition: d3dx9math.h:27
#define TRUE
Definition: mesh.c:42
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

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;
3889  D3DXVECTOR2 vec;
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 }
FT_Pos y
Definition: ftimage.h:77
int count
Definition: mesh.c:5331
Definition: mesh.c:4557
FLOAT y
Definition: d3dx9math.h:64
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
FT_Pos x
Definition: ftimage.h:76
#define pt(x, y)
Definition: drawing.c:79
const WCHAR * text
Definition: package.c:1827
Definition: mesh.c:197
static UINT UINT LPWORD glyphs
Definition: font.c:44
D3DXVECTOR3 normal
Definition: mesh.c:4560
enum pointtype corner
Definition: mesh.c:5319
D3DXVECTOR2 pos
Definition: mesh.c:5318
D3DXVECTOR3 position
Definition: mesh.c:4559
static BOOL new_mesh(struct mesh *mesh, DWORD number_of_vertices, DWORD number_of_faces)
Definition: mesh.c:215
D3DXVECTOR2 *WINAPI D3DXVec2Normalize(D3DXVECTOR2 *pout, const D3DXVECTOR2 *pv)
Definition: math.c:1659
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
FLOAT x
Definition: d3dx9math.h:64
struct vertex * vertices
Definition: mesh.c:200
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: mesh.c:5316
FT_Vector * vec
Definition: ftbbox.c:448
Definition: mesh.c:5329
struct point2d * items
Definition: mesh.c:5332
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 ok(value,...)
Definition: atltest.h:57
face * faces
Definition: mesh.c:203
int k
Definition: mpi.c:3369
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

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 }
Definition: mesh.c:197
#define cosf
Definition: cosf.c:6
static BOOL new_mesh(struct mesh *mesh, DWORD number_of_vertices, DWORD number_of_faces)
Definition: mesh.c:215
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
struct vertex * vertices
Definition: mesh.c:200
#define FALSE
Definition: mesh.c:45
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
face * faces
Definition: mesh.c:203
#define D3DX_PI
Definition: d3dx9math.h:27
#define sinf
Definition: sinf.c:6
#define TRUE
Definition: mesh.c:42

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 }
FLOAT y
Definition: d3dx9math.h:64
#define pt(x, y)
Definition: drawing.c:79
GLuint GLuint GLsizei count
Definition: gl.h:1545
FLOAT x
Definition: d3dx9math.h:64
int ret
char * value
Definition: compiler.c:67
static float(__cdecl *square_half_float)(float x

Referenced by create_outline().

◆ 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  {
3797  case POINTTYPE_CURVE_START:
3798  case POINTTYPE_CURVE_END:
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 struct outline * add_outline(struct outline_array *array)
Definition: mesh.c:3562
int count
Definition: mesh.c:5331
HRESULT hr
Definition: shlfolder.c:183
FLOAT y
Definition: d3dx9math.h:64
#define TT_POLYGON_TYPE
Definition: wingdi.h:1317
#define pt(x, y)
Definition: drawing.c:79
GLuint GLuint GLsizei count
Definition: gl.h:1545
static D3DXVECTOR2 * convert_fixed_to_float(POINTFX *pt, int count, float emsquare)
Definition: mesh.c:3574
static struct point2d * add_point(struct outline *array)
Definition: mesh.c:3550
struct outline_array outlines
Definition: mesh.c:5362
if(dx==0 &&dy==0)
Definition: linetemp.h:174
enum pointtype corner
Definition: mesh.c:5319
D3DXVECTOR2 pos
Definition: mesh.c:5318
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int BOOL
Definition: ntddk_ex.h:94
_STLP_DECLSPEC complex< float > _STLP_CALL cos(const complex< float > &)
static SIZE_T datasize
Definition: asm.c:30
#define D3DXToRadian(degree)
Definition: d3dx9math.h:33
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
static BOOL is_direction_similar(D3DXVECTOR2 *dir1, D3DXVECTOR2 *dir2, float cos_theta)
Definition: mesh.c:3616
GLfloat f
Definition: glext.h:7540
#define trace
Definition: atltest.h:70
POINTFX apfx[1]
Definition: wingdi.h:2713
LONG HRESULT
Definition: typedefs.h:79
FLOAT x
Definition: d3dx9math.h:64
Definition: mesh.c:5316
#define FALSE
Definition: mesh.c:45
static D3DXVECTOR2 * unit_vec2(D3DXVECTOR2 *dir, const D3DXVECTOR2 *pt1, const D3DXVECTOR2 *pt2)
Definition: mesh.c:3622
Definition: mesh.c:5329
#define S_OK
Definition: intsafe.h:51
struct point2d * items
Definition: mesh.c:5332