Bye bye GApp. We need more control.

This commit is contained in:
MusicalProgrammer
2018-06-02 21:27:10 -04:00
parent fb3513c6f6
commit cd7785ce06
2 changed files with 38 additions and 12 deletions

13
Demo.h
View File

@@ -2,7 +2,7 @@
#include <G3DAll.h> #include <G3DAll.h>
#include "CameraController.h" #include "CameraController.h"
class Demo : public GApp { class Demo { // : public GApp {
public: public:
Demo(const GAppSettings& settings,Win32Window* wind); Demo(const GAppSettings& settings,Win32Window* wind);
virtual ~Demo() {} virtual ~Demo() {}
@@ -16,6 +16,7 @@ class Demo : public GApp {
virtual void onCleanup(); virtual void onCleanup();
Instance* getSelection(); Instance* getSelection();
void run();
void QuitApp(); void QuitApp();
void onKeyPressed(int key); void onKeyPressed(int key);
void onKeyUp(int key); void onKeyUp(int key);
@@ -26,6 +27,8 @@ class Demo : public GApp {
void onMouseMoved(int x, int y); void onMouseMoved(int x, int y);
void onMouseWheel(int x, int y, short delta); void onMouseWheel(int x, int y, short delta);
CameraController cameraController; CameraController cameraController;
RenderDevice* renderDevice;
UserInput* userInput;
private: private:
void initGUI(); void initGUI();
HWND hWndMain; HWND hWndMain;
@@ -33,4 +36,12 @@ class Demo : public GApp {
bool quit; bool quit;
bool rightButtonHolding; bool rightButtonHolding;
void main(); void main();
GWindow* _window;
protected:
Stopwatch m_graphicsWatch;
Stopwatch m_logicWatch;
Stopwatch m_networkWatch;
Stopwatch m_userInputWatch;
Stopwatch m_simulationWatch;
Stopwatch m_waitWatch;
}; };

View File

@@ -63,10 +63,24 @@ Instance* selectedInstance = NULL;
Demo *usableApp = 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(); hWndMain = window->hwnd();
quit=false; quit=false;
rightButtonHolding=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() void clearInstances()
@@ -767,6 +781,7 @@ bool IsHolding(int button)
void Demo::onUserInput(UserInput* ui) { void Demo::onUserInput(UserInput* ui) {
/*
if(GetHoldKeyState(VK_LCONTROL)) if(GetHoldKeyState(VK_LCONTROL))
{ {
if(GetHoldKeyState('D')) if(GetHoldKeyState('D'))
@@ -779,6 +794,7 @@ void Demo::onUserInput(UserInput* ui) {
setDebugMode(!debugMode()); setDebugMode(!debugMode());
} }
} }
*/
if(GetHoldKeyState(VK_F8)) if(GetHoldKeyState(VK_F8))
{ {
messageTime = System::time(); messageTime = System::time();
@@ -967,7 +983,7 @@ void drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, LightingParameters
void Demo::exitApplication() void Demo::exitApplication()
{ {
//endApplet = true; //endApplet = true;
endProgram = true; //endProgram = true;
} }
@@ -986,14 +1002,14 @@ void Demo::onGraphics(RenderDevice* rd) {
{ {
mouseOnScreen = false; mouseOnScreen = false;
//ShowCursor(true); //ShowCursor(true);
window()->setMouseVisible(true); _window->setMouseVisible(true);
//rd->window()->setInputCaptureCount(0); //rd->window()->setInputCaptureCount(0);
} }
else else
{ {
mouseOnScreen = true; mouseOnScreen = true;
//SetCursor(NULL); //SetCursor(NULL);
window()->setMouseVisible(false); _window->setMouseVisible(false);
//rd->window()->setInputCaptureCount(1); //rd->window()->setInputCaptureCount(1);
} }
@@ -1315,10 +1331,10 @@ LRESULT CALLBACK ToolProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
return 0; return 0;
} }
void Demo::main() { void Demo::run() {
usableApp = this; usableApp = this;
setDebugMode(false); //setDebugMode(false);
debugController.setActive(false); //debugController.setActive(false);
/* /*
if (!createWindowClass("ToolWindowClass",ToolProc,GetModuleHandle(0))) if (!createWindowClass("ToolWindowClass",ToolProc,GetModuleHandle(0)))
{ {
@@ -1371,7 +1387,7 @@ void Demo::main() {
m_userInputWatch.tick(); m_userInputWatch.tick();
onUserInput(userInput); onUserInput(userInput);
m_moduleManager->onUserInput(userInput); //m_moduleManager->onUserInput(userInput);
m_userInputWatch.tock(); m_userInputWatch.tock();
m_simulationWatch.tick(); m_simulationWatch.tick();
@@ -1401,9 +1417,9 @@ void Demo::main() {
renderDevice->pushState(); renderDevice->pushState();
onGraphics(renderDevice); onGraphics(renderDevice);
renderDevice->popState(); renderDevice->popState();
renderDebugInfo(); //renderDebugInfo();
renderDevice->endFrame(); renderDevice->endFrame();
debugText.clear(); //debugText.clear();
m_graphicsWatch.tock(); m_graphicsWatch.tock();
while (PeekMessage (&messages, NULL, 0, 0,PM_REMOVE)) 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); Win32Window* win32Window = Win32Window::create(settings.window,hwndMain);
Demo demo = Demo(settings,win32Window); Demo demo = Demo(settings,win32Window);
SetWindowLongPtr(hwndMain,GWL_USERDATA,(LONG)&demo); SetWindowLongPtr(hwndMain,GWL_USERDATA,(LONG)&demo);
demo.run(); demo.run();
} }