[add] add some code + singleton, not working properly yet
This commit is contained in:
@@ -165,12 +165,12 @@ models::TexturedModel singleton::Model_Storage::get_misc(int index)
|
||||
//getters for default variables
|
||||
models::TexturedModel singleton::Model_Storage::get_house_model()
|
||||
{
|
||||
return models::TexturedModel();
|
||||
return house_model;
|
||||
}
|
||||
|
||||
models::ModelTexture singleton::Model_Storage::get_default_texture()
|
||||
{
|
||||
return models::ModelTexture();
|
||||
return default_texture;
|
||||
}
|
||||
|
||||
//setters for deafult variables
|
||||
@@ -185,3 +185,18 @@ void singleton::Model_Storage::set_default_texture(models::ModelTexture texture)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void singleton::Model_Storage::set_shared_test(entities::Entity* temp)
|
||||
{
|
||||
test_pointer = temp;
|
||||
}
|
||||
|
||||
entities::Entity* singleton::Model_Storage::get_test_pointer()
|
||||
{
|
||||
return test_pointer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
#include <deque>
|
||||
#include <mutex>
|
||||
#include "models/Model.h"
|
||||
#include "entities/Entity.h"
|
||||
|
||||
namespace singleton {
|
||||
class Model_Storage
|
||||
@@ -15,6 +17,8 @@ namespace singleton {
|
||||
//default texture
|
||||
models::ModelTexture default_texture;
|
||||
|
||||
entities::Entity* test_pointer;
|
||||
|
||||
//list of furniture:
|
||||
//couches
|
||||
std::deque<models::TexturedModel> couches;
|
||||
@@ -44,7 +48,7 @@ namespace singleton {
|
||||
std::deque<models::TexturedModel> miscs;
|
||||
|
||||
protected:
|
||||
Model_Storage() {}
|
||||
Model_Storage() { std::cout << "MAKING A NEW SINGLETON!!!" << std::endl; }
|
||||
~Model_Storage();
|
||||
|
||||
public:
|
||||
@@ -93,6 +97,10 @@ namespace singleton {
|
||||
//setters for the standard variables
|
||||
void set_house_model(models::TexturedModel house);
|
||||
void set_default_texture(models::ModelTexture texture);
|
||||
|
||||
void set_shared_test(entities::Entity* pointer);
|
||||
entities::Entity* get_test_pointer();
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,13 +6,24 @@
|
||||
#include "../renderEngine/Loader.h"
|
||||
#include "../renderEngine/obj_loader.h"
|
||||
#include "../gui/gui_element.h"
|
||||
#include "../entities/collision_entity.h"
|
||||
|
||||
namespace scene
|
||||
{
|
||||
std::unique_ptr<entities::Camera> camera_test;
|
||||
shaders::EntityShader* shader_test;
|
||||
|
||||
Loading_Scene::Loading_Scene()
|
||||
{
|
||||
shader_test = new shaders::EntityShader;
|
||||
shader_test->Init();
|
||||
render_engine::renderer::Init(*shader_test);
|
||||
|
||||
gui_shader = new shaders::GuiShader();
|
||||
gui_shader->Init();
|
||||
|
||||
camera_test = std::make_unique<entities::Camera>(glm::vec3(0, 0, 0), glm::vec3(0, 0, 0));
|
||||
|
||||
}
|
||||
|
||||
Loading_Scene::~Loading_Scene()
|
||||
@@ -29,11 +40,18 @@ namespace scene
|
||||
int vertices = singleton::Model_Storage::get_instance()->get_house_model().raw_model.vertex_count;
|
||||
GLuint number = singleton::Model_Storage::get_instance()->get_house_model().raw_model.vao_id;
|
||||
|
||||
std::cout << "check shine damper: " << singleton::Model_Storage::get_instance()->get_test_pointer()->GetModel().texture.shine_damper << std::endl;
|
||||
std::cout << "check texture id: " << singleton::Model_Storage::get_instance()->get_test_pointer()->GetModel().texture.texture_id << std::endl;
|
||||
|
||||
std::cout << "" << std::endl;
|
||||
std::cout << "amount of vertices of the house model: " << vertices << std::endl;
|
||||
std::cout << "GLUint of the house model: " << number << std::endl;
|
||||
|
||||
while (true) {
|
||||
render();
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
glfwPollEvents();
|
||||
}
|
||||
return scene::Scenes::STARTUP;
|
||||
}
|
||||
@@ -41,6 +59,15 @@ namespace scene
|
||||
void Loading_Scene::render()
|
||||
{
|
||||
render_engine::renderer::Prepare();
|
||||
//starts the shader and begins to render
|
||||
shader_test->Start();
|
||||
shader_test->LoadSkyColor(render_engine::renderer::SKY_COLOR);
|
||||
shader_test->LoadViewMatrix(*camera_test);
|
||||
|
||||
|
||||
//render_engine::renderer::Render(singleton::Model_Storage::get_instance()->get_test_pointer(), *shader_test);
|
||||
|
||||
/*render_engine::renderer::Prepare();
|
||||
|
||||
gui::GuiTexture loading_image = { render_engine::loader::LoadTexture("res/loading_screen.png"),
|
||||
glm::vec2(0,0),glm::vec2(1,1) };
|
||||
@@ -48,7 +75,8 @@ namespace scene
|
||||
std::vector<gui::GuiTexture*> image_list;
|
||||
image_list.push_back(&loading_image);
|
||||
|
||||
render_engine::renderer::Render(image_list, *gui_shader);
|
||||
render_engine::renderer::Render(image_list, *gui_shader);*/
|
||||
shader_test->Stop();
|
||||
}
|
||||
|
||||
void Loading_Scene::update(GLFWwindow* window)
|
||||
@@ -64,13 +92,18 @@ namespace scene
|
||||
void Loading_Scene::load_default_variables()
|
||||
{
|
||||
models::RawModel raw_model = render_engine::LoadObjModel("res/HouseNew.obj");
|
||||
std::cout << "raw model vertices: " << raw_model.vertex_count << std::endl;
|
||||
models::ModelTexture default_texture = { render_engine::loader::LoadTexture("res/Texture.png") };
|
||||
default_texture.shine_damper = 10;
|
||||
|
||||
models::TexturedModel house = { raw_model, default_texture };
|
||||
std::cout << "house struct vertices: " << house.raw_model.vertex_count << std::endl;
|
||||
|
||||
entities::Entity temp = entities::Entity(singleton::Model_Storage::get_instance()->get_house_model(), glm::vec3(0, -100, -500), glm::vec3(0, 90, 0), 30);
|
||||
|
||||
singleton::Model_Storage::get_instance()->set_default_texture(default_texture);
|
||||
singleton::Model_Storage::get_instance()->set_house_model(house);
|
||||
singleton::Model_Storage::get_instance()->set_shared_test(&temp);
|
||||
}
|
||||
|
||||
void Loading_Scene::load_all_models()
|
||||
|
||||
Reference in New Issue
Block a user