/* Generated by GOB (v2.0.9) on Tue Jan  4 21:23:04 2005
   (do not edit directly) */

/* End world hunger, donate to the World Food Programme, http://www.wfp.org */

#define GOB_VERSION_MAJOR 2
#define GOB_VERSION_MINOR 0
#define GOB_VERSION_PATCHLEVEL 9

#define selfp (self->_priv)

#include "gliv-image.h"

#ifdef G_LIKELY
#define ___GOB_LIKELY(expr) G_LIKELY(expr)
#define ___GOB_UNLIKELY(expr) G_UNLIKELY(expr)
#else /* ! G_LIKELY */
#define ___GOB_LIKELY(expr) (expr)
#define ___GOB_UNLIKELY(expr) (expr)
#endif /* G_LIKELY */

#line 1 "../tools/gliv-image.gob"

#include "gliv.h"
#include "opengl.h"
#include "options.h"

extern options_struct *options;

static int nb_images = 0;


#line 34 "gliv-image.c"

#line 12 "../tools/gliv-image.gob"

#include "texture_map.h"

#line 40 "gliv-image.c"
/* self casting macros */
#define SELF(x) GLIV_IMAGE(x)
#define SELF_CONST(x) GLIV_IMAGE_CONST(x)
#define IS_SELF(x) GLIV_IS_IMAGE(x)
#define TYPE_SELF GLIV_TYPE_IMAGE
#define SELF_CLASS(x) GLIV_IMAGE_CLASS(x)

#define SELF_GET_CLASS(x) GLIV_IMAGE_GET_CLASS(x)

/* self typedefs */
typedef GlivImage Self;
typedef GlivImageClass SelfClass;

/* here are local prototypes */
static void gliv_image_init (GlivImage * o) G_GNUC_UNUSED;
static void gliv_image_class_init (GlivImageClass * c) G_GNUC_UNUSED;
static void ___2_gliv_image_finalize (GObject * self) G_GNUC_UNUSED;

/* pointer to the class of our parent */
static GObjectClass *parent_class = NULL;

/* Short form macros */
#define self_new gliv_image_new
GType
gliv_image_get_type (void)
{
	static GType type = 0;

	if ___GOB_UNLIKELY(type == 0) {
		static const GTypeInfo info = {
			sizeof (GlivImageClass),
			(GBaseInitFunc) NULL,
			(GBaseFinalizeFunc) NULL,
			(GClassInitFunc) gliv_image_class_init,
			(GClassFinalizeFunc) NULL,
			NULL /* class_data */,
			sizeof (GlivImage),
			0 /* n_preallocs */,
			(GInstanceInitFunc) gliv_image_init,
			NULL
		};

		type = g_type_register_static (G_TYPE_OBJECT, "GlivImage", &info, (GTypeFlags)0);
	}

	return type;
}

/* a macro for creating a new object of our type */
#define GET_NEW ((GlivImage *)g_object_new(gliv_image_get_type(), NULL))

/* a function for creating a new object of our type */
#include <stdarg.h>
static GlivImage * GET_NEW_VARG (const char *first, ...) G_GNUC_UNUSED;
static GlivImage *
GET_NEW_VARG (const char *first, ...)
{
	GlivImage *ret;
	va_list ap;
	va_start (ap, first);
	ret = (GlivImage *)g_object_new_valist (gliv_image_get_type (), first, ap);
	va_end (ap);
	return ret;
}

static void 
gliv_image_init (GlivImage * o G_GNUC_UNUSED)
{
#define __GOB_FUNCTION__ "Gliv:Image::init"
}
#undef __GOB_FUNCTION__
static void 
gliv_image_class_init (GlivImageClass * c G_GNUC_UNUSED)
{
#define __GOB_FUNCTION__ "Gliv:Image::class_init"
	GObjectClass *g_object_class = (GObjectClass *)c;

	parent_class = g_type_class_ref (G_TYPE_OBJECT);

#line 41 "../tools/gliv-image.gob"
	g_object_class->finalize = ___2_gliv_image_finalize;
#line 122 "gliv-image.c"
}
#undef __GOB_FUNCTION__



#line 26 "../tools/gliv-image.gob"
GlivImage * 
gliv_image_new (void)
#line 131 "gliv-image.c"
{
#define __GOB_FUNCTION__ "Gliv:Image::new"
{
#line 27 "../tools/gliv-image.gob"
	
        /* This is used to detect bugs */
        nb_images++;
        if (nb_images > 4)
            g_printerr("There are more than 4 images: %d images\n", nb_images);

        else if (options->one_image && nb_images > 2)
            /* We can have two images : the displayed one and the just loaded */
            g_printerr("There are more than 2 images: %d images\n", nb_images);


        return GET_NEW;
    }}
#line 149 "gliv-image.c"
#undef __GOB_FUNCTION__

#line 41 "../tools/gliv-image.gob"
static void 
___2_gliv_image_finalize (GObject * self G_GNUC_UNUSED)
#line 155 "gliv-image.c"
#define PARENT_HANDLER(___self) \
	{ if(G_OBJECT_CLASS(parent_class)->finalize) \
		(* G_OBJECT_CLASS(parent_class)->finalize)(___self); }
{
#define __GOB_FUNCTION__ "Gliv:Image::finalize"
{
#line 42 "../tools/gliv-image.gob"
	
        gint level;
        texture_map *map;
        GlivImage *im = GLIV_IMAGE(self);

        for (level = 0; level < im->nb_maps; level++) {
            map = im->maps + level;

            glDeleteTextures(map->nb_tiles, map->tex_ids);
            g_free(map->tex_ids);

            glDeleteLists(map->list, map->nb_tiles);
            g_free(map->tiles);
        }

        g_free(im->maps);
        g_free(im->ident);

        PARENT_HANDLER(self);
        nb_images--;
    }}
#line 184 "gliv-image.c"
#undef __GOB_FUNCTION__
#undef PARENT_HANDLER
