Text Rendering works
This commit is contained in:
@@ -22,26 +22,24 @@ void Actor::launchStart()
|
||||
}
|
||||
start();
|
||||
}
|
||||
Array<Job> Actor::launchTick(float deltaTime) const
|
||||
void Actor::launchTick(float deltaTime) const
|
||||
{
|
||||
Array<Job> result = rootComponent->launchTick(deltaTime);
|
||||
rootComponent->launchTick(deltaTime);
|
||||
for(auto child : children)
|
||||
{
|
||||
result.addAll(child->launchTick(deltaTime));
|
||||
child->launchTick(deltaTime);
|
||||
}
|
||||
result.add(tick(deltaTime));
|
||||
return result;
|
||||
tick(deltaTime);
|
||||
}
|
||||
|
||||
Array<Job> Actor::launchUpdate()
|
||||
void Actor::launchUpdate()
|
||||
{
|
||||
Array<Job> result = rootComponent->launchUpdate();
|
||||
rootComponent->launchUpdate();
|
||||
for(auto child : children)
|
||||
{
|
||||
result.addAll(child->launchUpdate());
|
||||
child->launchUpdate();
|
||||
}
|
||||
result.add(update());
|
||||
return result;
|
||||
update();
|
||||
}
|
||||
void Actor::notifySceneAttach(PScene scene)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
#include "MinimalEngine.h"
|
||||
#include "Math/Transform.h"
|
||||
#include "ThreadPool.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
@@ -15,10 +14,10 @@ public:
|
||||
virtual ~Actor();
|
||||
virtual void launchStart();
|
||||
virtual void start() {}
|
||||
Array<Job> launchTick(float deltaTime) const;
|
||||
virtual Job tick(float) const { co_return; }
|
||||
Array<Job> launchUpdate();
|
||||
virtual Job update() { co_return; }
|
||||
void launchTick(float deltaTime) const;
|
||||
virtual void tick(float) const { }//co_return; }
|
||||
void launchUpdate();
|
||||
virtual void update() { }//co_return; }
|
||||
void notifySceneAttach(PScene scene);
|
||||
PScene getScene();
|
||||
|
||||
|
||||
@@ -20,26 +20,22 @@ void Component::launchStart()
|
||||
start();
|
||||
}
|
||||
|
||||
Array<Job> Component::launchTick(float deltaTime) const
|
||||
void Component::launchTick(float deltaTime) const
|
||||
{
|
||||
Array<Job> result;
|
||||
for(auto child : children)
|
||||
{
|
||||
result.addAll(child->launchTick(deltaTime));
|
||||
child->launchTick(deltaTime);
|
||||
}
|
||||
result.add(tick(deltaTime));
|
||||
return result;
|
||||
tick(deltaTime);
|
||||
}
|
||||
|
||||
Array<Job> Component::launchUpdate()
|
||||
void Component::launchUpdate()
|
||||
{
|
||||
Array<Job> result;
|
||||
for(auto child : children)
|
||||
{
|
||||
result.addAll(child->launchUpdate());
|
||||
child->launchUpdate();
|
||||
}
|
||||
result.add(update());
|
||||
return result;
|
||||
update();
|
||||
}
|
||||
|
||||
PComponent Component::getParent()
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include "MinimalEngine.h"
|
||||
#include "Math/Transform.h"
|
||||
#include "Scene/Util.h"
|
||||
#include "ThreadPool.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
@@ -16,10 +15,10 @@ public:
|
||||
virtual ~Component();
|
||||
void launchStart();
|
||||
virtual void start() {};
|
||||
Array<Job> launchTick(float deltaTime) const;
|
||||
virtual Job tick(float) const { co_return; }
|
||||
Array<Job> launchUpdate();
|
||||
virtual Job update() { co_return; }
|
||||
void launchTick(float deltaTime) const;
|
||||
virtual void tick(float) const { }//co_return; }
|
||||
void launchUpdate();
|
||||
virtual void update() { }//co_return; }
|
||||
PComponent getParent();
|
||||
PActor getOwner();
|
||||
const Array<PComponent>& getChildComponents();
|
||||
|
||||
@@ -12,19 +12,19 @@ void MyComponent::start()
|
||||
otherComp.update();
|
||||
}
|
||||
|
||||
Job MyComponent::tick(float) const
|
||||
void MyComponent::tick(float) const
|
||||
{
|
||||
//std::cout << "MyComponent::tick" << std::endl;
|
||||
++writable;
|
||||
//std::cout << "MyComponent::tick finished" << std::endl;
|
||||
otherComp->data = *writable;
|
||||
co_return;
|
||||
//co_return;
|
||||
}
|
||||
|
||||
Job MyComponent::update()
|
||||
void MyComponent::update()
|
||||
{
|
||||
//std::cout << "MyComponent::update" << std::endl;
|
||||
writable.update();
|
||||
//std::cout << "MyComponent::update finished" << std::endl;
|
||||
co_return;
|
||||
//co_return;
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ class MyComponent : public Component
|
||||
public:
|
||||
MyComponent();
|
||||
virtual void start();
|
||||
virtual Job tick(float deltatime) const;
|
||||
virtual Job update();
|
||||
virtual void tick(float deltatime) const;
|
||||
virtual void update();
|
||||
private:
|
||||
Writable<PMyOtherComponent> otherComp;
|
||||
Writable<uint32> writable = 0;
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
Job MyOtherComponent::tick(float) const
|
||||
void MyOtherComponent::tick(float) const
|
||||
{
|
||||
//std::cout << *data << std::endl;
|
||||
co_return;
|
||||
//co_return;
|
||||
}
|
||||
|
||||
Job MyOtherComponent::update()
|
||||
void MyOtherComponent::update()
|
||||
{
|
||||
data.update();
|
||||
co_return;
|
||||
//co_return;
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ namespace Seele
|
||||
class MyOtherComponent : public Component
|
||||
{
|
||||
public:
|
||||
virtual Job tick(float deltaTime) const;
|
||||
virtual Job update();
|
||||
virtual void tick(float deltaTime) const;
|
||||
virtual void update();
|
||||
Writable<uint32> data = Writable<uint32>(0);
|
||||
private:
|
||||
};
|
||||
|
||||
@@ -44,37 +44,33 @@ void Scene::start()
|
||||
static int64 lastUpdate;
|
||||
static uint64 numUpdates;
|
||||
|
||||
Job Scene::beginUpdate(double deltaTime)
|
||||
void Scene::beginUpdate(double deltaTime)
|
||||
{
|
||||
//std::cout << "Scene::beginUpdate" << std::endl;
|
||||
auto startTime = std::chrono::high_resolution_clock::now();
|
||||
//Array<Job> jobs;
|
||||
for(auto actor : rootActors)
|
||||
{
|
||||
co_await Job::all(actor->launchTick(static_cast<float>(deltaTime)));
|
||||
actor->launchTick(static_cast<float>(deltaTime));
|
||||
}
|
||||
//co_await Job::all(std::move(jobs));
|
||||
auto endTime = std::chrono::high_resolution_clock::now();
|
||||
int64 delta = (endTime - startTime).count();
|
||||
int64 delta = std::chrono::duration_cast<std::chrono::microseconds>(endTime - startTime).count();
|
||||
lastUpdate += delta;
|
||||
numUpdates++;
|
||||
if(lastUpdate > 1000)
|
||||
if(lastUpdate > 1000000)
|
||||
{
|
||||
lastUpdate -= 1000;
|
||||
lastUpdate -= 1000000;
|
||||
std::cout << numUpdates << " updates per second" << std::endl;
|
||||
numUpdates = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Job Scene::commitUpdate()
|
||||
void Scene::commitUpdate()
|
||||
{
|
||||
//std::cout << "Scene::commitUpdate" << std::endl;
|
||||
//std::vector<Job> jobs;
|
||||
for(auto actor : rootActors)
|
||||
{
|
||||
co_await Job::all(actor->launchUpdate());
|
||||
actor->launchUpdate();
|
||||
}
|
||||
//co_await Job::all(std::move(jobs));
|
||||
//std::cout << "Scene::commitUpdate finished waiting" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ public:
|
||||
Scene(Gfx::PGraphics graphics);
|
||||
~Scene();
|
||||
void start();
|
||||
Job beginUpdate(double deltaTime);
|
||||
Job commitUpdate();
|
||||
void beginUpdate(double deltaTime);
|
||||
void commitUpdate();
|
||||
void addActor(PActor actor);
|
||||
void addPrimitiveComponent(PPrimitiveComponent comp);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user