renderer_base.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <memory>
  6. #include <boost/optional.hpp>
  7. #include "common/assert.h"
  8. #include "common/common_types.h"
  9. #include "video_core/gpu.h"
  10. #include "video_core/rasterizer_interface.h"
  11. class EmuWindow;
  12. class RendererBase : NonCopyable {
  13. public:
  14. /// Used to reference a framebuffer
  15. enum kFramebuffer { kFramebuffer_VirtualXFB = 0, kFramebuffer_EFB, kFramebuffer_Texture };
  16. explicit RendererBase(EmuWindow& window);
  17. virtual ~RendererBase();
  18. /// Swap buffers (render frame)
  19. virtual void SwapBuffers(boost::optional<const Tegra::FramebufferConfig&> framebuffer) = 0;
  20. /// Initialize the renderer
  21. virtual bool Init() = 0;
  22. /// Shutdown the renderer
  23. virtual void ShutDown() = 0;
  24. /// Updates the framebuffer layout of the contained render window handle.
  25. void UpdateCurrentFramebufferLayout();
  26. // Getter/setter functions:
  27. // ------------------------
  28. f32 GetCurrentFPS() const {
  29. return m_current_fps;
  30. }
  31. int GetCurrentFrame() const {
  32. return m_current_frame;
  33. }
  34. VideoCore::RasterizerInterface* Rasterizer() const {
  35. return rasterizer.get();
  36. }
  37. void RefreshRasterizerSetting();
  38. protected:
  39. EmuWindow& render_window; ///< Reference to the render window handle.
  40. std::unique_ptr<VideoCore::RasterizerInterface> rasterizer;
  41. f32 m_current_fps = 0.0f; ///< Current framerate, should be set by the renderer
  42. int m_current_frame = 0; ///< Current frame, should be set by the renderer
  43. };