diff --git a/Demo.h b/Demo.h index a449294..44ba0e3 100644 --- a/Demo.h +++ b/Demo.h @@ -2,7 +2,7 @@ #include #include "CameraController.h" -class Demo : public GApp { +class Demo { // : public GApp { public: Demo(const GAppSettings& settings,Win32Window* wind); virtual ~Demo() {} @@ -16,6 +16,7 @@ class Demo : public GApp { virtual void onCleanup(); Instance* getSelection(); + void run(); void QuitApp(); void onKeyPressed(int key); void onKeyUp(int key); @@ -26,6 +27,8 @@ class Demo : public GApp { void onMouseMoved(int x, int y); void onMouseWheel(int x, int y, short delta); CameraController cameraController; + RenderDevice* renderDevice; + UserInput* userInput; private: void initGUI(); HWND hWndMain; @@ -33,4 +36,12 @@ class Demo : public GApp { bool quit; bool rightButtonHolding; void main(); + GWindow* _window; + protected: + Stopwatch m_graphicsWatch; + Stopwatch m_logicWatch; + Stopwatch m_networkWatch; + Stopwatch m_userInputWatch; + Stopwatch m_simulationWatch; + Stopwatch m_waitWatch; }; diff --git a/main.cpp b/main.cpp index 9a93c69..2a95577 100644 --- a/main.cpp +++ b/main.cpp @@ -63,10 +63,24 @@ Instance* selectedInstance = NULL; Demo *usableApp = NULL; -Demo::Demo(const GAppSettings& settings,Win32Window* window) : GApp(settings,window) { +Demo::Demo(const GAppSettings& settings,Win32Window* window) { //: GApp(settings,window) { hWndMain = window->hwnd(); quit=false; rightButtonHolding=false; + + // GApp replacement + renderDevice = new RenderDevice(); + + if (window != NULL) { + renderDevice->init(window, NULL); + } + else + { + MessageBox(NULL,"Window not found!","Error",MB_OK); + return; + } + _window = renderDevice->window(); + _window->makeCurrent(); } void clearInstances() @@ -767,6 +781,7 @@ bool IsHolding(int button) void Demo::onUserInput(UserInput* ui) { + /* if(GetHoldKeyState(VK_LCONTROL)) { if(GetHoldKeyState('D')) @@ -779,6 +794,7 @@ void Demo::onUserInput(UserInput* ui) { setDebugMode(!debugMode()); } } + */ if(GetHoldKeyState(VK_F8)) { messageTime = System::time(); @@ -967,7 +983,7 @@ void drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, LightingParameters void Demo::exitApplication() { //endApplet = true; - endProgram = true; + //endProgram = true; } @@ -986,14 +1002,14 @@ void Demo::onGraphics(RenderDevice* rd) { { mouseOnScreen = false; //ShowCursor(true); - window()->setMouseVisible(true); + _window->setMouseVisible(true); //rd->window()->setInputCaptureCount(0); } else { mouseOnScreen = true; //SetCursor(NULL); - window()->setMouseVisible(false); + _window->setMouseVisible(false); //rd->window()->setInputCaptureCount(1); } @@ -1315,10 +1331,10 @@ LRESULT CALLBACK ToolProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return 0; } -void Demo::main() { +void Demo::run() { usableApp = this; - setDebugMode(false); - debugController.setActive(false); + //setDebugMode(false); + //debugController.setActive(false); /* if (!createWindowClass("ToolWindowClass",ToolProc,GetModuleHandle(0))) { @@ -1371,7 +1387,7 @@ void Demo::main() { m_userInputWatch.tick(); onUserInput(userInput); - m_moduleManager->onUserInput(userInput); + //m_moduleManager->onUserInput(userInput); m_userInputWatch.tock(); m_simulationWatch.tick(); @@ -1401,9 +1417,9 @@ void Demo::main() { renderDevice->pushState(); onGraphics(renderDevice); renderDevice->popState(); - renderDebugInfo(); + //renderDebugInfo(); renderDevice->endFrame(); - debugText.clear(); + //debugText.clear(); m_graphicsWatch.tock(); while (PeekMessage (&messages, NULL, 0, 0,PM_REMOVE)) @@ -1471,7 +1487,6 @@ int main(int argc, char** argv) { Win32Window* win32Window = Win32Window::create(settings.window,hwndMain); Demo demo = Demo(settings,win32Window); - SetWindowLongPtr(hwndMain,GWL_USERDATA,(LONG)&demo); demo.run(); }