rasterizer_opengl.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*************************************************************************/
  2. /* rasterizer_opengl.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef RASTERIZER_OPENGL_H
  31. #define RASTERIZER_OPENGL_H
  32. #include "drivers/opengl/rasterizer_platforms.h"
  33. #ifdef OPENGL_BACKEND_ENABLED
  34. #include "rasterizer_canvas_opengl.h"
  35. #include "rasterizer_scene_opengl.h"
  36. #include "rasterizer_storage_opengl.h"
  37. #include "servers/rendering/renderer_compositor.h"
  38. class RasterizerOpenGL : public RendererCompositor {
  39. private:
  40. uint64_t frame = 1;
  41. float delta = 0;
  42. double time_total = 0.0;
  43. double time_scale = 1.0;
  44. protected:
  45. RasterizerCanvasOpenGL canvas;
  46. RasterizerStorageOpenGL storage;
  47. RasterizerSceneOpenGL scene;
  48. void _blit_render_target_to_screen(RID p_render_target, const Rect2 &p_screen_rect);
  49. public:
  50. RendererStorage *get_storage() { return &storage; }
  51. RendererCanvasRender *get_canvas() { return &canvas; }
  52. RendererSceneRender *get_scene() { return &scene; }
  53. void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true);
  54. void initialize();
  55. void begin_frame(double frame_step);
  56. void prepare_for_blitting_render_targets();
  57. void blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount);
  58. void end_frame(bool p_swap_buffers);
  59. void finalize() {}
  60. static RendererCompositor *_create_current() {
  61. return memnew(RasterizerOpenGL);
  62. }
  63. static void make_current() {
  64. _create_func = _create_current;
  65. }
  66. virtual bool is_low_end() const { return true; }
  67. uint64_t get_frame_number() const { return frame; }
  68. double get_frame_delta_time() const { return delta; }
  69. RasterizerOpenGL();
  70. ~RasterizerOpenGL() {}
  71. };
  72. #endif // OPENGL_BACKEND_ENABLED
  73. #endif