restructure v2
This commit is contained in:
parent
e01595e155
commit
dc5654ba9a
20 changed files with 910 additions and 791 deletions
|
|
@ -1,23 +1,54 @@
|
|||
|
||||
#include <iostream>
|
||||
#include <engine/Backend/Shader.h>
|
||||
#include <engine/Backend/Camera.h>
|
||||
#include <engine/Backend/Model.h>
|
||||
|
||||
#include <glad/glad.h>
|
||||
#include <optional>
|
||||
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
namespace game
|
||||
{
|
||||
const int SCREEN_WIDTH = 1366;
|
||||
const int SCREEN_HEIGHT = 768;
|
||||
|
||||
std::optional<Shader> shader;
|
||||
std::optional<Model> model;
|
||||
std::optional<Camera> camera;
|
||||
|
||||
float lastX = SCREEN_WIDTH / 2.0f;
|
||||
float lastY = SCREEN_HEIGHT / 2.0f;
|
||||
bool firstMouse = true;
|
||||
|
||||
bool Init()
|
||||
{
|
||||
shader.emplace("assets/shaders/basicVertex.vert", "assets/shaders/basicFragment.frag");
|
||||
shader->Use();
|
||||
|
||||
camera.emplace(glm::vec3(0.0f, 0.0f, 0.0f));
|
||||
model.emplace("assets/models/sponza/Sponza.gltf");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void PreFrame()
|
||||
{
|
||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
shader->Use();
|
||||
|
||||
camera->Update(shader.value(), SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
}
|
||||
|
||||
void Render()
|
||||
{
|
||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glm::mat4 modelTransform = glm::mat4(1.0f);
|
||||
modelTransform = glm::translate(modelTransform, glm::vec3(0.0f, 0.0f, 0.0f));
|
||||
modelTransform = glm::scale(modelTransform, glm::vec3(0.02f, 0.02f, 0.02f));
|
||||
shader->setMat4("model", modelTransform);
|
||||
model->Draw(shader.value());
|
||||
}
|
||||
|
||||
void Update()
|
||||
|
|
@ -34,4 +65,5 @@ namespace game
|
|||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue