00001 #ifndef WXD3D_H
00002 #define WXD3D_H
00003 
00004 #include "../Base/WXComBase.h"
00005 #include "../Base/WXError.h"
00006 #include <WinBasis/WBWindowMan.h>
00007 #include <Base/Affine.h>
00008 
00009 #if SPR_DXVER==9    //  see WXComBase.h
00010 # include <d3d9.h>
00011 # define D3DVIEWPORT_SPR    D3DVIEWPORT9
00012 # define D3DMATERIAL_SPR    D3DMATERIAL9
00013 # define D3DLIGHT_SPR       D3DLIGHT9
00014 
00015 #elif SPR_DXVER==8
00016 # include <d3d8.h>
00017 # define D3DVIEWPORT_SPR    D3DVIEWPORT8
00018 # define D3DMATERIAL_SPR    D3DMATERIAL8
00019 # define D3DLIGHT_SPR       D3DLIGHT8
00020 
00021 #endif
00022 
00023 #include <dxfile.h>
00024 namespace Spr{;
00025 
00026 
00027 class SPR_DLL WXD3D:public WXSINGLETONV(Direct3D){
00028     IUnknown* Create();
00029 public:
00030     WXD3D();
00031 };
00032 class SPR_DLL WXD3DPresentParameters:public D3DPRESENT_PARAMETERS{
00033 public:
00034     WXD3DPresentParameters();
00035     void Window(int adaptor=0, int width=0, int height=0);
00036     void Fullscreen(int adaptor=0);
00037 };
00038 
00039 
00040 class SPR_DLL WXD3DDevice:public WXINTFV(Direct3DDevice){
00041 protected:
00042     bool bCanDraw;
00043     bool bFullscreen;
00044     bool bInit;
00045 public:
00046 
00047     WXD3DPresentParameters presentParameters;
00048 
00049     HWND hFocusWindow;
00050 
00051     WBWindowMan winMan;
00052 
00053 
00054     WXD3DDevice(){
00055         bInit = false;
00056         hFocusWindow=NULL;
00057         presentParameters.Window();
00058         bCanDraw = false;
00059         bFullscreen = false;
00060     }
00061 
00062 
00063 
00064     bool Create(HWND hw,
00065         UINT adapter=D3DADAPTER_DEFAULT, D3DDEVTYPE deviceType=D3DDEVTYPE_HAL,
00066         DWORD behaviorFlags=D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_FPU_PRESERVE);
00067 
00068     Vec2f GetSurfaceSize();
00069 
00070     Vec2f GetViewportSize();
00071 
00072     bool SetViewport(Vec2f sz, Vec2f pos=Vec2f(), float minZ=0.0f, float maxZ=1.0f);
00073     bool SetViewport(HWND hw);
00074 
00075     bool Resize(Vec2f size, HWND wnd=NULL);
00076 
00077     bool Clear(DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil);
00078 
00079     bool Present(CONST RECT* pSourceRect=NULL, CONST RECT* pDestRect=NULL, HWND hDestWindowOverride=NULL, CONST RGNDATA* pDirtyRegion=NULL);
00080 
00081     
00082 
00083     bool IsFullscreen(){ return bFullscreen; }
00084 
00085     void Fullscreen();
00086 
00087     void Window();
00088 
00089     bool CanDraw(){ return bCanDraw; }
00090 
00091     void BeginScene();
00092 
00093     void EndScene();
00094 };
00095 
00096 
00097 class SPR_DLL WXDXFile: public WXSingletonInterface<IDirectXFile, &IID_IDirectXFile>{
00098     IUnknown* Create();
00099 public:
00100     WXDXFile();
00101 };
00102 
00103 }
00104 
00105 #endif