1 /*
2  * XPilotNG/SDL, an SDL/OpenGL XPilot client.
3  *
4  * Copyright (C) 2003-2004 Juha Lindstr�m <juhal@users.sourceforge.net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20 
21 #ifndef IMAGES_H
22 #define IMAGES_H
23 
24 #include "xpclient_sdl.h"
25 
26 typedef enum {
27     IMG_STATE_UNINITIALIZED,
28     IMG_STATE_ERROR,
29     IMG_STATE_READY
30 } image_state_e;
31 
32 /*
33  * This structure holds the information needed to paint an image with OpenGL.
34  * One image may contain multiple frames that represent the same object in
35  * different states. If rotate flag is true, the image will be rotated
36  * when it is created to generate num_frames-1 of new frames.
37  * Width is the cumulative width of all frames. Frame_width is the width
38  * of any single frame. Because OpenGL requires the dimensions of the images
39  * to be powers of 2, data_width and data_height are the nearest powers of 2
40  * corresponding to width and height respectively.
41  */
42 typedef struct {
43     GLuint          name;         /* OpenGL texture "name" */
44     char            *filename;    /* the name of the image file */
45     int             num_frames;   /* the number of frames */
46     bool            rotate;       /* should this image be rotated */
47     bool            scale;        /* should this image be scaled to fill data */
48     image_state_e   state;        /* the state of the image */
49     int             width;        /* width of the whole image */
50     int             height;       /* height of the whole image */
51     int             data_width;   /* width of the image data */
52     int             data_height;  /* height of the image data */
53     int             frame_width;  /* width of one image frame */
54     unsigned int    *data;        /* the image data */
55 } image_t;
56 
57 #define IMG_HOLDER_FRIEND 0
58 #define IMG_HOLDER_ENEMY  1
59 #define IMG_BALL          2
60 #define IMG_SHIP_SELF     3
61 #define IMG_SHIP_FRIEND   4
62 #define IMG_SHIP_ENEMY    5
63 #define IMG_BULLET        6
64 #define IMG_BULLET_OWN    7
65 #define IMG_BASE_DOWN     8
66 #define IMG_BASE_LEFT     9
67 #define IMG_BASE_UP       10
68 #define IMG_BASE_RIGHT    11
69 #define IMG_FUELCELL      12
70 #define IMG_FUEL          13
71 #define IMG_ALL_ITEMS     14
72 #define IMG_CANNON_DOWN   15
73 #define IMG_CANNON_LEFT   16
74 #define IMG_CANNON_UP     17
75 #define IMG_CANNON_RIGHT  18
76 #define IMG_SPARKS        19
77 #define IMG_PAUSED        20
78 #define IMG_REFUEL        21
79 #define IMG_WORMHOLE      22
80 #define IMG_MINE_TEAM     23
81 #define IMG_MINE_OTHER    24
82 #define IMG_CONCENTRATOR  25
83 #define IMG_PLUSGRAVITY   26
84 #define IMG_MINUSGRAVITY  27
85 #define IMG_CHECKPOINT	  28
86 #define IMG_METER	  29
87 #define IMG_ASTEROIDCONC  30
88 #define IMG_SHIELD        31
89 #define IMG_ACWISEGRAV    32
90 #define IMG_CWISEGRAV     33
91 #define IMG_MISSILE       34
92 #define IMG_ASTEROID      35
93 #define IMG_TARGET        36
94 #define IMG_HUD_ITEMS     37
95 
96 int Images_init(void);
97 void Images_cleanup(void);
98 void Image_paint(int ind, int x, int y, int frame, int c);
99 void Image_paint_area(int ind, int x, int y, int frame, irec_t *r, int c);
100 void Image_paint_rotated(int ind, int center_x, int center_y, int dir, int color);
101 image_t *Image_get(int ind);
102 image_t *Image_get_texture(int ind);
103 void Image_use_texture(int ind);
104 void Image_no_texture(void);
105 
106 #endif
107