00001
00002
00003
00004
00005
00006
00007
00008
00009
00020
00021
00022 #ifndef DIRECTX10_VIEW_H
00023 #define DIRECTX10_VIEW_H
00024
00025
00026 #include <d3d10.h>
00027 #include <d3dx10.h>
00028 #include <d3dx10tex.h>
00029 #include <SIBCArray.h>
00030 #include <iostream>
00031 #include <fstream>
00032
00033 struct SimpleVertex
00034 {
00035 D3DXVECTOR3 Pos;
00036 };
00037
00038
00039
00040 typedef struct tagDX10View_PhatVertex
00041 {
00042 XSI_RTS_Vector3 m_Pos;
00043 XSI_RTS_Vector3 m_Normal;
00044 XSI_RTS_ColorRGBAf m_Col[2];
00045 XSI_RTS_Vector4 m_TC[8];
00046 } DX10View_PhatVertex;
00047
00048 #define PhatVertexLayoutNumElems 12
00049 static D3D10_INPUT_ELEMENT_DESC PhatVertexLayout[PhatVertexLayoutNumElems] =
00050 {
00051 { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, (12*0) + (16*0), D3D10_INPUT_PER_VERTEX_DATA, 0 },
00052 { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, (12*1) + (16*0), D3D10_INPUT_PER_VERTEX_DATA, 0 },
00053 { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, (12*2) + (16*0), D3D10_INPUT_PER_VERTEX_DATA, 0 },
00054 { "COLOR", 1, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, (12*2) + (16*1), D3D10_INPUT_PER_VERTEX_DATA, 0 },
00055 { "TEXCOORD", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, (12*2) + (16*2), D3D10_INPUT_PER_VERTEX_DATA, 0 },
00056 { "TEXCOORD", 1, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, (12*2) + (16*3), D3D10_INPUT_PER_VERTEX_DATA, 0 },
00057 { "TEXCOORD", 2, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, (12*2) + (16*4), D3D10_INPUT_PER_VERTEX_DATA, 0 },
00058 { "TEXCOORD", 3, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, (12*2) + (16*5), D3D10_INPUT_PER_VERTEX_DATA, 0 },
00059 { "TEXCOORD", 4, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, (12*2) + (16*6), D3D10_INPUT_PER_VERTEX_DATA, 0 },
00060 { "TEXCOORD", 5, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, (12*2) + (16*7), D3D10_INPUT_PER_VERTEX_DATA, 0 },
00061 { "TEXCOORD", 6, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, (12*2) + (16*8), D3D10_INPUT_PER_VERTEX_DATA, 0 },
00062 { "TEXCOORD", 7, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, (12*2) + (16*9), D3D10_INPUT_PER_VERTEX_DATA, 0 }
00063 };
00064
00065 typedef struct tagDX10View_TexCoordMap
00066 {
00067 int nbActiveUVs;
00068 int target[256];
00069 int UVSet[256];
00070 } DX10View_TexCoordMap;
00071
00072
00073 #define NB_VTX_BUFFERS 8
00074 #define VTX_BUFFER_SIZE 49152
00075
00076
00087 typedef struct tagDX10ViewGlobals
00088 {
00089
00090
00091
00093 HWND m_hwnd;
00094 HWND m_ParentHwnd;
00095 RECT m_ParentRect;
00096 WNDCLASSEX m_wc;
00097 HINSTANCE m_hInst;
00098
00099
00100
00101
00103 ID3D10Device* m_pd3dDevice;
00104 IDXGISwapChain* m_pSwapChain;
00105 ID3D10RenderTargetView* m_pRenderTargetView;
00106 ID3D10DepthStencilView* m_pDSView;
00107 IDXGIFactory* m_pFactory;
00108
00109
00110
00111
00113 ID3D10Effect* m_pEffect;
00114 ID3D10EffectTechnique* m_pTechnique;
00115 ID3D10InputLayout* m_pGridVertexLayout;
00116 ID3D10Buffer* m_pGridVertexBuffer;
00117
00118
00119
00120
00122 ID3DX10Font* m_pFont;
00123 ID3DX10Sprite* m_pSprite;
00124 ID3D10BlendState* m_pFontBlendState;
00125
00126
00127
00128
00130 ID3D10BlendState* m_pDefaultBlendState;
00131 ID3D10RasterizerState* m_pDefaultRasterizerState;
00132 ID3D10EffectMatrixVariable* m_pProjectionMatrix;
00133 ID3D10EffectMatrixVariable* m_pModelMatrix;
00134 ID3D10EffectMatrixVariable* m_pViewMatrix;
00135
00136
00137
00138
00140 BYTE* m_pIACurrentInputSignature;
00141 SIZE_T m_nIACurrentInputSignatureSize;
00142 ID3D10Buffer* m_pCurrentVertexBuffer[NB_VTX_BUFFERS];
00143 int m_nCurrentVertexBufferSize;
00144 int m_nCurrentVertexBufferId;
00145 ID3D10ShaderReflection* m_pCurrentGS;
00146 ID3D10ShaderReflection* m_pCurrentVS;
00147 ID3D10ShaderReflection* m_pCurrentPS;
00148
00149
00150
00151
00153 DX10View_TexCoordMap m_TexCoordMap;
00154 XSI_RTS_FXSemantics m_Semantics;
00155
00156 } DX10ViewGlobals;
00157
00158
00159
00160
00196
00197
00198
00199 #define RELEASE( ptr ) \
00200 { if( ptr ) { if(ptr->Release() > 0) assert(0); ptr = NULL; } }
00201
00202 #define SAFE_RELEASE( ptr ) \
00203 { if( ptr ) ptr->Release(); }
00204
00205 #define NULLPTR( ptr ) \
00206 { ptr = NULL; }
00207
00208 RTSHADER_API void DX10View_Printf(XSI::siSeverityType in_lErrCode, wchar_t *in_pFormat, ...);
00209
00210
00211
00212
00222 RTSHADER_API DX10ViewGlobals* DX10View_GetContext();
00223
00224
00225
00226
00235 RTSHADER_API HRESULT DX10View_IsSupported();
00236
00249 RTSHADER_API HRESULT DX10View_Initialize();
00250
00266 RTSHADER_API HWND DX10View_InitializeWindow(HWND hWnd);
00267
00287 RTSHADER_API HRESULT DX10View_InitViewport(int x, int y, int width, int height);
00288
00298 RTSHADER_API void DX10View_Cleanup();
00299
00300
00301
00302
00303
00321 RTSHADER_API void DX10View_BeginRender(float red, float green, float blue);
00322
00335 RTSHADER_API void DX10View_SetInitialState();
00336
00348 RTSHADER_API void DX10View_EndRender();
00349
00350
00351
00352
00353 RTSHADER_API void DX10View_Display(wchar_t *in_pString);
00354 RTSHADER_API void DX10View_DrawGrid();
00355
00381 RTSHADER_API bool DX10View_DrawGeometry
00382 (
00383 XSI_RTS_Primitive *in_pPrimitive,
00384 void *in_pAttributes,
00385 XSI_RTS_Attribute_Size *in_pAttributesSize,
00386
00387 bool in_bNormals,
00388 bool in_bColors,
00389 bool in_bUVs,
00390 DX10View_TexCoordMap* in_pTexCoordMap
00391 );
00392
00393
00394
00395
00396
00413 RTSHADER_API HRESULT DX10View_UploadTexture1D(XSI_RTS_Texture* in_pImage, ID3D10Texture1D** out_pT1d, ID3D10ShaderResourceView** out_pTView);
00414
00431 RTSHADER_API HRESULT DX10View_UploadTexture2D(XSI_RTS_Texture* in_pImage, ID3D10Texture2D** out_pT2d, ID3D10ShaderResourceView** out_pTView);
00432
00449 RTSHADER_API HRESULT DX10View_UploadTexture3D(XSI_RTS_Texture* in_pImage, ID3D10Texture3D** out_pT3d, ID3D10ShaderResourceView** out_pTView);
00450
00467 RTSHADER_API HRESULT DX10View_UploadTextureCube(XSI_RTS_Texture* in_pImage, ID3D10Texture2D** out_pTCube, ID3D10ShaderResourceView** out_pTView);
00468
00469 extern "C" RTSHADER_API void* GetInterface();
00470
00471
00472 #endif // DIRECTX10_VIEW_H