ReactOS  0.4.15-dev-321-g2d9b385
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 ID3DXFileData * get_mesh_data (const char *memory, SIZE_T length)
 
static void D3DXLoadSkinMeshFromXofTest (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 test_D3DXFrameFind (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 1688 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 1718 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 1605 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 1661 of file mesh.c.

◆ check_matrix

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

Definition at line 1641 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 1503 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);
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
UINT WINAPI D3DXGetFVFVertexSize(DWORD FVF)
Definition: mesh.c:2290
DWORD exp
Definition: msg.c:16033

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:1992
Definition: devices.h:37
#define ARRAY_SIZE(a)
Definition: main.h:24

Definition at line 1988 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 3595 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 3685 of file mesh.c.

3688 {
3689  D3DXVECTOR2 split1 = {0, 0}, split2 = {0, 0}, middle, vec;
3690  float deviation;
3691 
3692  D3DXVec2Scale(&split1, D3DXVec2Add(&split1, p1, p2), 0.5f);
3693  D3DXVec2Scale(&split2, D3DXVec2Add(&split2, p2, p3), 0.5f);
3694  D3DXVec2Scale(&middle, D3DXVec2Add(&middle, &split1, &split2), 0.5f);
3695 
3696  deviation = D3DXVec2Length(D3DXVec2Subtract(&vec, &middle, p2));
3697  if (deviation < max_deviation) {
3698  struct point2d *pt = add_point(outline);
3699  if (!pt) return E_OUTOFMEMORY;
3700  pt->pos = *p2;
3701  pt->corner = POINTTYPE_CURVE;
3702  /* the end point is omitted because the end line merges into the next segment of
3703  * the split bezier curve, and the end of the split bezier curve is added outside
3704  * this recursive function. */
3705  } else {
3706  HRESULT hr = add_bezier_points(outline, p1, &split1, &middle, max_deviation);
3707  if (hr != S_OK) return hr;
3708  hr = add_bezier_points(outline, &middle, &split2, p3, max_deviation);
3709  if (hr != S_OK) return hr;
3710  }
3711 
3712  return S_OK;
3713 }
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:3649
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
GLfloat f
Definition: glext.h:7540
LONG HRESULT
Definition: typedefs.h:78
Definition: mesh.c:5316
FT_Vector * vec
Definition: ftbbox.c:448
Definition: mesh.c:5329
#define S_OK
Definition: intsafe.h:59
static HRESULT add_bezier_points(struct outline *outline, const D3DXVECTOR2 *p1, const D3DXVECTOR2 *p2, const D3DXVECTOR2 *p3, float max_deviation)
Definition: mesh.c:3685

Referenced by create_outline().

◆ add_outline()

static struct outline* add_outline ( struct outline_array array)
static

Definition at line 3661 of file mesh.c.

3662 {
3663  struct outline *item;
3664 
3665  if (!reserve((struct dynamic_array *)array, array->count + 1, sizeof(array->items[0])))
3666  return NULL;
3667 
3668  item = &array->items[array->count++];
3669  ZeroMemory(item, sizeof(*item));
3670  return item;
3671 }
#define ZeroMemory
Definition: winbase.h:1648
static BOOL reserve(struct dynamic_array *array, int count, int itemsize)
Definition: mesh.c:3629
smooth NULL
Definition: ftsmooth.c:416
Definition: mesh.c:5329
static ATOM item
Definition: dde.c:856

Referenced by create_outline().

◆ add_point()

static struct point2d* add_point ( struct outline array)
static

Definition at line 3649 of file mesh.c.

3650 {
3651  struct point2d *item;
3652 
3653  if (!reserve((struct dynamic_array *)array, array->count + 1, sizeof(array->items[0])))
3654  return NULL;
3655 
3656  item = &array->items[array->count++];
3657  ZeroMemory(item, sizeof(*item));
3658  return item;
3659 }
#define ZeroMemory
Definition: winbase.h:1648
static BOOL reserve(struct dynamic_array *array, int count, int itemsize)
Definition: mesh.c:3629
smooth NULL
Definition: ftsmooth.c:416
Definition: mesh.c:5316
static ATOM item
Definition: dde.c:856

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 3726 of file mesh.c.

3730 {
3731  D3DXVECTOR2 curdir, lastdir;
3732  struct point2d *prevpt, *pt;
3733  BOOL ret = FALSE;
3734  const float cos_half = cos(D3DXToRadian(0.5f));
3735 
3736  pt = &outline->items[pt_index];
3737  pt_index = (pt_index - 1 + outline->count) % outline->count;
3738  prevpt = &outline->items[pt_index];
3739 
3740  if (to_curve)
3742 
3743  if (outline->count < 2)
3744  return FALSE;
3745 
3746  /* remove last point if the next line continues the last line */
3747  unit_vec2(&lastdir, &prevpt->pos, &pt->pos);
3748  unit_vec2(&curdir, &pt->pos, nextpt);
3749  if (is_direction_similar(&lastdir, &curdir, cos_half))
3750  {
3751  outline->count--;
3752  if (pt->corner == POINTTYPE_CURVE_END)
3753  prevpt->corner = pt->corner;
3754  if (prevpt->corner == POINTTYPE_CURVE_END && to_curve)
3755  prevpt->corner = POINTTYPE_CURVE_MIDDLE;
3756  pt = prevpt;
3757 
3758  ret = TRUE;
3759  if (outline->count < 2)
3760  return ret;
3761 
3762  pt_index = (pt_index - 1 + outline->count) % outline->count;
3763  prevpt = &outline->items[pt_index];
3764  unit_vec2(&lastdir, &prevpt->pos, &pt->pos);
3765  unit_vec2(&curdir, &pt->pos, nextpt);
3766  }
3767  return ret;
3768 }
int count
Definition: mesh.c:5331
#define pt(x, y)
Definition: drawing.c:79
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:3715
GLfloat f
Definition: glext.h:7540
if(!(yy_init))
Definition: macro.lex.yy.c:714
Definition: mesh.c:5316
int ret
static D3DXVECTOR2 * unit_vec2(D3DXVECTOR2 *dir, const D3DXVECTOR2 *pt1, const D3DXVECTOR2 *pt2)
Definition: mesh.c:3721
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 1654 of file mesh.c.

1655 {
1656  ok_(__FILE__,line)(expected.r == got.r && expected.g == got.g && expected.b == got.b && expected.a == got.a,
1657  "%sExpected (%g, %g, %g, %g), got (%g, %g, %g, %g)\n", prefix,
1658  expected.r, expected.g, expected.b, expected.a, got.r, got.g, got.b, got.a);
1659 }
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
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
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: parser.c:48
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 1689 of file mesh.c.

1690 {
1691  DWORD *expected;
1692  DWORD num_faces = mesh->lpVtbl->GetNumFaces(mesh);
1693  HRESULT hr;
1694 
1695  expected = HeapAlloc(GetProcessHeap(), 0, num_faces * sizeof(DWORD) * 3);
1696  if (!expected) {
1697  skip_(__FILE__, line)("Out of memory\n");
1698  return;
1699  }
1700  hr = mesh->lpVtbl->GenerateAdjacency(mesh, epsilon, expected);
1701  ok_(__FILE__, line)(hr == D3D_OK, "Expected D3D_OK, got %#x\n", hr);
1702  if (SUCCEEDED(hr))
1703  {
1704  int i;
1705  for (i = 0; i < num_faces; i++)
1706  {
1707  ok_(__FILE__, line)(expected[i * 3] == got[i * 3] &&
1708  expected[i * 3 + 1] == got[i * 3 + 1] &&
1709  expected[i * 3 + 2] == got[i * 3 + 2],
1710  "Face %u adjacencies: Expected (%u, %u, %u), got (%u, %u, %u)\n", i,
1711  expected[i * 3], expected[i * 3 + 1], expected[i * 3 + 2],
1712  got[i * 3], got[i * 3 + 1], got[i * 3 + 2]);
1713  }
1714  }
1716 }
HRESULT hr
Definition: shlfolder.c:183
Definition: mesh.c:197
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
Definition: parser.c:48
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:78
unsigned long DWORD
Definition: ntddk_ex.h:95
#define D3D_OK
Definition: d3d.h:106
#define skip_(test, file, line,...)
Definition: kmt_test.h:222
#define HeapFree(x, y, z)
Definition: compat.h:403
BOOL expected
Definition: store.c:2063
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#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 1720 of file mesh.c.

1721 {
1722  int i;
1723  static const struct {
1724  const char *name;
1725  DWORD name_size;
1726  DWORD num_bytes;
1727  DWORD value_offset;
1728  } params[] = {
1729 #define EFFECT_TABLE_ENTRY(str, field) \
1730  {str, sizeof(str), sizeof(materials->MatD3D.field), offsetof(D3DXMATERIAL, MatD3D.field)}
1731  EFFECT_TABLE_ENTRY("Diffuse", Diffuse),
1732  EFFECT_TABLE_ENTRY("Power", Power),
1733  EFFECT_TABLE_ENTRY("Specular", Specular),
1734  EFFECT_TABLE_ENTRY("Emissive", Emissive),
1735  EFFECT_TABLE_ENTRY("Ambient", Ambient),
1736 #undef EFFECT_TABLE_ENTRY
1737  };
1738 
1739  if (!num_materials) {
1740  ok_(__FILE__, line)(effects == NULL, "Expected NULL effects, got %p\n", effects);
1741  return;
1742  }
1743  for (i = 0; i < num_materials; i++)
1744  {
1745  int j;
1746  DWORD expected_num_defaults = ARRAY_SIZE(params) + (materials[i].pTextureFilename ? 1 : 0);
1747 
1748  ok_(__FILE__,line)(expected_num_defaults == effects[i].NumDefaults,
1749  "effect[%u] NumDefaults: Expected %u, got %u\n", i,
1750  expected_num_defaults, effects[i].NumDefaults);
1751  for (j = 0; j < min(ARRAY_SIZE(params), effects[i].NumDefaults); j++)
1752  {
1753  int k;
1754  D3DXEFFECTDEFAULT *got_param = &effects[i].pDefaults[j];
1755  ok_(__FILE__,line)(!strcmp(params[j].name, got_param->pParamName),
1756  "effect[%u].pDefaults[%u].pParamName: Expected '%s', got '%s'\n", i, j,
1757  params[j].name, got_param->pParamName);
1758  ok_(__FILE__,line)(D3DXEDT_FLOATS == got_param->Type,
1759  "effect[%u].pDefaults[%u].Type: Expected %u, got %u\n", i, j,
1760  D3DXEDT_FLOATS, got_param->Type);
1761  ok_(__FILE__,line)(params[j].num_bytes == got_param->NumBytes,
1762  "effect[%u].pDefaults[%u].NumBytes: Expected %u, got %u\n", i, j,
1763  params[j].num_bytes, got_param->NumBytes);
1764  for (k = 0; k < min(params[j].num_bytes, got_param->NumBytes) / 4; k++)
1765  {
1766  FLOAT expected = ((FLOAT*)((BYTE*)&materials[i] + params[j].value_offset))[k];
1767  FLOAT got = ((FLOAT*)got_param->pValue)[k];
1768  ok_(__FILE__,line)(compare(expected, got),
1769  "effect[%u].pDefaults[%u] float value %u: Expected %g, got %g\n", i, j, k, expected, got);
1770  }
1771  }
1772  if (effects[i].NumDefaults > ARRAY_SIZE(params)) {
1773  D3DXEFFECTDEFAULT *got_param = &effects[i].pDefaults[j];
1774  static const char *expected_name = "Texture0@Name";
1775 
1776  ok_(__FILE__,line)(!strcmp(expected_name, got_param->pParamName),
1777  "effect[%u].pDefaults[%u].pParamName: Expected '%s', got '%s'\n", i, j,
1778  expected_name, got_param->pParamName);
1779  ok_(__FILE__,line)(D3DXEDT_STRING == got_param->Type,
1780  "effect[%u].pDefaults[%u].Type: Expected %u, got %u\n", i, j,
1781  D3DXEDT_STRING, got_param->Type);
1782  if (materials[i].pTextureFilename) {
1783  ok_(__FILE__,line)(strlen(materials[i].pTextureFilename) + 1 == got_param->NumBytes,
1784  "effect[%u] texture filename length: Expected %u, got %u\n", i,
1785  (DWORD)strlen(materials[i].pTextureFilename) + 1, got_param->NumBytes);
1786  ok_(__FILE__,line)(!strcmp(materials[i].pTextureFilename, got_param->pValue),
1787  "effect[%u] texture filename: Expected '%s', got '%s'\n", i,
1788  materials[i].pTextureFilename, (char*)got_param->pValue);
1789  }
1790  }
1791  }
1792 }
#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
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
LPD3DXEFFECTDEFAULT pDefaults
Definition: d3dx9mesh.h:211
GLenum const GLfloat * params
Definition: glext.h:5645
smooth NULL
Definition: ftsmooth.c:416
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
#define ARRAY_SIZE(a)
Definition: main.h:24
#define min(a, b)
Definition: monoChain.cc:55
Definition: name.c:38
float FLOAT
Definition: typedefs.h:68
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 1607 of file mesh.c.

1608 {
1609  DWORD mesh_index_size = (mesh->lpVtbl->GetOptions(mesh) & D3DXMESH_32BIT) ? 4 : 2;
1610  DWORD mesh_num_indices = mesh->lpVtbl->GetNumFaces(mesh) * 3;
1611  const void *mesh_indices;
1612  HRESULT hr;
1613  DWORD i;
1614 
1615  ok_(__FILE__,line)(index_size == mesh_index_size,
1616  "Expected index size %u, got %u\n", index_size, mesh_index_size);
1617  ok_(__FILE__,line)(num_indices == mesh_num_indices,
1618  "Expected %u indices, got %u\n", num_indices, mesh_num_indices);
1619 
1620  hr = mesh->lpVtbl->LockIndexBuffer(mesh, D3DLOCK_READONLY, (void**)&mesh_indices);
1621  ok_(__FILE__,line)(hr == D3D_OK, "LockIndexBuffer returned %x, expected %x (D3D_OK)\n", hr, D3D_OK);
1622  if (FAILED(hr))
1623  return;
1624 
1625  if (mesh_index_size == index_size) {
1626  for (i = 0; i < min(num_indices, mesh_num_indices); i++)
1627  {
1628  if (index_size == 4)
1629  ok_(__FILE__,line)(*(DWORD*)indices == *(DWORD*)mesh_indices,
1630  "Index[%u]: expected %u, got %u\n", i, *(DWORD*)indices, *(DWORD*)mesh_indices);
1631  else
1632  ok_(__FILE__,line)(*(WORD*)indices == *(WORD*)mesh_indices,
1633  "Index[%u]: expected %u, got %u\n", i, *(WORD*)indices, *(WORD*)mesh_indices);
1634  indices = (BYTE*)indices + index_size;
1635  mesh_indices = (BYTE*)mesh_indices + index_size;
1636  }
1637  }
1638  mesh->lpVtbl->UnlockIndexBuffer(mesh);
1639 }
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: gl.h:1545
HRESULT hr
Definition: shlfolder.c:183
Definition: mesh.c:197
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
Definition: parser.c:48
LONG HRESULT
Definition: typedefs.h:78
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
#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 1663 of file mesh.c.

1664 {
1665  int i;
1666  ok_(__FILE__,line)(expected_count == got_count, "Expected %u materials, got %u\n", expected_count, got_count);
1667  if (!expected) {
1668  ok_(__FILE__,line)(got == NULL, "Expected NULL material ptr, got %p\n", got);
1669  return;
1670  }
1671  for (i = 0; i < min(expected_count, got_count); i++)
1672  {
1673  if (!expected[i].pTextureFilename)
1674  ok_(__FILE__,line)(got[i].pTextureFilename == NULL,
1675  "Expected NULL pTextureFilename, got %p\n", got[i].pTextureFilename);
1676  else
1677  ok_(__FILE__,line)(!strcmp(expected[i].pTextureFilename, got[i].pTextureFilename),
1678  "Expected '%s' for pTextureFilename, got '%s'\n", expected[i].pTextureFilename, got[i].pTextureFilename);
1679  check_colorvalue_(line, "Diffuse: ", got[i].MatD3D.Diffuse, expected[i].MatD3D.Diffuse);
1680  check_colorvalue_(line, "Ambient: ", got[i].MatD3D.Ambient, expected[i].MatD3D.Ambient);
1681  check_colorvalue_(line, "Specular: ", got[i].MatD3D.Specular, expected[i].MatD3D.Specular);
1682  check_colorvalue_(line, "Emissive: ", got[i].MatD3D.Emissive, expected[i].MatD3D.Emissive);
1683  ok_(__FILE__,line)(expected[i].MatD3D.Power == got[i].MatD3D.Power,
1684  "Power: Expected %g, got %g\n", expected[i].MatD3D.Power, got[i].MatD3D.Power);
1685  }
1686 }
D3DMATERIAL9 MatD3D
Definition: d3dx9mesh.h:195
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
static void check_colorvalue_(int line, const char *prefix, const D3DCOLORVALUE got, const D3DCOLORVALUE expected)
Definition: mesh.c:1654
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
#define min(a, b)
Definition: monoChain.cc:55
static int expected_count(int *sink)
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 1642 of file mesh.c.

1643 {
1644  int i, j;
1645  for (i = 0; i < 4; i++) {
1646  for (j = 0; j < 4; j++) {
1647  ok_(__FILE__,line)(compare(U(*expected).m[i][j], U(*got).m[i][j]),
1648  "matrix[%u][%u]: expected %g, got %g\n",
1649  i, j, U(*expected).m[i][j], U(*got).m[i][j]);
1650  }
1651  }
1652 }
#define U(x)
Definition: wordpad.c:45
static BOOL compare(FLOAT u, FLOAT v)
Definition: mesh.c:59
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
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
#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 1505 of file mesh.c.

1506 {
1507  DWORD mesh_num_vertices = mesh->lpVtbl->GetNumVertices(mesh);
1508  DWORD mesh_fvf = mesh->lpVtbl->GetFVF(mesh);
1509  const void *mesh_vertices;
1510  HRESULT hr;
1511 
1512  ok_(__FILE__,line)(fvf == mesh_fvf, "expected FVF %x, got %x\n", fvf, mesh_fvf);
1513  ok_(__FILE__,line)(num_vertices == mesh_num_vertices,
1514  "Expected %u vertices, got %u\n", num_vertices, mesh_num_vertices);
1515 
1516  hr = mesh->lpVtbl->LockVertexBuffer(mesh, D3DLOCK_READONLY, (void**)&mesh_vertices);
1517  ok_(__FILE__,line)(hr == D3D_OK, "LockVertexBuffer returned %x, expected %x (D3D_OK)\n", hr, D3D_OK);
1518  if (FAILED(hr))
1519  return;
1520 
1521  if (mesh_fvf == fvf) {
1522  DWORD vertex_size = D3DXGetFVFVertexSize(fvf), i;
1523 
1524  for (i = 0; i < min(num_vertices, mesh_num_vertices); i++)
1525  {
1526  const FLOAT *exp_float = vertices;
1527  const FLOAT *got_float = mesh_vertices;
1528  DWORD texcount;
1529  DWORD pos_dim = 0;
1530  int j;
1531  BOOL last_beta_dword = FALSE;
1532  char prefix[128];
1533 
1534  switch (fvf & D3DFVF_POSITION_MASK) {
1535  case D3DFVF_XYZ: pos_dim = 3; break;
1536  case D3DFVF_XYZRHW: pos_dim = 4; break;
1537  case D3DFVF_XYZB1:
1538  case D3DFVF_XYZB2:
1539  case D3DFVF_XYZB3:
1540  case D3DFVF_XYZB4:
1541  case D3DFVF_XYZB5:
1542  pos_dim = (fvf & D3DFVF_POSITION_MASK) - D3DFVF_XYZB1 + 1;
1544  {
1545  pos_dim--;
1546  last_beta_dword = TRUE;
1547  }
1548  break;
1549  case D3DFVF_XYZW: pos_dim = 4; break;
1550  }
1551  sprintf(prefix, "vertex[%u] position, ", i);
1552  check_floats_(line, prefix, got_float, exp_float, pos_dim);
1553  exp_float += pos_dim;
1554  got_float += pos_dim;
1555 
1556  if (last_beta_dword) {
1557  ok_(__FILE__,line)(*(DWORD*)exp_float == *(DWORD*)got_float,
1558  "Vertex[%u]: Expected last beta %08x, got %08x\n", i, *(DWORD*)exp_float, *(DWORD*)got_float);
1559  exp_float++;
1560  got_float++;
1561  }
1562 
1563  if (fvf & D3DFVF_NORMAL) {
1564  sprintf(prefix, "vertex[%u] normal, ", i);
1565  check_floats_(line, prefix, got_float, exp_float, 3);
1566  exp_float += 3;
1567  got_float += 3;
1568  }
1569  if (fvf & D3DFVF_PSIZE) {
1570  ok_(__FILE__,line)(compare(*exp_float, *got_float),
1571  "Vertex[%u]: Expected psize %g, got %g\n", i, *exp_float, *got_float);
1572  exp_float++;
1573  got_float++;
1574  }
1575  if (fvf & D3DFVF_DIFFUSE) {
1576  ok_(__FILE__,line)(*(DWORD*)exp_float == *(DWORD*)got_float,
1577  "Vertex[%u]: Expected diffuse %08x, got %08x\n", i, *(DWORD*)exp_float, *(DWORD*)got_float);
1578  exp_float++;
1579  got_float++;
1580  }
1581  if (fvf & D3DFVF_SPECULAR) {
1582  ok_(__FILE__,line)(*(DWORD*)exp_float == *(DWORD*)got_float,
1583  "Vertex[%u]: Expected specular %08x, got %08x\n", i, *(DWORD*)exp_float, *(DWORD*)got_float);
1584  exp_float++;
1585  got_float++;
1586  }
1587 
1588  texcount = (fvf & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
1589  for (j = 0; j < texcount; j++) {
1590  DWORD dim = (((fvf >> (16 + 2 * j)) + 1) & 0x03) + 1;
1591  sprintf(prefix, "vertex[%u] texture, ", i);
1592  check_floats_(line, prefix, got_float, exp_float, dim);
1593  exp_float += dim;
1594  got_float += dim;
1595  }
1596 
1597  vertices = (BYTE*)vertices + vertex_size;
1598  mesh_vertices = (BYTE*)mesh_vertices + vertex_size;
1599  }
1600  }
1601 
1602  mesh->lpVtbl->UnlockVertexBuffer(mesh);
1603 }
#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:2290
#define sprintf(buf, format,...)
Definition: sprintf.c:55
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_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:78
#define D3DFVF_XYZB5
Definition: d3d8types.h:119
#define D3DFVF_XYZ
Definition: d3d8types.h:113
unsigned long DWORD
Definition: ntddk_ex.h:95
#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
#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:68
#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 6643 of file mesh.c.

6644 {
6645  const char *usage_strings[] =
6646  {
6647  "position",
6648  "blend weight",
6649  "blend indices",
6650  "normal",
6651  "point size",
6652  "texture coordinates",
6653  "tangent",
6654  "binormal",
6655  "tessellation factor",
6656  "position transformed",
6657  "color",
6658  "fog",
6659  "depth",
6660  "sample"
6661  };
6662  D3DVERTEXELEMENT9 *decl_ptr;
6663  const float PRECISION = 1e-5f;
6664 
6665  for (decl_ptr = declaration; decl_ptr->Stream != 0xFF; decl_ptr++)
6666  {
6667  switch (decl_ptr->Type)
6668  {
6669  case D3DDECLTYPE_FLOAT1:
6670  {
6671  FLOAT *got = (FLOAT*)(got_ptr + decl_ptr->Offset);
6672  FLOAT *exp = (FLOAT*)(exp_ptr + decl_ptr->Offset);
6673  FLOAT diff = fabsf(*got - *exp);
6674  ok_(__FILE__,line)(diff <= PRECISION, "Mesh %d: Got %f for vertex %d %s, expected %f.\n",
6675  mesh_number, *got, vertex_number, usage_strings[decl_ptr->Usage], *exp);
6676  break;
6677  }
6678  case D3DDECLTYPE_FLOAT2:
6679  {
6680  D3DXVECTOR2 *got = (D3DXVECTOR2*)(got_ptr + decl_ptr->Offset);
6681  D3DXVECTOR2 *exp = (D3DXVECTOR2*)(exp_ptr + decl_ptr->Offset);
6682  FLOAT diff = max(fabsf(got->x - exp->x), fabsf(got->y - exp->y));
6683  ok_(__FILE__,line)(diff <= PRECISION, "Mesh %d: Got (%f, %f) for vertex %d %s, expected (%f, %f).\n",
6684  mesh_number, got->x, got->y, vertex_number, usage_strings[decl_ptr->Usage], exp->x, exp->y);
6685  break;
6686  }
6687  case D3DDECLTYPE_FLOAT3:
6688  {
6689  D3DXVECTOR3 *got = (D3DXVECTOR3*)(got_ptr + decl_ptr->Offset);
6690  D3DXVECTOR3 *exp = (D3DXVECTOR3*)(exp_ptr + decl_ptr->Offset);
6691  FLOAT diff = max(fabsf(got->x - exp->x), fabsf(got->y - exp->y));
6692  diff = max(diff, fabsf(got->z - exp->z));
6693  ok_(__FILE__,line)(diff <= PRECISION, "Mesh %d: Got (%f, %f, %f) for vertex %d %s, expected (%f, %f, %f).\n",
6694  mesh_number, got->x, got->y, got->z, vertex_number, usage_strings[decl_ptr->Usage], exp->x, exp->y, exp->z);
6695  break;
6696  }
6697  case D3DDECLTYPE_FLOAT4:
6698  {
6699  D3DXVECTOR4 *got = (D3DXVECTOR4*)(got_ptr + decl_ptr->Offset);
6700  D3DXVECTOR4 *exp = (D3DXVECTOR4*)(exp_ptr + decl_ptr->Offset);
6701  FLOAT diff = max(fabsf(got->x - exp->x), fabsf(got->y - exp->y));
6702  diff = max(diff, fabsf(got->z - exp->z));
6703  diff = max(diff, fabsf(got->w - exp->w));
6704  ok_(__FILE__,line)(diff <= PRECISION, "Mesh %d: Got (%f, %f, %f, %f) for vertex %d %s, expected (%f, %f, %f, %f).\n",
6705  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);
6706  break;
6707  }
6708  case D3DDECLTYPE_D3DCOLOR:
6709  {
6710  BYTE *got = got_ptr + decl_ptr->Offset;
6711  const BYTE *exp = exp_ptr + decl_ptr->Offset;
6712  BOOL same_color = got[0] == exp[0] && got[1] == exp[1]
6713  && got[2] == exp[2] && got[3] == exp[3];
6714  const char *color_types[] = {"diffuse", "specular", "undefined color"};
6715  BYTE usage_index = decl_ptr->UsageIndex;
6716  if (usage_index > 1) usage_index = 2;
6717  ok_(__FILE__,line)(same_color, "Mesh %d: Got (%u, %u, %u, %u) for vertex %d %s, expected (%u, %u, %u, %u).\n",
6718  mesh_number, got[0], got[1], got[2], got[3], vertex_number, color_types[usage_index], exp[0], exp[1], exp[2], exp[3]);
6719  break;
6720  }
6721  case D3DDECLTYPE_UBYTE4:
6722  case D3DDECLTYPE_UBYTE4N:
6723  {
6724  BYTE *got = got_ptr + decl_ptr->Offset;
6725  const BYTE *exp = exp_ptr + decl_ptr->Offset;
6726  BOOL same = got[0] == exp[0] && got[1] == exp[1]
6727  && got[2] == exp[2] && got[3] == exp[3];
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[0], got[1], got[2], got[3], vertex_number, usage_strings[decl_ptr->Usage], exp[0], exp[1], exp[2], exp[3]);
6730  break;
6731  }
6732  case D3DDECLTYPE_SHORT2:
6733  case D3DDECLTYPE_SHORT2N:
6734  {
6735  SHORT *got = (SHORT*)(got_ptr + decl_ptr->Offset);
6736  SHORT *exp = (SHORT*)(exp_ptr + decl_ptr->Offset);
6737  BOOL same = got[0] == exp[0] && got[1] == exp[1];
6738  ok_(__FILE__,line)(same, "Mesh %d: Got (%hd, %hd) for vertex %d %s, expected (%hd, %hd).\n",
6739  mesh_number, got[0], got[1], vertex_number, usage_strings[decl_ptr->Usage], exp[0], exp[1]);
6740  break;
6741  }
6742  case D3DDECLTYPE_SHORT4:
6743  case D3DDECLTYPE_SHORT4N:
6744  {
6745  SHORT *got = (SHORT*)(got_ptr + decl_ptr->Offset);
6746  SHORT *exp = (SHORT*)(exp_ptr + decl_ptr->Offset);
6747  BOOL same = got[0] == exp[0] && got[1] == exp[1]
6748  && got[2] == exp[2] && got[3] == exp[3];
6749  ok_(__FILE__,line)(same, "Mesh %d: Got (%hd, %hd, %hd, %hd) for vertex %d %s, expected (%hd, %hd, %hd, %hd).\n",
6750  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]);
6751  break;
6752  }
6753  case D3DDECLTYPE_USHORT2N:
6754  {
6755  USHORT *got = (USHORT*)(got_ptr + decl_ptr->Offset);
6756  USHORT *exp = (USHORT*)(exp_ptr + decl_ptr->Offset);
6757  BOOL same = got[0] == exp[0] && got[1] == exp[1];
6758  ok_(__FILE__,line)(same, "Mesh %d: Got (%hu, %hu) for vertex %d %s, expected (%hu, %hu).\n",
6759  mesh_number, got[0], got[1], vertex_number, usage_strings[decl_ptr->Usage], exp[0], exp[1]);
6760  break;
6761  }
6762  case D3DDECLTYPE_USHORT4N:
6763  {
6764  USHORT *got = (USHORT*)(got_ptr + decl_ptr->Offset);
6765  USHORT *exp = (USHORT*)(exp_ptr + decl_ptr->Offset);
6766  BOOL same = got[0] == exp[0] && got[1] == exp[1]
6767  && got[2] == exp[2] && got[3] == exp[3];
6768  ok_(__FILE__,line)(same, "Mesh %d: Got (%hu, %hu, %hu, %hu) for vertex %d %s, expected (%hu, %hu, %hu, %hu).\n",
6769  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]);
6770  break;
6771  }
6772  case D3DDECLTYPE_UDEC3:
6773  {
6774  DWORD *got = (DWORD*)(got_ptr + decl_ptr->Offset);
6775  DWORD *exp = (DWORD*)(exp_ptr + decl_ptr->Offset);
6776  BOOL same = memcmp(got, exp, sizeof(*got)) == 0;
6777  struct udec3 got_udec3 = dword_to_udec3(*got);
6778  struct udec3 exp_udec3 = dword_to_udec3(*exp);
6779  ok_(__FILE__,line)(same, "Mesh %d: Got (%u, %u, %u, %u) for vertex %d %s, expected (%u, %u, %u, %u).\n",
6780  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);
6781 
6782  break;
6783  }
6784  case D3DDECLTYPE_DEC3N:
6785  {
6786  DWORD *got = (DWORD*)(got_ptr + decl_ptr->Offset);
6787  DWORD *exp = (DWORD*)(exp_ptr + decl_ptr->Offset);
6788  BOOL same = memcmp(got, exp, sizeof(*got)) == 0;
6789  struct dec3n got_dec3n = dword_to_dec3n(*got);
6790  struct dec3n exp_dec3n = dword_to_dec3n(*exp);
6791  ok_(__FILE__,line)(same, "Mesh %d: Got (%d, %d, %d, %d) for vertex %d %s, expected (%d, %d, %d, %d).\n",
6792  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);
6793  break;
6794  }
6795  case D3DDECLTYPE_FLOAT16_2:
6796  {
6797  WORD *got = (WORD*)(got_ptr + decl_ptr->Offset);
6798  WORD *exp = (WORD*)(exp_ptr + decl_ptr->Offset);
6799  BOOL same = got[0] == exp[0] && got[1] == exp[1];
6800  ok_(__FILE__,line)(same, "Mesh %d: Got (%hx, %hx) for vertex %d %s, expected (%hx, %hx).\n",
6801  mesh_number, got[0], got[1], vertex_number, usage_strings[decl_ptr->Usage], exp[0], exp[1]);
6802  break;
6803  }
6804  case D3DDECLTYPE_FLOAT16_4:
6805  {
6806  WORD *got = (WORD*)(got_ptr + decl_ptr->Offset);
6807  WORD *exp = (WORD*)(exp_ptr + decl_ptr->Offset);
6808  BOOL same = got[0] == exp[0] && got[1] == exp[1]
6809  && got[2] == exp[2] && got[3] == exp[3];
6810  ok_(__FILE__,line)(same, "Mesh %d: Got (%hx, %hx, %hx, %hx) for vertex %d %s, expected (%hx, %hx, %hx, %hx).\n",
6811  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]);
6812  break;
6813  }
6814  default:
6815  break;
6816  }
6817  }
6818 }
#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:6631
static struct udec3 dword_to_udec3(DWORD d)
Definition: mesh.c:6619
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:68
_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 10748 of file mesh.c.

