]> git.mxchange.org Git - simgear.git/blobdiff - simgear/screen/texture.hxx
New automake, new problems. Use $base_LIBS where $LIBS was automatically added before
[simgear.git] / simgear / screen / texture.hxx
index 7a947429e207d09e51a8c2e8d2808ba0e9cb74c4..05fa393d897f5c9b7136a32b6b312af83f91d2d2 100644 (file)
@@ -31,6 +31,7 @@ private:
 
     GLsizei texture_width;
     GLsizei texture_height;
+    GLsizei num_colors;
 
     void resize(unsigned int width = 256, unsigned int height = 256);
 
@@ -55,6 +56,8 @@ protected:
     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);
@@ -67,6 +70,7 @@ protected:
 #else
         glDeleteTexturesEXT(1, &texture_id);
 #endif
+        texture_id = 0;
     }
 
 
@@ -79,10 +83,11 @@ public:
     /* 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);
 
-    inline bool usable() { return texture_data ? true : false; }
+    inline bool usable() { return (texture_id > 0) ? true : false; }
 
     inline GLuint id() { return texture_id; }
     inline GLubyte *texture() { return texture_data; }
@@ -98,19 +103,20 @@ public:
     void prepare(unsigned int width = 256, unsigned int height = 256);
     void finish(unsigned int width, unsigned int height);
 
-#if 0
     // texture pixel manipulation functions.
     void set_pixel(GLuint x, GLuint y, sgVec3 &c);
-    sgVec3 *get_pixel(GLuint x, GLuint y);
-#endif
+    float *get_pixel(GLuint x, GLuint y);
 
     void bind();
-    inline void select() {
+    inline void select(bool keep_data = false) {
         glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB,
                       texture_width, texture_height, 0,
                       GL_RGB, GL_UNSIGNED_BYTE, texture_data );
 
-        delete texture_data;
+        if (!keep_data) {
+            delete[] texture_data;
+            texture_data = 0;
+        }
     }
 
     // Nowhere does it say that resident textures have to be in video memory!