]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texture.h
Inherit Loaders from the ObjectLoader classes
[libs/gl.git] / source / texture.h
index 28f9cb328979efdcefc0c6934e250da56748cdb7..21edb81a74ae53ac67d0c18dff005709c048c431 100644 (file)
@@ -8,6 +8,8 @@ Distributed under the LGPL
 #ifndef MSP_GL_TEXTURE_H_
 #define MSP_GL_TEXTURE_H_
 
+#include <istream>
+#include <msp/datafile/objectloader.h>
 #include "gl.h"
 #include "types.h"
 
@@ -24,6 +26,9 @@ enum TextureFilter
        LINEAR_MIPMAP_LINEAR   = GL_LINEAR_MIPMAP_LINEAR
 };
 
+std::istream &operator>>(std::istream &, TextureFilter &);
+
+
 /**
 Base class for textures.  This class only defines operations common for all
 texture types and is not instantiable.  For specifying images for textures, see
@@ -31,10 +36,21 @@ one of the dimensioned texture classes.
 */
 class Texture
 {
+protected:
+       class Loader: public DataFile::ObjectLoader<Texture>
+       {
+       public:
+               Loader(Texture &);
+               void min_filter(TextureFilter);
+               void mag_filter(TextureFilter);
+               void generate_mipmap(bool);
+       };
+
 public:
        ~Texture();
 
        void bind() const;
+       void bind_to(unsigned) const;
        void parameter(GLenum, int);
        void parameter(GLenum, float);
        void set_min_filter(TextureFilter f) { parameter(GL_TEXTURE_MIN_FILTER, f); }
@@ -43,6 +59,7 @@ public:
        uint  get_id() const                 { return id; }
 
        static void unbind();
+       static void unbind_from(unsigned);
 protected:
        uint   id;
        GLenum target;