00001 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- 00002 00003 this file is part of rcssserver3D 00004 Fri May 9 2003 00005 Copyright (C) 2002,2003 Koblenz University 00006 Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group 00007 $Id: texture.h,v 1.3 2003/11/14 14:05:52 fruit Exp $ 00008 00009 This program is free software; you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation; version 2 of the License. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program; if not, write to the Free Software 00020 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00021 */ 00022 #ifndef KEROSIN_TEXTURE_H 00023 #define KEROSIN_TEXTURE_H 00024 00025 #include <boost/weak_ptr.hpp> 00026 #include <boost/shared_ptr.hpp> 00027 00028 namespace kerosin 00029 { 00030 00031 class TextureServer; 00032 00033 /* \class Texture 00034 00035 This is the base class of all OpenGL based textures. In OpenGL a texture 00036 is represented by a so-called texture ID. This is a simple handle. The 00037 basic operations for creating/deleting this handle are contained in this 00038 class. 00039 00040 Usually, textures are created via the texture server. 00041 00042 NOTE: 00043 00044 HISTORY: 00045 14.10.02 - MK 00046 - Initial version 00047 00048 TODO: 00049 - support mipmap building (currently done only when SGIS_generate_mipmap is supported) 00050 00051 TOFIX: 00052 */ 00053 class Texture 00054 { 00055 // 00056 // functions 00057 // 00058 public: 00059 Texture(const boost::shared_ptr<TextureServer> &textureServer); 00060 virtual ~Texture(); 00061 00063 void Reset(); 00064 00066 void Acquire(); 00067 00069 virtual void Bind() const = 0; 00071 virtual void Enable() const = 0; 00073 virtual void Disable() const = 0; 00074 virtual void Clamp() const = 0; 00075 virtual void ClampToEdge() const = 0; 00076 virtual void Repeat() const = 0; 00077 00078 // accessors 00079 unsigned int GetWidth() const; 00080 unsigned int GetHeight() const; 00081 00082 boost::shared_ptr<TextureServer> GetTextureServer() const; 00083 // 00084 // members 00085 // 00086 protected: 00087 unsigned int mTexID; // OpenGL texture handle (initialized to 0) 00088 unsigned int mWidth; // width of texture 00089 unsigned int mHeight; // height of texture 00090 private: 00091 boost::weak_ptr<TextureServer> mTextureServer; // texture server, which created this object 00092 }; 00093 00094 } 00095 00096 #endif //KEROSIN_TEXTURE_H