Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members

glimage.h

00001 /***************************************************************************
00002                           glimage.h  -  description
00003                              -------------------
00004     begin                : Wed Apr 2 2003
00005     copyright            : (C) 2003 by 
00006     email                : jgasseli@localhost.localdomain
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU Lesser General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef GLIMAGE_H
00019 #define GLIMAGE_H
00020 
00021 
00028 #include <GL/gl.h>
00029 #include <GL/glu.h>
00030 
00031 
00032 class GLImage
00033 {
00034    protected:
00035 
00036    char bpp;
00037    GLsizei pixels;
00038    GLsizei size;
00039    GLsizei width, height;
00040    GLint internalFormat;
00041    GLint format;
00042    GLenum type;
00043    unsigned paletteSize;
00044    char* palette;
00045    void* data;
00046    GLuint texname;
00047    
00048    std::string fileName;
00049    
00050    public:
00051 
00052    GLImage();
00053    GLImage(GLsizei w, GLsizei h, GLint iForm = GL_RGB, GLint form = GL_RGB,
00054            GLenum t = GL_UNSIGNED_BYTE, unsigned pSize = 0);
00055    virtual ~GLImage();
00056 
00057    void set(GLsizei w, GLsizei h, GLint iForm = GL_RGB, GLint form = GL_RGB,
00058             GLenum t = GL_UNSIGNED_BYTE, unsigned pSize = 0);
00059 
00060    void setFileName(std::string fName)
00061    { fileName = fName; }
00062 
00063    inline char getBytesPerPixel() { return bpp; }
00064    inline GLsizei getNumberOfPixels() { return pixels; }
00065    inline GLsizei getWidth() { return width; }
00066    inline GLsizei getHeight() { return height; }
00067    
00068    void generateTexture(GLenum target, GLint mipmapLevel, GLint border);
00069    void generateMipmap(GLenum target);
00070 
00071    void copyFromBuffer(GLvoid* buf, GLsizei bufsize);
00072    void copyFromScreen(GLint x, GLint y);
00073 
00074    void copyToBuffer(GLvoid* buf, GLsizei bufsize);
00075    void copyToScreen(GLint x, GLint y);
00076 
00077    static GLImage* staticLoadFromFile(std::string fname);
00078 
00079    void loadFromFile(std::string fname);
00080    void loadFromFile()
00081    { loadFromFile( fileName ); }
00082    
00083    void loadFromBMP(std::string fname);
00084 
00085    void saveToFile(std::string fname);
00086    void saveToFile()
00087    { saveToFile( fileName ); }
00088    
00089    void saveToBMP(std::string fname);
00090    
00091    void use();
00092 
00094    void convertRGBtoBGR();
00095    void invert();
00096    void booleanNot();
00097 
00099    friend std::basic_istream<char, std::char_traits<char> >& operator >>
00100    ( std::basic_istream<char, std::char_traits<char> >& in, GLImage& im)
00101    { in>>im.fileName; im.loadFromFile(); return in;};
00102 
00103    friend std::basic_ostream<char, std::char_traits<char> >& operator <<
00104       ( std::basic_ostream<char, std::char_traits<char> >& out, GLImage& im)
00105    { out<<im.fileName; im.saveToFile(); return out;};
00106 
00107    //TODO
00108    //static methods for loading TGA, PCX, GIF, etc that returns a loaded
00109    //GLImage ready for use
00110 
00111    //TODO
00112    //non-static load method
00113 
00114 
00115 };
00116 #endif

Generated on Wed Feb 4 23:11:33 2004 by doxygen 1.3.3