/[usata]/usata2/src/texture.cpp
ViewVC logotype

Diff of /usata2/src/texture.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by Descender, Sun Dec 26 18:36:42 2004 UTC revision 1.6 by skunix, Sat Jan 15 19:17:35 2005 UTC
# Line 17  Line 17 
17  #include <GL/glew.h>  #include <GL/glew.h>
18  #include "texture.hpp"  #include "texture.hpp"
19  #include "texture-meta.hpp"  #include "texture-meta.hpp"
20    #include <boost/tuple/tuple.hpp>
21  #include <Magick++.h>  #include <Magick++.h>
22  #include "log.hpp"  #include "log.hpp"
23  namespace usata  namespace usata
# Line 46  class Pixmap Line 47  class Pixmap
47                  const std::string&                  const std::string&
48                  format() const {return Format;}                  format() const {return Format;}
49                  unsigned char*get_pixels(){ return pixels.get();}                  unsigned char*get_pixels(){ return pixels.get();}
50                    
51  };  };
52    
53  }  }
# Line 64  TextureMeta::TextureMeta(const boost::fi Line 66  TextureMeta::TextureMeta(const boost::fi
66  {  {
67    
68  }  }
69    
70    void
71    Texture::allocate_gltex(void)
72    {
73            glGenTextures(1,&tex_id);
74    }
75    
76  Texture::Texture (const TextureMeta* meta)  Texture::Texture (const TextureMeta* meta)
77  {  {
78          Magick::Image XI(meta->filepath.native_file_string());          Magick::Image XI(meta->filepath.native_file_string());
79          log::BufferedStream logstream(log::Level::DEBUG);          log::BufferedStream logstream(log::Level::DEBUG);
         logstream << XI.columns() << "x" <<XI.rows() << log::commit;  
80          Magick::ImageType image_type = XI.type();          Magick::ImageType image_type = XI.type();
81          unsigned Depth;          unsigned Depth;
82            GLint  format = 0;      
83          std::string Type;                std::string Type;      
84          switch (image_type)          switch (image_type)
85          {          {
86                  case Magick::TrueColorType:                  case Magick::TrueColorType:
87                  case Magick::PaletteType:                  case Magick::PaletteType:
88                  {                  {
89                            format = GL_RGB;
90                          Type="RGB";                          Type="RGB";
91                          Depth = 24;                          Depth = 24;
92                          break;                            break;  
# Line 85  Texture::Texture (const TextureMeta* met Line 95  Texture::Texture (const TextureMeta* met
95                  case Magick::TrueColorMatteType:                  case Magick::TrueColorMatteType:
96                  case Magick::PaletteMatteType:                  case Magick::PaletteMatteType:
97                  {                  {
98                            format = GL_RGBA;
99                          Type="RGBA";                          Type="RGBA";
100                          Depth = 32;                          Depth = 32;
101                          break;                          break;
# Line 103  Texture::Texture (const TextureMeta* met Line 114  Texture::Texture (const TextureMeta* met
114    
115          Pixmap pb(XI.columns(),XI.rows(),Depth,Type);          Pixmap pb(XI.columns(),XI.rows(),Depth,Type);
116          XI.write(0,0,pb.width(), pb.height(), pb.format(),Magick::CharPixel,pb.get_pixels());          XI.write(0,0,pb.width(), pb.height(), pb.format(),Magick::CharPixel,pb.get_pixels());
117            glBindTexture(GL_TEXTURE_2D, tex_id);
118                glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);    
119        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
120            gluBuild2DMipmaps(GL_TEXTURE_2D, format, pb.width(), pb.height(), format, GL_UNSIGNED_BYTE,pb.get_pixels());
121    
122          return;          return;
123  }  }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26