00001 #ifndef _MERCURYDISPLAY_D3D_H
00002 #define _MERCURYDISPLAY_D3D_H
00003 #if defined( USE_D3D )
00004
00005 #include "MercuryWindow.h"
00006 #include "Win32Window.h"
00007 #include "MercuryDisplay.h"
00008 #include "MercuryMesh.h"
00009
00010 #include <D3D9.h>
00011
00012 class MercuryDisplay_D3D : public MercuryDisplay
00013 {
00014 public:
00015 MercuryDisplay_D3D();
00016 virtual ~MercuryDisplay_D3D();
00017 virtual bool MakeWindow(const char* title, int width, int height, int bits, bool fullscreenflag);
00018 virtual void Init();
00019 virtual bool BeginFrame();
00020 virtual bool EndFrame();
00021 virtual void DrawParticleField(const MercuryParticleField* field);
00022 virtual void DrawNoGeometry(const MercuryMesh& mesh, DRAWTYPES drawtype);
00023
00024
00025 virtual void SetMaterial(const MercuryMaterial* material);
00026 virtual void RendererInfo();
00027
00028 virtual void ClearZBuffer();
00029 virtual void ClearFrameBuffer(){};
00030 virtual void BeginRenderToDynamicTexture (MercuryTexture* texture){};
00031 virtual void EndRenderToDynamicTexture (){};
00032
00033
00034 virtual void DeleteTextures(int n, unsigned int* textureNames);
00035
00036 virtual void UpdateTextureData(MercuryTexture* texture, unsigned int& ID);
00037 virtual void CreateCache(MercuryTexture* texture, unsigned int& ID);
00038 virtual void CreateCache(RawImageData* data, unsigned int& ID);
00039
00040
00041 virtual void EnablePixelshader ();
00042 virtual void DisablePixelshader ();
00043
00044 virtual void EnableAllLighting();
00045 virtual void DisableAllLighting();
00046
00047 virtual void EnableDepthTest();
00048 virtual void DisableDepthTest();
00049
00050 virtual void Viewport(int x, int y, int width, int height);
00051
00052 virtual void EnableTextures(MercuryMaterial* material);
00053
00054 virtual void ErrorCheck();
00055
00056 virtual void DisableOldLights();
00057
00058 virtual void ReadFrameBuffer(RawImageData& image);
00059
00060 virtual void SendMatrixData(const MercuryMatrix& m);
00061 virtual void SendProjectionMatrixData();
00062
00063 virtual void ToggleZBufferWrite(bool toggle);
00064 virtual void ToggleColorMask(bool toggle);
00065 virtual void ToggleStencilBufferWrite(bool toggle);
00066 virtual void StencilOp(STENCILOPS fail, STENCILOPS zfail, STENCILOPS zpass);
00067 virtual void CullBackface(bool toggle);
00068 virtual void StencilFunc(TFUNCT func, int ref, unsigned int zref);
00069
00070 virtual int CompileShader(MString vertStr, MString fragStr);
00071
00072 virtual void DefineClippingPlanes(const MVector<MQuaternion>& planes);
00073
00074 virtual void RenderTranslucentObject();
00075 virtual void RenderText(const MercuryText& text);
00076 virtual void DrawSprite(const MercuryMesh& sprite);
00077 private:
00078
00079
00080
00081 IDirect3D9 * m_d3d;
00082 D3DPRESENT_PARAMETERS m_PresentParameters;
00083 LPDIRECT3DDEVICE9 m_pDirect3DDevice;
00084 int ConvertDrawType(DRAWTYPES drawtype);
00085 virtual void ProcessLightsInternal( const MercuryLight* light[3], unsigned int count );
00086 void ProcessTexture(const MercuryTexture* texture);
00087
00088 unsigned int m_arrayDrawType;
00089 bool active;
00090
00091
00092 MVector< IDirect3DTexture9 * > m_vSurfaces;
00093 MDeque< int > m_vFreeSurfaces;
00094 void UpdateTextureData(unsigned char*d, int w, int h, ColorBytes vb, unsigned int& ID);
00095 int AllocTex();
00096 };
00097
00098 #endif
00099 #endif
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127