1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
/* $Id$ */
/*
libg3d - 3D object loading library
Copyright (C) 2005-2009 Markus Dahms <mad@automagically.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <g3d/config.h>
#ifdef HAVE_LIBGSF
# include <gsf/gsf-utils.h>
#endif
#include <g3d/types.h>
#include <g3d/plugins.h>
EAPI
G3DContext *g3d_context_new(void)
{
G3DContext *context;
context = g_new0(G3DContext, 1);
#ifdef HAVE_LIBGSF
gsf_init();
#endif
g3d_plugins_init(context);
return context;
}
EAPI
void g3d_context_free(G3DContext *context)
{
g3d_plugins_cleanup(context);
if (context->modelCache)
g_hash_table_destroy(context->modelCache);
#ifdef HAVE_LIBGSF
gsf_shutdown();
#endif
g_free(context);
}
/* callback wrappers - to be called from libg3d plugins */
EAPI
gboolean g3d_context_set_bgcolor(G3DContext *context,
G3DFloat r, G3DFloat g, G3DFloat b, G3DFloat a)
{
if(context->set_bgcolor_func)
return context->set_bgcolor_func(r, g, b, a,
context->set_bgcolor_data);
else
return FALSE;
}
EAPI
gboolean g3d_context_update_interface(G3DContext *context)
{
if(context->update_interface_func)
return context->update_interface_func(context->update_interface_data);
else
return FALSE;
}
EAPI
gboolean g3d_context_update_progress_bar(G3DContext *context,
G3DFloat percentage, gboolean visibility)
{
if(context->update_progress_bar_func)
return context->update_progress_bar_func(
percentage, visibility,
context->update_progress_bar_data);
else
return FALSE;
}
/* set callback functions - to be called from client program */
EAPI
void g3d_context_set_set_bgcolor_func(G3DContext *context,
G3DSetBgColorFunc func, gpointer user_data)
{
context->set_bgcolor_func = func;
context->set_bgcolor_data = user_data;
}
EAPI
void g3d_context_set_update_interface_func(G3DContext *context,
G3DUpdateInterfaceFunc func, gpointer user_data)
{
context->update_interface_func = func;
context->update_interface_data = user_data;
}
EAPI
void g3d_context_set_update_progress_bar_func(G3DContext *context,
G3DUpdateProgressBarFunc func, gpointer user_data)
{
context->update_progress_bar_func = func;
context->update_progress_bar_data = user_data;
}
|