Panda3D
dxTextureContext9.h
1 // Filename: dxTextureContext9.h
2 // Created by: drose (07Oct99)
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 DXTEXTURECONTEXT9_H
16 #define DXTEXTURECONTEXT9_H
17 
18 #include "dxgsg9base.h"
19 #include "texture.h"
20 #include "textureContext.h"
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : DXTextureContext9
24 // Description :
25 ////////////////////////////////////////////////////////////////////
26 class EXPCL_PANDADX DXTextureContext9 : public TextureContext {
27 public:
29  virtual ~DXTextureContext9();
30 
31  virtual void evict_lru();
32 
33  bool create_texture(DXScreenData &scrn);
34  bool create_simple_texture(DXScreenData &scrn);
35  void delete_texture();
36  bool extract_texture_data(DXScreenData &scrn);
37 
38  INLINE bool has_mipmaps() const;
39  INLINE IDirect3DBaseTexture9 *get_d3d_texture() const;
40  INLINE IDirect3DTexture9 *get_d3d_2d_texture() const;
41  INLINE IDirect3DVolumeTexture9 *get_d3d_volume_texture() const;
42  INLINE IDirect3DCubeTexture9 *get_d3d_cube_texture() const;
43 
44  static HRESULT d3d_surface_to_texture(RECT &source_rect,
45  IDirect3DSurface9 *d3d_surface,
46  bool inverted, Texture *result,
47  int view, int z);
48 
49 private:
50  HRESULT fill_d3d_texture_mipmap_pixels(int mip_level, int depth_index, D3DFORMAT source_format);
51  HRESULT fill_d3d_texture_pixels(DXScreenData &scrn, bool compress_texture);
52  HRESULT fill_d3d_volume_texture_pixels(DXScreenData &scrn);
53  static int down_to_power_2(int value);
54  unsigned int get_bits_per_pixel(Texture::Format format, int *alphbits);
55  PN_stdfloat d3d_format_to_bytes_per_pixel (D3DFORMAT format);
56 
57 private:
58  D3DFORMAT _d3d_format; // the 'D3DFORMAT' the Panda TextureBuffer fmt corresponds to
59  IDirect3DBaseTexture9 *_d3d_texture;
60  IDirect3DTexture9 *_d3d_2d_texture;
61  IDirect3DVolumeTexture9 *_d3d_volume_texture;
62  IDirect3DCubeTexture9 *_d3d_cube_texture;
63 
64  int _managed;
65 
66 private:
67  bool _has_mipmaps;
68  bool _is_render_target;
69 
70 public:
71  static TypeHandle get_class_type() {
72  return _type_handle;
73  }
74  static void init_type() {
75  TextureContext::init_type();
76  register_type(_type_handle, "DXTextureContext9",
77  TextureContext::get_class_type());
78  }
79  virtual TypeHandle get_type() const {
80  return get_class_type();
81  }
82  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
83 
84 private:
85  static TypeHandle _type_handle;
86 
87  friend class wdxGraphicsBuffer9;
88 };
89 
90 #include "dxTextureContext9.I"
91 
92 #endif
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:75
This is a special class object that holds all the information returned by a particular GSG to indicat...
virtual void evict_lru()
Evicts the page from the LRU.
A table of objects that are saved within the graphics context for reference by handle later...
An offscreen render buffer.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85