9 glm::vec3 suzannePosition = glm::vec3(0, 50, -200);
10 glm::vec3 lightPosition = glm::vec3(0, 0, 0);
13 Ref<Vivid::Shader> lightShader;
14 Ref<Vivid::Entity> suzanne = Vivid::ECS::CreateEntity(
"Suzanne");
15 Ref<Vivid::Entity> light = Vivid::ECS::CreateEntity(
"DirectionalLight");
16 Ref<Vivid::ModelComponent> modelComponent1;
17 Ref<Vivid::TransformComponent> sphereTransformComponent = Vivid::ECS::CreateComponent<Vivid::TransformComponent>();
20 Ref<Vivid::DirectionalLightComponent> directionalLightComponent;
21 Ref<Vivid::Shader> shader;
23 float shininess = 32.0f;
31 shader = MakeRef<Vivid::Shader>(
"./../assets/shaders/phong.vertexShader.glsl",
32 "./../assets/shaders/phong.pixelShader.glsl");
34 mesh =
new Vivid::Mesh(
"./../assets/obj/suzanne.obj", 1);
35 mesh->BindShader(shader);
37 modelComponent1 = Vivid::ECS::CreateComponent<Vivid::ModelComponent>();
38 modelComponent1->AddMesh(mesh);
40 directionalLightComponent = Vivid::ECS::CreateComponent<Vivid::DirectionalLightComponent>();
45 Vivid::ECS::AddComponent(modelComponent1->GetComponentID(), suzanne->GetEntityID());
46 Vivid::ECS::AddComponent(sphereTransformComponent->GetComponentID(), suzanne->GetEntityID());
48 Vivid::ECS::AddComponent(directionalLightComponent->GetComponentID(), light->GetEntityID());
53 Vector<Vivid::DirectionalLightComponent*> directionalLights;
54 Vivid::ECS::GetAllComponents(Vivid::ComponentType::DirectionalLightComponent, directionalLights);
55 float intensity = directionalLights[0]->GetIntensity();
58 mesh->BindShader(shader);
60 shader->SetUniform3f(
"LightDir", lightDir);
61 shader->SetUniform1f(
"LightIntensity", intensity);
62 shader->SetUniform3f(
"LightColor", lightColor);
63 shader->SetUniform1f(
"shininess", shininess);
68 ImGui::Begin(
"Debug");
70 ImGui::Text(
"Application average %.3f ms/frame (%.1f FPS)",
71 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
73 ImGui::SliderFloat(
"shininess", &shininess, 0.0f, 32.0f);
81 Application* app = Application::GetInstance(1920, 1080,
"Vivid: ECS TEST Example");
90 return Vivid::main(0,
nullptr);
void Setup() override
Setup function.
void ImGuiRender() override
ImGuiRender function.
void Draw() override
Draw function.
RenderingInterface class.