123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- #pragma once
- #include "Vec2.h"
- #include "Mat4.h"
- #include "Ebene3D.h"
- // 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;
- 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;
- enum GraphicApiType
- {
- NOT_SUPPORTED, // no graphic api supported
- DIRECTX9, // only 2d
- DIRECTX11, // 3d simple phong model without shadows
- DIRECTX12 // 3d phong model with raytraycing
- };
- 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;
- };
- class DirectX12 : public GraphicsApi
- {
- };
- }
|