GraphicsApi.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #pragma once
  2. #include "Vec2.h"
  3. // DirectX 11 Types
  4. struct ID3D11Device;
  5. struct ID3D11DeviceContext;
  6. struct IDXGISwapChain;
  7. struct ID3D11Texture2D;
  8. struct ID3D11SamplerState;
  9. struct ID3D11ShaderResourceView;
  10. struct ID3D11RenderTargetView;
  11. struct ID3D11DepthStencilView;
  12. struct ID3D11DepthStencilState;
  13. struct ID3D11RasterizerState;
  14. struct ID3D11BlendState;
  15. struct D3D11_VIEWPORT;
  16. // DirectX 9 Types
  17. struct IDirect3D9;
  18. struct IDirect3DDevice9;
  19. struct IDirect3DSurface9;
  20. struct _D3DLOCKED_RECT;
  21. namespace Framework
  22. {
  23. class WFenster;
  24. class Bild;
  25. class Textur;
  26. class PixelShader;
  27. class VertexShader;
  28. class TexturModel;
  29. class Render3D;
  30. class TexturList;
  31. class Kam3D;
  32. enum GraphicApiType
  33. {
  34. NOT_SUPPORTED, // no graphic api supported
  35. DIRECTX9, // only 2d
  36. DIRECTX11, // 3d simple phong model without shadows
  37. DIRECTX12 // 3d phong model with raytraycing
  38. };
  39. class GraphicsApi
  40. {
  41. protected:
  42. GraphicApiType typ;
  43. WFenster *fenster;
  44. Vec2<int> backBufferSize;
  45. bool fullScreen;
  46. private:
  47. int ref;
  48. public:
  49. GraphicsApi( GraphicApiType typ );
  50. virtual ~GraphicsApi();
  51. virtual void initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fullScreen );
  52. virtual void setBackBufferSize( Vec2< int > size );
  53. virtual void setFullScreen( bool fullScreen );
  54. virtual void update() = 0;
  55. virtual void beginFrame( bool fill2D = 0, bool fill3D = 0, int fillColor = 0 );
  56. virtual void renderKamera( Kam3D *zKamera );
  57. virtual void presentFrame() = 0;
  58. GraphicApiType getTyp() const;
  59. Vec2< int > getBackBufferSize() const;
  60. bool isFullScreen() const;
  61. virtual Bild *zUIRenderBild() const = 0;
  62. GraphicsApi *getThis();
  63. GraphicsApi *release();
  64. };
  65. class DirectX9 : public GraphicsApi
  66. {
  67. private:
  68. IDirect3D9 *pDirect3D;
  69. IDirect3DDevice9 *pDevice;
  70. IDirect3DSurface9 *pBackBuffer;
  71. _D3DLOCKED_RECT *backRect;
  72. Bild *uiBild;
  73. public:
  74. DirectX9();
  75. ~DirectX9();
  76. void initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fullScreen ) override;
  77. void update() override;
  78. void beginFrame( bool fill2D, bool fill3D, int fillColor ) override;
  79. void presentFrame() override;
  80. Bild *zUIRenderBild() const override;
  81. };
  82. class DirectX11 : public GraphicsApi
  83. {
  84. private:
  85. ID3D11Device *d3d11Device;
  86. ID3D11DeviceContext *d3d11Context;
  87. IDXGISwapChain *d3d11SpawChain;
  88. Textur *uiTextur;
  89. VertexShader *vertexShader;
  90. PixelShader *pixelShader;
  91. ID3D11SamplerState *sampleState;
  92. ID3D11RenderTargetView *rtview;
  93. ID3D11DepthStencilView *dsView;
  94. ID3D11Texture2D *depthStencilBuffer;
  95. ID3D11DepthStencilState *depthStencilState;
  96. ID3D11DepthStencilState *depthDisabledStencilState;
  97. ID3D11BlendState *blendStateAlphaBlend;
  98. D3D11_VIEWPORT *vp;
  99. TexturModel *texturModel;
  100. Render3D *renderObj;
  101. TexturList *texturRegister;
  102. public:
  103. DirectX11();
  104. ~DirectX11();
  105. void initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fullScreen ) override;
  106. void update() override;
  107. void beginFrame( bool fill2D, bool fill3D, int fillColor ) override;
  108. void renderKamera( Kam3D *zKamera ) override;
  109. void presentFrame() override;
  110. Bild *zUIRenderBild() const override;
  111. };
  112. class DirectX12 : public GraphicsApi
  113. {
  114. };
  115. }