1 /*
2  * File:         texture.h
3  *
4  * Description:  header for texture.c
5  *
6  *
7  * This source code is part of kludge3d, and is released under the
8  * GNU General Public License.
9  *
10  *
11  */
12 
13 #ifndef TEXTURE_H
14 #define TEXTURE_H
15 
16 #include <stdio.h>
17 #include <glib.h>
18 #include <gdk-pixbuf/gdk-pixbuf.h>
19 
20 
21 #define TEXTURE_NUM_MIP_LEVELS 4
22 
23 #define TEXTURE_MIP_LEVEL_SMALLEST 0
24 #define TEXTURE_MIP_LEVEL_MEDIUM   1
25 #define TEXTURE_MIP_LEVEL_LARGE    2
26 #define TEXTURE_MIP_LEVEL_OPENGL   3
27 
28 #define TEXTURE_MIP_LEVEL_SMALLEST_SIZE 32
29 #define TEXTURE_MIP_LEVEL_MEDIUM_SIZE   128
30 #define TEXTURE_MIP_LEVEL_LARGE_SIZE    512
31 #define TEXTURE_MIP_LEVEL_OPENGL_SIZE   TEXTURE_MIP_LEVEL_MEDIUM_SIZE
32 
33 #define TEXTURE_FORMAT_UNKNOWN	-1
34 
35 typedef struct _tex Texture;
36 typedef struct _tex_data tex_data;
37 
38 struct _tex_data {
39     gint width, height;
40     gint depth;
41     guchar *data;
42 };
43 
44 struct _tex {
45     char *filename;
46     tex_data original;
47     tex_data mip[TEXTURE_NUM_MIP_LEVELS];
48 	GdkPixbuf * pixbuf;
49 	int upside_down;
50 };
51 
52 
53 /* file load abstraction */
54 struct texture_file_fmt {
55   gchar *descr;
56   gchar *extension;	/* NULL indicates wildcard */
57 
58   gint (* load_tex) (FILE *fp, Texture *tex);
59 };
60 
61 
62 
63 Texture *tex_new( void );
64 void tex_delete( Texture *tt );
65 Texture * tex_load( const gchar *file_name, int fmt_idx, char *model_fname ) ;
66 void tex_scale( tex_data *td_src, tex_data *td_dest, int width, int height );
67 
68 #endif
69