10749 {
10750  HRESULT hr;
10751  BYTE *vertices;
10752  size_t normal_size;
10753  DWORD i, num_vertices, vertex_stride;
10754  const D3DXVECTOR4 normal = {NAN, NAN, NAN, NAN};
10755  D3DVERTEXELEMENT9 *normal_declaration = NULL;
10757 
10758  if (FAILED(hr = mesh->lpVtbl->GetDeclaration(mesh, declaration)))
10759  return hr;
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  return D3DERR_INVALIDCALL;
10772 
10773  if (normal_declaration->Type == D3DDECLTYPE_FLOAT3)
10774  {
10775  normal_size = sizeof(D3DXVECTOR3);
10776  }
10777  else if (normal_declaration->Type == D3DDECLTYPE_FLOAT4)
10778  {
10779  normal_size = sizeof(D3DXVECTOR4);
10780  }
10781  else
10782  {
10783  trace("Cannot clear normals\n");
10784  return E_NOTIMPL;
10785  }
10786 
10787  num_vertices = mesh->lpVtbl->GetNumVertices(mesh);
10788  vertex_stride = mesh->lpVtbl->GetNumBytesPerVertex(mesh);
10789 
10790  if (FAILED(hr = mesh->lpVtbl->LockVertexBuffer(mesh, 0, (void **)&vertices)))
10791  return hr;
10792 
10793  vertices += normal_declaration->Offset;
10794 
10795  for (i = 0; i < num_vertices; i++, vertices += vertex_stride)
10796  memcpy(vertices, &normal, normal_size);
10797 
10798  return mesh->lpVtbl->UnlockVertexBuffer(mesh);
10799 }
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
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
smooth NULL
Definition: ftsmooth.c:416
#define NAN
Definition: mesh.c:39
#define trace
Definition: atltest.h:70
LONG HRESULT
Definition: typedefs.h:78
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
#define E_NOTIMPL
Definition: ddrawi.h:99

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 586 of file mesh.c.

588 {
590  unsigned int i;
591 
592  for (i = 0; i < MAX_FVF_DECL_SIZE; i++)
593  {
594  int end1 = memcmp(&elements[i], &last, sizeof(last));
595  int end2 = memcmp(&expected_elements[i], &last, sizeof(last));
596  int status;
597 
598  if (!end1 && !end2) break;
599 
600  status = !end1 ^ !end2;
601  ok(!status, "Line %u, test %u: Mismatch in size, test declaration is %s than expected.\n",
602  line, test_id, end1 ? "shorter" : "longer");
603  if (status)
604  {
605  print_elements(elements);
606  break;
607  }
608 
609  status = memcmp(&elements[i], &expected_elements[i], sizeof(D3DVERTEXELEMENT9));
610  ok(!status, "Line %u, test %u: Mismatch in element %u.\n", line, test_id, i);
611  if (status)
612  {
613  print_elements(elements);
614  break;
615  }
616  }
617 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
POINT last
Definition: font.c:46
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
Definition: parser.c:48
#define D3DDECL_END()
Definition: d3d9types.h:311
#define ok(value,...)
Definition: atltest.h:57
static void print_elements(const D3DVERTEXELEMENT9 *elements)
Definition: mesh.c:570
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by test_create_skin_info(), and test_fvf_to_decl().

◆ 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:2290
D3DXVECTOR3 position
Definition: mesh.c:4559
UINT vertex_size
Definition: mesh.c:206
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_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:78
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
#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 10801 of file mesh.c.

10803 {
10804  unsigned int i;
10805  BYTE *vertices;
10806  DWORD num_vertices, vertex_stride;
10807  D3DVERTEXELEMENT9 *normal_declaration = NULL;
10809 
10810  if (FAILED(mesh->lpVtbl->GetDeclaration(mesh, declaration)))
10811  {
10812  ok_(__FILE__, line)(0, "%s: Failed to get declaration\n", test_name);
10813  return;
10814  }
10815 
10816  for (i = 0; declaration[i].Stream != 0xff; i++)
10817  {
10818  if (declaration[i].Usage == D3DDECLUSAGE_NORMAL && !declaration[i].UsageIndex)
10819  {
10820  normal_declaration = &declaration[i];
10821  break;
10822  }
10823  }
10824 
10825  if (!normal_declaration)
10826  {
10827  ok_(__FILE__, line)(0, "%s: Mesh has no normals\n", test_name);
10828  return;
10829  }
10830 
10831  if (normal_declaration->Type != D3DDECLTYPE_FLOAT3 && normal_declaration->Type != D3DDECLTYPE_FLOAT4)
10832  {
10833  ok_(__FILE__, line)(0, "%s: Mesh has invalid normals type\n", test_name);
10834  return;
10835  }
10836 
10837  num_vertices = mesh->lpVtbl->GetNumVertices(mesh);
10838  vertex_stride = mesh->lpVtbl->GetNumBytesPerVertex(mesh);
10839 
10840  ok_(__FILE__, line)(num_vertices == num_normals, "%s: Expected %u vertices, got %u\n", test_name,
10841  num_normals, num_vertices);
10842 
10843  if (FAILED(mesh->lpVtbl->LockVertexBuffer(mesh, 0, (void **)&vertices)))
10844  {
10845  ok_(__FILE__, line)(0, "%s: Failed to compare normals\n", test_name);
10846  return;
10847  }
10848 
10849  vertices += normal_declaration->Offset;
10850 
10851  for (i = 0; i < min(num_vertices, num_normals); i++, vertices += vertex_stride)
10852  {
10853  if (normal_declaration->Type == D3DDECLTYPE_FLOAT3)
10854  {
10855  const D3DXVECTOR3 *n = (D3DXVECTOR3 *)vertices;
10856  ok_(__FILE__, line)(compare_vec3(*n, normals[i]),
10857  "%s: normal %2u, expected (%f, %f, %f), got (%f, %f, %f)\n",
10858  test_name, i, normals[i].x, normals[i].y, normals[i].z, n->x, n->y, n->z);
10859  }
10860  else
10861  {
10862  const D3DXVECTOR4 *n = (D3DXVECTOR4 *)vertices;
10863  const D3DXVECTOR4 normal = {normals[i].x, normals[i].y, normals[i].z, 1.0f};
10864  ok_(__FILE__, line)(compare_vec4(*n, normal),
10865  "%s: normal %2u, expected (%f, %f, %f, %f), got (%f, %f, %f, %f)\n",
10866  test_name, i, normals[i].x, normals[i].y, normals[i].z, 1.0f,
10867  n->x, n->y, n->z, n->w);
10868  }
10869  }
10870 
10871  mesh->lpVtbl->UnlockVertexBuffer(mesh);
10872 }
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:382
GLdouble n
Definition: glext.h:7729
Definition: mesh.c:197
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
smooth NULL
Definition: ftsmooth.c:416
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
#define min(a, b)
Definition: monoChain.cc:55
#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 4076 of file mesh.c.

4078 {
4079  HRESULT hr;
4080  DWORD number_of_vertices, number_of_faces;
4081  IDirect3DVertexBuffer9 *vertex_buffer = NULL;
4082  IDirect3DIndexBuffer9 *index_buffer = NULL;
4083  D3DVERTEXBUFFER_DESC vertex_buffer_description;
4084  D3DINDEXBUFFER_DESC index_buffer_description;
4085  struct vertex *vertices = NULL;
4086  face *faces = NULL;
4087  int expected, i;
4088  int vtx_idx1, face_idx1, vtx_idx2, face_idx2;
4089 
4090  number_of_vertices = d3dxmesh->lpVtbl->GetNumVertices(d3dxmesh);
4091  number_of_faces = d3dxmesh->lpVtbl->GetNumFaces(d3dxmesh);
4092 
4093  hr = d3dxmesh->lpVtbl->GetVertexBuffer(d3dxmesh, &vertex_buffer);
4094  ok(hr == D3D_OK, "Test %s, unexpected hr %#x.\n", name, hr);
4095  hr = IDirect3DVertexBuffer9_GetDesc(vertex_buffer, &vertex_buffer_description);
4096  ok(hr == D3D_OK, "Test %s, unexpected hr %#x.\n", name, hr);
4097  ok(vertex_buffer_description.Format == D3DFMT_VERTEXDATA, "Test %s, unexpected format %u.\n",
4098  name, vertex_buffer_description.Format);
4099  ok(vertex_buffer_description.Type == D3DRTYPE_VERTEXBUFFER, "Test %s, unexpected resource type %u.\n",
4100  name, vertex_buffer_description.Type);
4101  ok(!vertex_buffer_description.Usage, "Test %s, unexpected usage %#x.\n", name, vertex_buffer_description.Usage);
4102  ok(vertex_buffer_description.Pool == D3DPOOL_MANAGED, "Test %s, unexpected pool %u.\n",
4103  name, vertex_buffer_description.Pool);
4104  ok(vertex_buffer_description.FVF == mesh->fvf, "Test %s, unexpected FVF %#x (expected %#x).\n",
4105  name, vertex_buffer_description.FVF, mesh->fvf);
4106  if (!mesh->fvf)
4107  expected = number_of_vertices * mesh->vertex_size;
4108  else
4109  expected = number_of_vertices * D3DXGetFVFVertexSize(mesh->fvf);
4110  ok(vertex_buffer_description.Size == expected, "Test %s, unexpected size %u (expected %u).\n",
4111  name, vertex_buffer_description.Size, expected);
4112 
4113  hr = d3dxmesh->lpVtbl->GetIndexBuffer(d3dxmesh, &index_buffer);
4114  ok(hr == D3D_OK, "Test %s, unexpected hr %#x.\n", name, hr);
4115  hr = IDirect3DIndexBuffer9_GetDesc(index_buffer, &index_buffer_description);
4116  ok(hr == D3D_OK, "Test %s, unexpected hr %#x.\n", name, hr);
4117  ok(index_buffer_description.Format == D3DFMT_INDEX16, "Test %s, unexpected format %u.\n",
4118  name, index_buffer_description.Format);
4119  ok(index_buffer_description.Type == D3DRTYPE_INDEXBUFFER, "Test %s, unexpected resource type %u.\n",
4120  name, index_buffer_description.Type);
4121  ok(!index_buffer_description.Usage, "Test %s, unexpected usage %#x.\n",
4122  name, index_buffer_description.Usage);
4123  ok(index_buffer_description.Pool == D3DPOOL_MANAGED, "Test %s, unexpected pool %u.\n",
4124  name, index_buffer_description.Pool);
4125  expected = number_of_faces * sizeof(WORD) * 3;
4126  ok(index_buffer_description.Size == expected, "Test %s, unexpected size %u.\n",
4127  name, index_buffer_description.Size);
4128 
4129  hr = IDirect3DVertexBuffer9_Lock(vertex_buffer, 0, number_of_vertices * sizeof(D3DXVECTOR3) * 2,
4130  (void **)&vertices, D3DLOCK_DISCARD);
4131  ok(hr == D3D_OK, "Test %s, unexpected hr %#x.\n", name, hr);
4132  hr = IDirect3DIndexBuffer9_Lock(index_buffer, 0, number_of_faces * sizeof(WORD) * 3,
4133  (void **)&faces, D3DLOCK_DISCARD);
4134  ok(hr == D3D_OK, "Test %s, unexpected hr %#x.\n", name, hr);
4135  face_idx1 = 0;
4136  vtx_idx2 = 0;
4137  face_idx2 = 0;
4138  vtx_idx1 = 0;
4139  for (i = 0; i < textlen; i++)
4140  {
4141  int nb_outline_vertices1, nb_outline_faces1;
4142  int nb_outline_vertices2, nb_outline_faces2;
4143  int nb_back_vertices, nb_back_faces;
4144  int first_vtx1, first_vtx2;
4145  int first_face1, first_face2;
4146  int j;
4147 
4148  first_vtx1 = vtx_idx1;
4149  first_vtx2 = vtx_idx2;
4150  /* Glyphs without outlines do not generate any vertices. */
4151  if (glyphs[i].outlines.count > 0)
4152  {
4153  for (; vtx_idx1 < number_of_vertices; vtx_idx1++)
4154  {
4155  if (vertices[vtx_idx1].normal.z != 0)
4156  break;
4157  }
4158 
4159  for (; vtx_idx2 < mesh->number_of_vertices; vtx_idx2++)
4160  {
4161  if (mesh->vertices[vtx_idx2].normal.z != 0)
4162  break;
4163  }
4164  }
4165  nb_outline_vertices1 = vtx_idx1 - first_vtx1;
4166  nb_outline_vertices2 = vtx_idx2 - first_vtx2;
4167  ok(nb_outline_vertices1 == nb_outline_vertices2,
4168  "Test %s, glyph %d, outline vertex count result %d, expected %d\n", name, i,
4169  nb_outline_vertices1, nb_outline_vertices2);
4170 
4171  for (j = 0; j < min(nb_outline_vertices1, nb_outline_vertices2); j++)
4172  {
4173  vtx_idx1 = first_vtx1 + j;
4174  vtx_idx2 = first_vtx2 + j;
4175  ok(compare_vec3(vertices[vtx_idx1].position, mesh->vertices[vtx_idx2].position),
4176  "Test %s, glyph %d, vertex position %d, result (%g, %g, %g), expected (%g, %g, %g)\n", name, i, vtx_idx1,
4177  vertices[vtx_idx1].position.x, vertices[vtx_idx1].position.y, vertices[vtx_idx1].position.z,
4178  mesh->vertices[vtx_idx2].position.x, mesh->vertices[vtx_idx2].position.y, mesh->vertices[vtx_idx2].position.z);
4179  ok(compare_vec3(vertices[vtx_idx1].normal, mesh->vertices[first_vtx2 + j].normal),
4180  "Test %s, glyph %d, vertex normal %d, result (%g, %g, %g), expected (%g, %g, %g)\n", name, i, vtx_idx1,
4181  vertices[vtx_idx1].normal.x, vertices[vtx_idx1].normal.y, vertices[vtx_idx1].normal.z,
4182  mesh->vertices[vtx_idx2].normal.x, mesh->vertices[vtx_idx2].normal.y, mesh->vertices[vtx_idx2].normal.z);
4183  }
4184  vtx_idx1 = first_vtx1 + nb_outline_vertices1;
4185  vtx_idx2 = first_vtx2 + nb_outline_vertices2;
4186 
4187  first_face1 = face_idx1;
4188  first_face2 = face_idx2;
4189  for (; face_idx1 < number_of_faces; face_idx1++)
4190  {
4191  if (faces[face_idx1][0] >= vtx_idx1 ||
4192  faces[face_idx1][1] >= vtx_idx1 ||
4193  faces[face_idx1][2] >= vtx_idx1)
4194  break;
4195  }
4196  for (; face_idx2 < mesh->number_of_faces; face_idx2++)
4197  {
4198  if (mesh->faces[face_idx2][0] >= vtx_idx2 ||
4199  mesh->faces[face_idx2][1] >= vtx_idx2 ||
4200  mesh->faces[face_idx2][2] >= vtx_idx2)
4201  break;
4202  }
4203  nb_outline_faces1 = face_idx1 - first_face1;
4204  nb_outline_faces2 = face_idx2 - first_face2;
4205  ok(nb_outline_faces1 == nb_outline_faces2,
4206  "Test %s, glyph %d, outline face count result %d, expected %d\n", name, i,
4207  nb_outline_faces1, nb_outline_faces2);
4208 
4209  for (j = 0; j < min(nb_outline_faces1, nb_outline_faces2); j++)
4210  {
4211  face_idx1 = first_face1 + j;
4212  face_idx2 = first_face2 + j;
4213  ok(faces[face_idx1][0] - first_vtx1 == mesh->faces[face_idx2][0] - first_vtx2 &&
4214  faces[face_idx1][1] - first_vtx1 == mesh->faces[face_idx2][1] - first_vtx2 &&
4215  faces[face_idx1][2] - first_vtx1 == mesh->faces[face_idx2][2] - first_vtx2,
4216  "Test %s, glyph %d, face %d, result (%d, %d, %d), expected (%d, %d, %d)\n", name, i, face_idx1,
4217  faces[face_idx1][0], faces[face_idx1][1], faces[face_idx1][2],
4218  mesh->faces[face_idx2][0] - first_vtx2 + first_vtx1,
4219  mesh->faces[face_idx2][1] - first_vtx2 + first_vtx1,
4220  mesh->faces[face_idx2][2] - first_vtx2 + first_vtx1);
4221  }
4222  face_idx1 = first_face1 + nb_outline_faces1;
4223  face_idx2 = first_face2 + nb_outline_faces2;
4224 
4225  /* partial test on back vertices and faces */
4226  first_vtx1 = vtx_idx1;
4227  for (; vtx_idx1 < number_of_vertices; vtx_idx1++) {
4228  struct vertex vtx;
4229 
4230  if (vertices[vtx_idx1].normal.z != 1.0f)
4231  break;
4232 
4233  vtx.position.z = 0.0f;
4234  vtx.normal.x = 0.0f;
4235  vtx.normal.y = 0.0f;
4236  vtx.normal.z = 1.0f;
4237  ok(compare(vertices[vtx_idx1].position.z, vtx.position.z),
4238  "Test %s, glyph %d, vertex position.z %d, result %g, expected %g\n", name, i, vtx_idx1,
4239  vertices[vtx_idx1].position.z, vtx.position.z);
4240  ok(compare_vec3(vertices[vtx_idx1].normal, vtx.normal),
4241  "Test %s, glyph %d, vertex normal %d, result (%g, %g, %g), expected (%g, %g, %g)\n", name, i, vtx_idx1,
4242  vertices[vtx_idx1].normal.x, vertices[vtx_idx1].normal.y, vertices[vtx_idx1].normal.z,
4243  vtx.normal.x, vtx.normal.y, vtx.normal.z);
4244  }
4245  nb_back_vertices = vtx_idx1 - first_vtx1;
4246  first_face1 = face_idx1;
4247  for (; face_idx1 < number_of_faces; face_idx1++)
4248  {
4249  const D3DXVECTOR3 *vtx1, *vtx2, *vtx3;
4251  D3DXVECTOR3 v1 = {0, 0, 0};
4252  D3DXVECTOR3 v2 = {0, 0, 0};
4253  D3DXVECTOR3 forward = {0.0f, 0.0f, 1.0f};
4254 
4255  if (faces[face_idx1][0] >= vtx_idx1 ||
4256  faces[face_idx1][1] >= vtx_idx1 ||
4257  faces[face_idx1][2] >= vtx_idx1)
4258  break;
4259 
4260  vtx1 = &vertices[faces[face_idx1][0]].position;
4261  vtx2 = &vertices[faces[face_idx1][1]].position;
4262  vtx3 = &vertices[faces[face_idx1][2]].position;
4263 
4264  D3DXVec3Subtract(&v1, vtx2, vtx1);
4265  D3DXVec3Subtract(&v2, vtx3, vtx2);
4266  D3DXVec3Cross(&normal, &v1, &v2);
4268  ok(!D3DXVec3Length(&normal) || compare_vec3(normal, forward),
4269  "Test %s, glyph %d, face %d normal, result (%g, %g, %g), expected (%g, %g, %g)\n", name, i, face_idx1,
4270  normal.x, normal.y, normal.z, forward.x, forward.y, forward.z);
4271  }
4272  nb_back_faces = face_idx1 - first_face1;
4273 
4274  /* compare front and back faces & vertices */
4275  if (extrusion == 0.0f) {
4276  /* Oddly there are only back faces in this case */
4277  nb_back_vertices /= 2;
4278  nb_back_faces /= 2;
4279  face_idx1 -= nb_back_faces;
4280  vtx_idx1 -= nb_back_vertices;
4281  }
4282  for (j = 0; j < nb_back_vertices; j++)
4283  {
4284  struct vertex vtx = vertices[first_vtx1];
4285  vtx.position.z = -extrusion;
4286  vtx.normal.x = 0.0f;
4287  vtx.normal.y = 0.0f;
4288  vtx.normal.z = extrusion == 0.0f ? 1.0f : -1.0f;
4289  ok(compare_vec3(vertices[vtx_idx1].position, vtx.position),
4290  "Test %s, glyph %d, vertex position %d, result (%g, %g, %g), expected (%g, %g, %g)\n", name, i, vtx_idx1,
4291  vertices[vtx_idx1].position.x, vertices[vtx_idx1].position.y, vertices[vtx_idx1].position.z,
4292  vtx.position.x, vtx.position.y, vtx.position.z);
4293  ok(compare_vec3(vertices[vtx_idx1].normal, vtx.normal),
4294  "Test %s, glyph %d, vertex normal %d, result (%g, %g, %g), expected (%g, %g, %g)\n", name, i, vtx_idx1,
4295  vertices[vtx_idx1].normal.x, vertices[vtx_idx1].normal.y, vertices[vtx_idx1].normal.z,
4296  vtx.normal.x, vtx.normal.y, vtx.normal.z);
4297  vtx_idx1++;
4298  first_vtx1++;
4299  }
4300  for (j = 0; j < nb_back_faces; j++)
4301  {
4302  int f1, f2;
4303  if (extrusion == 0.0f) {
4304  f1 = 1;
4305  f2 = 2;
4306  } else {
4307  f1 = 2;
4308  f2 = 1;
4309  }
4310  ok(faces[face_idx1][0] == faces[first_face1][0] + nb_back_vertices &&
4311  faces[face_idx1][1] == faces[first_face1][f1] + nb_back_vertices &&
4312  faces[face_idx1][2] == faces[first_face1][f2] + nb_back_vertices,
4313  "Test %s, glyph %d, face %d, result (%d, %d, %d), expected (%d, %d, %d)\n", name, i, face_idx1,
4314  faces[face_idx1][0], faces[face_idx1][1], faces[face_idx1][2],
4315  faces[first_face1][0] - nb_back_faces,
4316  faces[first_face1][f1] - nb_back_faces,
4317  faces[first_face1][f2] - nb_back_faces);
4318  first_face1++;
4319  face_idx1++;
4320  }
4321 
4322  /* skip to the outline for the next glyph */
4323  for (; vtx_idx2 < mesh->number_of_vertices; vtx_idx2++) {
4324  if (mesh->vertices[vtx_idx2].normal.z == 0)
4325  break;
4326  }
4327  for (; face_idx2 < mesh->number_of_faces; face_idx2++)
4328  {
4329  if (mesh->faces[face_idx2][0] >= vtx_idx2 ||
4330  mesh->faces[face_idx2][1] >= vtx_idx2 ||
4331  mesh->faces[face_idx2][2] >= vtx_idx2) break;
4332  }
4333  }
4334 
4335  IDirect3DIndexBuffer9_Unlock(index_buffer);
4337  IDirect3DIndexBuffer9_Release(index_buffer);
4339 }
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:2290
D3DXVECTOR3 normal
Definition: mesh.c:4560
D3DXVECTOR3 position
Definition: mesh.c:4559
UINT vertex_size
Definition: mesh.c:206
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_GetDesc(p, a)
Definition: d3d9.h:777
DWORD number_of_faces
Definition: mesh.c:202
smooth NULL
Definition: ftsmooth.c:416
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:78
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
#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
Definition: name.c:38
#define IDirect3DIndexBuffer9_Unlock(p)
Definition: d3d9.h:776
D3DXVECTOR3 *WINAPI D3DXVec3Normalize(D3DXVECTOR3 *pout, const D3DXVECTOR3 *pv)
Definition: math.c:1801
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 2673 of file mesh.c.

2674 {
2675  unsigned int i, face;
2676  static const D3DXVECTOR3 unit_box[] =
2677  {
2678  {-1.0f, -1.0f, -1.0f}, {-1.0f, -1.0f, 1.0f}, {-1.0f, 1.0f, 1.0f}, {-1.0f, 1.0f, -1.0f},
2679  {-1.0f, 1.0f, -1.0f}, {-1.0f, 1.0f, 1.0f}, { 1.0f, 1.0f, 1.0f}, { 1.0f, 1.0f, -1.0f},
2680  { 1.0f, 1.0f, -1.0f}, { 1.0f, 1.0f, 1.0f}, { 1.0f, -1.0f, 1.0f}, { 1.0f, -1.0f, -1.0f},
2681  {-1.0f, -1.0f, 1.0f}, {-1.0f, -1.0f, -1.0f}, { 1.0f, -1.0f, -1.0f}, { 1.0f, -1.0f, 1.0f},
2682  {-1.0f, -1.0f, 1.0f}, { 1.0f, -1.0f, 1.0f}, { 1.0f, 1.0f, 1.0f}, {-1.0f, 1.0f, 1.0f},
2683  {-1.0f, -1.0f, -1.0f}, {-1.0f, 1.0f, -1.0f}, { 1.0f, 1.0f, -1.0f}, { 1.0f, -1.0f, -1.0f}
2684  };
2685  static const D3DXVECTOR3 normals[] =
2686  {
2687  {-1.0f, 0.0f, 0.0f}, { 0.0f, 1.0f, 0.0f}, { 1.0f, 0.0f, 0.0f},
2688  { 0.0f, -1.0f, 0.0f}, { 0.0f, 0.0f, 1.0f}, { 0.0f, 0.0f, -1.0f}
2689  };
2690 
2691  if (!new_mesh(mesh, 24, 12))
2692  {
2693  return FALSE;
2694  }
2695 
2696  width /= 2.0f;
2697  height /= 2.0f;
2698  depth /= 2.0f;
2699 
2700  for (i = 0; i < 24; i++)
2701  {
2702  mesh->vertices[i].position.x = width * unit_box[i].x;
2703  mesh->vertices[i].position.y = height * unit_box[i].y;
2704  mesh->vertices[i].position.z = depth * unit_box[i].z;
2705  mesh->vertices[i].normal.x = normals[i / 4].x;
2706  mesh->vertices[i].normal.y = normals[i / 4].y;
2707  mesh->vertices[i].normal.z = normals[i / 4].z;
2708  }
2709 
2710  face = 0;
2711  for (i = 0; i < 12; i++)
2712  {
2713  mesh->faces[i][0] = face++;
2714  mesh->faces[i][1] = face++;
2715  mesh->faces[i][2] = (i % 2) ? face - 4 : face;
2716  }
2717 
2718  return TRUE;
2719 }
GLint GLint GLsizei width
Definition: gl.h:1546
Definition: mesh.c:197
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
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
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
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 3203 of file mesh.c.

3204 {
3205  float theta_step, theta_start;
3206  struct sincos_table theta;
3207  FLOAT delta_radius, radius, radius_step;
3208  FLOAT z, z_step, z_normal;
3209  DWORD number_of_vertices, number_of_faces;
3210  DWORD vertex, face;
3211  int slice, stack;
3212 
3213  /* theta = angle on xy plane wrt x axis */
3214  theta_step = -2 * D3DX_PI / slices;
3215  theta_start = D3DX_PI / 2;
3216 
3217  if (!compute_sincos_table(&theta, theta_start, theta_step, slices))
3218  {
3219  return FALSE;
3220  }
3221 
3222  number_of_vertices = 2 + (slices * (3 + stacks));
3223  number_of_faces = 2 * slices + stacks * (2 * slices);
3224 
3225  if (!new_mesh(mesh, number_of_vertices, number_of_faces))
3226  {
3227  free_sincos_table(&theta);
3228  return FALSE;
3229  }
3230 
3231  vertex = 0;
3232  face = 0;
3233 
3234  delta_radius = radius1 - radius2;
3235  radius = radius1;
3236  radius_step = delta_radius / stacks;
3237 
3238  z = -length / 2;
3239  z_step = length / stacks;
3240  z_normal = delta_radius / length;
3241  if (isnan(z_normal))
3242  {
3243  z_normal = 0.0f;
3244  }
3245 
3246  mesh->vertices[vertex].normal.x = 0.0f;
3247  mesh->vertices[vertex].normal.y = 0.0f;
3248  mesh->vertices[vertex].normal.z = -1.0f;
3249  mesh->vertices[vertex].position.x = 0.0f;
3250  mesh->vertices[vertex].position.y = 0.0f;
3251  mesh->vertices[vertex++].position.z = z;
3252 
3253  for (slice = 0; slice < slices; slice++, vertex++)
3254  {
3255  mesh->vertices[vertex].normal.x = 0.0f;
3256  mesh->vertices[vertex].normal.y = 0.0f;
3257  mesh->vertices[vertex].normal.z = -1.0f;
3258  mesh->vertices[vertex].position.x = radius * theta.cos[slice];
3259  mesh->vertices[vertex].position.y = radius * theta.sin[slice];
3260  mesh->vertices[vertex].position.z = z;
3261 
3262  if (slice > 0)
3263  {
3264  mesh->faces[face][0] = 0;
3265  mesh->faces[face][1] = slice;
3266  mesh->faces[face++][2] = slice + 1;
3267  }
3268  }
3269 
3270  mesh->faces[face][0] = 0;
3271  mesh->faces[face][1] = slice;
3272  mesh->faces[face++][2] = 1;
3273 
3274  for (stack = 1; stack <= stacks+1; stack++)
3275  {
3276  for (slice = 0; slice < slices; slice++, vertex++)
3277  {
3278  mesh->vertices[vertex].normal.x = theta.cos[slice];
3279  mesh->vertices[vertex].normal.y = theta.sin[slice];
3280  mesh->vertices[vertex].normal.z = z_normal;
3281  D3DXVec3Normalize(&mesh->vertices[vertex].normal, &mesh->vertices[vertex].normal);
3282  mesh->vertices[vertex].position.x = radius * theta.cos[slice];
3283  mesh->vertices[vertex].position.y = radius * theta.sin[slice];
3284  mesh->vertices[vertex].position.z = z;
3285 
3286  if (stack > 1 && slice > 0)
3287  {
3288  mesh->faces[face][0] = vertex_index(slices, slice-1, stack-1);
3289  mesh->faces[face][1] = vertex_index(slices, slice-1, stack);
3290  mesh->faces[face++][2] = vertex_index(slices, slice, stack-1);
3291 
3292  mesh->faces[face][0] = vertex_index(slices, slice, stack-1);
3293  mesh->faces[face][1] = vertex_index(slices, slice-1, stack);
3294  mesh->faces[face++][2] = vertex_index(slices, slice, stack);
3295  }
3296  }
3297 
3298  if (stack > 1)
3299  {
3300  mesh->faces[face][0] = vertex_index(slices, slice-1, stack-1);
3301  mesh->faces[face][1] = vertex_index(slices, slice-1, stack);
3302  mesh->faces[face++][2] = vertex_index(slices, 0, stack-1);
3303 
3304  mesh->faces[face][0] = vertex_index(slices, 0, stack-1);
3305  mesh->faces[face][1] = vertex_index(slices, slice-1, stack);
3306  mesh->faces[face++][2] = vertex_index(slices, 0, stack);
3307  }
3308 
3309  if (stack < stacks + 1)
3310  {
3311  z += z_step;
3312  radius -= radius_step;
3313  }
3314  }
3315 
3316  for (slice = 0; slice < slices; slice++, vertex++)
3317  {
3318  mesh->vertices[vertex].normal.x = 0.0f;
3319  mesh->vertices[vertex].normal.y = 0.0f;
3320  mesh->vertices[vertex].normal.z = 1.0f;
3321  mesh->vertices[vertex].position.x = radius * theta.cos[slice];
3322  mesh->vertices[vertex].position.y = radius * theta.sin[slice];
3323  mesh->vertices[vertex].position.z = z;
3324 
3325  if (slice > 0)
3326  {
3327  mesh->faces[face][0] = vertex_index(slices, slice-1, stack);
3328  mesh->faces[face][1] = number_of_vertices - 1;
3329  mesh->faces[face++][2] = vertex_index(slices, slice, stack);
3330  }
3331  }
3332 
3333  mesh->vertices[vertex].position.x = 0.0f;
3334  mesh->vertices[vertex].position.y = 0.0f;
3335  mesh->vertices[vertex].position.z = z;
3336  mesh->vertices[vertex].normal.x = 0.0f;
3337  mesh->vertices[vertex].normal.y = 0.0f;
3338  mesh->vertices[vertex].normal.z = 1.0f;
3339 
3340  mesh->faces[face][0] = vertex_index(slices, slice-1, stack);
3341  mesh->faces[face][1] = number_of_vertices - 1;
3342  mesh->faces[face][2] = vertex_index(slices, 0, stack);
3343 
3344  free_sincos_table(&theta);
3345 
3346  return TRUE;
3347 }
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:2947
static BOOL new_mesh(struct mesh *mesh, DWORD number_of_vertices, DWORD number_of_faces)
Definition: mesh.c:215
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:2954
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
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:2982
int isnan(double x)
face * faces
Definition: mesh.c:203
float FLOAT
Definition: typedefs.h:68
#define D3DX_PI
Definition: d3dx9math.h:27
#define TRUE
Definition: mesh.c:42
D3DXVECTOR3 *WINAPI D3DXVec3Normalize(D3DXVECTOR3 *pout, const D3DXVECTOR3 *pv)
Definition: math.c:1801
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 10874 of file mesh.c.

10875 {
10876  return D3DXComputeNormals((ID3DXBaseMesh *)mesh, adjacency);
10877 }
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 10879 of file mesh.c.

10880 {
10883  adjacency, -1.01f, -0.01f, -1.01f, NULL, NULL);
10884 }
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
smooth NULL
Definition: ftsmooth.c:416
GLfloat f
Definition: glext.h:7540

