Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TexDX9.h
Go to the documentation of this file.
1 /* Project nGenEx
2  Destroyer Studios LLC
3  Copyright © 1997-2004. All Rights Reserved.
4 
5  SUBSYSTEM: nGenEx.lib
6  FILE: TexDX9.h
7  AUTHOR: John DiCamillo
8 
9 
10  OVERVIEW
11  ========
12  Direct 3D Texture Cache
13 */
14 
15 #ifndef TexDX9_h
16 #define TexDX9_h
17 
18 #include "Bitmap.h"
19 
20 // +--------------------------------------------------------------------+
21 
22 class Video;
23 class VideoDX9;
24 class Bitmap;
25 struct VD3D_texture_format;
26 
27 // +--------------------------------------------------------------------+
28 
30 {
32  last_modified(0), normal(false) { }
33 
34  void Release();
35  void Unload();
36 
37  HANDLE bitmap_id;
38  IDirect3DTexture9* texture;
39  DWORD used_last;
41  bool normal;
42 };
43 
44 // +--------------------------------------------------------------------+
45 
47 {
48 public:
49  TexCacheDX9(VideoDX9* video);
50  virtual ~TexCacheDX9();
51 
52  void FrameNumber(int n) { frame_number = n; }
53  IDirect3DTexture9* FindTexture(Bitmap* bmp);
54  IDirect3DTexture9* FindNormalMap(Bitmap* bmp, float amp=1);
55  bool LoadTexture(Bitmap* bmp, TexCacheDX9Entry* entry);
56  void InvalidateCache();
57 
58  int count;
59 
60 private:
61  int FreeLRU(int tries=4);
62  int FreeUpCache();
63  void CreateNormalMap(int index, float amp=1);
64 
65  VideoDX9* video;
66  IDirect3D9* d3d;
67  IDirect3DDevice9* d3ddevice;
68 
69  DWORD vidmem;
70 
71  int bad_frame;
72  DWORD frame_number;
73 
74  int mru;
75  TexCacheDX9Entry* cache;
76 };
77 
78 #endif // TexDX9_h
79