Panda3D
 All Classes Functions Variables Enumerations
indexBufferContext.h
1 // Filename: indexBufferContext.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 INDEXBUFFERCONTEXT_H
16 #define INDEXBUFFERCONTEXT_H
17 
18 #include "pandabase.h"
19 
20 #include "bufferContext.h"
21 #include "geomPrimitive.h"
22 #include "preparedGraphicsObjects.h"
23 #include "adaptiveLru.h"
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : IndexBufferContext
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 IndexBufferContext : public BufferContext, public AdaptiveLruPage {
37 public:
39 
40 PUBLISHED:
41  INLINE GeomPrimitive *get_data() const;
42 
43  INLINE bool changed_size(const GeomPrimitivePipelineReader *reader) const;
44  INLINE bool changed_usage_hint(const GeomPrimitivePipelineReader *reader) const;
45  INLINE bool was_modified(const GeomPrimitivePipelineReader *reader) const;
46 
47 public:
48  INLINE void update_data_size_bytes(size_t new_data_size_bytes);
49  INLINE void mark_loaded(const GeomPrimitivePipelineReader *reader);
50  INLINE void mark_unloaded();
51 
52  virtual void output(ostream &out) const;
53  virtual void write(ostream &out, int indent_level) const;
54 
55 private:
56  // This cannot be a PT(GeomPrimitive), because the data and
57  // the GSG both own their IndexBufferContexts! That would create a
58  // circular reference count.
59  GeomPrimitive *_data;
60  GeomEnums::UsageHint _usage_hint;
61 
62 public:
63  static TypeHandle get_class_type() {
64  return _type_handle;
65  }
66  static void init_type() {
67  BufferContext::init_type();
68  register_type(_type_handle, "IndexBufferContext",
69  BufferContext::get_class_type());
70  }
71  virtual TypeHandle get_type() const {
72  return get_class_type();
73  }
74  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
75 
76 private:
77  static TypeHandle _type_handle;
78 
79  friend class PreparedGraphicsObjects;
80 };
81 
82 inline ostream &operator << (ostream &out, const IndexBufferContext &context) {
83  context.output(out);
84  return out;
85 }
86 
87 #include "indexBufferContext.I"
88 
89 #endif
90 
This is a special class object that holds all the information returned by a particular GSG to indicat...
This is a base class for those kinds of SavedContexts that occupy an easily-measured (and substantial...
Definition: bufferContext.h:41
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
Definition: geomPrimitive.h:63
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
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
Encapsulates the data from a GeomPrimitive, pre-fetched for one stage of the pipeline.