diff options
| author | Yuqian Yang <crupest@crupest.life> | 2025-12-04 22:23:45 +0800 |
|---|---|---|
| committer | Yuqian Yang <crupest@crupest.life> | 2025-12-05 03:03:21 +0800 |
| commit | 8dcca49f42627400773dcc707ebaa757cbeef37b (patch) | |
| tree | 4466c1552dffa62bba518f247acf1ba3a98d3685 /include/cru/platform/gui/sdl/OpenGLRenderer.h | |
| parent | d5d65b703244dfcc31228439e91ad0cfebb76456 (diff) | |
| download | cru-8dcca49f42627400773dcc707ebaa757cbeef37b.tar.gz cru-8dcca49f42627400773dcc707ebaa757cbeef37b.tar.bz2 cru-8dcca49f42627400773dcc707ebaa757cbeef37b.zip | |
Impl sdl opengl renderer.
Diffstat (limited to 'include/cru/platform/gui/sdl/OpenGLRenderer.h')
| -rw-r--r-- | include/cru/platform/gui/sdl/OpenGLRenderer.h | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/include/cru/platform/gui/sdl/OpenGLRenderer.h b/include/cru/platform/gui/sdl/OpenGLRenderer.h index 2db9d68d..18de3d55 100644 --- a/include/cru/platform/gui/sdl/OpenGLRenderer.h +++ b/include/cru/platform/gui/sdl/OpenGLRenderer.h @@ -3,8 +3,13 @@ #include "gl.h" #include <cru/base/Base.h> +#include <cru/base/Guard.h> +#include <cru/platform/GraphicsBase.h> +#include <cru/platform/graphics/Painter.h> +#include <cru/platform/gui/Base.h> #include <SDL3/SDL_video.h> +#include <cairo.h> namespace cru::platform::gui::sdl { class SdlWindow; @@ -12,14 +17,34 @@ class SdlWindow; class SdlOpenGLRenderer { CRU_DEFINE_CLASS_LOG_TAG("cru::platform::gui::sdl::SdlOpenGLRenderer") public: - explicit SdlOpenGLRenderer(SdlWindow* window); + SdlOpenGLRenderer(SdlWindow* window, int width, int height); ~SdlOpenGLRenderer(); + void Resize(int width, int height); + std::unique_ptr<graphics::IPainter> BeginPaint(); + void Present(); + + private: + GLuint CreateGLProgram(); + Guard MakeContextCurrent(); + private: SdlWindow* window_; SDL_Window* sdl_window_; SDL_WindowID sdl_window_id_; + + int width_, height_; + SDL_GLContext sdl_gl_context_; GladGLContext glad_gl_context_; + + GLuint gl_shader_program_; + GLuint gl_vertex_array_; + GLuint gl_vertex_buffer_; + GLuint gl_element_buffer_; + GLuint gl_texture_; + + cairo_surface_t* cairo_surface_; + cairo_t* cairo_; }; } // namespace cru::platform::gui::sdl |
