diff options
Diffstat (limited to 'src/others/mimesh/libg3d-0.0.8/src/context.c')
-rw-r--r-- | src/others/mimesh/libg3d-0.0.8/src/context.c | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/src/others/mimesh/libg3d-0.0.8/src/context.c b/src/others/mimesh/libg3d-0.0.8/src/context.c new file mode 100644 index 0000000..81bbfad --- /dev/null +++ b/src/others/mimesh/libg3d-0.0.8/src/context.c | |||
@@ -0,0 +1,119 @@ | |||
1 | /* $Id$ */ | ||
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 <g3d/config.h> | ||
24 | |||
25 | #ifdef HAVE_LIBGSF | ||
26 | # include <gsf/gsf-utils.h> | ||
27 | #endif | ||
28 | |||
29 | #include <g3d/types.h> | ||
30 | #include <g3d/plugins.h> | ||
31 | |||
32 | EAPI | ||
33 | G3DContext *g3d_context_new(void) | ||
34 | { | ||
35 | G3DContext *context; | ||
36 | |||
37 | context = g_new0(G3DContext, 1); | ||
38 | #ifdef HAVE_LIBGSF | ||
39 | gsf_init(); | ||
40 | #endif | ||
41 | |||
42 | g3d_plugins_init(context); | ||
43 | |||
44 | return context; | ||
45 | } | ||
46 | |||
47 | EAPI | ||
48 | void g3d_context_free(G3DContext *context) | ||
49 | { | ||
50 | g3d_plugins_cleanup(context); | ||
51 | if (context->modelCache) | ||
52 | g_hash_table_destroy(context->modelCache); | ||
53 | #ifdef HAVE_LIBGSF | ||
54 | gsf_shutdown(); | ||
55 | #endif | ||
56 | |||
57 | g_free(context); | ||
58 | } | ||
59 | |||
60 | /* callback wrappers - to be called from libg3d plugins */ | ||
61 | |||
62 | EAPI | ||
63 | gboolean g3d_context_set_bgcolor(G3DContext *context, | ||
64 | G3DFloat r, G3DFloat g, G3DFloat b, G3DFloat a) | ||
65 | { | ||
66 | if(context->set_bgcolor_func) | ||
67 | return context->set_bgcolor_func(r, g, b, a, | ||
68 | context->set_bgcolor_data); | ||
69 | else | ||
70 | return FALSE; | ||
71 | } | ||
72 | |||
73 | EAPI | ||
74 | gboolean g3d_context_update_interface(G3DContext *context) | ||
75 | { | ||
76 | if(context->update_interface_func) | ||
77 | return context->update_interface_func(context->update_interface_data); | ||
78 | else | ||
79 | return FALSE; | ||
80 | } | ||
81 | |||
82 | EAPI | ||
83 | gboolean g3d_context_update_progress_bar(G3DContext *context, | ||
84 | G3DFloat percentage, gboolean visibility) | ||
85 | { | ||
86 | if(context->update_progress_bar_func) | ||
87 | return context->update_progress_bar_func( | ||
88 | percentage, visibility, | ||
89 | context->update_progress_bar_data); | ||
90 | else | ||
91 | return FALSE; | ||
92 | } | ||
93 | |||
94 | /* set callback functions - to be called from client program */ | ||
95 | |||
96 | EAPI | ||
97 | void g3d_context_set_set_bgcolor_func(G3DContext *context, | ||
98 | G3DSetBgColorFunc func, gpointer user_data) | ||
99 | { | ||
100 | context->set_bgcolor_func = func; | ||
101 | context->set_bgcolor_data = user_data; | ||
102 | } | ||
103 | |||
104 | EAPI | ||
105 | void g3d_context_set_update_interface_func(G3DContext *context, | ||
106 | G3DUpdateInterfaceFunc func, gpointer user_data) | ||
107 | { | ||
108 | context->update_interface_func = func; | ||
109 | context->update_interface_data = user_data; | ||
110 | } | ||
111 | |||
112 | EAPI | ||
113 | void g3d_context_set_update_progress_bar_func(G3DContext *context, | ||
114 | G3DUpdateProgressBarFunc func, gpointer user_data) | ||
115 | { | ||
116 | context->update_progress_bar_func = func; | ||
117 | context->update_progress_bar_data = user_data; | ||
118 | } | ||
119 | |||