Skip to content

Instantly share code, notes, and snippets.

@npruehs
Created April 1, 2017 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save npruehs/34a73465430588abbaad6a1156ea1d30 to your computer and use it in GitHub Desktop.
Save npruehs/34a73465430588abbaad6a1156ea1d30 to your computer and use it in GitHub Desktop.
PUGL system samples
// 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();
}
#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;
}
#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;
};
}
#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());
});
}
#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