Referenced by test_compute_normals().

◆ compute_polygon()

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

Definition at line 2807 of file mesh.c.

2808 {
2809  unsigned int i;
2810  float angle, scale;
2811 
2812  if (!new_mesh(mesh, sides + 1, sides))
2813  return FALSE;
2814 
2815  angle = D3DX_PI / sides;
2816  scale = 0.5f * length / sinf(angle);
2817  angle *= 2.0f;
2818 
2819  mesh->vertices[0].position.x = 0.0f;
2820  mesh->vertices[0].position.y = 0.0f;
2821  mesh->vertices[0].position.z = 0.0f;
2822  mesh->vertices[0].normal.x = 0.0f;
2823  mesh->vertices[0].normal.y = 0.0f;
2824  mesh->vertices[0].normal.z = 1.0f;
2825 
2826  for (i = 0; i < sides; ++i)
2827  {
2828  mesh->vertices[i + 1].position.x = cosf(angle * i) * scale;
2829  mesh->vertices[i + 1].position.y = sinf(angle * i) * scale;
2830  mesh->vertices[i + 1].position.z = 0.0f;
2831  mesh->vertices[i + 1].normal.x = 0.0f;
2832  mesh->vertices[i + 1].normal.y = 0.0f;
2833  mesh->vertices[i + 1].normal.z = 1.0f;
2834 
2835  mesh->faces[i][0] = 0;
2836  mesh->faces[i][1] = i + 1;
2837  mesh->faces[i][2] = i + 2;
2838  }
2839 
2840  mesh->faces[sides - 1][2] = 1;
2841 
2842  return TRUE;
2843 }
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
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
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
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 2954 of file mesh.c.

