GraphicsApi.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #pragma once
  2. #include "DXBuffer.h"
  3. #include "Mat4.h"
  4. #include "Vec2.h"
  5. namespace Framework
  6. {
  7. class NativeWindow;
  8. class Image;
  9. class Texture;
  10. class Cam3D;
  11. class Model3DList;
  12. class Model3DData;
  13. enum GraphicApiType;
  14. struct DiffuseLight
  15. {
  16. Vec3<float> direction;
  17. Vec3<float> color;
  18. };
  19. struct PointLight
  20. {
  21. Vec3<float> position;
  22. Vec3<float> color;
  23. float radius;
  24. };
  25. class GraphicsApi : public virtual ReferenceCounter
  26. {
  27. protected:
  28. GraphicApiType typ;
  29. NativeWindow* fenster;
  30. Vec2<int> backBufferSize;
  31. Model3DList* modelList;
  32. int nextModelId;
  33. ReadWriteLock rwLock;
  34. bool fullScreen;
  35. public:
  36. DLLEXPORT GraphicsApi(GraphicApiType typ);
  37. DLLEXPORT virtual ~GraphicsApi();
  38. DLLEXPORT virtual void initialize(
  39. NativeWindow* fenster, Vec2<int> backBufferSize, bool fullScreen);
  40. DLLEXPORT virtual void beginFrame(
  41. bool fill2D = 0, bool fill3D = 0, int fillColor = 0);
  42. DLLEXPORT virtual void renderKamera(Cam3D* zKamera);
  43. DLLEXPORT virtual void renderKamera(Cam3D* zKamera, Texture* zTarget);
  44. DLLEXPORT virtual void presentFrame() = 0;
  45. DLLEXPORT virtual Texture* createOrGetTexture(
  46. const char* name, Image* b = 0);
  47. DLLEXPORT GraphicApiType getTyp() const;
  48. DLLEXPORT Vec2<int> getBackBufferSize() const;
  49. DLLEXPORT bool isFullScreen() const;
  50. DLLEXPORT virtual Image* zUIRenderImage() const = 0;
  51. //! returns the specified model without increased reference counter
  52. DLLEXPORT virtual Model3DData* zModel(const char* name);
  53. //! returns the specified model with increased reference counter
  54. DLLEXPORT virtual Model3DData* getModel(const char* name);
  55. //! creates a new empty Model3DData object if the model does not exist
  56. //! yet
  57. DLLEXPORT virtual Model3DData* createModel(const char* name);
  58. //! check if a model exists
  59. DLLEXPORT virtual bool hasModel(const char* name);
  60. //! creates a StructuredBuffer that is stored in the GPU memory and can
  61. //! be used as a shader resource
  62. //! \param eSize the size of one element of the buffer in bytes
  63. DLLEXPORT virtual DXBuffer* createStructuredBuffer(int eSize) = 0;
  64. };
  65. } // namespace Framework