File: gliv-image.gob

package info (click to toggle)
gliv 1.9.7-2
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, jessie, jessie-kfreebsd, sid, stretch, trixie, wheezy
  • size: 5,780 kB
  • ctags: 4,039
  • sloc: ansic: 30,070; sh: 5,207; makefile: 740; yacc: 291; awk: 185; sed: 16
file content (66 lines) | stat: -rw-r--r-- 1,504 bytes parent folder | download
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
%{
#include "gliv.h"
#include "opengl.h"
#include "options.h"

extern options_struct *options;

static int nb_images = 0;

%}

%a{
#include "texture_map.h"
%}

class Gliv:Image from G:Object {
    public GList *node;
    public gint number;
    public gchar *ident;
    public gint width;
    public gint height;
    public gint nb_maps;
    public texture_map *maps;
    public gboolean has_alpha;
    public gboolean first_image;
    public gfloat initial_angle;
    public gboolean initial_h_flip;

    public GlivImage *new(void)
    {
        /* 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;
    }

    override (G:Object) void finalize(GObject * self)
    {
        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--;
    }
}