Panda3D
Loading...
Searching...
No Matches
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 */
33class EXPCL_PANDA_GOBJ IndexBufferContext : public BufferContext, public AdaptiveLruPage {
34public:
35 INLINE IndexBufferContext(PreparedGraphicsObjects *pgo, GeomPrimitive *data);
36
37PUBLISHED:
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
44public:
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
52private:
53 GeomEnums::UsageHint _usage_hint;
54
55public:
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
69private:
70 static TypeHandle _type_handle;
71
72 friend class PreparedGraphicsObjects;
73};
74
75inline 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.
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.
Encapsulates the data from a GeomPrimitive, pre-fetched for one stage of the pipeline.
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
This is a special class object that holds all the information returned by a particular GSG to indicat...
void mark_unloaded()
Should be called after the buffer has been forced out of graphics memory.
bool changed_usage_hint(const GeomPrimitivePipelineReader *reader) const
Returns true if the data has changed its usage hint since the last time mark_loaded() was called.
bool changed_size(const GeomPrimitivePipelineReader *reader) const
Returns true if the data has changed size since the last time mark_loaded() was called.
void mark_loaded(const GeomPrimitivePipelineReader *reader)
Should be called after the IndexBufferContext has been loaded into graphics memory,...
bool was_modified(const GeomPrimitivePipelineReader *reader) const
Returns true if the data has been modified since the last time mark_loaded() was called.
GeomPrimitive * get_data() const
Returns the pointer to the client-side array data object.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...