2955 {
2956  float angle;
2957  int i;
2958 
2959  sincos_table->sin = HeapAlloc(GetProcessHeap(), 0, n * sizeof(*sincos_table->sin));
2960  if (!sincos_table->sin)
2961  {
2962  return FALSE;
2963  }
2964  sincos_table->cos = HeapAlloc(GetProcessHeap(), 0, n * sizeof(*sincos_table->cos));
2965  if (!sincos_table->cos)
2966  {
2968  return FALSE;
2969  }
2970 
2971  angle = angle_start;
2972  for (i = 0; i < n; i++)
2973  {
2974  sincos_table->sin[i] = sin(angle);
2975  sincos_table->cos[i] = cos(angle);
2976  angle += angle_step;
2977  }
2978 
2979  return TRUE;
2980 }
GLdouble n
Definition: glext.h:7729
float * cos
Definition: mesh.c:4752
GLfloat angle
Definition: glext.h:10853
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 cos(const complex< float > &)
float * sin
Definition: mesh.c:4751
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
_STLP_DECLSPEC complex< float > _STLP_CALL sin(const complex< float > &)
#define TRUE
Definition: mesh.c:42
#define HeapFree(x, y, z)
Definition: compat.h:403

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 2988 of file mesh.c.

2989 {
2990  float theta_step, theta_start;
2991  struct sincos_table theta;
2992  float phi_step, phi_start;
2993  struct sincos_table phi;
2994  DWORD number_of_vertices, number_of_faces;
2995  DWORD vertex, face;
2996  int slice, stack;
2997 
2998  /* theta = angle on xy plane wrt x axis */
2999  theta_step = D3DX_PI / stacks;
3000  theta_start = theta_step;
3001 
3002  /* phi = angle on xz plane wrt z axis */
3003  phi_step = -2 * D3DX_PI / slices;
3004  phi_start = D3DX_PI / 2;
3005 
3006  if (!compute_sincos_table(&theta, theta_start, theta_step, stacks))
3007  {
3008  return FALSE;
3009  }
3010  if (!compute_sincos_table(&phi, phi_start, phi_step, slices))
3011  {
3012  free_sincos_table(&theta);
3013  return FALSE;
3014  }
3015 
3016  number_of_vertices = 2 + slices * (stacks-1);
3017  number_of_faces = 2 * slices + (stacks - 2) * (2 * slices);
3018 
3019  if (!new_mesh(mesh, number_of_vertices, number_of_faces))
3020  {
3021  free_sincos_table(&phi);
3022  free_sincos_table(&theta);
3023  return FALSE;
3024  }
3025 
3026  vertex = 0;
3027  face = 0;
3028 
3029  mesh->vertices[vertex].normal.x = 0.0f;
3030  mesh->vertices[vertex].normal.y = 0.0f;
3031  mesh->vertices[vertex].normal.z = 1.0f;
3032  mesh->vertices[vertex].position.x = 0.0f;
3033  mesh->vertices[vertex].position.y = 0.0f;
3034  mesh->vertices[vertex].position.z = radius;
3035  vertex++;
3036 
3037  for (stack = 0; stack < stacks - 1; stack++)
3038  {
3039  for (slice = 0; slice < slices; slice++)
3040  {
3041  mesh->vertices[vertex].normal.x = theta.sin[stack] * phi.cos[slice];
3042  mesh->vertices[vertex].normal.y = theta.sin[stack] * phi.sin[slice];
3043  mesh->vertices[vertex].normal.z = theta.cos[stack];
3044  mesh->vertices[vertex].position.x = radius * theta.sin[stack] * phi.cos[slice];
3045  mesh->vertices[vertex].position.y = radius * theta.sin[stack] * phi.sin[slice];
3046  mesh->vertices[vertex].position.z = radius * theta.cos[stack];
3047  vertex++;
3048 
3049  if (slice > 0)
3050  {
3051  if (stack == 0)
3052  {
3053  /* top stack is triangle fan */
3054  mesh->faces[face][0] = 0;
3055  mesh->faces[face][1] = slice + 1;
3056  mesh->faces[face][2] = slice;
3057  face++;
3058  }
3059  else
3060  {
3061  /* stacks in between top and bottom are quad strips */
3062  mesh->faces[face][0] = vertex_index(slices, slice-1, stack-1);
3063  mesh->faces[face][1] = vertex_index(slices, slice, stack-1);
3064  mesh->faces[face][2] = vertex_index(slices, slice-1, stack);
3065  face++;
3066 
3067  mesh->faces[face][0] = vertex_index(slices, slice, stack-1);
3068  mesh->faces[face][1] = vertex_index(slices, slice, stack);
3069  mesh->faces[face][2] = vertex_index(slices, slice-1, stack);
3070  face++;
3071  }
3072  }
3073  }
3074 
3075  if (stack == 0)
3076  {
3077  mesh->faces[face][0] = 0;
3078  mesh->faces[face][1] = 1;
3079  mesh->faces[face][2] = slice;
3080  face++;
3081  }
3082  else
3083  {
3084  mesh->faces[face][0] = vertex_index(slices, slice-1, stack-1);
3085  mesh->faces[face][1] = vertex_index(slices, 0, stack-1);
3086  mesh->faces[face][2] = vertex_index(slices, slice-1, stack);
3087  face++;
3088 
3089  mesh->faces[face][0] = vertex_index(slices, 0, stack-1);
3090  mesh->faces[face][1] = vertex_index(slices, 0, stack);
3091  mesh->faces[face][2] = vertex_index(slices, slice-1, stack);
3092  face++;
3093  }
3094  }
3095 
3096  mesh->vertices[vertex].position.x = 0.0f;
3097  mesh->vertices[vertex].position.y = 0.0f;
3098  mesh->vertices[vertex].position.z = -radius;
3099  mesh->vertices[vertex].normal.x = 0.0f;
3100  mesh->vertices[vertex].normal.y = 0.0f;
3101  mesh->vertices[vertex].normal.z = -1.0f;
3102 
3103  /* bottom stack is triangle fan */
3104  for (slice = 1; slice < slices; slice++)
3105  {
3106  mesh->faces[face][0] = vertex_index(slices, slice-1, stack-1);
3107  mesh->faces[face][1] = vertex_index(slices, slice, stack-1);
3108  mesh->faces[face][2] = vertex;
3109  face++;
3110  }
3111 
3112  mesh->faces[face][0] = vertex_index(slices, slice-1, stack-1);
3113  mesh->faces[face][1] = vertex_index(slices, 0, stack-1);
3114  mesh->faces[face][2] = vertex;
3115 
3116  free_sincos_table(&phi);
3117  free_sincos_table(&theta);
3118 
3119  return TRUE;
3120 }
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:2947
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:2954
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:2982
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 3932 of file mesh.c.

