2020-11-24 23:54:49 +01:00
|
|
|
#include <pw/core/vector.hpp>
|
|
|
|
#include <pw/core/serialize.hpp>
|
|
|
|
#include <pw/scene/node.hpp>
|
|
|
|
#include <pw/scene/transform.hpp>
|
|
|
|
#include <pw/scene/scene.hpp>
|
|
|
|
#include <pw/scene/entity.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
#include <pw/core/serialize.hpp>
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
2020-12-04 22:05:04 +01:00
|
|
|
using pw::scene;
|
|
|
|
using pw::entity;
|
2020-11-24 23:54:49 +01:00
|
|
|
|
|
|
|
|
2020-12-04 22:05:04 +01:00
|
|
|
struct test {
|
|
|
|
int val = 0;
|
|
|
|
test(int v) : val(v) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void test_stack()
|
|
|
|
{
|
|
|
|
auto s = scene();
|
|
|
|
auto e = entity(s);
|
|
|
|
|
|
|
|
auto t = e.add_component<test>(112);
|
|
|
|
|
|
|
|
std::cout << t.val << std::endl;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void test_heap()
|
|
|
|
{
|
2020-11-24 23:54:49 +01:00
|
|
|
auto s = std::make_unique<scene>();
|
|
|
|
|
2020-12-04 22:05:04 +01:00
|
|
|
auto e = std::make_unique<entity>(*s);
|
|
|
|
|
|
|
|
auto t = e->add_component<test>(112);
|
|
|
|
|
|
|
|
std::cout << t.val << std::endl;
|
|
|
|
|
|
|
|
}
|
2020-11-24 23:54:49 +01:00
|
|
|
|
|
|
|
|
2020-12-04 22:05:04 +01:00
|
|
|
int main()
|
|
|
|
{
|
|
|
|
test_stack();
|
|
|
|
test_heap();
|
2020-11-24 23:54:49 +01:00
|
|
|
|
|
|
|
}
|