aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/mimesh/libg3d-0.0.8/tests/test_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/mimesh/libg3d-0.0.8/tests/test_lib.c')
-rw-r--r--src/others/mimesh/libg3d-0.0.8/tests/test_lib.c99
1 files changed, 99 insertions, 0 deletions
diff --git a/src/others/mimesh/libg3d-0.0.8/tests/test_lib.c b/src/others/mimesh/libg3d-0.0.8/tests/test_lib.c
new file mode 100644
index 0000000..335c540
--- /dev/null
+++ b/src/others/mimesh/libg3d-0.0.8/tests/test_lib.c
@@ -0,0 +1,99 @@
1/* $Id: test_lib.c,v 1.1.2.2 2006/01/23 17:04:37 dahms Exp $ */
2
3/*
4 libg3d - 3D object loading library
5
6 Copyright (C) 2005-2009 Markus Dahms <mad@automagically.de>
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21*/
22
23#include <stdio.h>
24#include <stdlib.h>
25
26#include <g3d/g3d.h>
27
28#if 0
29#define DEBUG_MEM 1
30#endif
31
32#ifdef DEBUG_MEM
33static gpointer (*def_malloc)(gsize size) = NULL;
34
35static void break_here(gsize size)
36{
37 g_printerr("I'm here (%d bytes)\n", size);
38}
39
40static gpointer malloc_debug(gsize size)
41{
42 if(size == 84)
43 {
44 break_here(size);
45 }
46
47 return def_malloc(size);
48}
49#endif
50
51int main(int argc, char *argv[])
52{
53 G3DContext *context;
54 G3DModel *model;
55 G3DObject *object;
56 GSList *oitem;
57 guint32 i;
58
59#ifdef DEBUG_MEM
60 atexit(g_mem_profile);
61 def_malloc = glib_mem_profiler_table->malloc;
62 glib_mem_profiler_table->malloc = malloc_debug;
63 g_mem_set_vtable(glib_mem_profiler_table);
64#endif
65
66 context = g3d_context_new();
67
68 if(argc > 1)
69 {
70 model = g3d_model_load(context, argv[1]);
71
72 if(model)
73 {
74 g_print("%s: %d objects:\n", argv[1],
75 g_slist_length(model->objects));
76
77 i = 0;
78 oitem = model->objects;
79 while(oitem)
80 {
81 object = (G3DObject *)oitem->data;
82 g_print(" [%2u] %-50s (%d faces, %d mats)\n",
83 i,
84 object->name ? object->name : "(NULL)",
85 g_slist_length(object->faces),
86 g_slist_length(object->materials));
87
88 oitem = oitem->next;
89 i ++;
90 }
91
92 g3d_model_free(model);
93 }
94 }
95
96 g3d_context_free(context);
97
98 return EXIT_SUCCESS;
99}