Panda3D
|
00001 // Filename: indexBufferContext.h 00002 // Created by: drose (17Mar05) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef INDEXBUFFERCONTEXT_H 00016 #define INDEXBUFFERCONTEXT_H 00017 00018 #include "pandabase.h" 00019 00020 #include "bufferContext.h" 00021 #include "geomPrimitive.h" 00022 #include "preparedGraphicsObjects.h" 00023 #include "adaptiveLru.h" 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Class : IndexBufferContext 00027 // Description : This is a special class object that holds all the 00028 // information returned by a particular GSG to indicate 00029 // the vertex data array's internal context identifier. 00030 // 00031 // This allows the GSG to cache the vertex data array in 00032 // whatever way makes sense. For instance, DirectX can 00033 // allocate a vertex buffer for the array. OpenGL can 00034 // create a buffer object. 00035 //////////////////////////////////////////////////////////////////// 00036 class EXPCL_PANDA_GOBJ IndexBufferContext : public BufferContext, public AdaptiveLruPage { 00037 public: 00038 INLINE IndexBufferContext(PreparedGraphicsObjects *pgo, GeomPrimitive *data); 00039 00040 PUBLISHED: 00041 INLINE GeomPrimitive *get_data() const; 00042 00043 INLINE bool changed_size(const GeomPrimitivePipelineReader *reader) const; 00044 INLINE bool changed_usage_hint(const GeomPrimitivePipelineReader *reader) const; 00045 INLINE bool was_modified(const GeomPrimitivePipelineReader *reader) const; 00046 00047 public: 00048 INLINE void update_data_size_bytes(size_t new_data_size_bytes); 00049 INLINE void mark_loaded(const GeomPrimitivePipelineReader *reader); 00050 INLINE void mark_unloaded(); 00051 00052 virtual void output(ostream &out) const; 00053 virtual void write(ostream &out, int indent_level) const; 00054 00055 private: 00056 // This cannot be a PT(GeomPrimitive), because the data and 00057 // the GSG both own their IndexBufferContexts! That would create a 00058 // circular reference count. 00059 GeomPrimitive *_data; 00060 GeomEnums::UsageHint _usage_hint; 00061 00062 public: 00063 static TypeHandle get_class_type() { 00064 return _type_handle; 00065 } 00066 static void init_type() { 00067 BufferContext::init_type(); 00068 register_type(_type_handle, "IndexBufferContext", 00069 BufferContext::get_class_type()); 00070 } 00071 virtual TypeHandle get_type() const { 00072 return get_class_type(); 00073 } 00074 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00075 00076 private: 00077 static TypeHandle _type_handle; 00078 00079 friend class PreparedGraphicsObjects; 00080 }; 00081 00082 inline ostream &operator << (ostream &out, const IndexBufferContext &context) { 00083 context.output(out); 00084 return out; 00085 } 00086 00087 #include "indexBufferContext.I" 00088 00089 #endif 00090