Panda3D
indexBufferContext.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file indexBufferContext.h
10  * @author drose
11  * @date 2005-03-17
12  */
13 
14 #ifndef INDEXBUFFERCONTEXT_H
15 #define INDEXBUFFERCONTEXT_H
16 
17 #include "pandabase.h"
18 
19 #include "bufferContext.h"
20 #include "geomPrimitive.h"
22 #include "adaptiveLru.h"
23 
24 /**
25  * This is a special class object that holds all the information returned by a
26  * particular GSG to indicate the vertex data array's internal context
27  * identifier.
28  *
29  * This allows the GSG to cache the vertex data array in whatever way makes
30  * sense. For instance, DirectX can allocate a vertex buffer for the array.
31  * OpenGL can create a buffer object.
32  */
33 class EXPCL_PANDA_GOBJ IndexBufferContext : public BufferContext, public AdaptiveLruPage {
34 public:
36 
37 PUBLISHED:
38  INLINE GeomPrimitive *get_data() const;
39 
40  INLINE bool changed_size(const GeomPrimitivePipelineReader *reader) const;
41  INLINE bool changed_usage_hint(const GeomPrimitivePipelineReader *reader) const;
42  INLINE bool was_modified(const GeomPrimitivePipelineReader *reader) const;
43 
44 public:
45  INLINE void update_data_size_bytes(size_t new_data_size_bytes);
46  INLINE void mark_loaded(const GeomPrimitivePipelineReader *reader);
47  INLINE void mark_unloaded();
48 
49  virtual void output(std::ostream &out) const;
50  virtual void write(std::ostream &out, int indent_level) const;
51 
52 private:
53  GeomEnums::UsageHint _usage_hint;
54 
55 public:
56  static TypeHandle get_class_type() {
57  return _type_handle;
58  }
59  static void init_type() {
60  BufferContext::init_type();
61  register_type(_type_handle, "IndexBufferContext",
62  BufferContext::get_class_type());
63  }
64  virtual TypeHandle get_type() const {
65  return get_class_type();
66  }
67  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
68 
69 private:
70  static TypeHandle _type_handle;
71 
72  friend class PreparedGraphicsObjects;
73 };
74 
75 inline std::ostream &operator << (std::ostream &out, const IndexBufferContext &context) {
76  context.output(out);
77  return out;
78 }
79 
80 #include "indexBufferContext.I"
81 
82 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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:38
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
Definition: geomPrimitive.h:56
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:135
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Encapsulates the data from a GeomPrimitive, pre-fetched for one stage of the pipeline.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.