00001 #pragma once 00002 00003 class Shader; 00004 00005 #include <d3d10.h> 00006 #include <d3dx10.h> 00007 #include "d3d10drv.h" 00008 #include "geometrybuffer.h" 00009 00010 class Shader 00011 { 00012 protected: 00013 GeometryBuffer* geometryBuffer; 00014 ID3D10RenderTargetView* renderTargetView; 00015 ID3D10DepthStencilView* depthStencilView; 00016 ID3D10InputLayout* vertexLayout; 00017 ID3D10ShaderResourceView* shaderResourceView; 00018 ID3D10Blob* blob; 00019 ID3D10Device *device; 00020 ID3D10Effect* effect; 00021 D3D10_PRIMITIVE_TOPOLOGY topology; 00022 HRESULT hr; 00023 00024 bool checkCompileResult(HRESULT hr) const; 00025 bool createRenderTargetViews(DXGI_FORMAT format, DXGI_FORMAT depthFormat,float scaleX, float scaleY, int samples, const DXGI_SWAP_CHAIN_DESC &swapChainDesc); 00026 00027 00028 public: 00029 Shader(ID3D10Device *device); 00030 virtual bool compile(const D3D10_SHADER_MACRO *macros, DWORD shaderFlags)=0; 00031 virtual bool createRenderTargetViews(ID3D10RenderTargetView *backbuffer, const DXGI_SWAP_CHAIN_DESC &swapChainDesc, int multiSampleCount)=0; 00032 virtual void releaseRenderTargetViews(); 00033 virtual ~Shader(); 00034 virtual void bind(); 00035 virtual void apply(); 00036 GeometryBuffer *getGeometryBuffer() const; 00037 ID3D10ShaderResourceView *getResourceView() const; 00038 };