Fixed runtime

This commit is contained in:
2022-04-24 07:24:14 +03:00
parent 5994334a06
commit 583f4bb4f3
3 changed files with 8 additions and 8 deletions
+2 -2
View File
@@ -29,7 +29,7 @@ GLenum to_gl(const blending_constant &c) {
void set_material(std::shared_ptr<material> &mat) { void set_material(std::shared_ptr<material> &mat) {
// glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); // glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
mat->shader->use(); mat->shader_->use();
// if (material->textures[TextureRole::Diffuse]) { // if (material->textures[TextureRole::Diffuse]) {
// std::cout << "CAN has diffuse texture!!!!!!!!!11" << std::endl; // std::cout << "CAN has diffuse texture!!!!!!!!!11" << std::endl;
@@ -86,7 +86,7 @@ void unset_material(std::shared_ptr<material> &mat) {
// textureUnit++; // textureUnit++;
// } // }
mat->shader->unuse(); mat->shader_->unuse();
if (mat->transparent) if (mat->transparent)
glDisable(GL_BLEND); glDisable(GL_BLEND);
+1 -1
View File
@@ -52,7 +52,7 @@ struct material {
blending_constant blend_dst_fact = blending_constant::one_minus_src_alpha; blending_constant blend_dst_fact = blending_constant::one_minus_src_alpha;
fill_mode_type fill_mode = fill_mode_type::solid; fill_mode_type fill_mode = fill_mode_type::solid;
std::shared_ptr<shader> shader; std::shared_ptr<shader> shader_;
texture_map textures; texture_map textures;
}; };
+5 -5
View File
@@ -199,7 +199,7 @@ scene_renderer::scene_renderer()
first_pass_shadow_shader = std::make_shared<shader>(vs, ps); first_pass_shadow_shader = std::make_shared<shader>(vs, ps);
first_pass_shadow_material = std::make_shared<material>(); first_pass_shadow_material = std::make_shared<material>();
first_pass_shadow_material->shader = first_pass_shadow_shader; first_pass_shadow_material->shader_ = first_pass_shadow_shader;
first_pass_shadow_material->zbuffer_write = true; first_pass_shadow_material->zbuffer_write = true;
first_pass_shadow_material->zbuffer_test = true; first_pass_shadow_material->zbuffer_test = true;
first_pass_shadow_material->transparent = false; first_pass_shadow_material->transparent = false;
@@ -209,7 +209,7 @@ scene_renderer::scene_renderer()
second_pass_shadow_shader = std::make_shared<shader>(vs2, ps2); second_pass_shadow_shader = std::make_shared<shader>(vs2, ps2);
second_pass_shadow_material = std::make_shared<material>(); second_pass_shadow_material = std::make_shared<material>();
second_pass_shadow_material->shader = second_pass_shadow_shader; second_pass_shadow_material->shader_ = second_pass_shadow_shader;
second_pass_shadow_material->diffuse = glm::vec4(1, 0, 0, 1); second_pass_shadow_material->diffuse = glm::vec4(1, 0, 0, 1);
second_pass_shadow_material->zbuffer_write = true; second_pass_shadow_material->zbuffer_write = true;
second_pass_shadow_material->zbuffer_test = true; second_pass_shadow_material->zbuffer_test = true;
@@ -296,14 +296,14 @@ void scene_renderer::render(const scene_tree &scene, const std::string &cameraNa
shader_consts.set(uniforms::MaterialSpecularColor, meshNode.material_->specular); shader_consts.set(uniforms::MaterialSpecularColor, meshNode.material_->specular);
shader_consts.set(uniforms::MaterialShininess, meshNode.material_->shininess); shader_consts.set(uniforms::MaterialShininess, meshNode.material_->shininess);
shader_consts.apply_to(*second_pass_shadow_material->shader); shader_consts.apply_to(*second_pass_shadow_material->shader_);
if (meshNode.material_->textures[texture_role::diffuse]) { if (meshNode.material_->textures[texture_role::diffuse]) {
int textureUnit = 0; int textureUnit = 0;
glActiveTexture(GL_TEXTURE0 + textureUnit); glActiveTexture(GL_TEXTURE0 + textureUnit);
meshNode.material_->textures[texture_role::diffuse]->use(); meshNode.material_->textures[texture_role::diffuse]->use();
second_pass_shadow_material->shader->setIntUniform(textureUnit, "diffuseMap"); second_pass_shadow_material->shader_->setIntUniform(textureUnit, "diffuseMap");
} else { } else {
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
@@ -341,7 +341,7 @@ void scene_renderer::render_shadow_map(const scene_tree &scene, light_node &ligh
if (!meshNode.material_->transparent && meshNode.material_->cast_shadows) { if (!meshNode.material_->transparent && meshNode.material_->cast_shadows) {
shader_consts.set(uniforms::ModelToWorldMatrix, meshNode.model_to_world_space_matrix); shader_consts.set(uniforms::ModelToWorldMatrix, meshNode.model_to_world_space_matrix);
shader_consts.apply_to(*first_pass_shadow_material->shader); shader_consts.apply_to(*first_pass_shadow_material->shader_);
meshNode.mesh_->render(first_pass_shadow_material->flat_shaded); meshNode.mesh_->render(first_pass_shadow_material->flat_shaded);
} }