Рефакторинг лабы 2, добавлен пункт 1 по методичке

This commit is contained in:
2023-04-06 16:35:39 +03:00
parent 1c7ef19ec8
commit e8fe646155
15 changed files with 26 additions and 11 deletions

View File

@@ -18,7 +18,7 @@
#include "window/Events.h"
#include "graphics/Mesh.h"
#include "graphics/Shader.h"
#include "render.h"
#include "render/render.h"
#define SPEED_FACTOR 2.5f

View File

@@ -3,14 +3,15 @@
//
#include "render.h"
#include "graphics/MeshLoader.h"
#include "graphics/Shader.h"
#include "../graphics/MeshLoader.h"
#include "../graphics/Shader.h"
#include <glm/ext/matrix_transform.hpp>
static Mesh* mesh_xyz;
static Mesh* mesh_snowman;
static Mesh* mesh_three;
static Mesh* mesh_table;
static Shader* shader;
@@ -58,6 +59,8 @@ void renderScene(Camera& cam) {
shader->uniformMatrix("model", glm::mat4(1.0f));
mesh_xyz->draw();
mesh_table->draw();
drawStaticSnowman();
drawThree();
}
@@ -81,6 +84,12 @@ int loadResources() {
return -1;
}
mesh_table = MeshLoader::loadMesh("res/table");
if (mesh_table == nullptr) {
std::cerr << "Failed to load 'table' mesh!" << std::endl;
return -1;
}
shader = Shader::loadShader("res/main-colored.vsh", "res/main-colored.fsh");
if (shader == nullptr) {
return -1;
@@ -90,6 +99,7 @@ int loadResources() {
}
void unloadResources() {
delete mesh_table;
delete mesh_xyz;
delete mesh_snowman;
delete mesh_three;

View File

@@ -5,11 +5,10 @@
#ifndef GRAPHICS_LABS_RENDER_H
#define GRAPHICS_LABS_RENDER_H
#include "window/Camera.h"
#include "../window/Camera.h"
int loadResources();
void unloadResources();
void renderScene(Camera& cam);
#endif //GRAPHICS_LABS_RENDER_H