00001 #pragma once
00002
00003 class Texture2D;
00004
00005 #include "Vis.hpp"
00006 #include <ImfArray.h>
00007
00013 class Texture2D
00014 {
00015 private:
00019 Imf::Array2D<Color4f> pixels;
00020 GLenum min_filter;
00021 GLenum mag_filter;
00022 GLuint texture_name;
00023
00027 V2i size;
00028
00029 public:
00030
00037 Texture2D( const char* path,
00038 GLenum wrapS = GL_REPEAT,
00039 GLenum wrapT = GL_REPEAT,
00040 GLenum magFilter = GL_LINEAR,
00041 GLenum minFilter = GL_LINEAR_MIPMAP_LINEAR);
00042
00048 Texture2D( V2i size,
00049 Color4f color = Color4f(0.0),
00050 GLenum wrapS = GL_REPEAT,
00051 GLenum wrapT = GL_REPEAT,
00052 GLenum magFilter = GL_LINEAR,
00053 GLenum minFilter = GL_LINEAR_MIPMAP_LINEAR);
00054
00058 Texture2D( V2i size,
00059 Color4f* pixels,
00060 GLenum wrapS = GL_REPEAT,
00061 GLenum wrapT = GL_REPEAT,
00062 GLenum magFilter = GL_LINEAR,
00063 GLenum minFilter = GL_LINEAR_MIPMAP_LINEAR);
00064
00065 virtual ~Texture2D() {
00066 glDeleteTextures(1, &texture_name);
00067 };
00068
00070 V2i get_size()
00071 {
00072 return size;
00073 };
00074
00076 Color4f* get_pixels()
00077 {
00078 return &(pixels[0][0]);
00079 };
00080
00086 void send_to_GPU();
00087
00091 void build_mipmaps();
00092
00093
00094 void bind(GLuint texUnit);
00095
00099 GLuint get_texture_name()
00100 {
00101 return texture_name;
00102 };
00103
00104 private:
00105
00106 void setup( GLenum wrapS,
00107 GLenum wrapT,
00108 GLenum magFilter,
00109 GLenum minFilter);
00110 };