Panda3D
 All Classes Functions Variables Enumerations
vertexBufferContext.h
1 // Filename: vertexBufferContext.h
2 // Created by: drose (17Mar05)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef VERTEXBUFFERCONTEXT_H
16 #define VERTEXBUFFERCONTEXT_H
17 
18 #include "pandabase.h"
19 
20 #include "bufferContext.h"
21 #include "geomVertexArrayData.h"
22 #include "preparedGraphicsObjects.h"
23 #include "adaptiveLru.h"
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : VertexBufferContext
27 // Description : This is a special class object that holds all the
28 // information returned by a particular GSG to indicate
29 // the vertex data array's internal context identifier.
30 //
31 // This allows the GSG to cache the vertex data array in
32 // whatever way makes sense. For instance, DirectX can
33 // allocate a vertex buffer for the array. OpenGL can
34 // create a buffer object.
35 ////////////////////////////////////////////////////////////////////
36 class EXPCL_PANDA_GOBJ VertexBufferContext : public BufferContext, public AdaptiveLruPage {
37 public:
39  GeomVertexArrayData *data);
40 
41 PUBLISHED:
42  INLINE GeomVertexArrayData *get_data() const;
43 
44  INLINE bool changed_size(const GeomVertexArrayDataHandle *reader) const;
45  INLINE bool changed_usage_hint(const GeomVertexArrayDataHandle *reader) const;
46  INLINE bool was_modified(const GeomVertexArrayDataHandle *reader) const;
47 
48 public:
49  INLINE void update_data_size_bytes(size_t new_data_size_bytes);
50  INLINE void mark_loaded(const GeomVertexArrayDataHandle *reader);
51  INLINE void mark_unloaded();
52 
53  virtual void output(ostream &out) const;
54  virtual void write(ostream &out, int indent_level) const;
55 
56 private:
57  // This cannot be a PT(GeomVertexArrayData), because the data and
58  // the GSG both own their VertexBufferContexts! That would create a
59  // circular reference count.
60  GeomVertexArrayData *_data;
61  GeomEnums::UsageHint _usage_hint;
62 
63 public:
64  static TypeHandle get_class_type() {
65  return _type_handle;
66  }
67  static void init_type() {
68  BufferContext::init_type();
69  register_type(_type_handle, "VertexBufferContext",
70  BufferContext::get_class_type());
71  }
72  virtual TypeHandle get_type() const {
73  return get_class_type();
74  }
75  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
76 
77 private:
78  static TypeHandle _type_handle;
79 
80  friend class PreparedGraphicsObjects;
81 };
82 
83 inline ostream &operator << (ostream &out, const VertexBufferContext &context) {
84  context.output(out);
85  return out;
86 }
87 
88 #include "vertexBufferContext.I"
89 
90 #endif
91 
This is a base class for those kinds of SavedContexts that occupy an easily-measured (and substantial...
Definition: bufferContext.h:41
This data object is returned by GeomVertexArrayData::get_handle() or modify_handle().
A table of objects that are saved within the graphics context for reference by handle later...
void update_data_size_bytes(size_t new_data_size_bytes)
Should be called (usually by a derived class) when the on-card size of this object has changed...
One atomic piece that may be managed by a AdaptiveLru chain.
Definition: adaptiveLru.h:145
This is a special class object that holds all the information returned by a particular GSG to indicat...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
This is the data for one array of a GeomVertexData structure.