1 /* Generated by GOB (v2.0.16)   (do not edit directly) */
2 
3 /* End world hunger, donate to the World Food Programme, http://www.wfp.org */
4 
5 #define GOB_VERSION_MAJOR 2
6 #define GOB_VERSION_MINOR 0
7 #define GOB_VERSION_PATCHLEVEL 16
8 
9 #define selfp (self->_priv)
10 
11 #include <string.h> /* memset() */
12 
13 #include "gliv-image.h"
14 
15 #ifdef G_LIKELY
16 #define ___GOB_LIKELY(expr) G_LIKELY(expr)
17 #define ___GOB_UNLIKELY(expr) G_UNLIKELY(expr)
18 #else /* ! G_LIKELY */
19 #define ___GOB_LIKELY(expr) (expr)
20 #define ___GOB_UNLIKELY(expr) (expr)
21 #endif /* G_LIKELY */
22 
23 #line 1 "../tools/gliv-image.gob"
24 
25 #include "gliv.h"
26 #include "opengl.h"
27 #include "options.h"
28 
29 extern options_struct *options;
30 
31 static int nb_images = 0;
32 
33 
34 #line 35 "gliv-image.c"
35 
36 #line 12 "../tools/gliv-image.gob"
37 
38 #include "texture_map.h"
39 
40 #line 41 "gliv-image.c"
41 /* self casting macros */
42 #define SELF(x) GLIV_IMAGE(x)
43 #define SELF_CONST(x) GLIV_IMAGE_CONST(x)
44 #define IS_SELF(x) GLIV_IS_IMAGE(x)
45 #define TYPE_SELF GLIV_TYPE_IMAGE
46 #define SELF_CLASS(x) GLIV_IMAGE_CLASS(x)
47 
48 #define SELF_GET_CLASS(x) GLIV_IMAGE_GET_CLASS(x)
49 
50 /* self typedefs */
51 typedef GlivImage Self;
52 typedef GlivImageClass SelfClass;
53 
54 /* here are local prototypes */
55 #line 0 "../tools/gliv-image.gob"
56 static void gliv_image_init (GlivImage * o) G_GNUC_UNUSED;
57 #line 58 "gliv-image.c"
58 #line 0 "../tools/gliv-image.gob"
59 static void gliv_image_class_init (GlivImageClass * c) G_GNUC_UNUSED;
60 #line 61 "gliv-image.c"
61 #line 44 "../tools/gliv-image.gob"
62 static void ___2_gliv_image_finalize (GObject * self) G_GNUC_UNUSED;
63 #line 64 "gliv-image.c"
64 
65 /* pointer to the class of our parent */
66 static GObjectClass *parent_class = NULL;
67 
68 /* Short form macros */
69 #define self_new gliv_image_new
70 GType
gliv_image_get_type(void)71 gliv_image_get_type (void)
72 {
73 	static GType type = 0;
74 
75 	if ___GOB_UNLIKELY(type == 0) {
76 		static const GTypeInfo info = {
77 			sizeof (GlivImageClass),
78 			(GBaseInitFunc) NULL,
79 			(GBaseFinalizeFunc) NULL,
80 			(GClassInitFunc) gliv_image_class_init,
81 			(GClassFinalizeFunc) NULL,
82 			NULL /* class_data */,
83 			sizeof (GlivImage),
84 			0 /* n_preallocs */,
85 			(GInstanceInitFunc) gliv_image_init,
86 			NULL
87 		};
88 
89 		type = g_type_register_static (G_TYPE_OBJECT, "GlivImage", &info, (GTypeFlags)0);
90 	}
91 
92 	return type;
93 }
94 
95 /* a macro for creating a new object of our type */
96 #define GET_NEW ((GlivImage *)g_object_new(gliv_image_get_type(), NULL))
97 
98 /* a function for creating a new object of our type */
99 #include <stdarg.h>
100 static GlivImage * GET_NEW_VARG (const char *first, ...) G_GNUC_UNUSED;
101 static GlivImage *
GET_NEW_VARG(const char * first,...)102 GET_NEW_VARG (const char *first, ...)
103 {
104 	GlivImage *ret;
105 	va_list ap;
106 	va_start (ap, first);
107 	ret = (GlivImage *)g_object_new_valist (gliv_image_get_type (), first, ap);
108 	va_end (ap);
109 	return ret;
110 }
111 
112 static void
gliv_image_init(GlivImage * o G_GNUC_UNUSED)113 gliv_image_init (GlivImage * o G_GNUC_UNUSED)
114 {
115 #define __GOB_FUNCTION__ "Gliv:Image::init"
116 }
117 #undef __GOB_FUNCTION__
118 static void
gliv_image_class_init(GlivImageClass * c G_GNUC_UNUSED)119 gliv_image_class_init (GlivImageClass * c G_GNUC_UNUSED)
120 {
121 #define __GOB_FUNCTION__ "Gliv:Image::class_init"
122 	GObjectClass *g_object_class = (GObjectClass *)c;
123 
124 	parent_class = g_type_class_ref (G_TYPE_OBJECT);
125 
126 #line 44 "../tools/gliv-image.gob"
127 	g_object_class->finalize = ___2_gliv_image_finalize;
128 #line 129 "gliv-image.c"
129 }
130 #undef __GOB_FUNCTION__
131 
132 
133 
134 #line 29 "../tools/gliv-image.gob"
135 GlivImage *
gliv_image_new(void)136 gliv_image_new (void)
137 {
138 #line 139 "gliv-image.c"
139 #define __GOB_FUNCTION__ "Gliv:Image::new"
140 {
141 #line 30 "../tools/gliv-image.gob"
142 
143         /* This is used to detect bugs */
144         nb_images++;
145         if (nb_images > 4)
146             g_printerr("There are more than 4 images: %d images\n", nb_images);
147 
148         else if (options->one_image && nb_images > 2)
149             /* We can have two images : the displayed one and the just loaded */
150             g_printerr("There are more than 2 images: %d images\n", nb_images);
151 
152 
153         return GET_NEW;
154     }}
155 #line 156 "gliv-image.c"
156 #undef __GOB_FUNCTION__
157 
158 #line 44 "../tools/gliv-image.gob"
159 static void
___2_gliv_image_finalize(GObject * self G_GNUC_UNUSED)160 ___2_gliv_image_finalize (GObject * self G_GNUC_UNUSED)
161 #line 162 "gliv-image.c"
162 #define PARENT_HANDLER(___self) \
163 	{ if(G_OBJECT_CLASS(parent_class)->finalize) \
164 		(* G_OBJECT_CLASS(parent_class)->finalize)(___self); }
165 {
166 #define __GOB_FUNCTION__ "Gliv:Image::finalize"
167 {
168 #line 45 "../tools/gliv-image.gob"
169 
170         gint level;
171         texture_map *map;
172         GlivImage *im = GLIV_IMAGE(self);
173 
174         for (level = 0; level < im->nb_maps; level++) {
175             map = im->maps + level;
176 
177             glDeleteTextures(map->nb_tiles, map->tex_ids);
178             g_free(map->tex_ids);
179 
180             glDeleteLists(map->list, map->nb_tiles);
181             g_free(map->tiles);
182         }
183 
184         g_free(im->maps);
185         g_free(im->ident);
186 
187         PARENT_HANDLER(self);
188         nb_images--;
189     }}
190 #line 191 "gliv-image.c"
191 #undef __GOB_FUNCTION__
192 #undef PARENT_HANDLER
193