Panda3D
textureContext.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 textureContext.h
10  * @author drose
11  * @date 1999-10-07
12  */
13 
14 #ifndef TEXTURECONTEXT_H
15 #define TEXTURECONTEXT_H
16 
17 #include "pandabase.h"
18 
19 #include "bufferContext.h"
20 #include "texture.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 texture's internal context identifier.
27  *
28  * Textures typically have an immediate-mode and a retained-mode operation.
29  * When using textures in retained-mode (in response to Texture::prepare()),
30  * the GSG will create some internal handle for the texture and store it here.
31  * The texture stores all of these handles internally.
32  */
33 class EXPCL_PANDA_GOBJ TextureContext : public BufferContext, public AdaptiveLruPage {
34 public:
35  INLINE TextureContext(PreparedGraphicsObjects *pgo, Texture *tex, int view);
36 
37 PUBLISHED:
38  INLINE Texture *get_texture() const;
39  INLINE int get_view() const;
40  virtual uint64_t get_native_id() const;
41  virtual uint64_t get_native_buffer_id() const;
42 
43  INLINE bool was_modified() const;
44  INLINE bool was_properties_modified() const;
45  INLINE bool was_image_modified() const;
46  INLINE bool was_simple_image_modified() const;
47 
48  INLINE UpdateSeq get_properties_modified() const;
49  INLINE UpdateSeq get_image_modified() const;
50  INLINE UpdateSeq get_simple_image_modified() const;
51 
52 public:
53  INLINE void update_data_size_bytes(size_t new_data_size_bytes);
54  INLINE void mark_loaded();
55  INLINE void mark_simple_loaded();
56  INLINE void mark_unloaded();
57  INLINE void mark_needs_reload();
58 
59  virtual void output(std::ostream &out) const;
60  virtual void write(std::ostream &out, int indent_level) const;
61 
62 private:
63  int _view;
64  UpdateSeq _properties_modified;
65  UpdateSeq _image_modified;
66  UpdateSeq _simple_image_modified;
67 
68 public:
69  static TypeHandle get_class_type() {
70  return _type_handle;
71  }
72  static void init_type() {
73  BufferContext::init_type();
74  register_type(_type_handle, "TextureContext",
75  BufferContext::get_class_type());
76  }
77  virtual TypeHandle get_type() const {
78  return get_class_type();
79  }
80  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
81 
82 private:
83  static TypeHandle _type_handle;
84 
85  friend class PreparedGraphicsObjects;
86 };
87 
88 inline std::ostream &operator << (std::ostream &out, const TextureContext &context) {
89  context.output(out);
90  return out;
91 }
92 
93 #include "textureContext.I"
94 
95 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a base class for those kinds of SavedContexts that occupy an easily-measured (and substantial...
Definition: bufferContext.h:38
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:71
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 a special class object that holds all the information returned by a particular GSG to indicat...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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
This is a sequence number that increments monotonically.
Definition: updateSeq.h:37
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.