#ifndef __SG_TEXTURE_HXX
#define __SG_TEXTURE_HXX 1
-#include <GL/gl.h>
+#include <simgear/compiler.h>
+#include SG_GL_H
#include <zlib.h>
#include <plib/sg.h>
GLsizei texture_width;
GLsizei texture_height;
+ GLsizei num_colors;
void resize(unsigned int width = 256, unsigned int height = 256);
void ConvertUint(unsigned *array, unsigned int length);
void ConvertShort(unsigned short *array, unsigned int length);
void rgbtorgb(GLubyte *r, GLubyte *g, GLubyte *b, GLubyte *l, int n);
+ void rgbatorgba(GLubyte *r, GLubyte *g, GLubyte *b, GLubyte *a,
+ GLubyte *l, int n);
ImageRec *ImageOpen(const char *fileName);
ImageRec *RawImageOpen(const char *fileName);
/* Copyright (c) Mark J. Kilgard, 1997. */
void read_alpha_texture(const char *name);
void read_rgb_texture(const char *name);
+ void read_rgba_texture(const char *name);
void read_raw_texture(const char *name);
void read_r8_texture(const char *name);
void bind();
inline void select(bool keep_data = false) {
- glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB,
+ glTexImage2D( GL_TEXTURE_2D, 0, num_colors,
texture_width, texture_height, 0,
- GL_RGB, GL_UNSIGNED_BYTE, texture_data );
+ (num_colors==1)?GL_LUMINANCE:(num_colors==3)?GL_RGB:GL_RGBA, GL_UNSIGNED_BYTE, texture_data );
if (!keep_data) {
delete[] texture_data;
inline bool is_resident() {
GLboolean is_res;
glAreTexturesResident(1, &texture_id, &is_res);
- return is_res;
+ return is_res != 0;
}
};