Magic_Game/samples/ImGuiSample/main.cpp

69 lines
1.1 KiB
C++
Raw Normal View History

// Copyright (C) 2019 Nomango
2019-03-11 11:11:39 +08:00
#include "easy2d.h"
2019-03-13 15:48:25 +08:00
#include "easy2d-imgui.h"
2019-03-11 11:11:39 +08:00
using namespace easy2d;
const int WINDOW_WIDTH = 1280;
const int WINDOW_HEIGHT = 800;
E2D_DECLARE_SMART_PTR(ImGuiScene);
class ImGuiScene
: public Scene
{
bool show_demo_window = true;
public:
ImGuiScene()
2019-03-11 11:11:39 +08:00
{
// <20><><EFBFBD><EFBFBD> ImGui ͼ<><CDBC>
ImGuiLayerPtr layer = new ImGuiLayer;
AddChild(layer);
// <20><><EFBFBD><EFBFBD> ImGui <20><EFBFBD><E1B9A9> Demo <20><><EFBFBD><EFBFBD>
layer->AddItem([=]() {
if (show_demo_window)
ImGui::ShowDemoWindow(&show_demo_window);
}, L"DemoWindow");
2019-03-11 11:11:39 +08:00
}
};
class ImGuiApp
: public Application
{
public:
ImGuiApp()
{
// <20><><EFBFBD><EFBFBD> ImGui <20><><EFBFBD><EFBFBD>
Use(&ImGuiView::Instance());
// <20><>ʼ<EFBFBD><CABC>
Options options(L"ImGui Demo", WINDOW_WIDTH, WINDOW_HEIGHT);
2019-03-11 11:11:39 +08:00
options.clear_color = Color(0.45f, 0.55f, 0.6f, 1.f);
Init(options);
}
void OnStart() override
{
ImGuiScenePtr scene = new ImGuiScene;
EnterScene(scene);
}
};
int main()
{
try
{
ImGuiApp app;
app.Run();
}
catch (std::exception& e)
{
::MessageBoxA(nullptr, e.what(), "An exception has occurred!", MB_ICONERROR | MB_OK);
}
return 0;
}