3934 {
3935  DWORD nb_vertices, nb_faces;
3936  DWORD nb_corners, nb_outline_points;
3937  int textlen = 0;
3938  int i;
3939  struct vertex *vertex_ptr;
3940  face *face_ptr;
3941 
3942  textlen = strlen(text);
3943 
3944  /* corner points need an extra vertex for the different side faces normals */
3945  nb_corners = 0;
3946  nb_outline_points = 0;
3947  for (i = 0; i < textlen; i++)
3948  {
3949  int j;
3950  for (j = 0; j < glyphs[i].outlines.count; j++)
3951  {
3952  int k;
3953  struct outline *outline = &glyphs[i].outlines.items[j];
3954  nb_outline_points += outline->count;
3955  nb_corners++; /* first outline point always repeated as a corner */
3956  for (k = 1; k < outline->count; k++)
3957  if (outline->items[k].corner)
3958  nb_corners++;
3959  }
3960  }
3961 
3962  nb_vertices = (nb_outline_points + nb_corners) * 2 + textlen;
3963  nb_faces = nb_outline_points * 2;
3964 
3965  ok(new_mesh(mesh, nb_vertices, nb_faces), "Failed to create reference text mesh.\n");
3966 
3967  /* convert 2D vertices and faces into 3D mesh */
3968  vertex_ptr = mesh->vertices;
3969  face_ptr = mesh->faces;
3970  for (i = 0; i < textlen; i++)
3971  {
3972  int j;
3973 
3974  /* side vertices and faces */
3975  for (j = 0; j < glyphs[i].outlines.count; j++)
3976  {
3977  struct vertex *outline_vertices = vertex_ptr;
3978  struct outline *outline = &glyphs[i].outlines.items[j];
3979  int k;
3980  struct point2d *prevpt = &outline->items[outline->count - 1];
3981  struct point2d *pt = &outline->items[0];
3982 
3983  for (k = 1; k <= outline->count; k++)
3984  {
3985  struct vertex vtx;
3986  struct point2d *nextpt = &outline->items[k % outline->count];
3987  WORD vtx_idx = vertex_ptr - mesh->vertices;
3988  D3DXVECTOR2 vec;
3989 
3990  if (pt->corner == POINTTYPE_CURVE_START)
3991  D3DXVec2Subtract(&vec, &pt->pos, &prevpt->pos);
3992  else if (pt->corner)
3993  D3DXVec2Subtract(&vec, &nextpt->pos, &pt->pos);
3994  else
3995  D3DXVec2Subtract(&vec, &nextpt->pos, &prevpt->pos);
3997  vtx.normal.x = -vec.y;
3998  vtx.normal.y = vec.x;
3999  vtx.normal.z = 0;
4000 
4001  vtx.position.x = pt->pos.x + glyphs[i].offset_x;
4002  vtx.position.y = pt->pos.y;
4003  vtx.position.z = 0;
4004  *vertex_ptr++ = vtx;
4005 
4006  vtx.position.z = -extrusion;
4007  *vertex_ptr++ = vtx;
4008 
4009  vtx.position.x = nextpt->pos.x + glyphs[i].offset_x;
4010  vtx.position.y = nextpt->pos.y;
4011  if (pt->corner && nextpt->corner && nextpt->corner != POINTTYPE_CURVE_END) {
4012  vtx.position.z = -extrusion;
4013  *vertex_ptr++ = vtx;
4014  vtx.position.z = 0;
4015  *vertex_ptr++ = vtx;
4016 
4017  (*face_ptr)[0] = vtx_idx;
4018  (*face_ptr)[1] = vtx_idx + 2;
4019  (*face_ptr)[2] = vtx_idx + 1;
4020  face_ptr++;
4021 
4022  (*face_ptr)[0] = vtx_idx;
4023  (*face_ptr)[1] = vtx_idx + 3;
4024  (*face_ptr)[2] = vtx_idx + 2;
4025  face_ptr++;
4026  } else {
4027  if (nextpt->corner) {
4028  if (nextpt->corner == POINTTYPE_CURVE_END) {
4029  struct point2d *nextpt2 = &outline->items[(k + 1) % outline->count];
4030  D3DXVec2Subtract(&vec, &nextpt2->pos, &nextpt->pos);
4031  } else {
4032  D3DXVec2Subtract(&vec, &nextpt->pos, &pt->pos);
4033  }
4035  vtx.normal.x = -vec.y;
4036  vtx.normal.y = vec.x;
4037 
4038  vtx.position.z = 0;
4039  *vertex_ptr++ = vtx;
4040  vtx.position.z = -extrusion;
4041  *vertex_ptr++ = vtx;
4042  }
4043 
4044  (*face_ptr)[0] = vtx_idx;
4045  (*face_ptr)[1] = vtx_idx + 3;
4046  (*face_ptr)[2] = vtx_idx + 1;
4047  face_ptr++;
4048 
4049  (*face_ptr)[0] = vtx_idx;
4050  (*face_ptr)[1] = vtx_idx + 2;
4051  (*face_ptr)[2] = vtx_idx + 3;
4052  face_ptr++;
4053  }
4054 
4055  prevpt = pt;
4056  pt = nextpt;
4057  }
4058  if (!pt->corner) {
4059  *vertex_ptr++ = *outline_vertices++;
4060  *vertex_ptr++ = *outline_vertices++;
4061  }
4062  }
4063 
4064  /* FIXME: compute expected faces */
4065  /* Add placeholder to separate glyph outlines */
4066  vertex_ptr->position.x = 0;
4067  vertex_ptr->position.y = 0;
4068  vertex_ptr->position.z = 0;
4069  vertex_ptr->normal.x = 0;
4070  vertex_ptr->normal.y = 0;
4071  vertex_ptr->normal.z = 1;
4072  vertex_ptr++;
4073  }
4074 }
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
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
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:1655
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
#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 3454 of file mesh.c.

