summaryrefslogtreecommitdiff
path: root/Editor/GUI
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-10-18 19:56:41 +0800
committerchai <chaifix@163.com>2021-10-18 19:56:41 +0800
commit45328cbadd8a946c19a77301f218efbf650e2f28 (patch)
tree8ec4f3a9737b2cbb9744f8347a56783743be2a4c /Editor/GUI
parentb5702ece4c2cf751c252e76fb885a7ec41ccabe8 (diff)
*misc
Diffstat (limited to 'Editor/GUI')
-rw-r--r--Editor/GUI/ContainnerWindow.cpp11
-rw-r--r--Editor/GUI/EditorWindows.h24
-rw-r--r--Editor/GUI/GUIWindow.cpp14
-rw-r--r--Editor/GUI/WindowUtil.cpp2
4 files changed, 44 insertions, 7 deletions
diff --git a/Editor/GUI/ContainnerWindow.cpp b/Editor/GUI/ContainnerWindow.cpp
index 3778485..d6a67c9 100644
--- a/Editor/GUI/ContainnerWindow.cpp
+++ b/Editor/GUI/ContainnerWindow.cpp
@@ -5,6 +5,7 @@
#include "Editor/Utils/HelperFuncs.h"
#include "MenuManager.h"
#include "Runtime/Utilities/Assert.h"
+#include "Editor/Graphics/Graphics.h"
using namespace std;
@@ -260,6 +261,15 @@ bool ContainnerWindow::SetRenderContext()
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;
+ }
}
// 初始化,创建窗口
@@ -388,6 +398,7 @@ void ContainnerWindow::Init(Rectf pixelRect, int showMode, const Vector2f& minSi
//ShowInTaskbarIfNoMainWindow(m_Window);
SetRenderContext();
+
}
void ContainnerWindow::SetTitle(const char* title)
diff --git a/Editor/GUI/EditorWindows.h b/Editor/GUI/EditorWindows.h
index 307ab86..97175b3 100644
--- a/Editor/GUI/EditorWindows.h
+++ b/Editor/GUI/EditorWindows.h
@@ -4,7 +4,8 @@
#include <windows.h>
#include <vector>
#include "Runtime/Math/Rect.h"
-#include "Runtime/LuaBind/LuaBind.h"
+#include "Runtime/Lua/LuaBind/LuaBind.h"
+#include "Runtime/Lua/LuaHelper.h"
#include "Runtime/Utilities/Singleton.h"
#include "Runtime/Debug/Log.h"
#include "Runtime/Graphics/OpenGL.h"
@@ -18,7 +19,7 @@ class GUIWindow;
class WindowUtil
{
public :
- static void Init();
+ static void RegisterClasses();
static const wchar_t* kContainerWindowClassName;
static const wchar_t* kPopupWindowClassName;
@@ -89,8 +90,11 @@ private:
POINT m_MaxSize;
LUA_BIND_DECL_FACTORY(ContainnerWindow);
- LUA_BIND_DECL_METHOD(_SetTitle);
- LUA_BIND_DECL_METHOD(_DoPaint);
+
+ LUA_BIND_DECL_METHOD(_New);
+ LUA_BIND_DECL_METHOD(_SetTitle);
+ LUA_BIND_DECL_METHOD(_SetIcon);
+ LUA_BIND_DECL_METHOD(_DoPaint);
};
@@ -122,7 +126,9 @@ private:
};
// GUI窗口,事件相应、绘制、布局的单元
-class GUIWindow : public WindowBase
+class GUIWindow
+ : public WindowBase
+ , public LuaBind::NativeClass<GUIWindow>
{
public:
static LRESULT CALLBACK GUIViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
@@ -155,6 +161,14 @@ private:
LuaBind::Ref m_Script;
+ LUA_BIND_DECL_FACTORY(GUIWindow);
+
+ LUA_BIND_DECL_METHOD(_New);
+ LUA_BIND_DECL_METHOD(_DoPaint);
+ LUA_BIND_DECL_METHOD(_Focus);
+ LUA_BIND_DECL_METHOD(_SetContainnerWindow);
+ LUA_BIND_DECL_METHOD(_SetPosition);
+
};
#endif \ No newline at end of file
diff --git a/Editor/GUI/GUIWindow.cpp b/Editor/GUI/GUIWindow.cpp
index 3df0370..34d7705 100644
--- a/Editor/GUI/GUIWindow.cpp
+++ b/Editor/GUI/GUIWindow.cpp
@@ -1,6 +1,7 @@
#include "EditorWindows.h"
#include "WinUtils.h"
#include "Runtime/Graphics/OpenGL.h"
+#include "Editor/Graphics/Graphics.h"
static bool RedirectMouseWheel(HWND window, WPARAM wParam, LPARAM lParam)
{
@@ -223,10 +224,12 @@ void GUIWindow::Init(std::string name)
ShowWindow(m_Handle, SW_SHOW);
- if (!SetRenderContext())
+ bool bRC = SetRenderContext();
+ if (!bRC)
log_error("Failed to setup rendering context");
log_info("Created GUIWindow " /*+ (long)this*/);
+
}
bool GUIWindow::SetRenderContext()
@@ -288,6 +291,15 @@ bool GUIWindow::SetRenderContext()
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;
}
diff --git a/Editor/GUI/WindowUtil.cpp b/Editor/GUI/WindowUtil.cpp
index fc32719..b76b6d0 100644
--- a/Editor/GUI/WindowUtil.cpp
+++ b/Editor/GUI/WindowUtil.cpp
@@ -9,7 +9,7 @@ static ATOM ContainerWindowClassAtom;
static ATOM PopupWindowClassAtom;
static ATOM GUIViewClassAtom;
-void WindowUtil::Init()
+void WindowUtil::RegisterClasses()
{
log_info("WindowUtil::Init()");