123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- #pragma once
- #include "Vec2.h"
- #include "Mat4.h"
- #include "Ebene3D.h"
- #include "Bildschirm.h"
- // DirectX 12 Types
- struct ID3D12Debug;
- struct ID3D12Device2;
- struct ID3D12InfoQueue;
- struct ID3D12CommandQueue;
- struct IDXGISwapChain4;
- struct ID3D12DescriptorHeap;
- struct ID3D12Resource;
- struct ID3D12CommandAllocator;
- struct ID3D12GraphicsCommandList;
- struct ID3D12Fence;
- struct D3D12_VIEWPORT;
- struct D3D12_VERTEX_BUFFER_VIEW;
- struct D3D12_INDEX_BUFFER_VIEW;
- struct ID3D12RootSignature;
- struct ID3D12PipelineState;
- // DirectX 11 Types
- struct ID3D11Device;
- struct ID3D11DeviceContext;
- struct IDXGISwapChain;
- struct ID3D11Texture2D;
- struct ID3D11SamplerState;
- struct ID3D11ShaderResourceView;
- struct ID3D11RenderTargetView;
- struct ID3D11DepthStencilView;
- struct ID3D11DepthStencilState;
- struct ID3D11RasterizerState;
- struct ID3D11BlendState;
- struct D3D11_VIEWPORT;
- // DirectX 9 Types
- struct IDirect3D9;
- struct IDirect3DDevice9;
- struct IDirect3DSurface9;
- struct _D3DLOCKED_RECT;
- struct tagRECT;
- namespace Framework
- {
- class WFenster;
- class Bild;
- class Textur;
- class DX11PixelShader;
- class DX11VertexShader;
- class TexturModel;
- class Render3D;
- class TexturList;
- class Kam3D;
- class Model3D;
- class DX11Buffer;
- class DX11StructuredBuffer;
- class DX12Buffer;
- class DX12DirectCommandQueue;
- class DX12CopyCommandQueue;
- class DX12ComputeCommandQueue;
- class DX12PixelShader;
- class DX12VertexShader;
- class DX12VertexBuffer;
- class DX12IndexBuffer;
- enum GraphicApiType;
- struct DiffuseLight
- {
- Vec3<float> direction;
- Vec3<float> color;
- };
- struct PointLight
- {
- Vec3<float> position;
- Vec3<float> color;
- float radius;
- };
- class GraphicsApi
- {
- protected:
- GraphicApiType typ;
- WFenster *fenster;
- Vec2<int> backBufferSize;
- bool fullScreen;
- private:
- int ref;
- public:
- __declspec( dllexport ) GraphicsApi( GraphicApiType typ );
- __declspec( dllexport ) virtual ~GraphicsApi();
- __declspec( dllexport ) virtual void initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fullScreen );
- __declspec( dllexport ) virtual void setBackBufferSize( Vec2< int > size );
- __declspec( dllexport ) virtual void setFullScreen( bool fullScreen );
- __declspec( dllexport ) virtual void update() = 0;
- __declspec( dllexport ) virtual void beginFrame( bool fill2D = 0, bool fill3D = 0, int fillColor = 0 );
- __declspec( dllexport ) virtual void renderKamera( Kam3D *zKamera );
- __declspec( dllexport ) virtual void presentFrame() = 0;
- __declspec( dllexport ) virtual Textur *createOrGetTextur( const char *name, Bild *b = 0 );
- __declspec( dllexport ) GraphicApiType getTyp() const;
- __declspec( dllexport ) Vec2< int > getBackBufferSize() const;
- __declspec( dllexport ) bool isFullScreen() const;
- __declspec( dllexport ) virtual Bild *zUIRenderBild() const = 0;
- __declspec( dllexport ) GraphicsApi *getThis();
- __declspec( dllexport ) GraphicsApi *release();
- };
- class DirectX9 : public GraphicsApi
- {
- private:
- IDirect3D9 *pDirect3D;
- IDirect3DDevice9 *pDevice;
- IDirect3DSurface9 *pBackBuffer;
- _D3DLOCKED_RECT *backRect;
- Bild *uiBild;
- public:
- __declspec( dllexport ) DirectX9();
- __declspec( dllexport ) ~DirectX9();
- __declspec( dllexport ) void initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fullScreen ) override;
- __declspec( dllexport ) void update() override;
- __declspec( dllexport ) void beginFrame( bool fill2D, bool fill3D, int fillColor ) override;
- __declspec( dllexport ) void presentFrame() override;
- __declspec( dllexport ) Bild *zUIRenderBild() const override;
- };
- class DirectX11 : public GraphicsApi
- {
- private:
- ID3D11Device *d3d11Device;
- ID3D11DeviceContext *d3d11Context;
- IDXGISwapChain *d3d11SpawChain;
- Textur *uiTextur;
- DX11VertexShader *vertexShader;
- DX11PixelShader *pixelShader;
- ID3D11SamplerState *sampleState;
- ID3D11RenderTargetView *rtview;
- ID3D11DepthStencilView *dsView;
- ID3D11Texture2D *depthStencilBuffer;
- ID3D11DepthStencilState *depthStencilState;
- ID3D11DepthStencilState *depthDisabledStencilState;
- ID3D11BlendState *blendStateAlphaBlend;
- D3D11_VIEWPORT *vp;
- TexturModel *texturModel;
- TexturList *texturRegister;
- ID3D11RasterizerState *texturRS;
- ID3D11RasterizerState *meshRS;
- Textur *defaultTextur;
- DX11StructuredBuffer *diffuseLights;
- DX11StructuredBuffer *pointLights;
- DX11Buffer *vertexBuffer;
- DX11Buffer *indexBuffer;
- Mat4< float > matrixBuffer[ MAX_KNOCHEN_ANZ ];
- Mat4< float > viewAndProj[ 2 ];
- Vec3< float > kamPos;
- Ebene3D< float > frustrum[ 6 ];
- void renderObject( Model3D *zObj );
- // Überprüft, ob eine Kugel in dem Sichtbaren Raum der Welt liegt und gezeichnet werden muss
- // pos: Der Mittelpunkt der Kugel
- // radius: Der Radius der Kugel
- // dist: Einen Zeiger auf einen float, in dem das quadrat des Abstands zur Kammeraposition gespeichert wird, falls diese Funktion true zurückgiebt und der Zeiger nicht 0 ist
- bool isInFrustrum( const Vec3< float > &pos, float radius, float *dist = 0 ) const;
- public:
- __declspec( dllexport ) DirectX11();
- __declspec( dllexport ) ~DirectX11();
- __declspec( dllexport ) void initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fullScreen ) override;
- __declspec( dllexport ) void update() override;
- __declspec( dllexport ) void beginFrame( bool fill2D, bool fill3D, int fillColor ) override;
- __declspec( dllexport ) void renderKamera( Kam3D *zKamera ) override;
- __declspec( dllexport ) void presentFrame() override;
- __declspec( dllexport ) Textur *createOrGetTextur( const char *name, Bild *b ) override;
- __declspec( dllexport ) Bild *zUIRenderBild() const override;
- __declspec( dllexport ) static bool isAvailable();
- };
- class DirectX12 : public GraphicsApi
- {
- private:
- ID3D12Debug *debug;
- ID3D12Device2 *device;
- ID3D12InfoQueue *infoQueue;
- DX12DirectCommandQueue *directCommandQueue;
- DX12CopyCommandQueue *copyCommandQueue;
- DX12ComputeCommandQueue *computeCommandQueue;
- IDXGISwapChain4 *swapChain;
- ID3D12DescriptorHeap *rtvHeap;
- ID3D12DescriptorHeap *dsvHeap;
- ID3D12DescriptorHeap *shaderBufferHeap;
- ID3D12Resource *depthBuffer;
- ID3D12Resource *backBuffer[ 2 ];
- int backBufferIndex;
- int tearing;
- D3D12_VIEWPORT *viewPort;
- tagRECT *allowedRenderArea;
- D3D12_VERTEX_BUFFER_VIEW *vertexBufferView;
- D3D12_INDEX_BUFFER_VIEW *indexBufferView;
- DX12VertexBuffer *vertexBuffer;
- DX12IndexBuffer *indexBuffer;
- ID3D12RootSignature *signature;
- ID3D12PipelineState *pipeline;
- Mat4< float > matrixBuffer[ MAX_KNOCHEN_ANZ ];
- Mat4< float > viewAndProj[ 2 ];
- Vec3< float > kamPos;
- Ebene3D< float > frustrum[ 6 ];
- TexturModel *texturModel;
- Textur *uiTextur;
- TexturList *texturRegister;
- DX12VertexShader *vertexShader;
- DX12PixelShader *pixelShader;
- void renderObject( Model3D *zObj );
- // Überprüft, ob eine Kugel in dem Sichtbaren Raum der Welt liegt und gezeichnet werden muss
- // pos: Der Mittelpunkt der Kugel
- // radius: Der Radius der Kugel
- // dist: Einen Zeiger auf einen float, in dem das quadrat des Abstands zur Kammeraposition gespeichert wird, falls diese Funktion true zurückgiebt und der Zeiger nicht 0 ist
- bool isInFrustrum( const Vec3< float > &pos, float radius, float *dist = 0 ) const;
- public:
- __declspec( dllexport ) DirectX12();
- __declspec( dllexport ) ~DirectX12();
- __declspec( dllexport ) void initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fullScreen ) override;
- __declspec( dllexport ) void update() override;
- __declspec( dllexport ) void beginFrame( bool fill2D, bool fill3D, int fillColor ) override;
- __declspec( dllexport ) void renderKamera( Kam3D *zKamera ) override;
- __declspec( dllexport ) void presentFrame() override;
- __declspec( dllexport ) Textur *createOrGetTextur( const char *name, Bild *b ) override;
- __declspec( dllexport ) Bild *zUIRenderBild() const override;
- __declspec( dllexport ) static bool isAvailable();
- };
- }
|