]> git.draconx.ca Git - upkg.git/blob - src/engine/texture.c
Begin work on Engine.Texture.
[upkg.git] / src / engine / texture.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <glib-object.h>
4
5 #include "exportable.h"
6 #include "uobject.h"
7 #include "texture.h"
8 #include "upkg.h"
9
10 #define TEXTURE_GET_PRIV(o) \
11         G_TYPE_INSTANCE_GET_PRIVATE(o, ENGINE_TEXTURE_TYPE, struct texture_priv)
12
13 struct texture_priv {
14         unsigned type;
15
16         struct upkg_file *f;
17         size_t base, len;
18
19         unsigned char buf[2048];
20         unsigned long nbuf;
21 };
22
23 void exportable_init(UObjectExportable *e)
24 {
25 }
26
27 G_DEFINE_DYNAMIC_TYPE(EngineTexture, engine_texture, U_OBJECT_TYPE);
28
29 static int deserialize(UObject *o, struct upkg_file *f)
30 {
31         struct texture_priv *priv = TEXTURE_GET_PRIV(o);
32         EngineTexture *t = ENGINE_TEXTURE(o);
33         const GValue *val;
34
35         U_OBJECT_CLASS(engine_texture_parent_class)->deserialize(o, f);
36
37         val = u_object_get_property(o, "USize");
38         if (!(val && G_VALUE_HOLDS(val, G_TYPE_ULONG)))
39                 return -1;
40         t->usize = g_value_get_ulong(val);
41
42         val = u_object_get_property(o, "USize");
43         if (!(val && G_VALUE_HOLDS(val, G_TYPE_ULONG)))
44                 return -1;
45         t->vsize = g_value_get_ulong(val);
46
47         printf("Texture size: %lux%lu\n", t->usize, t->vsize);
48
49         return 0;
50 }
51
52 void texture_register(GTypeModule *m)
53 {
54         engine_texture_register_type(m);
55 }
56
57 static void engine_texture_init(EngineTexture *m)
58 {
59 }
60
61 static void engine_texture_class_init(EngineTextureClass *class)
62 {
63         UObjectClass *uo = U_OBJECT_CLASS(class);
64
65         g_type_class_add_private(class, sizeof (struct texture_priv));
66
67         uo->deserialize = deserialize;
68 }
69
70 static void engine_texture_class_finalize(EngineTextureClass *class)
71 {
72 }