Panda3D
|
00001 // Filename: dxTextureContext9.h 00002 // Created by: drose (07Oct99) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef DXTEXTURECONTEXT9_H 00016 #define DXTEXTURECONTEXT9_H 00017 00018 #include "dxgsg9base.h" 00019 #include "texture.h" 00020 #include "textureContext.h" 00021 00022 #include "lru.h" 00023 00024 //////////////////////////////////////////////////////////////////// 00025 // Class : DXTextureContext9 00026 // Description : 00027 //////////////////////////////////////////////////////////////////// 00028 class EXPCL_PANDADX DXTextureContext9 : public TextureContext { 00029 public: 00030 DXTextureContext9(PreparedGraphicsObjects *pgo, Texture *tex, int view); 00031 virtual ~DXTextureContext9(); 00032 00033 virtual void evict_lru(); 00034 00035 bool create_texture(DXScreenData &scrn); 00036 bool create_simple_texture(DXScreenData &scrn); 00037 void delete_texture(); 00038 bool extract_texture_data(DXScreenData &scrn); 00039 00040 INLINE bool has_mipmaps() const; 00041 INLINE IDirect3DBaseTexture9 *get_d3d_texture() const; 00042 INLINE IDirect3DTexture9 *get_d3d_2d_texture() const; 00043 INLINE IDirect3DVolumeTexture9 *get_d3d_volume_texture() const; 00044 INLINE IDirect3DCubeTexture9 *get_d3d_cube_texture() const; 00045 00046 static HRESULT d3d_surface_to_texture(RECT &source_rect, 00047 IDirect3DSurface9 *d3d_surface, 00048 bool inverted, Texture *result, 00049 int z); 00050 00051 private: 00052 HRESULT fill_d3d_texture_mipmap_pixels(int mip_level, int depth_index, D3DFORMAT source_format); 00053 HRESULT fill_d3d_texture_pixels(DXScreenData &scrn, bool compress_texture); 00054 HRESULT fill_d3d_volume_texture_pixels(DXScreenData &scrn); 00055 static int down_to_power_2(int value); 00056 unsigned int get_bits_per_pixel(Texture::Format format, int *alphbits); 00057 PN_stdfloat d3d_format_to_bytes_per_pixel (D3DFORMAT format); 00058 00059 private: 00060 D3DFORMAT _d3d_format; // the 'D3DFORMAT' the Panda TextureBuffer fmt corresponds to 00061 IDirect3DBaseTexture9 *_d3d_texture; 00062 IDirect3DTexture9 *_d3d_2d_texture; 00063 IDirect3DVolumeTexture9 *_d3d_volume_texture; 00064 IDirect3DCubeTexture9 *_d3d_cube_texture; 00065 00066 int _managed; 00067 00068 private: 00069 bool _has_mipmaps; 00070 bool _is_render_target; 00071 00072 public: 00073 static TypeHandle get_class_type() { 00074 return _type_handle; 00075 } 00076 static void init_type() { 00077 TextureContext::init_type(); 00078 register_type(_type_handle, "DXTextureContext9", 00079 TextureContext::get_class_type()); 00080 } 00081 virtual TypeHandle get_type() const { 00082 return get_class_type(); 00083 } 00084 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00085 00086 private: 00087 static TypeHandle _type_handle; 00088 00089 friend class wdxGraphicsBuffer9; 00090 }; 00091 00092 #include "dxTextureContext9.I" 00093 00094 #endif