diff options
author | chai <chaifix@163.com> | 2021-10-30 22:59:42 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-10-30 22:59:42 +0800 |
commit | 26f05c6e3dcac9995345fb5a2b031be7e3ea79e9 (patch) | |
tree | fc32c3e9d235817df0be331a6100b7f8263facab /Editor/GUI | |
parent | c3e259f4d29e9bdcb73617ad8e4d71f117b4d289 (diff) |
*TextGenerator
Diffstat (limited to 'Editor/GUI')
-rw-r--r-- | Editor/GUI/ContainerWindow.cpp | 19 | ||||
-rw-r--r-- | Editor/GUI/EditorWindows.h | 4 | ||||
-rw-r--r-- | Editor/GUI/GUIWindow.cpp | 18 |
3 files changed, 10 insertions, 31 deletions
diff --git a/Editor/GUI/ContainerWindow.cpp b/Editor/GUI/ContainerWindow.cpp index 62c6cb7..01bb1e9 100644 --- a/Editor/GUI/ContainerWindow.cpp +++ b/Editor/GUI/ContainerWindow.cpp @@ -196,8 +196,8 @@ void ContainerWindow::DoPaint() void ContainerWindow::SetAsRenderContext() { Assert(m_DC != NULL); - Assert(m_RC != NULL); - Assert(wglMakeCurrent(m_DC, m_RC)); + Assert(g_GLRC != NULL); + Assert(wglMakeCurrent(m_DC, g_GLRC)); RECT rect; GetWindowRect(m_Window, &rect); glViewport(0, 0, rect.right - rect.left, rect.bottom - rect.top); @@ -256,16 +256,15 @@ bool ContainerWindow::SetRenderContext() int pf = 0; DescribePixelFormat(m_DC, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd); - if (!(m_RC = wglCreateContext(m_DC))) // Are We Able To Get A Rendering Context? - { - MessageBox(NULL, "Can't Create A GL Rendering Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION); - return FALSE; // Return FALSE - } - - if (m_RC && !g_IsGLInitialized) + if (g_GLRC == NULL || !g_IsGLInitialized) { + if (!(g_GLRC = wglCreateContext(m_DC))) // Are We Able To Get A Rendering Context? + { + MessageBox(NULL, "Can't Create A GL Rendering Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION); + return FALSE; // Return FALSE + } log_info("Initialize OpenGL"); - wglMakeCurrent(m_DC, m_RC); + wglMakeCurrent(m_DC, g_GLRC); if (!gladLoadGL()) { log_error("初始化GL错误"); } diff --git a/Editor/GUI/EditorWindows.h b/Editor/GUI/EditorWindows.h index 79e047c..e1ad89a 100644 --- a/Editor/GUI/EditorWindows.h +++ b/Editor/GUI/EditorWindows.h @@ -67,7 +67,6 @@ public: GET(HWND, WindowHandle, m_Window); GET(HDC, DC, m_DC); - GET(HGLRC, RC, m_RC); void OnRectChanged(); void OnActivateApplication(bool active); @@ -79,7 +78,6 @@ private: HWND m_Window; HDC m_DC; - HGLRC m_RC; POINT m_Size; ShowMode m_ShowMode; // 窗口类型 bool m_IsClosing; @@ -149,7 +147,6 @@ public: GET_SET(std::string, Name, m_Name); GET(HDC, DC, m_DC); - GET(HGLRC, RC, m_RC); private: void ProcessEventMessages(UINT message, WPARAM wParam, LPARAM lParam); @@ -160,7 +157,6 @@ private: ContainerWindow* m_ContainerWindow; HWND m_Handle; HDC m_DC; - HGLRC m_RC; std::vector<LuaBind::MemberRef> m_EditorWindows; diff --git a/Editor/GUI/GUIWindow.cpp b/Editor/GUI/GUIWindow.cpp index fddc68d..eb44647 100644 --- a/Editor/GUI/GUIWindow.cpp +++ b/Editor/GUI/GUIWindow.cpp @@ -293,21 +293,6 @@ bool GUIWindow::SetRenderContext() int pf = 0; DescribePixelFormat(m_DC, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd); - if (!(m_RC = wglCreateContext(m_DC))) // Are We Able To Get A Rendering Context? - { - MessageBox(NULL, "Can't Create A GL Rendering Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION); - return FALSE; // Return FALSE - } - - if (m_RC && !g_IsGLInitialized) - { - log_info("Initialize OpenGL"); - wglMakeCurrent(m_DC, m_RC); - if (!gladLoadGL()) { - log_error("初始化GL错误"); - } - g_IsGLInitialized = true; - } return true; } @@ -345,8 +330,7 @@ void GUIWindow::SetPosition(Internal::Rect position) void GUIWindow::SetAsRenderContext() { Assert(m_DC != NULL); - Assert(m_RC != NULL); - Assert(wglMakeCurrent(m_DC, m_RC)); + Assert(wglMakeCurrent(m_DC, g_GLRC)); RECT rect; GetWindowRect(m_Handle, &rect); glViewport(0, 0, rect.right - rect.left, rect.bottom - rect.top); |