3455 {
3456  float phi, phi_step, sin_phi, cos_phi;
3457  float theta, theta_step, sin_theta, cos_theta;
3458  unsigned int numvert, numfaces, i, j;
3459 
3460  numvert = sides * rings;
3461  numfaces = numvert * 2;
3462 
3463  if (!new_mesh(mesh, numvert, numfaces))
3464  return FALSE;
3465 
3466  phi_step = D3DX_PI / sides * 2.0f;
3467  theta_step = D3DX_PI / rings * -2.0f;
3468 
3469  theta = 0.0f;
3470 
3471  for (i = 0; i < rings; ++i)
3472  {
3473  phi = 0.0f;
3474 
3475  cos_theta = cosf(theta);
3476  sin_theta = sinf(theta);
3477 
3478  for (j = 0; j < sides; ++j)
3479  {
3480  sin_phi = sinf(phi);
3481  cos_phi = cosf(phi);
3482 
3483  mesh->vertices[i * sides + j].position.x = (innerradius * cos_phi + outerradius) * cos_theta;
3484  mesh->vertices[i * sides + j].position.y = (innerradius * cos_phi + outerradius) * sin_theta;
3485  mesh->vertices[i * sides + j].position.z = innerradius * sin_phi;
3486  mesh->vertices[i * sides + j].normal.x = cos_phi * cos_theta;
3487  mesh->vertices[i * sides + j].normal.y = cos_phi * sin_theta;
3488  mesh->vertices[i * sides + j].normal.z = sin_phi;
3489 
3490  phi += phi_step;
3491  }
3492 
3493  theta += theta_step;
3494  }
3495 
3496  for (i = 0; i < numfaces - sides * 2; ++i)
3497  {
3498  mesh->faces[i][0] = i % 2 ? i / 2 + sides : i / 2;
3499  mesh->faces[i][1] = (i / 2 + 1) % sides ? i / 2 + 1 : i / 2 + 1 - sides;
3500  mesh->faces[i][2] = (i + 1) % (sides * 2) ? (i + 1) / 2 + sides : (i + 1) / 2;
3501  }
3502 
3503  for (j = 0; i < numfaces; ++i, ++j)
3504  {
3505  mesh->faces[i][0] = i % 2 ? j / 2 : i / 2;
3506  mesh->faces[i][1] = (i / 2 + 1) % sides ? i / 2 + 1 : i / 2 + 1 - sides;
3507  mesh->faces[i][2] = i == numfaces - 1 ? 0 : (j + 1) / 2;
3508  }
3509 
3510  return TRUE;
3511 }
Definition: mesh.c:197
#define cosf
Definition: cosf.c:6
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
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
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 3673 of file mesh.c.

