-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
58 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// Created by Conni Bilham on 16/10/2023. | ||
// | ||
|
||
#include "star_viewer.h" | ||
#include "logging.h" | ||
|
||
void star_viewer::Init(Camera *camera) { | ||
this->camera = camera; | ||
camera->type = CAMERA_TYPE::PERSPECTIVE; | ||
|
||
shaders.emplace_back(new Shader("shaders/vertex.glsl", "shaders/fragment.glsl")); | ||
auto entity = new Entity_t(shaders[0], | ||
glm::vec3(0, 0, 0), | ||
glm::vec3(0.0f), | ||
glm::vec3(0.5f)); | ||
|
||
entity_list.push_back(entity); | ||
} | ||
|
||
void star_viewer::Update(double deltaTime) { | ||
glm::mat4 view = glm::mat4(1.0f); | ||
glm::mat4 projection = camera->getProjectionMatrix(storage->window.width, storage->window.height); | ||
view *= camera->view_matrix(); | ||
|
||
for (auto &entity: entity_list) { | ||
{ | ||
entity->shader->apply(view, projection); | ||
entity->draw(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// Created by Conni Bilham on 16/10/2023. | ||
// | ||
|
||
#ifndef INC_2D_ENGINE_STAR_VIEWER_H | ||
#define INC_2D_ENGINE_STAR_VIEWER_H | ||
|
||
#include "Scene.h" | ||
|
||
class star_viewer : public Scene { | ||
public: | ||
void Init(Camera *camera) override; | ||
void Update(double deltaTime) override; | ||
}; | ||
|
||
#endif//INC_2D_ENGINE_STAR_VIEWER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters