Panda3D
|
00001 // Filename: vertexBufferContext.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 VERTEXBUFFERCONTEXT_H 00016 #define VERTEXBUFFERCONTEXT_H 00017 00018 #include "pandabase.h" 00019 00020 #include "bufferContext.h" 00021 #include "geomVertexArrayData.h" 00022 #include "preparedGraphicsObjects.h" 00023 #include "adaptiveLru.h" 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Class : VertexBufferContext 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 VertexBufferContext : public BufferContext, public AdaptiveLruPage { 00037 public: 00038 INLINE VertexBufferContext(PreparedGraphicsObjects *pgo, 00039 GeomVertexArrayData *data); 00040 00041 PUBLISHED: 00042 INLINE GeomVertexArrayData *get_data() const; 00043 00044 INLINE bool changed_size(const GeomVertexArrayDataHandle *reader) const; 00045 INLINE bool changed_usage_hint(const GeomVertexArrayDataHandle *reader) const; 00046 INLINE bool was_modified(const GeomVertexArrayDataHandle *reader) const; 00047 00048 public: 00049 INLINE void update_data_size_bytes(size_t new_data_size_bytes); 00050 INLINE void mark_loaded(const GeomVertexArrayDataHandle *reader); 00051 INLINE void mark_unloaded(); 00052 00053 virtual void output(ostream &out) const; 00054 virtual void write(ostream &out, int indent_level) const; 00055 00056 private: 00057 // This cannot be a PT(GeomVertexArrayData), because the data and 00058 // the GSG both own their VertexBufferContexts! That would create a 00059 // circular reference count. 00060 GeomVertexArrayData *_data; 00061 GeomEnums::UsageHint _usage_hint; 00062 00063 public: 00064 static TypeHandle get_class_type() { 00065 return _type_handle; 00066 } 00067 static void init_type() { 00068 BufferContext::init_type(); 00069 register_type(_type_handle, "VertexBufferContext", 00070 BufferContext::get_class_type()); 00071 } 00072 virtual TypeHandle get_type() const { 00073 return get_class_type(); 00074 } 00075 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00076 00077 private: 00078 static TypeHandle _type_handle; 00079 00080 friend class PreparedGraphicsObjects; 00081 }; 00082 00083 inline ostream &operator << (ostream &out, const VertexBufferContext &context) { 00084 context.output(out); 00085 return out; 00086 } 00087 00088 #include "vertexBufferContext.I" 00089 00090 #endif 00091