| 
									
										
										
										
											2019-03-12 00:27:54 +08:00
										 |  |  |  | // 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-12 00:27:54 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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: | 
					
						
							| 
									
										
										
										
											2019-03-12 00:27:54 +08:00
										 |  |  |  | 	ImGuiScene() | 
					
						
							| 
									
										
										
										
											2019-03-11 11:11:39 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2019-03-12 00:27:54 +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() | 
					
						
							|  |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2019-03-12 00:27:54 +08:00
										 |  |  |  | 		// <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; | 
					
						
							|  |  |  |  | } |