2 #ifndef __SG_TEXTURE_HXX
3 #define __SG_TEXTURE_HXX 1
13 GLubyte *texture_data;
15 GLsizei texture_width;
16 GLsizei texture_height;
18 void resize(unsigned int width = 256, unsigned int height = 256);
22 typedef struct _ImageRec {
23 unsigned short imagic;
26 unsigned short xsize, ysize, zsize;
27 unsigned int min, max;
28 unsigned int wasteBytes;
30 unsigned long colorMap;
34 unsigned int *rowStart;
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);
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);
50 SGTexture(unsigned int width, unsigned int height);
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);
59 inline bool usable() { return texture_data ? true : false; }
61 inline GLuint id() { return texture_id; }
62 inline GLubyte *texture() { return texture_data; }
64 inline int width() { return texture_width; }
65 inline int height() { return texture_height; }
67 void prepare(unsigned int width = 256, unsigned int height = 256);
68 void finish(unsigned int width, unsigned int height);
71 inline void select() {
73 glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB,
74 texture_width, texture_height, 0,
75 GL_RGB, GL_UNSIGNED_BYTE, texture_data );