Created
April 1, 2017 15:37
-
-
Save npruehs/34a73465430588abbaad6a1156ea1d30 to your computer and use it in GitHub Desktop.
PUGL system samples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Setup: | |
this->testSystem = new TestSystem(); | |
this->testScene = this->testSystem->CreateScene(); | |
this->taskManager = new TaskManager(); | |
// Usage: | |
if (taskManager->HasFinished()) | |
{ | |
IAsyncAction^ task = testScene->GetPrimaryTask(); | |
taskManager->QueueTask(task); | |
taskManager->ExecuteTasks(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "pch.h" | |
#include "TestSystem.h" | |
#include "TestSystemScene.h" | |
using namespace Pugl; | |
using namespace PinnedDownClient; | |
TestSystem::TestSystem() | |
{ | |
} | |
TestSystem::~TestSystem() | |
{ | |
} | |
SystemScene* TestSystem::CreateScene() | |
{ | |
return new TestSystemScene(); | |
} | |
void TestSystem::DestroyScene(SystemScene* scene) | |
{ | |
delete scene; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <pugl/System.h> | |
#include <pugl/SystemScene.h> | |
using namespace Pugl; | |
namespace PinnedDownClient | |
{ | |
class TestSystem : public System | |
{ | |
public: | |
TestSystem(); | |
~TestSystem(); | |
Pugl::SystemScene* CreateScene() override; | |
void DestroyScene(SystemScene* scene) override; | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "pch.h" | |
#include "TestSystemScene.h" | |
#include <string> | |
using namespace Pugl; | |
using namespace PinnedDownClient; | |
using namespace concurrency; | |
TestSystemScene::TestSystemScene() | |
: frame(0) | |
{ | |
} | |
TestSystemScene::~TestSystemScene() | |
{ | |
} | |
SystemObject* TestSystemScene::CreateObject() | |
{ | |
return nullptr; | |
} | |
void TestSystemScene::DestroyObject(SystemObject* object) | |
{ | |
delete object; | |
} | |
IAsyncAction^ TestSystemScene::GetPrimaryTask() | |
{ | |
return create_async([this] { | |
for (float f = 0.0f; f < 16000000.0f; ++f) | |
{ | |
float g = f / 12345.0f; | |
} | |
++frame; | |
std::wstring s = std::to_wstring(frame); | |
s.append(L"\r\n"); | |
OutputDebugString(s.c_str()); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <pugl/SystemScene.h> | |
using namespace Pugl; | |
using namespace Windows::Foundation; | |
namespace PinnedDownClient | |
{ | |
class TestSystemScene : public SystemScene | |
{ | |
public: | |
TestSystemScene(); | |
~TestSystemScene(); | |
SystemObject* CreateObject() override; | |
void DestroyObject(SystemObject* object) override; | |
IAsyncAction^ GetPrimaryTask() override; | |
private: | |
int frame; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment