| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- #pragma once
- #include "GraphicsApi.h"
- #include "Plane3D.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;
- namespace Framework
- {
- class DX11StructuredBuffer;
- class DX11PixelShader;
- class DX11VertexShader;
- class DX11Buffer;
- class TextureList;
- class Model3D;
- class TextureModel;
- class DirectX11 : public GraphicsApi
- {
- private:
- ID3D11Device* d3d11Device;
- ID3D11DeviceContext* d3d11Context;
- IDXGISwapChain* d3d11SpawChain;
- Texture* uiTexture;
- DX11VertexShader* vertexShader;
- DX11PixelShader* pixelShader;
- ID3D11SamplerState* sampleState;
- ID3D11RenderTargetView* rtview;
- ID3D11DepthStencilView* dsView;
- ID3D11Texture2D* depthStencilBuffer;
- ID3D11DepthStencilState* depthStencilState;
- ID3D11DepthStencilState* depthDisabledStencilState;
- ID3D11BlendState* blendStateAlphaBlend;
- D3D11_VIEWPORT* vp;
- TextureModel* texturModel;
- TextureList* texturRegister;
- Texture* defaultTexture;
- DX11StructuredBuffer* diffuseLights;
- DX11StructuredBuffer* pointLights;
- Mat4<float> matrixBuffer[MAX_KNOCHEN_ANZ];
- Mat4<float> viewAndProj[2];
- Vec3<float> kamPos;
- Plane3D<float> frustrum[6];
- int lastModelId;
- DX11Buffer** indexBuffers;
- DX11Buffer** vertexBuffers;
- void renderObject(Model3D* zObj);
- DX11Buffer* createIndexBuffer();
- DX11Buffer* createVertexBuffer();
- protected:
- Critical deviceLock;
- ID3D11RasterizerState* texturRS;
- ID3D11RasterizerState* meshRS;
- DLLEXPORT virtual DX11VertexShader* initializeVertexShader(
- unsigned char* byteCode, int size);
- DLLEXPORT virtual DX11PixelShader* initializePixelShader(
- unsigned char* byteCode, int size);
- DLLEXPORT ID3D11DeviceContext* zContext();
- public:
- DLLEXPORT DirectX11();
- DLLEXPORT ~DirectX11();
- DLLEXPORT void initialize(NativeWindow* fenster,
- Vec2<int> backBufferSize,
- bool fullScreen) override;
- DLLEXPORT void beginFrame(
- bool fill2D, bool fill3D, int fillColor) override;
- DLLEXPORT void renderKamera(Cam3D* zKamera) override;
- DLLEXPORT void renderKamera(Cam3D* zKamera, Texture* zTarget) override;
- DLLEXPORT void presentFrame() override;
- DLLEXPORT Texture* createOrGetTexture(
- const char* name, Image* b, TextureDirection dir) override;
- DLLEXPORT Image* zUIRenderImage() const override;
- DLLEXPORT virtual DXBuffer* createStructuredBuffer(int eSize) override;
- DLLEXPORT virtual Model3DData* createModel(const char* name) override;
- //! Checks whether a sphere is in the visible space of the world and
- //! needs to be drawn \param pos The center of the sphere \param
- //! radius The radius of the sphere \param dist A pointer to a
- //! float where the square of the distance to the camera position
- //! is stored if this function returns true and the pointer is not 0
- DLLEXPORT bool isInFrustrum(
- const Vec3<float>& pos, float radius, float* dist = 0) const;
- DLLEXPORT bool isInFrustrum(
- const Vec3<float>& pos, Vec3<float> radius, float* dist = 0) const;
- DLLEXPORT static bool isAvailable();
- };
- } // namespace Framework
|