3674 {
3676  while (count--) {
3677  D3DXVECTOR2 *pt_flt = (D3DXVECTOR2*)pt;
3678  pt_flt->x = (pt->x.value + pt->x.fract / (float)0x10000) / emsquare;
3679  pt_flt->y = (pt->y.value + pt->y.fract / (float)0x10000) / emsquare;
3680  pt++;
3681  }
3682  return ret;
3683 }
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 3770 of file mesh.c.

3772 {
3773  const float cos_45 = cos(D3DXToRadian(45.0f));
3774  const float cos_90 = cos(D3DXToRadian(90.0f));
3775  TTPOLYGONHEADER *header = (TTPOLYGONHEADER *)raw_outline;
3776 
3777  while ((char *)header < (char *)raw_outline + datasize)
3778  {
3779  TTPOLYCURVE *curve = (TTPOLYCURVE *)(header + 1);
3780  struct point2d *lastpt, *pt;
3781  D3DXVECTOR2 lastdir;
3782  D3DXVECTOR2 *pt_flt;
3783  int j;
3784  struct outline *outline = add_outline(&glyph->outlines);
3785 
3786  if (!outline)
3787  return E_OUTOFMEMORY;
3788 
3789  pt = add_point(outline);
3790  if (!pt)
3791  return E_OUTOFMEMORY;
3792  pt_flt = convert_fixed_to_float(&header->pfxStart, 1, emsquare);
3793  pt->pos = *pt_flt;
3794  pt->corner = POINTTYPE_CORNER;
3795 
3796  if (header->dwType != TT_POLYGON_TYPE)
3797  trace("Unknown header type %d\n", header->dwType);
3798 
3799  while ((char *)curve < (char *)header + header->cb)
3800  {
3801  D3DXVECTOR2 bezier_start = outline->items[outline->count - 1].pos;
3802  BOOL to_curve = curve->wType != TT_PRIM_LINE && curve->cpfx > 1;
3803 
3804  if (!curve->cpfx) {
3805  curve = (TTPOLYCURVE *)&curve->apfx[curve->cpfx];
3806  continue;
3807  }
3808 
3809  pt_flt = convert_fixed_to_float(curve->apfx, curve->cpfx, emsquare);
3810 
3811  attempt_line_merge(outline, outline->count - 1, &pt_flt[0], to_curve);
3812 
3813  if (to_curve)
3814  {
3815  HRESULT hr;
3816  int count = curve->cpfx;
3817  j = 0;
3818 
3819  while (count > 2)
3820  {
3821  D3DXVECTOR2 bezier_end;
3822 
3823  D3DXVec2Scale(&bezier_end, D3DXVec2Add(&bezier_end, &pt_flt[j], &pt_flt[j+1]), 0.5f);
3824  hr = add_bezier_points(outline, &bezier_start, &pt_flt[j], &bezier_end, max_deviation);
3825  if (hr != S_OK)
3826  return hr;
3827  bezier_start = bezier_end;
3828  count--;
3829  j++;
3830  }
3831  hr = add_bezier_points(outline, &bezier_start, &pt_flt[j], &pt_flt[j+1], max_deviation);
3832  if (hr != S_OK)
3833  return hr;
3834 
3835  pt = add_point(outline);
3836  if (!pt)
3837  return E_OUTOFMEMORY;
3838  j++;
3839  pt->pos = pt_flt[j];
3840  pt->corner = POINTTYPE_CURVE_END;
3841  } else {
3842  for (j = 0; j < curve->cpfx; j++)
3843  {
3844  pt = add_point(outline);
3845  if (!pt)
3846  return E_OUTOFMEMORY;
3847  pt->pos = pt_flt[j];
3848  pt->corner = POINTTYPE_CORNER;
3849  }
3850  }
3851 
3852  curve = (TTPOLYCURVE *)&curve->apfx[curve->cpfx];
3853  }
3854 
3855  /* remove last point if the next line continues the last line */
3856  if (outline->count >= 3) {
3857  BOOL to_curve;
3858 
3859  lastpt = &outline->items[outline->count - 1];
3860  pt = &outline->items[0];
3861  if (pt->pos.x == lastpt->pos.x && pt->pos.y == lastpt->pos.y) {
3862  if (lastpt->corner == POINTTYPE_CURVE_END)
3863  {
3864  if (pt->corner == POINTTYPE_CURVE_START)
3865  pt->corner = POINTTYPE_CURVE_MIDDLE;
3866  else
3867  pt->corner = POINTTYPE_CURVE_END;
3868  }
3869  outline->count--;
3870  } else {
3871  /* outline closed with a line from end to start point */
3873  }
3874  lastpt = &outline->items[0];
3875  to_curve = lastpt->corner != POINTTYPE_CORNER && lastpt->corner != POINTTYPE_CURVE_END;
3876  if (lastpt->corner == POINTTYPE_CURVE_START)
3877  lastpt->corner = POINTTYPE_CORNER;
3878  pt = &outline->items[1];
3879  if (attempt_line_merge(outline, 0, &pt->pos, to_curve))
3880  *lastpt = outline->items[outline->count];
3881  }
3882 
3883  lastpt = &outline->items[outline->count - 1];
3884  pt = &outline->items[0];
3885  unit_vec2(&lastdir, &lastpt->pos, &pt->pos);
3886  for (j = 0; j < outline->count; j++)
3887  {
3888  D3DXVECTOR2 curdir;
3889 
3890  lastpt = pt;
3891  pt = &outline->items[(j + 1) % outline->count];
3892  unit_vec2(&curdir, &lastpt->pos, &pt->pos);
3893 
3894  switch (lastpt->corner)
3895  {
3896  case POINTTYPE_CURVE_START:
3897  case POINTTYPE_CURVE_END:
3898  if (!is_direction_similar(&lastdir, &curdir, cos_45))
3899  lastpt->corner = POINTTYPE_CORNER;
3900  break;
3902  if (!is_direction_similar(&lastdir, &curdir, cos_90))
3903  lastpt->corner = POINTTYPE_CORNER;
3904  else
3905  lastpt->corner = POINTTYPE_CURVE;
3906  break;
3907  default:
3908  break;
3909  }
3910  lastdir = curdir;
3911  }
3912 
3913  header = (TTPOLYGONHEADER *)((char *)header + header->cb);
3914  }
3915  return S_OK;
3916 }
static struct outline * add_outline(struct outline_array *array)
Definition: mesh.c:3661
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:3673
static struct point2d * add_point(struct outline *array)
Definition: mesh.c:3649
struct outline_array outlines
Definition: mesh.c:5362
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:3715
GLfloat f
Definition: glext.h:7540
#define trace
Definition: atltest.h:70
if(!(yy_init))
Definition: macro.lex.yy.c:714
POINTFX apfx[1]
Definition: wingdi.h:2713
LONG HRESULT
Definition: typedefs.h:78
FLOAT x
Definition: d3dx9math.h:64
Definition: mesh.c:5316
static D3DXVECTOR2 * unit_vec2(D3DXVECTOR2 *dir, const D3DXVECTOR2 *pt1, const D3DXVECTOR2 *pt2)
Definition: mesh.c:3721
Definition: mesh.c:5329
#define S_OK
Definition: intsafe.h:59
struct point2d * items
Definition: mesh.c:5332
static HRESULT add_bezier_points(struct outline *outline, const D3DXVECTOR2 *p1, const D3DXVECTOR2 *p2, const D3DXVECTOR2 *p3, float max_deviation)
Definition: mesh.c:3685
static BOOL attempt_line_merge(struct outline *outline, int pt_index, const D3DXVECTOR2 *nextpt, BOOL to_curve)
Definition: mesh.c:3726
#define TT_PRIM_LINE
Definition: wingdi.h:1318

Referenced by