MercuryDisplay_D3D.h

Go to the documentation of this file.
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         //The following functions are used in managers      
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         //Texture info
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  * Copyright (c) 2006 Joshua Allen
00103  * All rights reserved.
00104  *
00105  * Redistribution and use in source and binary forms, with or
00106  * without modification, are permitted provided that the following
00107  * conditions are met:
00108  *  -   Redistributions of source code must retain the above
00109  *      copyright notice, this list of conditions and the following disclaimer.
00110  *  -   Redistributions in binary form must reproduce the above copyright
00111  *      notice, this list of conditions and the following disclaimer in
00112  *      the documentation and/or other materials provided with the distribution.
00113  *  -   Neither the name of the Mercury Engine nor the names of its
00114  *      contributors may be used to endorse or promote products derived from
00115  *      this software without specific prior written permission.
00116  *
00117  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00118  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00119  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00120  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
00121  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00122  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00123  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00124  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00125  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00126  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00127  */

Hosted by SourceForge.net Logo