- Your Widget Set For OpenGL
Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | Related Pages

ugl_image.hpp

00001 /*************************************************************************** 00002 LibUFO - UI For OpenGL 00003 copyright : (C) 2001-2005 by Johannes Schmidt 00004 email : schmidtjf at users.sourceforge.net 00005 ------------------- 00006 00007 file : include/ufo/gl/ugl_image.hpp 00008 begin : Sat Oct 18 2003 00009 $Id: ugl_image.hpp,v 1.5 2005/05/21 15:18:46 schmidtjf Exp $ 00010 ***************************************************************************/ 00011 00012 /*************************************************************************** 00013 * This library is free software; you can redistribute it and/or * 00014 * modify it under the terms of the GNU Lesser General Public * 00015 * License as published by the Free Software Foundation; either * 00016 * version 2.1 of the License, or (at your option) any later version. * 00017 * * 00018 * This library is distributed in the hope that it will be useful, * 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00021 * Lesser General Public License for more details. * 00022 * * 00023 * You should have received a copy of the GNU Lesser General Public * 00024 * License along with this library; if not, write to the Free Software * 00025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 00026 ***************************************************************************/ 00027 00028 #ifndef UGL_IMAGE_HPP 00029 #define UGL_IMAGE_HPP 00030 00031 #include "../image/uimage.hpp" 00032 00033 // we need some opengl specific types 00034 #include "../ufo_gl.hpp" 00035 #include "../image/uimageio.hpp" 00036 00037 #include "../util/udimension.hpp" 00038 #include "../util/urectangle.hpp" 00039 00040 namespace ufo { 00041 00051 class UFO_EXPORT UGL_Image : public UImage { 00052 UFO_DECLARE_DYNAMIC_CLASS(UGL_Image) 00053 public: // constructors 00063 UGL_Image(const std::string & fileName, bool lazy = true, bool autoRefresh = true, 00064 GLenum imageFormat = 0, GLenum internalFormat = 0); 00065 00075 UGL_Image(UImageIO * imageIO, bool lazy = true, bool autoRefresh = true, 00076 GLenum imageFormat = 0, GLenum internalFormat = 0); 00077 00078 virtual ~UGL_Image(); 00079 00080 public: // Implements UImage 00081 virtual UDimension getImageSize() const; 00082 virtual int getImageComponents() const; 00083 virtual unsigned long handle() const; 00084 00085 public: // Public methods 00087 UDimension getSize() const; 00088 00090 void paint(UGraphics * g); 00091 00093 void paint(UGraphics * g, const UPoint & location); 00096 void paint(UGraphics * g, const URectangle & rect); 00097 00103 void paintSubImage(UGraphics * g, const URectangle & rect, 00104 const UPoint & dest); 00111 void paintSubImage(UGraphics * g, const URectangle & rect, 00112 const URectangle & dest); 00113 00117 void dispose(); 00121 void disposeGL(); 00122 00124 void refresh(); 00125 00127 void setQuality(int quality); 00128 int getQuality() const; 00129 00130 protected: // Protected methods 00132 virtual bool createGLTexture(GLubyte * dataA, int componentsA, 00133 GLenum imageFormatA, GLenum internalFormatA); 00134 00135 void ensureImage(); 00138 int round2(int n); 00139 00140 private: // Private attributes 00141 GLuint m_index; 00142 GLenum m_imageFormat; 00143 GLenum m_internalFormat; 00145 UDimension m_size; 00146 int m_imageComponents : 4; 00147 int m_quality : 4; 00148 int m_isValid : 1; 00149 int m_isLazy : 1; 00150 int m_autoRefresh : 1; 00151 00153 std::string m_fileName; 00155 UImageIO * m_imageData; 00156 }; 00157 00158 } // namespace ufo 00159 00160 #endif // UGL_IMAGE_HPP

The libUFO Project - written by Johannes Schmidt