]> git.mxchange.org Git - simgear.git/blob - simgear/misc/texture.hxx
remove a depreciated file
[simgear.git] / simgear / misc / texture.hxx
1
2 #ifndef __SG_TEXTURE_HXX
3 #define __SG_TEXTURE_HXX 1
4
5 #include <GL/gl.h>
6 #include <zlib.h>
7
8 class SGTexture {
9
10 private:
11
12     GLuint texture_id;
13     GLubyte *texture_data;
14
15     GLsizei texture_width;
16     GLsizei texture_height;
17
18     void resize(unsigned int width = 256, unsigned int height = 256);
19
20 protected:
21
22     typedef struct _ImageRec {
23         unsigned short imagic;
24         unsigned short type;
25         unsigned short dim;
26         unsigned short xsize, ysize, zsize;
27         unsigned int min, max;
28         unsigned int wasteBytes;
29         char name[80];
30         unsigned long colorMap;
31         gzFile file;
32         GLubyte *tmp;
33         unsigned long rleEnd;
34         unsigned int *rowStart;
35         int *rowSize;
36     } ImageRec;
37
38     void ConvertUint(unsigned *array, unsigned int length);
39     void ConvertShort(unsigned short *array, unsigned int length);
40     void rgbtorgb(GLubyte *r, GLubyte *g, GLubyte *b, GLubyte *l, int n);
41
42     ImageRec *ImageOpen(const char *fileName);
43     ImageRec *RawImageOpen(const char *fileName);
44     void ImageClose(ImageRec *image);
45     void ImageGetRow(ImageRec *image, GLubyte *buf, int y, int z);
46
47 public:
48
49     SGTexture();
50     SGTexture(unsigned int width, unsigned int height);
51     ~SGTexture();
52
53     /* Copyright (c) Mark J. Kilgard, 1997.  */
54     void read_alpha_texture(const char *name);
55     void read_rgb_texture(const char *name);
56     void read_raw_texture(const char *name);
57     void read_r8_texture(const char *name);
58
59     inline bool usable() { return texture_data ? true : false; }
60
61     inline GLuint id() { return texture_id; }
62     inline GLubyte *texture() { return texture_data; }
63
64     inline int width() { return texture_width; }
65     inline int height() { return texture_height; }
66
67     void prepare(unsigned int width = 256, unsigned int height = 256);
68     void finish(unsigned int width, unsigned int height);
69
70     void bind();
71     inline void select() {
72         // if (texture_data)
73             glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB,
74                           texture_width, texture_height, 0,
75                           GL_RGB, GL_UNSIGNED_BYTE, texture_data );
76     }
77 };
78
79 #endif
80