From 53ae3f24c9458d324572ac8c23f5b8c90c4ac24e Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 4 Dec 2021 20:11:09 +0000 Subject: Refactor wrapped_ptr to include destory function as template param, and possibly constructor function --- gfx/window.cpp | 7 +++---- gfx/window.h | 7 +++++-- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'gfx') diff --git a/gfx/window.cpp b/gfx/window.cpp index 2e3c843..dd300a7 100644 --- a/gfx/window.cpp +++ b/gfx/window.cpp @@ -3,10 +3,9 @@ #include Window::Window(int width, int height, const std::string & title) : - m_window {m_window.create(SDL_CreateWindow, SDL_DestroyWindow, title.c_str(), - static_cast(SDL_WINDOWPOS_CENTERED), static_cast(SDL_WINDOWPOS_CENTERED), width, height, - static_cast(SDL_WINDOW_OPENGL))}, - m_glContext {m_glContext.create(SDL_GL_CreateContext, SDL_GL_DeleteContext, m_window)} + m_window {title.c_str(), static_cast(SDL_WINDOWPOS_CENTERED), static_cast(SDL_WINDOWPOS_CENTERED), width, + height, static_cast(SDL_WINDOW_OPENGL)}, + m_glContext {m_window} { if (glewInit() != GLEW_OK) { throw std::runtime_error {"Glew failed to initialize!"}; diff --git a/gfx/window.h b/gfx/window.h index 3ac583f..252ccaa 100644 --- a/gfx/window.h +++ b/gfx/window.h @@ -19,8 +19,11 @@ public: void SwapBuffers() const; private: - wrapped_ptr m_window; - wrapped_ptr> m_glContext; + using GL_Context = std::remove_pointer_t; + using SDL_WindowPtr = wrapped_ptrt; + using SDL_GLContextPtr = wrapped_ptrt; + SDL_WindowPtr m_window; + SDL_GLContextPtr m_glContext; }; #endif -- cgit v1.2.3