00001
00005 #pragma once
00006 #define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
00007 #define CLAMP(p,min,max) { if(p < min) p = min; else if (p>max) p = max; }
00008
00009 #include <D3D10.h>
00010
00011 class D3D
00012 {
00013 private:
00014 static int createRenderTargetViews();
00015 static int findAALevel();
00016 static void commit();
00017
00018
00019 public:
00024 enum TexturePass {PASS_DIFFUSE,PASS_LIGHT,PASS_DETAIL,PASS_FOG,PASS_MACRO,DUMMY_NUM_PASSES};
00025
00032 enum ProjectionMode {PROJ_NORMAL,PROJ_Z_ONLY,PROJ_COMPENSATE_Z_NEAR};
00033
00037 enum Polyflag {FLAG_NO_MSAA = 0x1};
00038
00040 struct Vec2
00041 {
00042 float x,y;
00043 };
00044
00046 struct Vec3
00047 {
00048 float x,y,z;
00049 };
00050
00052 struct Vec4
00053 {
00054 float x,y,z,w;
00055 };
00056
00058 struct Vec4_byte
00059 {
00060 BYTE x,y,z,w;
00061 };
00062
00064 struct Vertex
00065 {
00066 Vec3 Pos;
00067 Vec4 Color;
00068 Vec4 Fog;
00069 Vec3 Normal;
00070 Vec2 TexCoord[D3D::DUMMY_NUM_PASSES];
00071 DWORD flags;
00072 };
00073
00075 struct TextureMetaData
00076 {
00077
00078
00079
00081 FLOAT multU;
00082 FLOAT multV;
00083 bool masked;
00084 };
00085
00087 struct CachedTexture
00088 {
00089 TextureMetaData metadata;
00090 ID3D10ShaderResourceView* resourceView;
00091 };
00092
00094 static struct Options
00095 {
00096 int samples;
00097 int VSync;
00098 int aniso;
00099 int LODBias;
00100 float brightness;
00101 };
00102
00105 static int init(HWND hwnd,D3D::Options &createOptions,const float zNear);
00106 static void uninit();
00107 static int resize(int X, int Y, bool fullScreen);
00109
00112 static void newFrame();
00113 static void clear(D3D::Vec4& clearColor);
00114 static void clearDepth();
00116
00119 static void map(bool clear);
00120 static void render();
00121 static void present();
00123
00126 static void indexTriangleFan(int num);
00127 static void indexQuad();
00128 static D3D::Vertex* getVertex();
00130
00133 static void setViewPort(int X, int Y, int left, int top);
00134 static void setProjectionMode(D3D::ProjectionMode mode);
00135 static void setProjection(float aspect, float XoverZ);
00136 static void setFlags(int flags, int d3dflags);
00138
00141 static ID3D10Texture2D *createTexture(D3D10_TEXTURE2D_DESC &desc, D3D10_SUBRESOURCE_DATA &data);
00142 static void updateMip(DWORD64 id,int mipNum,D3D10_SUBRESOURCE_DATA &data);
00143 static void cacheTexture(DWORD64 id,TextureMetaData &metadata,ID3D10Texture2D *tex);
00144 static bool textureIsCached(DWORD64 id);
00145 static D3D::TextureMetaData &getTextureMetaData(DWORD64 id);
00146 static D3D::TextureMetaData *setTexture(D3D::TexturePass pass,DWORD64 id);
00147 static void deleteTexture(DWORD64 id);
00148 static void flush();
00150
00153 static void flash(bool enable,D3D::Vec4 &color);
00154 static void fog(float dist, D3D::Vec4 *color);
00155 static TCHAR *getModes();
00156 static void getScreenshot(D3D::Vec4_byte* buf);
00157 static void setBrightness(float brightness);
00159 };