2020-12-28 15:45:09 -05:00
|
|
|
#include "example.hpp"
|
|
|
|
|
2021-04-20 12:45:55 -04:00
|
|
|
#include "platform.hpp"
|
|
|
|
#include "file.hpp"
|
|
|
|
#include "engine.hpp"
|
|
|
|
#include "scene.hpp"
|
2021-05-31 06:28:06 -04:00
|
|
|
#include "asset.hpp"
|
|
|
|
#include "path.hpp"
|
2021-04-20 12:45:55 -04:00
|
|
|
|
2021-04-20 12:17:49 -04:00
|
|
|
void app_main(prism::engine* engine) {
|
2021-05-12 08:50:02 -04:00
|
|
|
prism::set_domain_path(prism::domain::app, "data");
|
|
|
|
prism::set_domain_path(prism::domain::internal, "{resource_dir}/shaders");
|
2021-04-20 12:45:55 -04:00
|
|
|
|
2021-04-20 12:57:59 -04:00
|
|
|
platform::open_window("Example", {-1, -1, 1280, 720}, WindowFlags::Resizable);
|
2021-04-20 12:45:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ExampleApp::initialize_render() {
|
|
|
|
engine->create_empty_scene();
|
|
|
|
auto scene = engine->get_scene();
|
|
|
|
|
|
|
|
auto camera_obj = scene->add_object();
|
|
|
|
auto& camera = scene->add<Camera>(camera_obj);
|
2021-05-31 06:28:06 -04:00
|
|
|
camera_look_at(*scene, camera_obj, {2, 2, -2}, {0, 0, 0});
|
2020-12-28 15:45:09 -05:00
|
|
|
|
2021-04-20 12:45:55 -04:00
|
|
|
auto sun_obj = scene->add_object();
|
|
|
|
auto& sun = scene->add<Light>(sun_obj);
|
|
|
|
sun.type = Light::Type::Sun;
|
|
|
|
auto& sun_trans = scene->get<Transform>(sun_obj);
|
|
|
|
sun_trans.position = {5, 5, 5};
|
2021-05-31 06:28:06 -04:00
|
|
|
|
|
|
|
auto sphere_obj = scene->add_object();
|
|
|
|
auto& sphere_render = scene->add<Renderable>(sphere_obj);
|
|
|
|
sphere_render.mesh = assetm->get<Mesh>(prism::path("data/models/sphere.model"));
|
|
|
|
sphere_render.materials = { assetm->get<Material>(prism::path("data/materials/Material.material")) };
|
|
|
|
|
|
|
|
auto probe_obj = scene->add_object();
|
|
|
|
scene->add<EnvironmentProbe>(probe_obj);
|
2020-12-28 15:45:09 -05:00
|
|
|
}
|