diff options
| author | Yuqian Yang <crupest@crupest.life> | 2025-12-01 21:25:37 +0800 |
|---|---|---|
| committer | Yuqian Yang <crupest@crupest.life> | 2025-12-01 21:25:37 +0800 |
| commit | d5d65b703244dfcc31228439e91ad0cfebb76456 (patch) | |
| tree | 9550fdf372dc36fc512ba8af73168e1e9aae93bf /src/platform/gui/sdl/Window.cpp | |
| parent | d54732324827bcfdc75e684b6636c53c109757c4 (diff) | |
| download | cru-d5d65b703244dfcc31228439e91ad0cfebb76456.tar.gz cru-d5d65b703244dfcc31228439e91ad0cfebb76456.tar.bz2 cru-d5d65b703244dfcc31228439e91ad0cfebb76456.zip | |
Move out OpengGLRenderer.
Diffstat (limited to 'src/platform/gui/sdl/Window.cpp')
| -rw-r--r-- | src/platform/gui/sdl/Window.cpp | 24 |
1 files changed, 3 insertions, 21 deletions
diff --git a/src/platform/gui/sdl/Window.cpp b/src/platform/gui/sdl/Window.cpp index 9bb94398..c3772fbe 100644 --- a/src/platform/gui/sdl/Window.cpp +++ b/src/platform/gui/sdl/Window.cpp @@ -1,6 +1,5 @@ #include "cru/platform/gui/sdl/Window.h" #include "cru/base/Base.h" -#include "cru/base/log/Logger.h" #include "cru/platform/Base.h" #include "cru/platform/GraphicsBase.h" #include "cru/platform/graphics/NullPainter.h" @@ -10,6 +9,7 @@ #include "cru/platform/gui/sdl/Cursor.h" #include "cru/platform/gui/sdl/Input.h" #include "cru/platform/gui/sdl/InputMethod.h" +#include "cru/platform/gui/sdl/OpenGLRenderer.h" #include "cru/platform/gui/sdl/UiApplication.h" #include <SDL3/SDL_events.h> @@ -419,28 +419,10 @@ bool SdlWindow::HandleEvent(const SDL_Event* event) { #ifdef __unix void SdlWindow::UnixOnCreateWindow() { assert(sdl_window_); - sdl_gl_context_ = SDL_GL_CreateContext(sdl_window_); - - if (!sdl_gl_context_) { - throw SdlException("Failed to create sdl gl context."); - } - - CheckSdlReturn(SDL_GL_MakeCurrent(sdl_window_, sdl_gl_context_)); - - glad_gl_context_ = std::make_unique<GladGLContext>(); - auto version = - gladLoadGLContext(glad_gl_context_.get(), SDL_GL_GetProcAddress); - CRU_LOG_TAG_DEBUG("SDL window id {}, openGL version: {}.", sdl_window_id_, - version); + renderer_ = std::make_unique<SdlOpenGLRenderer>(this); } -void SdlWindow::UnixOnDestroyWindow() { - assert(sdl_window_); - assert(sdl_gl_context_); - assert(glad_gl_context_); - CheckSdlReturn(SDL_GL_DestroyContext(sdl_gl_context_)); - glad_gl_context_ = nullptr; -} +void SdlWindow::UnixOnDestroyWindow() { renderer_ = nullptr; } #endif } // namespace cru::platform::gui::sdl |
