00001 // Filename: textureContext.h 00002 // Created by: drose (07Oct99) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #ifndef TEXTURECONTEXT_H 00020 #define TEXTURECONTEXT_H 00021 00022 #include "pandabase.h" 00023 00024 #include "savedContext.h" 00025 #include "texture.h" 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Class : TextureContext 00029 // Description : This is a special class object that holds all the 00030 // information returned by a particular GSG to indicate 00031 // the texture's internal context identifier. 00032 // 00033 // Textures typically have an immediate-mode and a 00034 // retained-mode operation. When using textures in 00035 // retained-mode (in response to 00036 // Texture::prepare_texture()), the GSG will create some 00037 // internal handle for the texture and store it here. 00038 // The texture stores all of these handles internally. 00039 //////////////////////////////////////////////////////////////////// 00040 class EXPCL_PANDA TextureContext : public SavedContext { 00041 public: 00042 INLINE TextureContext(Texture *tex); 00043 00044 virtual size_t estimate_texture_memory(); 00045 00046 // This cannot be a PT(Texture), because the texture and the GSG 00047 // both own their TextureContexts! That would create a circular 00048 // reference count. 00049 Texture *_texture; 00050 00051 INLINE void mark_dirty(int flags_to_set); 00052 INLINE void clear_dirty_flags(int flags_to_clear = ~0); 00053 INLINE int get_dirty_flags() const; 00054 00055 private: 00056 int _dirty_flags; 00057 00058 00059 public: 00060 static TypeHandle get_class_type() { 00061 return _type_handle; 00062 } 00063 static void init_type() { 00064 SavedContext::init_type(); 00065 register_type(_type_handle, "TextureContext", 00066 SavedContext::get_class_type()); 00067 } 00068 virtual TypeHandle get_type() const { 00069 return get_class_type(); 00070 } 00071 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00072 00073 private: 00074 static TypeHandle _type_handle; 00075 }; 00076 00077 #include "textureContext.I" 00078 00079 #endif 00080