From d88b490b3422618ba863be2e0dd8eb21485e74f3 Mon Sep 17 00:00:00 2001 From: jpaone Date: Fri, 18 Oct 2024 14:14:53 -0600 Subject: [PATCH] Tagging v5.5.0 --- CHANGELOG.md | 2 +- csci441.dox.config | 2 +- docs/_arcball_cam_8hpp.html | 2 +- docs/_arcball_cam_8hpp_source.html | 2 +- docs/_c_s_c_i441_8hpp.html | 2 +- docs/_c_s_c_i441_8hpp_source.html | 2 +- docs/_camera_8hpp.html | 2 +- docs/_camera_8hpp_source.html | 2 +- docs/_compute_shader_program_8hpp.html | 2 +- docs/_compute_shader_program_8hpp_source.html | 10 +- docs/_fixed_cam_8hpp.html | 2 +- docs/_fixed_cam_8hpp_source.html | 2 +- docs/_framebuffer_utils_8hpp.html | 2 +- docs/_framebuffer_utils_8hpp_source.html | 2 +- docs/_free_cam_8hpp.html | 2 +- docs/_free_cam_8hpp_source.html | 2 +- docs/_h_u_d_camera_8hpp.html | 2 +- docs/_h_u_d_camera_8hpp_source.html | 2 +- docs/_m_d5_camera_8hpp.html | 2 +- docs/_m_d5_camera_8hpp_source.html | 2 +- docs/_m_d5_model_8hpp.html | 2 +- docs/_m_d5_model_8hpp_source.html | 1240 +++---- docs/_model_loader_8hpp.html | 2 +- docs/_model_loader_8hpp_source.html | 2 +- docs/_open_g_l3_d_engine_8hpp.html | 2 +- docs/_open_g_l3_d_engine_8hpp_source.html | 2 +- docs/_open_g_l_engine_8hpp.html | 2 +- docs/_open_g_l_engine_8hpp_source.html | 2 +- docs/_open_g_l_utils_8hpp.html | 2 +- docs/_open_g_l_utils_8hpp_source.html | 2 +- docs/_orthographic_camera_8hpp_source.html | 2 +- docs/_perspective_camera_8hpp_source.html | 2 +- docs/_shader_program_8hpp.html | 3 +- docs/_shader_program_8hpp_source.html | 2949 +++++++++-------- docs/_shader_program_pipeline_8hpp.html | 2 +- .../_shader_program_pipeline_8hpp_source.html | 8 +- docs/_shader_utils_8hpp.html | 2 +- docs/_shader_utils_8hpp_source.html | 2 +- docs/_simple_shader_8hpp.html | 2 +- docs/_simple_shader_8hpp_source.html | 2 +- docs/_texture_utils_8hpp.html | 45 +- docs/_texture_utils_8hpp_source.html | 234 +- docs/_uniform_buffer_object_8hpp.html | 2 +- docs/_uniform_buffer_object_8hpp_source.html | 10 +- docs/annotated.html | 2 +- ...ss_c_s_c_i441_1_1_arcball_cam-members.html | 2 +- docs/class_c_s_c_i441_1_1_arcball_cam.html | 2 +- docs/class_c_s_c_i441_1_1_camera-members.html | 2 +- docs/class_c_s_c_i441_1_1_camera.html | 2 +- ...41_1_1_compute_shader_program-members.html | 2 +- ...c_s_c_i441_1_1_compute_shader_program.html | 2 +- ...lass_c_s_c_i441_1_1_fixed_cam-members.html | 2 +- docs/class_c_s_c_i441_1_1_fixed_cam.html | 2 +- ...class_c_s_c_i441_1_1_free_cam-members.html | 2 +- docs/class_c_s_c_i441_1_1_free_cam.html | 2 +- ...s_c_s_c_i441_1_1_h_u_d_camera-members.html | 2 +- docs/class_c_s_c_i441_1_1_h_u_d_camera.html | 2 +- ...ss_c_s_c_i441_1_1_m_d5_camera-members.html | 2 +- docs/class_c_s_c_i441_1_1_m_d5_camera.html | 2 +- ...ass_c_s_c_i441_1_1_m_d5_model-members.html | 2 +- docs/class_c_s_c_i441_1_1_m_d5_model.html | 2 +- ...s_c_s_c_i441_1_1_model_loader-members.html | 2 +- docs/class_c_s_c_i441_1_1_model_loader.html | 2 +- ...c_i441_1_1_open_g_l3_d_engine-members.html | 2 +- ...ass_c_s_c_i441_1_1_open_g_l3_d_engine.html | 2 +- ..._s_c_i441_1_1_open_g_l_engine-members.html | 2 +- .../class_c_s_c_i441_1_1_open_g_l_engine.html | 2 +- ..._i441_1_1_orthographic_camera-members.html | 2 +- ...ss_c_s_c_i441_1_1_orthographic_camera.html | 2 +- ...c_i441_1_1_perspective_camera-members.html | 2 +- ...ass_c_s_c_i441_1_1_perspective_camera.html | 2 +- ...c_s_c_i441_1_1_shader_program-members.html | 2 +- docs/class_c_s_c_i441_1_1_shader_program.html | 2 +- ...1_1_1_shader_program_pipeline-members.html | 2 +- ..._s_c_i441_1_1_shader_program_pipeline.html | 2 +- ...441_1_1_uniform_buffer_object-members.html | 2 +- ..._c_s_c_i441_1_1_uniform_buffer_object.html | 2 +- docs/classes.html | 2 +- docs/files.html | 2 +- docs/functions.html | 2 +- docs/functions_b.html | 2 +- docs/functions_c.html | 2 +- docs/functions_d.html | 2 +- docs/functions_e.html | 2 +- docs/functions_enum.html | 2 +- docs/functions_eval.html | 2 +- docs/functions_f.html | 2 +- docs/functions_func.html | 2 +- docs/functions_func_b.html | 2 +- docs/functions_func_c.html | 2 +- docs/functions_func_d.html | 2 +- docs/functions_func_e.html | 2 +- docs/functions_func_f.html | 2 +- docs/functions_func_g.html | 2 +- docs/functions_func_h.html | 2 +- docs/functions_func_i.html | 2 +- docs/functions_func_l.html | 2 +- docs/functions_func_m.html | 2 +- docs/functions_func_o.html | 2 +- docs/functions_func_p.html | 2 +- docs/functions_func_r.html | 2 +- docs/functions_func_s.html | 2 +- docs/functions_func_t.html | 2 +- docs/functions_func_u.html | 2 +- docs/functions_func_v.html | 2 +- docs/functions_func_w.html | 2 +- docs/functions_func_~.html | 2 +- docs/functions_g.html | 2 +- docs/functions_h.html | 2 +- docs/functions_i.html | 2 +- docs/functions_j.html | 2 +- docs/functions_l.html | 2 +- docs/functions_m.html | 2 +- docs/functions_n.html | 2 +- docs/functions_o.html | 2 +- docs/functions_p.html | 2 +- docs/functions_r.html | 2 +- docs/functions_s.html | 2 +- docs/functions_t.html | 2 +- docs/functions_u.html | 2 +- docs/functions_v.html | 2 +- docs/functions_vars.html | 2 +- docs/functions_w.html | 2 +- docs/functions_~.html | 2 +- docs/hierarchy.html | 2 +- docs/index.html | 2 +- docs/materials_8hpp.html | 5 +- docs/materials_8hpp_source.html | 180 +- docs/md__c_h_a_n_g_e_l_o_g.html | 161 +- docs/md__r_e_a_d_m_e.html | 4 +- docs/model_material_8hpp.html | 2 +- docs/model_material_8hpp_source.html | 2 +- docs/namespace_c_s_c_i441.html | 2 +- docs/namespace_framebuffer_utils.html | 2 +- docs/namespace_materials.html | 2 +- docs/namespace_open_g_l_utils.html | 2 +- docs/namespace_simple_shader2.html | 2 +- docs/namespace_simple_shader3.html | 2 +- docs/namespace_texture_utils.html | 2 +- docs/namespacemembers.html | 2 +- docs/namespacemembers_func.html | 2 +- docs/namespaces.html | 2 +- docs/objects_8hpp.html | 2 +- docs/objects_8hpp_source.html | 1515 +++++---- docs/pages.html | 2 +- docs/search/all_a.js | 4 +- docs/search/functions_9.js | 4 +- ...m_d5_model_1_1_m_d5_animation-members.html | 2 +- ...441_1_1_m_d5_model_1_1_m_d5_animation.html | 2 +- ...odel_1_1_m_d5_animation_state-members.html | 2 +- ...1_m_d5_model_1_1_m_d5_animation_state.html | 2 +- ...del_1_1_m_d5_base_frame_joint-members.html | 2 +- ..._m_d5_model_1_1_m_d5_base_frame_joint.html | 2 +- ...5_model_1_1_m_d5_bounding_box-members.html | 2 +- ..._1_1_m_d5_model_1_1_m_d5_bounding_box.html | 2 +- ...1_1_m_d5_model_1_1_m_d5_joint-members.html | 2 +- ..._c_i441_1_1_m_d5_model_1_1_m_d5_joint.html | 2 +- ..._d5_model_1_1_m_d5_joint_info-members.html | 2 +- ...41_1_1_m_d5_model_1_1_m_d5_joint_info.html | 2 +- ..._1_1_m_d5_model_1_1_m_d5_mesh-members.html | 2 +- ...s_c_i441_1_1_m_d5_model_1_1_m_d5_mesh.html | 2 +- ...1_m_d5_model_1_1_m_d5_texture-members.html | 2 +- ..._i441_1_1_m_d5_model_1_1_m_d5_texture.html | 2 +- ..._m_d5_model_1_1_m_d5_triangle-members.html | 2 +- ...i441_1_1_m_d5_model_1_1_m_d5_triangle.html | 2 +- ..._1_m_d5_model_1_1_m_d5_vertex-members.html | 2 +- ...c_i441_1_1_m_d5_model_1_1_m_d5_vertex.html | 2 +- ..._1_m_d5_model_1_1_m_d5_weight-members.html | 2 +- ...c_i441_1_1_m_d5_model_1_1_m_d5_weight.html | 2 +- ...41_1_1_materials_1_1_material-members.html | 2 +- ...c_s_c_i441_1_1_materials_1_1_material.html | 2 +- docs/teapot_8hpp.html | 2 +- docs/teapot_8hpp_source.html | 2 +- 173 files changed, 3359 insertions(+), 3329 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90b26d0f..f0287712 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Revision History -## v ?.?.? - ?? ??? ???? +## v 5.5.0 - 18 Oct 2024 - TextureUtils::loadAndRegister2DTexture() can silence error message - MD5Model silences all but final texture fail messages during load - ShaderProgram uses glm::value_ptr() for passing vectors and matrices to program uniforms diff --git a/csci441.dox.config b/csci441.dox.config index 212d37ed..bf74ed73 100644 --- a/csci441.dox.config +++ b/csci441.dox.config @@ -5,7 +5,7 @@ #--------------------------------------------------------------------------- DOXYFILE_ENCODING = UTF-8 PROJECT_NAME = "CSCI441 OpenGL Library" -PROJECT_NUMBER = 5.4.1 +PROJECT_NUMBER = 5.5.0 PROJECT_BRIEF = "CS@Mines CSCI441 Computer Graphics Course Library" PROJECT_LOGO = OUTPUT_DIRECTORY = diff --git a/docs/_arcball_cam_8hpp.html b/docs/_arcball_cam_8hpp.html index 65200010..360b429f 100644 --- a/docs/_arcball_cam_8hpp.html +++ b/docs/_arcball_cam_8hpp.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_arcball_cam_8hpp_source.html b/docs/_arcball_cam_8hpp_source.html index 05b4c226..8889cc06 100644 --- a/docs/_arcball_cam_8hpp_source.html +++ b/docs/_arcball_cam_8hpp_source.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_c_s_c_i441_8hpp.html b/docs/_c_s_c_i441_8hpp.html index 95f865c1..588ea91a 100644 --- a/docs/_c_s_c_i441_8hpp.html +++ b/docs/_c_s_c_i441_8hpp.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_c_s_c_i441_8hpp_source.html b/docs/_c_s_c_i441_8hpp_source.html index 33dbff18..6e09b00c 100644 --- a/docs/_c_s_c_i441_8hpp_source.html +++ b/docs/_c_s_c_i441_8hpp_source.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_camera_8hpp.html b/docs/_camera_8hpp.html index 0525c64d..88eba580 100644 --- a/docs/_camera_8hpp.html +++ b/docs/_camera_8hpp.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_camera_8hpp_source.html b/docs/_camera_8hpp_source.html index 0a5b4ebc..3bd74910 100644 --- a/docs/_camera_8hpp_source.html +++ b/docs/_camera_8hpp_source.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_compute_shader_program_8hpp.html b/docs/_compute_shader_program_8hpp.html index 9d6c61e2..8c26d022 100644 --- a/docs/_compute_shader_program_8hpp.html +++ b/docs/_compute_shader_program_8hpp.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_compute_shader_program_8hpp_source.html b/docs/_compute_shader_program_8hpp_source.html index c2f8aff4..d338cb0c 100644 --- a/docs/_compute_shader_program_8hpp_source.html +++ b/docs/_compute_shader_program_8hpp_source.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
@@ -187,10 +187,10 @@
Handles registration and compilation of Compute Shaders.
Definition: ComputeShaderProgram.hpp:24
virtual void dispatchWork(GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ) final
dispatches work to the Compute Shader on the GPU
Definition: ComputeShaderProgram.hpp:141
~ComputeShaderProgram() final=default
Clean up memory associated with the Compute Shader Program.
-
Handles registration and compilation of Shaders.
Definition: ShaderProgram.hpp:34
-
GLuint mShaderProgramHandle
handle to the shader program
Definition: ShaderProgram.hpp:844
-
std::map< std::string, GLint > * mpUniformLocationsMap
caches locations of uniform names within shader program
Definition: ShaderProgram.hpp:849
-
static bool sDEBUG
if DEBUG information should be printed or not
Definition: ShaderProgram.hpp:818
+
Handles registration and compilation of Shaders.
Definition: ShaderProgram.hpp:35
+
GLuint mShaderProgramHandle
handle to the shader program
Definition: ShaderProgram.hpp:845
+
std::map< std::string, GLint > * mpUniformLocationsMap
caches locations of uniform names within shader program
Definition: ShaderProgram.hpp:850
+
static bool sDEBUG
if DEBUG information should be printed or not
Definition: ShaderProgram.hpp:819
CSCI441 Helper Functions for OpenGL.
Definition: ArcballCam.hpp:17
diff --git a/docs/_fixed_cam_8hpp.html b/docs/_fixed_cam_8hpp.html index acc848bd..45ca0c96 100644 --- a/docs/_fixed_cam_8hpp.html +++ b/docs/_fixed_cam_8hpp.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_fixed_cam_8hpp_source.html b/docs/_fixed_cam_8hpp_source.html index 9aef1891..46aff4bb 100644 --- a/docs/_fixed_cam_8hpp_source.html +++ b/docs/_fixed_cam_8hpp_source.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_framebuffer_utils_8hpp.html b/docs/_framebuffer_utils_8hpp.html index 37cbcdc4..c09b7fab 100644 --- a/docs/_framebuffer_utils_8hpp.html +++ b/docs/_framebuffer_utils_8hpp.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_framebuffer_utils_8hpp_source.html b/docs/_framebuffer_utils_8hpp_source.html index 8d4bdd38..8a94d3a7 100644 --- a/docs/_framebuffer_utils_8hpp_source.html +++ b/docs/_framebuffer_utils_8hpp_source.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_free_cam_8hpp.html b/docs/_free_cam_8hpp.html index 41be853c..7be2c31e 100644 --- a/docs/_free_cam_8hpp.html +++ b/docs/_free_cam_8hpp.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_free_cam_8hpp_source.html b/docs/_free_cam_8hpp_source.html index 3aeb3e66..3ae2f014 100644 --- a/docs/_free_cam_8hpp_source.html +++ b/docs/_free_cam_8hpp_source.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_h_u_d_camera_8hpp.html b/docs/_h_u_d_camera_8hpp.html index 80e379d5..9005f190 100644 --- a/docs/_h_u_d_camera_8hpp.html +++ b/docs/_h_u_d_camera_8hpp.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_h_u_d_camera_8hpp_source.html b/docs/_h_u_d_camera_8hpp_source.html index e62b8584..9cb06f92 100644 --- a/docs/_h_u_d_camera_8hpp_source.html +++ b/docs/_h_u_d_camera_8hpp_source.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_m_d5_camera_8hpp.html b/docs/_m_d5_camera_8hpp.html index 61cda1b3..fefb490b 100644 --- a/docs/_m_d5_camera_8hpp.html +++ b/docs/_m_d5_camera_8hpp.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_m_d5_camera_8hpp_source.html b/docs/_m_d5_camera_8hpp_source.html index 31814b6f..0967454b 100644 --- a/docs/_m_d5_camera_8hpp_source.html +++ b/docs/_m_d5_camera_8hpp_source.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_m_d5_model_8hpp.html b/docs/_m_d5_model_8hpp.html index 3c1d1e5d..597547a5 100644 --- a/docs/_m_d5_model_8hpp.html +++ b/docs/_m_d5_model_8hpp.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_m_d5_model_8hpp_source.html b/docs/_m_d5_model_8hpp_source.html index a1d0417d..a5a6430b 100644 --- a/docs/_m_d5_model_8hpp_source.html +++ b/docs/_m_d5_model_8hpp_source.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
@@ -432,665 +432,677 @@
603 // diffuse map
604 strcpy(mesh->textures[MD5Mesh::TextureMap::DIFFUSE].filename, mesh->shader);
605 strcat(mesh->textures[MD5Mesh::TextureMap::DIFFUSE].filename, ".tga");
-
606 mesh->textures[MD5Mesh::TextureMap::DIFFUSE].texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->textures[MD5Mesh::TextureMap::DIFFUSE].filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT, false );
+
606 mesh->textures[MD5Mesh::TextureMap::DIFFUSE].texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->textures[MD5Mesh::TextureMap::DIFFUSE].filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT, GL_FALSE, GL_FALSE);
607 if( mesh->textures[MD5Mesh::TextureMap::DIFFUSE].texHandle == 0 ) {
608 strcpy(mesh->textures[MD5Mesh::TextureMap::DIFFUSE].filename, mesh->shader);
609 strcat(mesh->textures[MD5Mesh::TextureMap::DIFFUSE].filename, "_d.tga");
-
610 mesh->textures[MD5Mesh::TextureMap::DIFFUSE].texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->textures[MD5Mesh::TextureMap::DIFFUSE].filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT, false );
+
610 mesh->textures[MD5Mesh::TextureMap::DIFFUSE].texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->textures[MD5Mesh::TextureMap::DIFFUSE].filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT, GL_FALSE, GL_FALSE );
611 if( mesh->textures[MD5Mesh::TextureMap::DIFFUSE].texHandle == 0 ) {
612 strcpy(mesh->textures[MD5Mesh::TextureMap::DIFFUSE].filename, mesh->shader);
613 strcat(mesh->textures[MD5Mesh::TextureMap::DIFFUSE].filename, ".png");
-
614 mesh->textures[MD5Mesh::TextureMap::DIFFUSE].texHandle = CSCI441::TextureUtils::loadAndRegisterTexture(mesh->textures[MD5Mesh::TextureMap::DIFFUSE].filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT, false );
-
615 }
-
616 }
-
617
-
618 // specular map
-
619 strcpy(mesh->textures[MD5Mesh::TextureMap::SPECULAR].filename, mesh->shader);
-
620 strcat(mesh->textures[MD5Mesh::TextureMap::SPECULAR].filename, "_s.tga");
-
621 mesh->textures[MD5Mesh::TextureMap::SPECULAR].texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->textures[MD5Mesh::TextureMap::SPECULAR].filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT, false );
-
622 if( mesh->textures[MD5Mesh::TextureMap::SPECULAR].texHandle == 0 ) {
-
623 strcpy(mesh->textures[MD5Mesh::TextureMap::SPECULAR].filename, mesh->shader);
-
624 strcat(mesh->textures[MD5Mesh::TextureMap::SPECULAR].filename, "_s.png");
-
625 mesh->textures[MD5Mesh::TextureMap::SPECULAR].texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->textures[MD5Mesh::TextureMap::SPECULAR].filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT, false );
-
626 }
-
627
-
628 // normal map
-
629 strcpy(mesh->textures[MD5Mesh::TextureMap::NORMAL].filename, mesh->shader);
-
630 strcat(mesh->textures[MD5Mesh::TextureMap::NORMAL].filename, "_local.tga");
-
631 mesh->textures[MD5Mesh::TextureMap::NORMAL].texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->textures[MD5Mesh::TextureMap::NORMAL].filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT, false );
-
632 if( mesh->textures[MD5Mesh::TextureMap::NORMAL].texHandle == 0 ) {
-
633 strcpy(mesh->textures[MD5Mesh::TextureMap::NORMAL].filename, mesh->shader);
-
634 strcat(mesh->textures[MD5Mesh::TextureMap::NORMAL].filename, "_local.png");
-
635 mesh->textures[MD5Mesh::TextureMap::NORMAL].texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->textures[MD5Mesh::TextureMap::NORMAL].filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT, false );
-
636 }
-
637
-
638 // height map
-
639 strcpy(mesh->textures[MD5Mesh::TextureMap::HEIGHT].filename, mesh->shader);
-
640 strcat(mesh->textures[MD5Mesh::TextureMap::HEIGHT].filename, "_h.tga");
-
641 mesh->textures[MD5Mesh::TextureMap::HEIGHT].texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->textures[MD5Mesh::TextureMap::HEIGHT].filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT, false );
-
642 if( mesh->textures[MD5Mesh::TextureMap::HEIGHT].texHandle == 0 ) {
-
643 strcpy(mesh->textures[MD5Mesh::TextureMap::HEIGHT].filename, mesh->shader);
-
644 strcat(mesh->textures[MD5Mesh::TextureMap::HEIGHT].filename, "_h.png");
-
645 mesh->textures[MD5Mesh::TextureMap::HEIGHT].texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->textures[MD5Mesh::TextureMap::HEIGHT].filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT, false );
-
646 }
-
647 }
-
648 } else if( sscanf(buff, " numverts %d", &mesh->numVertices) == 1 ) {
-
649 if( mesh->numVertices > 0 ) {
-
650 // Allocate memory for vertices
-
651 mesh->vertices = new MD5Vertex[mesh->numVertices];
-
652 }
-
653
-
654 if( mesh->numVertices > _maxVertices )
-
655 _maxVertices = mesh->numVertices;
-
656
-
657 totalVertices += mesh->numVertices;
-
658 } else if( sscanf(buff, " numtris %d", &mesh->numTriangles) == 1 ) {
-
659 if( mesh->numTriangles > 0 ) {
-
660 // Allocate memory for triangles
-
661 mesh->triangles = new MD5Triangle[mesh->numTriangles];
-
662 }
-
663
-
664 if( mesh->numTriangles > _maxTriangles )
-
665 _maxTriangles = mesh->numTriangles;
-
666
-
667 totalTriangles += mesh->numTriangles;
-
668 } else if( sscanf(buff, " numweights %d", &mesh->numWeights) == 1 ) {
-
669 if( mesh->numWeights > 0 ) {
-
670 // Allocate memory for vertex weights
-
671 mesh->weights = new MD5Weight[mesh->numWeights];
-
672 }
-
673
-
674 totalWeights += mesh->numWeights;
-
675 } else if( sscanf(buff, " vert %d ( %f %f ) %d %d",
-
676 &vert_index,
-
677 &fdata[0], &fdata[1],
-
678 &idata[0], &idata[1]) == 5
-
679 ) {
-
680 // Copy vertex data
-
681 mesh->vertices[vert_index].texCoord.s = fdata[0];
-
682 mesh->vertices[vert_index].texCoord.t = fdata[1];
-
683 mesh->vertices[vert_index].start = idata[0];
-
684 mesh->vertices[vert_index].count = idata[1];
-
685 } else if( sscanf(buff, " tri %d %d %d %d",
-
686 &tri_index,
-
687 &idata[0], &idata[1], &idata[2]) == 4
-
688 ) {
-
689 // Copy triangle data
-
690 mesh->triangles[tri_index ].index[0] = idata[0];
-
691 mesh->triangles[tri_index ].index[1] = idata[1];
-
692 mesh->triangles[tri_index ].index[2] = idata[2];
-
693 } else if( sscanf(buff, " weight %d %d %f ( %f %f %f )",
-
694 &weight_index, &idata[0], &fdata[3],
-
695 &fdata[0], &fdata[1], &fdata[2]) == 6
-
696 ) {
-
697 // Copy vertex data
-
698 mesh->weights[weight_index].joint = idata[0];
-
699 mesh->weights[weight_index].bias = fdata[3];
-
700 mesh->weights[weight_index].position[0] = fdata[0];
-
701 mesh->weights[weight_index].position[1] = fdata[1];
-
702 mesh->weights[weight_index].position[2] = fdata[2];
-
703
-
704 if( fdata[0] < minX ) { minX = fdata[0]; }
-
705 if( fdata[0] > maxX ) { maxX = fdata[0]; }
-
706 if( fdata[1] < minY ) { minY = fdata[1]; }
-
707 if( fdata[1] > maxY ) { maxY = fdata[1]; }
-
708 if( fdata[2] < minZ ) { minZ = fdata[2]; }
-
709 if( fdata[2] > maxZ ) { maxZ = fdata[2]; }
-
710 }
-
711 }
-
712
-
713 currentMesh++;
-
714 }
-
715 }
-
716
-
717 fclose(fp);
-
718
-
719 _skeleton = _baseSkeleton;
-
720
-
721 printf("[.md5mesh]: finished reading %s\n", FILENAME );
-
722 printf("[.md5mesh]: read in %d meshes, %d joints, %d vertices, %d weights, and %d triangles\n", _numMeshes, _numJoints, totalVertices, totalWeights, totalTriangles );
-
723 printf( "[.md5mesh]: base pose %f units across in X, %f units across in Y, %f units across in Z\n", (maxX - minX), (maxY-minY), (maxZ - minZ) );
-
724 printf( "\n" );
-
725
-
726 return true;
-
727}
+
614 mesh->textures[MD5Mesh::TextureMap::DIFFUSE].texHandle = CSCI441::TextureUtils::loadAndRegisterTexture(mesh->textures[MD5Mesh::TextureMap::DIFFUSE].filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT, GL_FALSE, GL_FALSE );
+
615 if( mesh->textures[MD5Mesh::TextureMap::DIFFUSE].texHandle == 0 ) {
+
616 printf("[.md5mesh | ERROR]: Could not load diffuse map %s\n", mesh->shader);
+
617 }
+
618 }
+
619 }
+
620
+
621 // specular map
+
622 strcpy(mesh->textures[MD5Mesh::TextureMap::SPECULAR].filename, mesh->shader);
+
623 strcat(mesh->textures[MD5Mesh::TextureMap::SPECULAR].filename, "_s.tga");
+
624 mesh->textures[MD5Mesh::TextureMap::SPECULAR].texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->textures[MD5Mesh::TextureMap::SPECULAR].filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT, GL_FALSE, GL_FALSE );
+
625 if( mesh->textures[MD5Mesh::TextureMap::SPECULAR].texHandle == 0 ) {
+
626 strcpy(mesh->textures[MD5Mesh::TextureMap::SPECULAR].filename, mesh->shader);
+
627 strcat(mesh->textures[MD5Mesh::TextureMap::SPECULAR].filename, "_s.png");
+
628 mesh->textures[MD5Mesh::TextureMap::SPECULAR].texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->textures[MD5Mesh::TextureMap::SPECULAR].filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT, GL_FALSE, GL_FALSE );
+
629 if( mesh->textures[MD5Mesh::TextureMap::DIFFUSE].texHandle == 0 ) {
+
630 printf("[.md5mesh | ERROR]: Could not load specular map %s\n", mesh->shader);
+
631 }
+
632 }
+
633
+
634 // normal map
+
635 strcpy(mesh->textures[MD5Mesh::TextureMap::NORMAL].filename, mesh->shader);
+
636 strcat(mesh->textures[MD5Mesh::TextureMap::NORMAL].filename, "_local.tga");
+
637 mesh->textures[MD5Mesh::TextureMap::NORMAL].texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->textures[MD5Mesh::TextureMap::NORMAL].filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT, GL_FALSE, GL_FALSE );
+
638 if( mesh->textures[MD5Mesh::TextureMap::NORMAL].texHandle == 0 ) {
+
639 strcpy(mesh->textures[MD5Mesh::TextureMap::NORMAL].filename, mesh->shader);
+
640 strcat(mesh->textures[MD5Mesh::TextureMap::NORMAL].filename, "_local.png");
+
641 mesh->textures[MD5Mesh::TextureMap::NORMAL].texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->textures[MD5Mesh::TextureMap::NORMAL].filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT, GL_FALSE, GL_FALSE );
+
642 if( mesh->textures[MD5Mesh::TextureMap::DIFFUSE].texHandle == 0 ) {
+
643 printf("[.md5mesh | ERROR]: Could not load normal map %s\n", mesh->shader);
+
644 }
+
645 }
+
646
+
647 // height map
+
648 strcpy(mesh->textures[MD5Mesh::TextureMap::HEIGHT].filename, mesh->shader);
+
649 strcat(mesh->textures[MD5Mesh::TextureMap::HEIGHT].filename, "_h.tga");
+
650 mesh->textures[MD5Mesh::TextureMap::HEIGHT].texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->textures[MD5Mesh::TextureMap::HEIGHT].filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT, GL_FALSE, GL_FALSE );
+
651 if( mesh->textures[MD5Mesh::TextureMap::HEIGHT].texHandle == 0 ) {
+
652 strcpy(mesh->textures[MD5Mesh::TextureMap::HEIGHT].filename, mesh->shader);
+
653 strcat(mesh->textures[MD5Mesh::TextureMap::HEIGHT].filename, "_h.png");
+
654 mesh->textures[MD5Mesh::TextureMap::HEIGHT].texHandle = CSCI441::TextureUtils::loadAndRegisterTexture( mesh->textures[MD5Mesh::TextureMap::HEIGHT].filename, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT, GL_REPEAT, GL_FALSE, GL_FALSE );
+
655 if( mesh->textures[MD5Mesh::TextureMap::DIFFUSE].texHandle == 0 ) {
+
656 printf("[.md5mesh | ERROR]: Could not load height map %s\n", mesh->shader);
+
657 }
+
658 }
+
659 }
+
660 } else if( sscanf(buff, " numverts %d", &mesh->numVertices) == 1 ) {
+
661 if( mesh->numVertices > 0 ) {
+
662 // Allocate memory for vertices
+
663 mesh->vertices = new MD5Vertex[mesh->numVertices];
+
664 }
+
665
+
666 if( mesh->numVertices > _maxVertices )
+
667 _maxVertices = mesh->numVertices;
+
668
+
669 totalVertices += mesh->numVertices;
+
670 } else if( sscanf(buff, " numtris %d", &mesh->numTriangles) == 1 ) {
+
671 if( mesh->numTriangles > 0 ) {
+
672 // Allocate memory for triangles
+
673 mesh->triangles = new MD5Triangle[mesh->numTriangles];
+
674 }
+
675
+
676 if( mesh->numTriangles > _maxTriangles )
+
677 _maxTriangles = mesh->numTriangles;
+
678
+
679 totalTriangles += mesh->numTriangles;
+
680 } else if( sscanf(buff, " numweights %d", &mesh->numWeights) == 1 ) {
+
681 if( mesh->numWeights > 0 ) {
+
682 // Allocate memory for vertex weights
+
683 mesh->weights = new MD5Weight[mesh->numWeights];
+
684 }
+
685
+
686 totalWeights += mesh->numWeights;
+
687 } else if( sscanf(buff, " vert %d ( %f %f ) %d %d",
+
688 &vert_index,
+
689 &fdata[0], &fdata[1],
+
690 &idata[0], &idata[1]) == 5
+
691 ) {
+
692 // Copy vertex data
+
693 mesh->vertices[vert_index].texCoord.s = fdata[0];
+
694 mesh->vertices[vert_index].texCoord.t = fdata[1];
+
695 mesh->vertices[vert_index].start = idata[0];
+
696 mesh->vertices[vert_index].count = idata[1];
+
697 } else if( sscanf(buff, " tri %d %d %d %d",
+
698 &tri_index,
+
699 &idata[0], &idata[1], &idata[2]) == 4
+
700 ) {
+
701 // Copy triangle data
+
702 mesh->triangles[tri_index ].index[0] = idata[0];
+
703 mesh->triangles[tri_index ].index[1] = idata[1];
+
704 mesh->triangles[tri_index ].index[2] = idata[2];
+
705 } else if( sscanf(buff, " weight %d %d %f ( %f %f %f )",
+
706 &weight_index, &idata[0], &fdata[3],
+
707 &fdata[0], &fdata[1], &fdata[2]) == 6
+
708 ) {
+
709 // Copy vertex data
+
710 mesh->weights[weight_index].joint = idata[0];
+
711 mesh->weights[weight_index].bias = fdata[3];
+
712 mesh->weights[weight_index].position[0] = fdata[0];
+
713 mesh->weights[weight_index].position[1] = fdata[1];
+
714 mesh->weights[weight_index].position[2] = fdata[2];
+
715
+
716 if( fdata[0] < minX ) { minX = fdata[0]; }
+
717 if( fdata[0] > maxX ) { maxX = fdata[0]; }
+
718 if( fdata[1] < minY ) { minY = fdata[1]; }
+
719 if( fdata[1] > maxY ) { maxY = fdata[1]; }
+
720 if( fdata[2] < minZ ) { minZ = fdata[2]; }
+
721 if( fdata[2] > maxZ ) { maxZ = fdata[2]; }
+
722 }
+
723 }
+
724
+
725 currentMesh++;
+
726 }
+
727 }
728
-
729//Free resources allocated for the model.
-
730inline void
-
731CSCI441::MD5Model::_freeModel()
-
732{
-
733 delete _baseSkeleton;
-
734 _baseSkeleton = nullptr;
-
735
-
736 // Free mesh data
-
737 for(GLint i = 0; i < _numMeshes; ++i) {
-
738 delete _meshes[i].vertices;
-
739 _meshes[i].vertices = nullptr;
+
729 fclose(fp);
+
730
+
731 _skeleton = _baseSkeleton;
+
732
+
733 printf("[.md5mesh]: finished reading %s\n", FILENAME );
+
734 printf("[.md5mesh]: read in %d meshes, %d joints, %d vertices, %d weights, and %d triangles\n", _numMeshes, _numJoints, totalVertices, totalWeights, totalTriangles );
+
735 printf( "[.md5mesh]: base pose %f units across in X, %f units across in Y, %f units across in Z\n", (maxX - minX), (maxY-minY), (maxZ - minZ) );
+
736 printf( "\n" );
+
737
+
738 return true;
+
739}
740
-
741 delete _meshes[i].triangles;
-
742 _meshes[i].triangles = nullptr;
-
743
-
744 delete _meshes[i].weights;
-
745 _meshes[i].weights = nullptr;
-
746 }
+
741//Free resources allocated for the model.
+
742inline void
+
743CSCI441::MD5Model::_freeModel()
+
744{
+
745 delete _baseSkeleton;
+
746 _baseSkeleton = nullptr;
747
-
748 delete _meshes;
-
749 _meshes = nullptr;
-
750}
-
751
-
752[[maybe_unused]]
-
753inline void
- -
755{
-
756 // Draw each mesh of the model
-
757 for(GLint i = 0; i < _numMeshes; ++i) {
-
758 MD5Mesh mesh = _meshes[i]; // get the mesh
-
759 _prepareMesh(&mesh); // do some preprocessing on it
-
760 _drawMesh(&mesh);
-
761 }
+
748 // Free mesh data
+
749 for(GLint i = 0; i < _numMeshes; ++i) {
+
750 delete _meshes[i].vertices;
+
751 _meshes[i].vertices = nullptr;
+
752
+
753 delete _meshes[i].triangles;
+
754 _meshes[i].triangles = nullptr;
+
755
+
756 delete _meshes[i].weights;
+
757 _meshes[i].weights = nullptr;
+
758 }
+
759
+
760 delete _meshes;
+
761 _meshes = nullptr;
762}
763
-
764// Prepare a mesh for drawing. Compute mesh's final vertex positions
-
765// given a skeleton. Put the vertices in vertex arrays.
-
766inline void
-
767CSCI441::MD5Model::_prepareMesh(
-
768 const MD5Mesh *pMESH
-
769) const {
-
770 GLint i, j, k;
-
771
-
772 // Setup vertex indices
-
773 for(k = 0, i = 0; i < pMESH->numTriangles; ++i) {
-
774 for(j = 0; j < 3; ++j, ++k)
-
775 _vertexIndicesArray[k] = pMESH->triangles[i].index[j];
-
776 }
-
777
-
778 // Setup vertices
-
779 for(i = 0; i < pMESH->numVertices; ++i) {
-
780 glm::vec3 finalVertex = {0.0f, 0.0f, 0.0f };
-
781
-
782 // Calculate final vertex to draw with weights
-
783 for(j = 0; j < pMESH->vertices[i].count; ++j) {
-
784 const MD5Weight *weight = &pMESH->weights[pMESH->vertices[i].start + j];
-
785 const MD5Joint *joint = &_skeleton[weight->joint];
-
786
-
787 // Calculate transformed vertex for this weight
-
788 glm::vec3 weightedVertex;
-
789 weightedVertex = glm::rotate(joint->orientation, glm::vec4(weight->position, 0.0f));
-
790
-
791 // The sum of all weight->bias should be 1.0
-
792 finalVertex.x += (joint->position.x + weightedVertex.x) * weight->bias;
-
793 finalVertex.y += (joint->position.y + weightedVertex.y) * weight->bias;
-
794 finalVertex.z += (joint->position.z + weightedVertex.z) * weight->bias;
-
795 }
-
796
-
797 _vertexArray[i].x = finalVertex.x;
-
798 _vertexArray[i].y = finalVertex.y;
-
799 _vertexArray[i].z = finalVertex.z;
-
800
-
801 _texelArray[i].s = pMESH->vertices[i].texCoord.s;
-
802 _texelArray[i].t = pMESH->vertices[i].texCoord.t;
-
803 }
-
804
-
805 glBindVertexArray(_vao );
-
806 glBindBuffer(GL_ARRAY_BUFFER, _vbo[0] );
-
807 glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(glm::vec3) * pMESH->numVertices, &_vertexArray[0] );
-
808 glBufferSubData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * _maxVertices, sizeof(glm::vec2) * pMESH->numVertices, &_texelArray[0] );
-
809 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vbo[1] );
-
810 glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(GLuint) * pMESH->numTriangles * 3, _vertexIndicesArray );
-
811}
+
764[[maybe_unused]]
+
765inline void
+ +
767{
+
768 // Draw each mesh of the model
+
769 for(GLint i = 0; i < _numMeshes; ++i) {
+
770 MD5Mesh mesh = _meshes[i]; // get the mesh
+
771 _prepareMesh(&mesh); // do some preprocessing on it
+
772 _drawMesh(&mesh);
+
773 }
+
774}
+
775
+
776// Prepare a mesh for drawing. Compute mesh's final vertex positions
+
777// given a skeleton. Put the vertices in vertex arrays.
+
778inline void
+
779CSCI441::MD5Model::_prepareMesh(
+
780 const MD5Mesh *pMESH
+
781) const {
+
782 GLint i, j, k;
+
783
+
784 // Setup vertex indices
+
785 for(k = 0, i = 0; i < pMESH->numTriangles; ++i) {
+
786 for(j = 0; j < 3; ++j, ++k)
+
787 _vertexIndicesArray[k] = pMESH->triangles[i].index[j];
+
788 }
+
789
+
790 // Setup vertices
+
791 for(i = 0; i < pMESH->numVertices; ++i) {
+
792 glm::vec3 finalVertex = {0.0f, 0.0f, 0.0f };
+
793
+
794 // Calculate final vertex to draw with weights
+
795 for(j = 0; j < pMESH->vertices[i].count; ++j) {
+
796 const MD5Weight *weight = &pMESH->weights[pMESH->vertices[i].start + j];
+
797 const MD5Joint *joint = &_skeleton[weight->joint];
+
798
+
799 // Calculate transformed vertex for this weight
+
800 glm::vec3 weightedVertex;
+
801 weightedVertex = glm::rotate(joint->orientation, glm::vec4(weight->position, 0.0f));
+
802
+
803 // The sum of all weight->bias should be 1.0
+
804 finalVertex.x += (joint->position.x + weightedVertex.x) * weight->bias;
+
805 finalVertex.y += (joint->position.y + weightedVertex.y) * weight->bias;
+
806 finalVertex.z += (joint->position.z + weightedVertex.z) * weight->bias;
+
807 }
+
808
+
809 _vertexArray[i].x = finalVertex.x;
+
810 _vertexArray[i].y = finalVertex.y;
+
811 _vertexArray[i].z = finalVertex.z;
812
-
813inline void
-
814CSCI441::MD5Model::_drawMesh(
-
815 const MD5Mesh *pMESH
-
816) const {
-
817 // Bind Diffuse Map
-
818 glBindTexture(GL_TEXTURE_2D, pMESH->textures[MD5Mesh::TextureMap::DIFFUSE].texHandle );
-
819
-
820 glBindVertexArray(_vao );
-
821 glDrawElements(GL_TRIANGLES, pMESH->numTriangles * 3, GL_UNSIGNED_INT, (void*)nullptr );
-
822}
-
823
-
824[[maybe_unused]]
+
813 _texelArray[i].s = pMESH->vertices[i].texCoord.s;
+
814 _texelArray[i].t = pMESH->vertices[i].texCoord.t;
+
815 }
+
816
+
817 glBindVertexArray(_vao );
+
818 glBindBuffer(GL_ARRAY_BUFFER, _vbo[0] );
+
819 glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(glm::vec3) * pMESH->numVertices, &_vertexArray[0] );
+
820 glBufferSubData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * _maxVertices, sizeof(glm::vec2) * pMESH->numVertices, &_texelArray[0] );
+
821 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vbo[1] );
+
822 glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(GLuint) * pMESH->numTriangles * 3, _vertexIndicesArray );
+
823}
+
824
825inline void
- -
827 GLuint vPosAttribLoc,
-
828 GLuint vColorAttribLoc,
-
829 GLuint vTexCoordAttribLoc
-
830) {
-
831 _vertexArray = new glm::vec3[_maxVertices];
-
832 _texelArray = new glm::vec2[_maxVertices];
-
833 _vertexIndicesArray = new GLuint[_maxTriangles * 3];
-
834
-
835 glGenVertexArrays( 1, &_vao );
-
836 glBindVertexArray(_vao );
-
837
-
838 glGenBuffers(2, _vbo );
-
839 glBindBuffer(GL_ARRAY_BUFFER, _vbo[0] );
-
840 glBufferData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * _maxVertices + sizeof(glm::vec2) * _maxVertices, nullptr, GL_DYNAMIC_DRAW );
-
841
-
842 glEnableVertexAttribArray( vPosAttribLoc );
-
843 glVertexAttribPointer( vPosAttribLoc, 3, GL_FLOAT, GL_FALSE, 0, (void*)nullptr );
-
844
-
845 glEnableVertexAttribArray( vTexCoordAttribLoc );
-
846 glVertexAttribPointer( vTexCoordAttribLoc, 2, GL_FLOAT, GL_FALSE, 0, (void*)(sizeof(glm::vec3) * _maxVertices) );
-
847
-
848 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vbo[1] );
-
849 glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLuint) * _maxTriangles * 3, nullptr, GL_DYNAMIC_DRAW );
-
850
-
851 printf("[.md5mesh]: Model VAO/VBO/IBO registered at %u/%u/%u\n", _vao, _vbo[0], _vbo[1] );
-
852
-
853 glGenVertexArrays( 1, &_skeletonVAO );
-
854 glBindVertexArray(_skeletonVAO );
-
855
-
856 glGenBuffers( 1, &_skeletonVBO );
-
857 glBindBuffer(GL_ARRAY_BUFFER, _skeletonVBO );
-
858 glBufferData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * _numJoints * 3 * 2, nullptr, GL_DYNAMIC_DRAW );
+
826CSCI441::MD5Model::_drawMesh(
+
827 const MD5Mesh *pMESH
+
828) const {
+
829 // Bind Diffuse Map
+
830 glBindTexture(GL_TEXTURE_2D, pMESH->textures[MD5Mesh::TextureMap::DIFFUSE].texHandle );
+
831
+
832 glBindVertexArray(_vao );
+
833 glDrawElements(GL_TRIANGLES, pMESH->numTriangles * 3, GL_UNSIGNED_INT, (void*)nullptr );
+
834}
+
835
+
836[[maybe_unused]]
+
837inline void
+ +
839 GLuint vPosAttribLoc,
+
840 GLuint vColorAttribLoc,
+
841 GLuint vTexCoordAttribLoc
+
842) {
+
843 _vertexArray = new glm::vec3[_maxVertices];
+
844 _texelArray = new glm::vec2[_maxVertices];
+
845 _vertexIndicesArray = new GLuint[_maxTriangles * 3];
+
846
+
847 glGenVertexArrays( 1, &_vao );
+
848 glBindVertexArray(_vao );
+
849
+
850 glGenBuffers(2, _vbo );
+
851 glBindBuffer(GL_ARRAY_BUFFER, _vbo[0] );
+
852 glBufferData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * _maxVertices + sizeof(glm::vec2) * _maxVertices, nullptr, GL_DYNAMIC_DRAW );
+
853
+
854 glEnableVertexAttribArray( vPosAttribLoc );
+
855 glVertexAttribPointer( vPosAttribLoc, 3, GL_FLOAT, GL_FALSE, 0, (void*)nullptr );
+
856
+
857 glEnableVertexAttribArray( vTexCoordAttribLoc );
+
858 glVertexAttribPointer( vTexCoordAttribLoc, 2, GL_FLOAT, GL_FALSE, 0, (void*)(sizeof(glm::vec3) * _maxVertices) );
859
-
860 glEnableVertexAttribArray( vPosAttribLoc ); // vPos
-
861 glVertexAttribPointer( vPosAttribLoc, 3, GL_FLOAT, GL_FALSE, 0, (void*)nullptr );
+
860 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vbo[1] );
+
861 glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLuint) * _maxTriangles * 3, nullptr, GL_DYNAMIC_DRAW );
862
-
863 glEnableVertexAttribArray( vColorAttribLoc ); // vColor
-
864 glVertexAttribPointer( vColorAttribLoc, 3, GL_FLOAT, GL_FALSE, 0, (void*)(sizeof(glm::vec3) * _numJoints * 3) );
-
865
-
866 printf("[.md5mesh]: Skeleton VAO/VBO registered at %u/%u\n", _skeletonVAO, _skeletonVBO );
-
867}
-
868
-
869inline void
-
870CSCI441::MD5Model::_freeVertexArrays()
-
871{
-
872 delete[] _vertexArray;
-
873 _vertexArray = nullptr;
+
863 printf("[.md5mesh]: Model VAO/VBO/IBO registered at %u/%u/%u\n", _vao, _vbo[0], _vbo[1] );
+
864
+
865 glGenVertexArrays( 1, &_skeletonVAO );
+
866 glBindVertexArray(_skeletonVAO );
+
867
+
868 glGenBuffers( 1, &_skeletonVBO );
+
869 glBindBuffer(GL_ARRAY_BUFFER, _skeletonVBO );
+
870 glBufferData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * _numJoints * 3 * 2, nullptr, GL_DYNAMIC_DRAW );
+
871
+
872 glEnableVertexAttribArray( vPosAttribLoc ); // vPos
+
873 glVertexAttribPointer( vPosAttribLoc, 3, GL_FLOAT, GL_FALSE, 0, (void*)nullptr );
874
-
875 delete[] _vertexIndicesArray;
-
876 _vertexIndicesArray = nullptr;
+
875 glEnableVertexAttribArray( vColorAttribLoc ); // vColor
+
876 glVertexAttribPointer( vColorAttribLoc, 3, GL_FLOAT, GL_FALSE, 0, (void*)(sizeof(glm::vec3) * _numJoints * 3) );
877
-
878 delete[] _texelArray;
-
879 _texelArray = nullptr;
+
878 printf("[.md5mesh]: Skeleton VAO/VBO registered at %u/%u\n", _skeletonVAO, _skeletonVBO );
+
879}
880
-
881 glDeleteVertexArrays( 1, &_vao );
-
882 glDeleteBuffers(2, _vbo );
-
883 glDeleteVertexArrays( 1, &_skeletonVAO );
-
884 glDeleteBuffers( 1, &_skeletonVBO );
-
885}
+
881inline void
+
882CSCI441::MD5Model::_freeVertexArrays()
+
883{
+
884 delete[] _vertexArray;
+
885 _vertexArray = nullptr;
886
-
887// Draw the skeleton as lines and points (for joints).
-
888[[maybe_unused]]
-
889inline void
- -
891{
-
892 glBindVertexArray(_skeletonVAO );
-
893 glBindBuffer(GL_ARRAY_BUFFER, _skeletonVBO );
-
894
-
895 glm::vec3 jointColor = {1.0f, 1.0f, 0.0f };
-
896 glm::vec3 boneColor = {1.0f, 0.0f, 1.0f };
-
897
-
898 // put in points for joints
-
899 for(GLint i = 0; i < _numJoints; ++i ) {
-
900 glBufferSubData(GL_ARRAY_BUFFER, i * sizeof(glm::vec3), sizeof(glm::vec3), &(_skeleton[i].position) );
-
901 glBufferSubData(GL_ARRAY_BUFFER, i * sizeof(glm::vec3) + sizeof(glm::vec3) * _numJoints * 3, sizeof(glm::vec3), &jointColor[0]);
-
902 }
-
903
-
904 // put in lines for bones
-
905 GLint numBones = 0;
-
906 for(GLint i = 0; i < _numJoints; ++i ) {
-
907 if( _skeleton[i].parent != MD5Joint::NULL_JOINT ) {
-
908 glBufferSubData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * _numJoints + (i * 2) * sizeof(glm::vec3), sizeof(glm::vec3), &(_skeleton[_skeleton[i].parent].position) );
-
909 glBufferSubData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * _numJoints + (i * 2) * sizeof(glm::vec3) + sizeof(glm::vec3) * _numJoints * 3, sizeof(glm::vec3), &boneColor[0]);
-
910
-
911 glBufferSubData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * _numJoints + (i * 2) * sizeof(glm::vec3) + sizeof(glm::vec3), sizeof(glm::vec3), &(_skeleton[i].position) );
-
912 glBufferSubData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * _numJoints + (i * 2) * sizeof(glm::vec3) + sizeof(glm::vec3) + sizeof(glm::vec3) * _numJoints * 3, sizeof(glm::vec3), &boneColor[0]);
-
913 numBones++;
-
914 }
-
915 }
-
916
-
917 glPointSize (5.0f);
-
918 glDrawArrays(GL_POINTS, 0, _numJoints );
-
919 glPointSize(1.0f);
-
920
-
921 glLineWidth( 3.0f );
-
922 glDrawArrays(GL_LINES, _numJoints, numBones * 2 );
-
923 glLineWidth(1.0f);
-
924}
-
925
-
926// Check if an animation can be used for a given model. Model's
-
927// skeleton and animation's skeleton must match.
-
928inline bool
-
929CSCI441::MD5Model::_checkAnimValidity() const
-
930{
-
931 // md5mesh and md5anim must have the same number of joints
-
932 if( _numJoints != _animation.numJoints ) {
-
933 printf("\n[.md5anim]: skeleton and animation do not have same number of joints. cannot apply animation to skeleton\n\n");
-
934 return false;
-
935 }
-
936
-
937 // We just check with frame[0]
-
938 for(GLint i = 0; i < _numJoints; ++i) {
-
939 // Joints must have the same parent index
-
940 if (_baseSkeleton[i].parent != _animation.skeletonFrames[0][i].parent) {
-
941 printf("\n[.md5anim]: skeleton and animation joints do not have same parent index. cannot apply animation to skeleton\n\n");
-
942 return false;
-
943 }
-
944
-
945 // Joints must have the same name
-
946 if (strcmp (_baseSkeleton[i].name, _animation.skeletonFrames[0][i].name) != 0) {
-
947 printf("\n[.md5anim]: skeleton and animation joints do not have same name. cannot apply animation to skeleton\n\n");
-
948 return false;
-
949 }
-
950 }
-
951
-
952 printf("\n[.md5anim]: skeleton and animation match. animation can be applied to skeleton\n\n");
-
953 return true;
-
954}
-
955
-
956// Build _skeleton for a given frame data.
-
957inline void
-
958CSCI441::MD5Model::_buildFrameSkeleton(
-
959 const MD5JointInfo* pJOINT_INFOS,
-
960 const MD5BaseFrameJoint* pBASE_FRAME,
-
961 const GLfloat* pANIM_FRAME_DATA,
-
962 MD5Joint* pSkeletonFrame,
-
963 const GLint NUM_JOINTS
-
964) {
-
965 if(pJOINT_INFOS == nullptr
-
966 || pBASE_FRAME == nullptr
-
967 || pANIM_FRAME_DATA == nullptr
-
968 || pSkeletonFrame == nullptr) return;
-
969
-
970 GLint i;
-
971
-
972 for(i = 0; i < NUM_JOINTS; ++i) {
-
973 const MD5BaseFrameJoint *baseJoint = &pBASE_FRAME[i];
-
974 glm::vec3 animatedPosition = baseJoint->position;
-
975 glm::quat animatedOrientation = baseJoint->orientation;
-
976 GLint j = 0;
-
977
-
978 // Tx
-
979 if(pJOINT_INFOS[i].flags & 1 ) {
-
980 animatedPosition.x = pANIM_FRAME_DATA[pJOINT_INFOS[i].startIndex + j];
-
981 ++j;
-
982 }
+
887 delete[] _vertexIndicesArray;
+
888 _vertexIndicesArray = nullptr;
+
889
+
890 delete[] _texelArray;
+
891 _texelArray = nullptr;
+
892
+
893 glDeleteVertexArrays( 1, &_vao );
+
894 glDeleteBuffers(2, _vbo );
+
895 glDeleteVertexArrays( 1, &_skeletonVAO );
+
896 glDeleteBuffers( 1, &_skeletonVBO );
+
897}
+
898
+
899// Draw the skeleton as lines and points (for joints).
+
900[[maybe_unused]]
+
901inline void
+ +
903{
+
904 glBindVertexArray(_skeletonVAO );
+
905 glBindBuffer(GL_ARRAY_BUFFER, _skeletonVBO );
+
906
+
907 glm::vec3 jointColor = {1.0f, 1.0f, 0.0f };
+
908 glm::vec3 boneColor = {1.0f, 0.0f, 1.0f };
+
909
+
910 // put in points for joints
+
911 for(GLint i = 0; i < _numJoints; ++i ) {
+
912 glBufferSubData(GL_ARRAY_BUFFER, i * sizeof(glm::vec3), sizeof(glm::vec3), &(_skeleton[i].position) );
+
913 glBufferSubData(GL_ARRAY_BUFFER, i * sizeof(glm::vec3) + sizeof(glm::vec3) * _numJoints * 3, sizeof(glm::vec3), &jointColor[0]);
+
914 }
+
915
+
916 // put in lines for bones
+
917 GLint numBones = 0;
+
918 for(GLint i = 0; i < _numJoints; ++i ) {
+
919 if( _skeleton[i].parent != MD5Joint::NULL_JOINT ) {
+
920 glBufferSubData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * _numJoints + (i * 2) * sizeof(glm::vec3), sizeof(glm::vec3), &(_skeleton[_skeleton[i].parent].position) );
+
921 glBufferSubData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * _numJoints + (i * 2) * sizeof(glm::vec3) + sizeof(glm::vec3) * _numJoints * 3, sizeof(glm::vec3), &boneColor[0]);
+
922
+
923 glBufferSubData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * _numJoints + (i * 2) * sizeof(glm::vec3) + sizeof(glm::vec3), sizeof(glm::vec3), &(_skeleton[i].position) );
+
924 glBufferSubData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * _numJoints + (i * 2) * sizeof(glm::vec3) + sizeof(glm::vec3) + sizeof(glm::vec3) * _numJoints * 3, sizeof(glm::vec3), &boneColor[0]);
+
925 numBones++;
+
926 }
+
927 }
+
928
+
929 glPointSize (5.0f);
+
930 glDrawArrays(GL_POINTS, 0, _numJoints );
+
931 glPointSize(1.0f);
+
932
+
933 glLineWidth( 3.0f );
+
934 glDrawArrays(GL_LINES, _numJoints, numBones * 2 );
+
935 glLineWidth(1.0f);
+
936}
+
937
+
938// Check if an animation can be used for a given model. Model's
+
939// skeleton and animation's skeleton must match.
+
940inline bool
+
941CSCI441::MD5Model::_checkAnimValidity() const
+
942{
+
943 // md5mesh and md5anim must have the same number of joints
+
944 if( _numJoints != _animation.numJoints ) {
+
945 printf("\n[.md5anim]: skeleton and animation do not have same number of joints. cannot apply animation to skeleton\n\n");
+
946 return false;
+
947 }
+
948
+
949 // We just check with frame[0]
+
950 for(GLint i = 0; i < _numJoints; ++i) {
+
951 // Joints must have the same parent index
+
952 if (_baseSkeleton[i].parent != _animation.skeletonFrames[0][i].parent) {
+
953 printf("\n[.md5anim]: skeleton and animation joints do not have same parent index. cannot apply animation to skeleton\n\n");
+
954 return false;
+
955 }
+
956
+
957 // Joints must have the same name
+
958 if (strcmp (_baseSkeleton[i].name, _animation.skeletonFrames[0][i].name) != 0) {
+
959 printf("\n[.md5anim]: skeleton and animation joints do not have same name. cannot apply animation to skeleton\n\n");
+
960 return false;
+
961 }
+
962 }
+
963
+
964 printf("\n[.md5anim]: skeleton and animation match. animation can be applied to skeleton\n\n");
+
965 return true;
+
966}
+
967
+
968// Build _skeleton for a given frame data.
+
969inline void
+
970CSCI441::MD5Model::_buildFrameSkeleton(
+
971 const MD5JointInfo* pJOINT_INFOS,
+
972 const MD5BaseFrameJoint* pBASE_FRAME,
+
973 const GLfloat* pANIM_FRAME_DATA,
+
974 MD5Joint* pSkeletonFrame,
+
975 const GLint NUM_JOINTS
+
976) {
+
977 if(pJOINT_INFOS == nullptr
+
978 || pBASE_FRAME == nullptr
+
979 || pANIM_FRAME_DATA == nullptr
+
980 || pSkeletonFrame == nullptr) return;
+
981
+
982 GLint i;
983
-
984 // Ty
-
985 if(pJOINT_INFOS[i].flags & 2 ) {
-
986 animatedPosition.y = pANIM_FRAME_DATA[pJOINT_INFOS[i].startIndex + j];
-
987 ++j;
-
988 }
+
984 for(i = 0; i < NUM_JOINTS; ++i) {
+
985 const MD5BaseFrameJoint *baseJoint = &pBASE_FRAME[i];
+
986 glm::vec3 animatedPosition = baseJoint->position;
+
987 glm::quat animatedOrientation = baseJoint->orientation;
+
988 GLint j = 0;
989
-
990 // Tz
-
991 if(pJOINT_INFOS[i].flags & 4 ) {
-
992 animatedPosition.z = pANIM_FRAME_DATA[pJOINT_INFOS[i].startIndex + j];
+
990 // Tx
+
991 if(pJOINT_INFOS[i].flags & 1 ) {
+
992 animatedPosition.x = pANIM_FRAME_DATA[pJOINT_INFOS[i].startIndex + j];
993 ++j;
994 }
995
-
996 // Qx
-
997 if(pJOINT_INFOS[i].flags & 8 ) {
-
998 animatedOrientation.x = pANIM_FRAME_DATA[pJOINT_INFOS[i].startIndex + j];
+
996 // Ty
+
997 if(pJOINT_INFOS[i].flags & 2 ) {
+
998 animatedPosition.y = pANIM_FRAME_DATA[pJOINT_INFOS[i].startIndex + j];
999 ++j;
1000 }
1001
-
1002 // Qy
-
1003 if(pJOINT_INFOS[i].flags & 16 ) {
-
1004 animatedOrientation.y = pANIM_FRAME_DATA[pJOINT_INFOS[i].startIndex + j];
+
1002 // Tz
+
1003 if(pJOINT_INFOS[i].flags & 4 ) {
+
1004 animatedPosition.z = pANIM_FRAME_DATA[pJOINT_INFOS[i].startIndex + j];
1005 ++j;
1006 }
1007
-
1008 // Qz
-
1009 if(pJOINT_INFOS[i].flags & 32 ) {
-
1010 animatedOrientation.z = pANIM_FRAME_DATA[pJOINT_INFOS[i].startIndex + j];
-
1011 }
-
1012
-
1013 // Compute orientation quaternion's w value
-
1014 animatedOrientation.w = glm::extractRealComponent(animatedOrientation);
-
1015
-
1016 // NOTE: we assume that this joint's parent has
-
1017 // already been calculated, i.e. joint's ID should
-
1018 // never be smaller than its parent ID.
-
1019 MD5Joint *thisJoint = &pSkeletonFrame[i];
-
1020
-
1021 GLint parent = pJOINT_INFOS[i].parent;
-
1022 thisJoint->parent = parent;
-
1023 strcpy (thisJoint->name, pJOINT_INFOS[i].name);
+
1008 // Qx
+
1009 if(pJOINT_INFOS[i].flags & 8 ) {
+
1010 animatedOrientation.x = pANIM_FRAME_DATA[pJOINT_INFOS[i].startIndex + j];
+
1011 ++j;
+
1012 }
+
1013
+
1014 // Qy
+
1015 if(pJOINT_INFOS[i].flags & 16 ) {
+
1016 animatedOrientation.y = pANIM_FRAME_DATA[pJOINT_INFOS[i].startIndex + j];
+
1017 ++j;
+
1018 }
+
1019
+
1020 // Qz
+
1021 if(pJOINT_INFOS[i].flags & 32 ) {
+
1022 animatedOrientation.z = pANIM_FRAME_DATA[pJOINT_INFOS[i].startIndex + j];
+
1023 }
1024
-
1025 // Has parent?
-
1026 if( thisJoint->parent == MD5Joint::NULL_JOINT ) {
-
1027 thisJoint->position = animatedPosition;
-
1028 thisJoint->orientation = animatedOrientation;
-
1029 } else {
-
1030 MD5Joint *parentJoint = &pSkeletonFrame[parent];
-
1031 glm::vec3 rotatedPosition = glm::rotate(parentJoint->orientation, glm::vec4(animatedPosition, 0.0f));
+
1025 // Compute orientation quaternion's w value
+
1026 animatedOrientation.w = glm::extractRealComponent(animatedOrientation);
+
1027
+
1028 // NOTE: we assume that this joint's parent has
+
1029 // already been calculated, i.e. joint's ID should
+
1030 // never be smaller than its parent ID.
+
1031 MD5Joint *thisJoint = &pSkeletonFrame[i];
1032
-
1033 // Add positions
-
1034 thisJoint->position = parentJoint->position + rotatedPosition;
-
1035
-
1036 // Concatenate rotations
-
1037 thisJoint->orientation = glm::normalize( glm::cross(parentJoint->orientation, animatedOrientation) );
-
1038 }
-
1039 }
-
1040}
-
1041
-
1042// Load an MD5 animation from file.
-
1043inline bool
- -
1045 const char *filename
-
1046) {
-
1047 char buff[512];
-
1048 MD5JointInfo *jointInfos = nullptr;
-
1049 MD5BaseFrameJoint *baseFrame = nullptr;
-
1050 GLfloat *animFrameData = nullptr;
-
1051 GLint version;
-
1052 GLint numAnimatedComponents;
-
1053 GLint frameIndex;
-
1054 GLint i;
-
1055
-
1056 printf( "[.md5anim]: about to read %s\n", filename );
-
1057
-
1058 FILE *fp = fopen( filename, "rb" );
-
1059 if( !fp ) {
-
1060 fprintf (stderr, "[.md5anim]: Error: couldn't open \"%s\"!\n", filename);
-
1061 return false;
-
1062 }
-
1063
-
1064 while( !feof(fp) ) {
-
1065 // Read whole line
-
1066 fgets( buff, sizeof(buff), fp );
+
1033 GLint parent = pJOINT_INFOS[i].parent;
+
1034 thisJoint->parent = parent;
+
1035 strcpy (thisJoint->name, pJOINT_INFOS[i].name);
+
1036
+
1037 // Has parent?
+
1038 if( thisJoint->parent == MD5Joint::NULL_JOINT ) {
+
1039 thisJoint->position = animatedPosition;
+
1040 thisJoint->orientation = animatedOrientation;
+
1041 } else {
+
1042 MD5Joint *parentJoint = &pSkeletonFrame[parent];
+
1043 glm::vec3 rotatedPosition = glm::rotate(parentJoint->orientation, glm::vec4(animatedPosition, 0.0f));
+
1044
+
1045 // Add positions
+
1046 thisJoint->position = parentJoint->position + rotatedPosition;
+
1047
+
1048 // Concatenate rotations
+
1049 thisJoint->orientation = glm::normalize( glm::cross(parentJoint->orientation, animatedOrientation) );
+
1050 }
+
1051 }
+
1052}
+
1053
+
1054// Load an MD5 animation from file.
+
1055inline bool
+ +
1057 const char *filename
+
1058) {
+
1059 char buff[512];
+
1060 MD5JointInfo *jointInfos = nullptr;
+
1061 MD5BaseFrameJoint *baseFrame = nullptr;
+
1062 GLfloat *animFrameData = nullptr;
+
1063 GLint version;
+
1064 GLint numAnimatedComponents;
+
1065 GLint frameIndex;
+
1066 GLint i;
1067
-
1068 if( sscanf(buff, " MD5Version %d", &version) == 1 ) {
-
1069 if( version != 10 ) {
-
1070 // Bad version
-
1071 fprintf (stderr, "[.md5anim]: Error: bad animation version\n");
-
1072 fclose (fp);
-
1073 return false;
-
1074 }
-
1075 } else if( sscanf(buff, " numFrames %d", &_animation.numFrames) == 1 ) {
-
1076 // Allocate memory for skeleton frames and bounding boxes
-
1077 if( _animation.numFrames > 0 ) {
-
1078 _animation.skeletonFrames = new MD5Joint*[_animation.numFrames];
-
1079 _animation.boundingBoxes = new MD5BoundingBox[_animation.numFrames];
-
1080 }
-
1081 } else if( sscanf(buff, " numJoints %d", &_animation.numJoints) == 1 ) {
-
1082 if( _animation.numJoints > 0 ) {
-
1083 for(i = 0; i < _animation.numFrames; ++i) {
-
1084 // Allocate memory for joints of each frame
-
1085 _animation.skeletonFrames[i] = new MD5Joint[_animation.numJoints];
-
1086 }
-
1087
-
1088 // Allocate temporary memory for building skeleton frames
-
1089 jointInfos = new MD5JointInfo[_animation.numJoints];
-
1090
-
1091 baseFrame = new MD5BaseFrameJoint[_animation.numJoints];
+
1068 printf( "[.md5anim]: about to read %s\n", filename );
+
1069
+
1070 FILE *fp = fopen( filename, "rb" );
+
1071 if( !fp ) {
+
1072 fprintf (stderr, "[.md5anim]: Error: couldn't open \"%s\"!\n", filename);
+
1073 return false;
+
1074 }
+
1075
+
1076 while( !feof(fp) ) {
+
1077 // Read whole line
+
1078 fgets( buff, sizeof(buff), fp );
+
1079
+
1080 if( sscanf(buff, " MD5Version %d", &version) == 1 ) {
+
1081 if( version != 10 ) {
+
1082 // Bad version
+
1083 fprintf (stderr, "[.md5anim]: Error: bad animation version\n");
+
1084 fclose (fp);
+
1085 return false;
+
1086 }
+
1087 } else if( sscanf(buff, " numFrames %d", &_animation.numFrames) == 1 ) {
+
1088 // Allocate memory for skeleton frames and bounding boxes
+
1089 if( _animation.numFrames > 0 ) {
+
1090 _animation.skeletonFrames = new MD5Joint*[_animation.numFrames];
+
1091 _animation.boundingBoxes = new MD5BoundingBox[_animation.numFrames];
1092 }
-
1093 } else if( sscanf(buff, " frameRate %d", &_animation.frameRate) == 1 ) {
-
1094
-
1095 } else if( sscanf(buff, " numAnimatedComponents %d", &numAnimatedComponents) == 1 ) {
-
1096 if( numAnimatedComponents > 0 ) {
-
1097 // Allocate memory for animation frame data
-
1098 animFrameData = new GLfloat[numAnimatedComponents];
-
1099 }
-
1100 } else if( strncmp(buff, "hierarchy {", 11) == 0 ) {
-
1101 for(i = 0; i < _animation.numJoints; ++i) {
-
1102 // Read whole line
-
1103 fgets( buff, sizeof(buff), fp );
-
1104
-
1105 // Read joint info
-
1106 sscanf(buff, " %s %d %d %d",
-
1107 jointInfos[i].name, &jointInfos[i].parent,
-
1108 &jointInfos[i].flags, &jointInfos[i].startIndex);
-
1109 }
-
1110 } else if( strncmp(buff, "bounds {", 8) == 0 ) {
-
1111 for(i = 0; i < _animation.numFrames; ++i) {
-
1112 // Read whole line
-
1113 fgets( buff, sizeof(buff), fp );
-
1114
-
1115 // Read bounding box
-
1116 sscanf(buff, " ( %f %f %f ) ( %f %f %f )",
-
1117 &_animation.boundingBoxes[i].min[0], &_animation.boundingBoxes[i].min[1], &_animation.boundingBoxes[i].min[2],
-
1118 &_animation.boundingBoxes[i].max[0], &_animation.boundingBoxes[i].max[1], &_animation.boundingBoxes[i].max[2]);
-
1119 }
-
1120 } else if( strncmp(buff, "baseframe {", 10) == 0 ) {
-
1121 for(i = 0; i < _animation.numJoints; ++i) {
-
1122 // Read whole line
-
1123 fgets( buff, sizeof(buff), fp );
-
1124
-
1125 // Read base frame joint
-
1126 if( sscanf(buff, " ( %f %f %f ) ( %f %f %f )",
-
1127 &baseFrame[i].position[0], &baseFrame[i].position[1], &baseFrame[i].position[2],
-
1128 &baseFrame[i].orientation[0], &baseFrame[i].orientation[1], &baseFrame[i].orientation[2]) == 6 ) {
-
1129 // Compute the w component
-
1130 baseFrame[i].orientation.w = glm::extractRealComponent(baseFrame[i].orientation);
-
1131 }
-
1132 }
-
1133 } else if(sscanf(buff, " frame %d", &frameIndex) == 1 ) {
-
1134 // Read frame data
-
1135 for(i = 0; i < numAnimatedComponents; ++i)
-
1136 fscanf( fp, "%f", &animFrameData[i] );
-
1137
-
1138 // Build frame _skeleton from the collected data
-
1139 _buildFrameSkeleton(jointInfos, baseFrame, animFrameData,
-
1140 _animation.skeletonFrames[frameIndex],
-
1141 _animation.numJoints);
-
1142 }
-
1143 }
-
1144
-
1145 fclose( fp );
-
1146
-
1147 printf( "[.md5anim]: finished reading %s\n", filename );
-
1148 printf( "[.md5anim]: read in %d frames of %d joints with %d animated components\n", _animation.numFrames, _animation.numJoints, numAnimatedComponents );
-
1149 printf( "[.md5anim]: animation's frame rate is %d\n", _animation.frameRate );
-
1150
-
1151 // Free temporary data allocated
-
1152 if( animFrameData )
-
1153 free( animFrameData );
-
1154
-
1155 if( baseFrame )
-
1156 free( baseFrame );
-
1157
-
1158 if( jointInfos )
-
1159 free( jointInfos );
-
1160
-
1161 // successful loading...set up animation parameters
-
1162 _animationInfo.currFrame = 0;
-
1163 _animationInfo.nextFrame = 1;
-
1164
-
1165 _animationInfo.lastTime = 0.0f;
-
1166 _animationInfo.maxTime = 1.0f / (GLfloat)_animation.frameRate;
-
1167
-
1168 // Allocate memory for animated _skeleton
-
1169 _skeleton = new MD5Joint[_animation.numJoints];
-
1170
-
1171 if( _checkAnimValidity() ) {
-
1172 _isAnimated = true;
-
1173 // compute initial pose
-
1174 animate(0.0);
-
1175 }
+
1093 } else if( sscanf(buff, " numJoints %d", &_animation.numJoints) == 1 ) {
+
1094 if( _animation.numJoints > 0 ) {
+
1095 for(i = 0; i < _animation.numFrames; ++i) {
+
1096 // Allocate memory for joints of each frame
+
1097 _animation.skeletonFrames[i] = new MD5Joint[_animation.numJoints];
+
1098 }
+
1099
+
1100 // Allocate temporary memory for building skeleton frames
+
1101 jointInfos = new MD5JointInfo[_animation.numJoints];
+
1102
+
1103 baseFrame = new MD5BaseFrameJoint[_animation.numJoints];
+
1104 }
+
1105 } else if( sscanf(buff, " frameRate %d", &_animation.frameRate) == 1 ) {
+
1106
+
1107 } else if( sscanf(buff, " numAnimatedComponents %d", &numAnimatedComponents) == 1 ) {
+
1108 if( numAnimatedComponents > 0 ) {
+
1109 // Allocate memory for animation frame data
+
1110 animFrameData = new GLfloat[numAnimatedComponents];
+
1111 }
+
1112 } else if( strncmp(buff, "hierarchy {", 11) == 0 ) {
+
1113 for(i = 0; i < _animation.numJoints; ++i) {
+
1114 // Read whole line
+
1115 fgets( buff, sizeof(buff), fp );
+
1116
+
1117 // Read joint info
+
1118 sscanf(buff, " %s %d %d %d",
+
1119 jointInfos[i].name, &jointInfos[i].parent,
+
1120 &jointInfos[i].flags, &jointInfos[i].startIndex);
+
1121 }
+
1122 } else if( strncmp(buff, "bounds {", 8) == 0 ) {
+
1123 for(i = 0; i < _animation.numFrames; ++i) {
+
1124 // Read whole line
+
1125 fgets( buff, sizeof(buff), fp );
+
1126
+
1127 // Read bounding box
+
1128 sscanf(buff, " ( %f %f %f ) ( %f %f %f )",
+
1129 &_animation.boundingBoxes[i].min[0], &_animation.boundingBoxes[i].min[1], &_animation.boundingBoxes[i].min[2],
+
1130 &_animation.boundingBoxes[i].max[0], &_animation.boundingBoxes[i].max[1], &_animation.boundingBoxes[i].max[2]);
+
1131 }
+
1132 } else if( strncmp(buff, "baseframe {", 10) == 0 ) {
+
1133 for(i = 0; i < _animation.numJoints; ++i) {
+
1134 // Read whole line
+
1135 fgets( buff, sizeof(buff), fp );
+
1136
+
1137 // Read base frame joint
+
1138 if( sscanf(buff, " ( %f %f %f ) ( %f %f %f )",
+
1139 &baseFrame[i].position[0], &baseFrame[i].position[1], &baseFrame[i].position[2],
+
1140 &baseFrame[i].orientation[0], &baseFrame[i].orientation[1], &baseFrame[i].orientation[2]) == 6 ) {
+
1141 // Compute the w component
+
1142 baseFrame[i].orientation.w = glm::extractRealComponent(baseFrame[i].orientation);
+
1143 }
+
1144 }
+
1145 } else if(sscanf(buff, " frame %d", &frameIndex) == 1 ) {
+
1146 // Read frame data
+
1147 for(i = 0; i < numAnimatedComponents; ++i)
+
1148 fscanf( fp, "%f", &animFrameData[i] );
+
1149
+
1150 // Build frame _skeleton from the collected data
+
1151 _buildFrameSkeleton(jointInfos, baseFrame, animFrameData,
+
1152 _animation.skeletonFrames[frameIndex],
+
1153 _animation.numJoints);
+
1154 }
+
1155 }
+
1156
+
1157 fclose( fp );
+
1158
+
1159 printf( "[.md5anim]: finished reading %s\n", filename );
+
1160 printf( "[.md5anim]: read in %d frames of %d joints with %d animated components\n", _animation.numFrames, _animation.numJoints, numAnimatedComponents );
+
1161 printf( "[.md5anim]: animation's frame rate is %d\n", _animation.frameRate );
+
1162
+
1163 // Free temporary data allocated
+
1164 if( animFrameData )
+
1165 free( animFrameData );
+
1166
+
1167 if( baseFrame )
+
1168 free( baseFrame );
+
1169
+
1170 if( jointInfos )
+
1171 free( jointInfos );
+
1172
+
1173 // successful loading...set up animation parameters
+
1174 _animationInfo.currFrame = 0;
+
1175 _animationInfo.nextFrame = 1;
1176
-
1177 return true;
-
1178}
+
1177 _animationInfo.lastTime = 0.0f;
+
1178 _animationInfo.maxTime = 1.0f / (GLfloat)_animation.frameRate;
1179
-
1180// Free resources allocated for the animation.
-
1181inline void
-
1182CSCI441::MD5Model::_freeAnim()
-
1183{
-
1184 GLint i;
-
1185
-
1186 for(i = 0; i < _animation.numFrames; ++i) {
-
1187 delete _animation.skeletonFrames[i];
-
1188 _animation.skeletonFrames[i] = nullptr;
-
1189 }
-
1190
-
1191 delete[] _animation.skeletonFrames;
-
1192 _animation.skeletonFrames = nullptr;
-
1193
-
1194 delete _animation.boundingBoxes;
-
1195 _animation.boundingBoxes = nullptr;
-
1196
-
1197 delete _skeleton;
-
1198 _skeleton = nullptr;
-
1199}
-
1200
-
1201// Smoothly interpolate two skeletons
-
1202inline void
-
1203CSCI441::MD5Model::_interpolateSkeletons(GLfloat interp)
-
1204{
-
1205 const MD5Joint *skeletonA = _animation.skeletonFrames[_animationInfo.currFrame];
-
1206 const MD5Joint *skeletonB = _animation.skeletonFrames[_animationInfo.nextFrame];
-
1207
-
1208 GLint i;
-
1209
-
1210 for(i = 0; i < _animation.numJoints; ++i) {
-
1211 // Copy parent index
-
1212 _skeleton[i].parent = skeletonA[i].parent;
-
1213
-
1214 // Linear interpolation for position
-
1215 _skeleton[i].position[0] = skeletonA[i].position[0] + interp * (skeletonB[i].position[0] - skeletonA[i].position[0]);
-
1216 _skeleton[i].position[1] = skeletonA[i].position[1] + interp * (skeletonB[i].position[1] - skeletonA[i].position[1]);
-
1217 _skeleton[i].position[2] = skeletonA[i].position[2] + interp * (skeletonB[i].position[2] - skeletonA[i].position[2]);
-
1218
-
1219 // Spherical linear interpolation for orientation
-
1220 _skeleton[i].orientation = glm::slerp(skeletonA[i].orientation, skeletonB[i].orientation, interp);
-
1221 }
-
1222}
-
1223
-
1224// Perform animation related computations. Calculate the current and
-
1225// next frames, given a delta time.
-
1226inline void
- -
1228{
-
1229 GLint maxFrames = _animation.numFrames - 1;
+
1180 // Allocate memory for animated _skeleton
+
1181 _skeleton = new MD5Joint[_animation.numJoints];
+
1182
+
1183 if( _checkAnimValidity() ) {
+
1184 _isAnimated = true;
+
1185 // compute initial pose
+
1186 animate(0.0);
+
1187 }
+
1188
+
1189 return true;
+
1190}
+
1191
+
1192// Free resources allocated for the animation.
+
1193inline void
+
1194CSCI441::MD5Model::_freeAnim()
+
1195{
+
1196 GLint i;
+
1197
+
1198 for(i = 0; i < _animation.numFrames; ++i) {
+
1199 delete _animation.skeletonFrames[i];
+
1200 _animation.skeletonFrames[i] = nullptr;
+
1201 }
+
1202
+
1203 delete[] _animation.skeletonFrames;
+
1204 _animation.skeletonFrames = nullptr;
+
1205
+
1206 delete _animation.boundingBoxes;
+
1207 _animation.boundingBoxes = nullptr;
+
1208
+
1209 delete _skeleton;
+
1210 _skeleton = nullptr;
+
1211}
+
1212
+
1213// Smoothly interpolate two skeletons
+
1214inline void
+
1215CSCI441::MD5Model::_interpolateSkeletons(GLfloat interp)
+
1216{
+
1217 const MD5Joint *skeletonA = _animation.skeletonFrames[_animationInfo.currFrame];
+
1218 const MD5Joint *skeletonB = _animation.skeletonFrames[_animationInfo.nextFrame];
+
1219
+
1220 GLint i;
+
1221
+
1222 for(i = 0; i < _animation.numJoints; ++i) {
+
1223 // Copy parent index
+
1224 _skeleton[i].parent = skeletonA[i].parent;
+
1225
+
1226 // Linear interpolation for position
+
1227 _skeleton[i].position[0] = skeletonA[i].position[0] + interp * (skeletonB[i].position[0] - skeletonA[i].position[0]);
+
1228 _skeleton[i].position[1] = skeletonA[i].position[1] + interp * (skeletonB[i].position[1] - skeletonA[i].position[1]);
+
1229 _skeleton[i].position[2] = skeletonA[i].position[2] + interp * (skeletonB[i].position[2] - skeletonA[i].position[2]);
1230
-
1231 _animationInfo.lastTime += dt;
-
1232
-
1233 // move to next frame
-
1234 if( _animationInfo.lastTime >= _animationInfo.maxTime ) {
-
1235 _animationInfo.currFrame++;
-
1236 _animationInfo.nextFrame++;
-
1237 _animationInfo.lastTime = 0.0;
-
1238
-
1239 if( _animationInfo.currFrame > maxFrames )
-
1240 _animationInfo.currFrame = 0;
-
1241
-
1242 if( _animationInfo.nextFrame > maxFrames )
-
1243 _animationInfo.nextFrame = 0;
-
1244 }
-
1245
-
1246 // Interpolate skeletons between two frames
-
1247 _interpolateSkeletons( _animationInfo.lastTime * _animation.frameRate );
-
1248}
-
1249
-
1250#endif//CSCI441_MD5_MODEL_HPP
+
1231 // Spherical linear interpolation for orientation
+
1232 _skeleton[i].orientation = glm::slerp(skeletonA[i].orientation, skeletonB[i].orientation, interp);
+
1233 }
+
1234}
+
1235
+
1236// Perform animation related computations. Calculate the current and
+
1237// next frames, given a delta time.
+
1238inline void
+ +
1240{
+
1241 GLint maxFrames = _animation.numFrames - 1;
+
1242
+
1243 _animationInfo.lastTime += dt;
+
1244
+
1245 // move to next frame
+
1246 if( _animationInfo.lastTime >= _animationInfo.maxTime ) {
+
1247 _animationInfo.currFrame++;
+
1248 _animationInfo.nextFrame++;
+
1249 _animationInfo.lastTime = 0.0;
+
1250
+
1251 if( _animationInfo.currFrame > maxFrames )
+
1252 _animationInfo.currFrame = 0;
+
1253
+
1254 if( _animationInfo.nextFrame > maxFrames )
+
1255 _animationInfo.nextFrame = 0;
+
1256 }
+
1257
+
1258 // Interpolate skeletons between two frames
+
1259 _interpolateSkeletons( _animationInfo.lastTime * _animation.frameRate );
+
1260}
+
1261
+
1262#endif//CSCI441_MD5_MODEL_HPP
Helper functions to work with OpenGL Textures.
stores a Doom3 MD5 Mesh + Animation
Definition: MD5Model.hpp:75
-
void draw() const
draws all the meshes that make up the model
Definition: MD5Model.hpp:754
+
void draw() const
draws all the meshes that make up the model
Definition: MD5Model.hpp:766
bool readMD5Model(const char *FILENAME)
parses md5mesh file and allocates corresponding mesh data
Definition: MD5Model.hpp:513
bool isAnimated() const
returns if the MD5 Model has an accompanying animation
Definition: MD5Model.hpp:362
bool loadMD5Model(const char *MD5_MESH_FILE, const char *MD5_ANIM_FILE="")
loads a corresponding md5mesh and md5anim file to the object
Definition: MD5Model.hpp:489
MD5Model()
initializes an empty MD5 Model
Definition: MD5Model.hpp:457
MD5Model & operator=(const MD5Model &)=delete
do not allow MD5 models to be copied
-
bool readMD5Anim(const char *filename)
reads in an animation sequence from an external file
Definition: MD5Model.hpp:1044
-
void allocVertexArrays(GLuint vPosAttribLoc, GLuint vColorAttribLoc, GLuint vTexCoordAttribLoc)
binds model VBOs to attribute pointer locations
Definition: MD5Model.hpp:826
-
void animate(GLfloat dt)
advances the model forward in its animation sequence the corresponding amount of time based on frame ...
Definition: MD5Model.hpp:1227
+
bool readMD5Anim(const char *filename)
reads in an animation sequence from an external file
Definition: MD5Model.hpp:1056
+
void allocVertexArrays(GLuint vPosAttribLoc, GLuint vColorAttribLoc, GLuint vTexCoordAttribLoc)
binds model VBOs to attribute pointer locations
Definition: MD5Model.hpp:838
+
void animate(GLfloat dt)
advances the model forward in its animation sequence the corresponding amount of time based on frame ...
Definition: MD5Model.hpp:1239
MD5Model(const MD5Model &)=delete
do not allow MD5 models to be copied
~MD5Model()
deallocates any used memory on the CPU and GPU
Definition: MD5Model.hpp:479
-
void drawSkeleton() const
draws the skeleton joints (as points) and bones (as lines)
Definition: MD5Model.hpp:890
+
void drawSkeleton() const
draws the skeleton joints (as points) and bones (as lines)
Definition: MD5Model.hpp:902
CSCI441 Helper Functions for OpenGL.
Definition: ArcballCam.hpp:17
stores an entire animation sequence for a given MD5 Model
Definition: MD5Model.hpp:280
stores state of current animation frame
Definition: MD5Model.hpp:309
diff --git a/docs/_model_loader_8hpp.html b/docs/_model_loader_8hpp.html index b004313f..3a22706c 100644 --- a/docs/_model_loader_8hpp.html +++ b/docs/_model_loader_8hpp.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_model_loader_8hpp_source.html b/docs/_model_loader_8hpp_source.html index 1b91ef1e..7f4c4db0 100644 --- a/docs/_model_loader_8hpp_source.html +++ b/docs/_model_loader_8hpp_source.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_open_g_l3_d_engine_8hpp.html b/docs/_open_g_l3_d_engine_8hpp.html index 964f7c78..5648dbbc 100644 --- a/docs/_open_g_l3_d_engine_8hpp.html +++ b/docs/_open_g_l3_d_engine_8hpp.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_open_g_l3_d_engine_8hpp_source.html b/docs/_open_g_l3_d_engine_8hpp_source.html index b24e69ff..54e3d340 100644 --- a/docs/_open_g_l3_d_engine_8hpp_source.html +++ b/docs/_open_g_l3_d_engine_8hpp_source.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_open_g_l_engine_8hpp.html b/docs/_open_g_l_engine_8hpp.html index 24d25b6e..d594a4de 100644 --- a/docs/_open_g_l_engine_8hpp.html +++ b/docs/_open_g_l_engine_8hpp.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_open_g_l_engine_8hpp_source.html b/docs/_open_g_l_engine_8hpp_source.html index f0c147ff..aed06459 100644 --- a/docs/_open_g_l_engine_8hpp_source.html +++ b/docs/_open_g_l_engine_8hpp_source.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_open_g_l_utils_8hpp.html b/docs/_open_g_l_utils_8hpp.html index cbe4dbe9..e4abee86 100644 --- a/docs/_open_g_l_utils_8hpp.html +++ b/docs/_open_g_l_utils_8hpp.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_open_g_l_utils_8hpp_source.html b/docs/_open_g_l_utils_8hpp_source.html index f70bf505..d42deaed 100644 --- a/docs/_open_g_l_utils_8hpp_source.html +++ b/docs/_open_g_l_utils_8hpp_source.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_orthographic_camera_8hpp_source.html b/docs/_orthographic_camera_8hpp_source.html index 717a515a..87a970ae 100644 --- a/docs/_orthographic_camera_8hpp_source.html +++ b/docs/_orthographic_camera_8hpp_source.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_perspective_camera_8hpp_source.html b/docs/_perspective_camera_8hpp_source.html index 81cff6ef..c8321f68 100644 --- a/docs/_perspective_camera_8hpp_source.html +++ b/docs/_perspective_camera_8hpp_source.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_shader_program_8hpp.html b/docs/_shader_program_8hpp.html index 62d3d1b4..4ab226c0 100644 --- a/docs/_shader_program_8hpp.html +++ b/docs/_shader_program_8hpp.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
@@ -81,6 +81,7 @@ More...

#include "ShaderUtils.hpp"
#include <glm/glm.hpp>
+#include <glm/gtc/type_ptr.hpp>
#include <cstdlib>
#include <fstream>
#include <map>
diff --git a/docs/_shader_program_8hpp_source.html b/docs/_shader_program_8hpp_source.html index 722202e9..d4265709 100644 --- a/docs/_shader_program_8hpp_source.html +++ b/docs/_shader_program_8hpp_source.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
@@ -80,1482 +80,1483 @@
16#include "ShaderUtils.hpp"
17
18#include <glm/glm.hpp>
-
19
-
20#include <cstdlib>
-
21#include <fstream>
-
22#include <map>
-
23#include <string>
-
24#include <vector>
-
25
-
27
-
28namespace CSCI441 {
-
29
- -
35 public:
-
40 [[maybe_unused]] static void enableDebugMessages();
-
45 [[maybe_unused]] static void disableDebugMessages();
-
46
-
52 ShaderProgram( const char *vertexShaderFilename,
-
53 const char *fragmentShaderFilename );
-
54
-
61 [[maybe_unused]]
-
62 ShaderProgram( const char *vertexShaderFilename,
-
63 const char *fragmentShaderFilename,
-
64 bool isSeparable );
-
65
-
73 [[maybe_unused]]
-
74 ShaderProgram( const char *vertexShaderFilename,
-
75 const char *tessellationControlShaderFilename,
-
76 const char *tessellationEvaluationShaderFilename,
-
77 const char *geometryShaderFilename,
-
78 const char *fragmentShaderFilename );
-
79
-
89 [[maybe_unused]]
-
90 ShaderProgram( const char *vertexShaderFilename,
-
91 const char *tessellationControlShaderFilename,
-
92 const char *tessellationEvaluationShaderFilename,
-
93 const char *geometryShaderFilename,
-
94 const char *fragmentShaderFilename,
-
95 bool isSeparable );
-
96
-
104 [[maybe_unused]]
-
105 ShaderProgram( const char *vertexShaderFilename,
-
106 const char *tessellationControlShaderFilename,
-
107 const char *tessellationEvaluationShaderFilename,
-
108 const char *fragmentShaderFilename );
-
109
-
118 [[maybe_unused]]
-
119 ShaderProgram( const char *vertexShaderFilename,
-
120 const char *tessellationControlShaderFilename,
-
121 const char *tessellationEvaluationShaderFilename,
-
122 const char *fragmentShaderFilename,
-
123 bool isSeparable);
-
124
-
131 ShaderProgram( const char *vertexShaderFilename,
-
132 const char *geometryShaderFilename,
-
133 const char *fragmentShaderFilename );
-
134
-
142 [[maybe_unused]]
-
143 ShaderProgram( const char *vertexShaderFilename,
-
144 const char *geometryShaderFilename,
-
145 const char *fragmentShaderFilename,
-
146 bool isSeparable );
-
147
-
158 [[maybe_unused]]
-
159 ShaderProgram( const char **shaderFilenames,
-
160 bool vertexPresent, bool tessellationPresent, bool geometryPresent, bool fragmentPresent,
-
161 bool isSeparable );
-
162
-
166 virtual ~ShaderProgram();
-
167
-
171 ShaderProgram(const ShaderProgram&) = delete;
- -
176
-
182 virtual bool writeShaderProgramBinaryToFile(const char* BINARY_FILE_NAME) const final;
-
183
-
190 static ShaderProgram* loadShaderProgramFromBinaryFile(const char* BINARY_FILE_NAME, GLenum format);
-
191
-
198 virtual GLint getUniformLocation( const char *uniformName ) const final;
-
199
-
206 virtual GLint getUniformBlockIndex( const char *uniformBlockName ) const final;
-
213 virtual GLint getUniformBlockSize( const char *uniformBlockName ) const final;
-
220 [[maybe_unused]] virtual GLubyte* getUniformBlockBuffer( const char *uniformBlockName ) const final;
-
227 [[maybe_unused]] virtual GLint* getUniformBlockOffsets( const char *uniformBlockName ) const final;
-
235 [[maybe_unused]] virtual GLint* getUniformBlockOffsets( const char *uniformBlockName, const char *names[] ) const final;
-
242 [[nodiscard]] virtual GLint* getUniformBlockOffsets(GLint uniformBlockIndex ) const final;
-
250 [[nodiscard]] virtual GLint* getUniformBlockOffsets(GLint uniformBlockIndex, const char *names[] ) const final;
-
257 virtual void setUniformBlockBinding( const char *uniformBlockName, GLuint binding ) const final;
-
258
-
265 [[maybe_unused]] virtual GLint getAttributeLocation( const char *attributeName ) const final;
-
266
-
275 [[maybe_unused]] virtual GLuint getSubroutineIndex( GLenum shaderStage, const char *subroutineName ) const final;
-
276
-
283 [[maybe_unused]] virtual GLint getImageBinding(const char* imageName) const final;
-
284
-
291 [[maybe_unused]] virtual GLint getShaderStorageBlockBinding(const char* ssboName) const final;
-
292
-
299 [[maybe_unused]] virtual GLint getAtomicCounterBufferBinding(const char* atomicName) const final;
-
306 [[maybe_unused]] virtual GLint getAtomicCounterBufferOffset(const char* atomicName) const final;
-
313 [[maybe_unused]] virtual GLint getAtomicCounterBufferSize(const char* atomicName) const final;
-
314
-
319 [[maybe_unused]] [[nodiscard]] virtual GLuint getNumUniforms() const final;
-
324 [[maybe_unused]] [[nodiscard]] virtual GLuint getNumUniformBlocks() const final;
-
329 [[maybe_unused]] [[nodiscard]] virtual GLuint getNumAttributes() const final;
-
330
-
335 [[nodiscard]] virtual GLuint getShaderProgramHandle() const final;
-
336
-
340 [[maybe_unused]] virtual void useProgram() const final;
-
341
-
347 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLfloat v0) const final;
-
353 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLint v0) const final;
-
359 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLuint v0) const final;
-
365 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::mat2 mtx) const final;
-
371 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::mat3 mtx) const final;
-
377 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::mat4 mtx) const final;
-
383 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::mat2x3 mtx) const final;
-
389 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::mat3x2 mtx) const final;
-
395 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::mat2x4 mtx) const final;
-
401 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::mat4x2 mtx) const final;
-
407 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::mat3x4 mtx) const final;
-
413 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::mat4x3 mtx) const final;
-
414
-
421 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLfloat v0, GLfloat v1) const final;
-
428 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLint v0, GLint v1) const final;
-
435 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLuint v0, GLuint v1) const final;
-
436
-
444 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLfloat v0, GLfloat v1, GLfloat v2) const final;
-
452 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLint v0, GLint v1, GLint v2) const final;
-
460 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLuint v0, GLuint v1, GLuint v2) const final;
-
461
-
470 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) const final;
-
479 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLint v0, GLint v1, GLint v2, GLint v3) const final;
-
488 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLuint v0, GLuint v1, GLuint v2, GLuint v3) const final;
-
489
-
495 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::vec2 value) const final;
-
501 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::ivec2 value) const final;
-
507 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::uvec2 value) const final;
-
508
-
514 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::vec3 value) const final;
-
520 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::ivec3 value) const final;
-
526 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::uvec3 value) const final;
-
527
-
533 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::vec4 value) const final;
-
539 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::ivec4 value) const final;
-
545 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::uvec4 value) const final;
-
546
-
554 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLuint dim, GLsizei count, const GLfloat *value) const final;
-
562 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLuint dim, GLsizei count, const GLint *value) const final;
-
570 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLuint dim, GLsizei count, const GLuint *value) const final;
-
571
-
577 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, GLfloat v0) const final;
-
583 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, GLint v0) const final;
-
589 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, GLuint v0) const final;
-
595 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::mat2 mtx) const final;
-
601 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::mat3 mtx) const final;
-
607 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::mat4 mtx) const final;
-
613 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::mat2x3 mtx) const final;
-
619 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::mat3x2 mtx) const final;
-
625 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::mat2x4 mtx) const final;
-
631 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::mat4x2 mtx) const final;
-
637 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::mat3x4 mtx) const final;
-
643 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::mat4x3 mtx) const final;
-
644
-
651 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, GLfloat v0, GLfloat v1) const final;
-
658 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, GLint v0, GLint v1) const final;
-
665 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, GLuint v0, GLuint v1) const final;
-
666
-
674 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, GLfloat v0, GLfloat v1, GLfloat v2) const final;
-
682 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, GLint v0, GLint v1, GLint v2) const final;
-
690 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, GLuint v0, GLuint v1, GLuint v2) const final;
-
691
-
700 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) const final;
-
709 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, GLint v0, GLint v1, GLint v2, GLint v3) const final;
-
718 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, GLuint v0, GLuint v1, GLuint v2, GLuint v3) const final;
-
719
-
725 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::vec2 value) const final;
-
731 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::ivec2 value) const final;
-
737 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::uvec2 value) const final;
-
738
-
744 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::vec3 value) const final;
-
750 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::ivec3 value) const final;
-
756 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::uvec3 value) const final;
-
757
-
763 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::vec4 value) const final;
-
769 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::ivec4 value) const final;
-
775 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::uvec4 value) const final;
-
776
-
784 virtual void setProgramUniform(GLint uniformLocation, GLuint dim, GLsizei count, const GLfloat *value) const final;
-
792 virtual void setProgramUniform(GLint uniformLocation, GLuint dim, GLsizei count, const GLint *value) const final;
-
800 virtual void setProgramUniform(GLint uniformLocation, GLuint dim, GLsizei count, const GLuint *value) const final;
-
801
-
806 [[maybe_unused]] [[nodiscard]] virtual GLbitfield getProgramStages() const final;
-
807
-
808 protected:
- -
813
-
818 static bool sDEBUG;
-
819
- - - - - -
840
- -
845
-
849 std::map<std::string, GLint> *mpUniformLocationsMap;
-
853 std::map<std::string, GLint> *mpAttributeLocationsMap;
-
854
-
865 virtual bool mRegisterShaderProgram(const char *vertexShaderFilename,
-
866 const char *tessellationControlShaderFilename,
-
867 const char *tessellationEvaluationShaderFilename,
-
868 const char *geometryShaderFilename,
-
869 const char *fragmentShaderFilename,
-
870 bool isSeparable ) final;
-
871
-
872 private:
-
873 void _initialize();
-
874 };
-
875
-
876}
-
877
-
879
-
880inline bool CSCI441::ShaderProgram::sDEBUG = true;
-
881
-
882[[maybe_unused]]
- -
884 sDEBUG = true;
-
885}
-
886
-
887[[maybe_unused]]
- -
889 sDEBUG = false;
-
890}
-
891
-
892inline CSCI441::ShaderProgram::ShaderProgram( const char *vertexShaderFilename, const char *fragmentShaderFilename ) {
-
893 _initialize();
-
894 mRegisterShaderProgram(vertexShaderFilename, "", "", "", fragmentShaderFilename, false);
-
895}
-
896
-
897[[maybe_unused]]
-
898inline CSCI441::ShaderProgram::ShaderProgram( const char *vertexShaderFilename, const char *fragmentShaderFilename, const bool isSeparable ) {
-
899 _initialize();
-
900 mRegisterShaderProgram(vertexShaderFilename, "", "", "", fragmentShaderFilename, isSeparable);
-
901}
-
902
-
903[[maybe_unused]]
-
904inline CSCI441::ShaderProgram::ShaderProgram(const char *vertexShaderFilename, const char *tessellationControlShaderFilename, const char *tessellationEvaluationShaderFilename, const char *geometryShaderFilename, const char *fragmentShaderFilename ) {
-
905 _initialize();
-
906 mRegisterShaderProgram(vertexShaderFilename, tessellationControlShaderFilename, tessellationEvaluationShaderFilename,
-
907 geometryShaderFilename, fragmentShaderFilename, false);
-
908}
-
909
-
910[[maybe_unused]]
-
911inline CSCI441::ShaderProgram::ShaderProgram(const char *vertexShaderFilename, const char *tessellationControlShaderFilename, const char *tessellationEvaluationShaderFilename, const char *geometryShaderFilename, const char *fragmentShaderFilename, bool isSeparable ) {
-
912 _initialize();
-
913 mRegisterShaderProgram(vertexShaderFilename, tessellationControlShaderFilename, tessellationEvaluationShaderFilename,
-
914 geometryShaderFilename, fragmentShaderFilename, isSeparable);
-
915}
-
916
-
917[[maybe_unused]]
-
918inline CSCI441::ShaderProgram::ShaderProgram(const char *vertexShaderFilename, const char *tessellationControlShaderFilename, const char *tessellationEvaluationShaderFilename, const char *fragmentShaderFilename ) {
-
919 _initialize();
-
920 mRegisterShaderProgram(vertexShaderFilename, tessellationControlShaderFilename, tessellationEvaluationShaderFilename,
-
921 "", fragmentShaderFilename, false);
-
922}
-
923
-
924[[maybe_unused]]
-
925inline CSCI441::ShaderProgram::ShaderProgram(const char *vertexShaderFilename, const char *tessellationControlShaderFilename, const char *tessellationEvaluationShaderFilename, const char *fragmentShaderFilename, bool isSeparable ) {
-
926 _initialize();
-
927 mRegisterShaderProgram(vertexShaderFilename, tessellationControlShaderFilename, tessellationEvaluationShaderFilename,
-
928 "", fragmentShaderFilename, isSeparable);
-
929}
-
930
-
931inline CSCI441::ShaderProgram::ShaderProgram( const char *vertexShaderFilename, const char *geometryShaderFilename, const char *fragmentShaderFilename ) {
-
932 _initialize();
-
933 mRegisterShaderProgram(vertexShaderFilename, "", "", geometryShaderFilename, fragmentShaderFilename, false);
-
934}
-
935
-
936[[maybe_unused]]
-
937inline CSCI441::ShaderProgram::ShaderProgram( const char *vertexShaderFilename, const char *geometryShaderFilename, const char *fragmentShaderFilename, bool isSeparable ) {
-
938 _initialize();
-
939 mRegisterShaderProgram(vertexShaderFilename, "", "", geometryShaderFilename, fragmentShaderFilename, isSeparable);
-
940}
-
941
-
942[[maybe_unused]]
-
943inline CSCI441::ShaderProgram::ShaderProgram( const char **shaderFilenames,
-
944 const bool vertexPresent, const bool tessellationPresent, const bool geometryPresent, const bool fragmentPresent,
-
945 const bool isSeparable ) {
-
946 _initialize();
-
947 if( vertexPresent && !tessellationPresent && !geometryPresent && !fragmentPresent ) {
-
948 if( !isSeparable ) {
-
949 fprintf(stderr, "[ERROR]: Fragment Shader not present. Program must be separable.\n");
-
950 } else {
-
951 mRegisterShaderProgram(shaderFilenames[0], "", "", "", "", isSeparable);
-
952 }
-
953 } else if( vertexPresent && tessellationPresent && !geometryPresent && !fragmentPresent ) {
-
954 if( !isSeparable ) {
-
955 fprintf(stderr, "[ERROR]: Fragment Shader not present. Program must be separable.\n");
-
956 } else {
-
957 mRegisterShaderProgram(shaderFilenames[0], shaderFilenames[1], shaderFilenames[2], "", "", isSeparable);
-
958 }
-
959 } else if( vertexPresent && tessellationPresent && geometryPresent && !fragmentPresent ) {
-
960 if( !isSeparable ) {
-
961 fprintf(stderr, "[ERROR]: Fragment Shader not present. Program must be separable.\n");
-
962 } else {
-
963 mRegisterShaderProgram(shaderFilenames[0], shaderFilenames[1], shaderFilenames[2], shaderFilenames[3], "",
-
964 isSeparable);
-
965 }
-
966 } else if( vertexPresent && tessellationPresent && geometryPresent && fragmentPresent ) {
-
967 mRegisterShaderProgram(shaderFilenames[0], shaderFilenames[1], shaderFilenames[2], shaderFilenames[3],
-
968 shaderFilenames[4], isSeparable);
-
969 } else if( vertexPresent && tessellationPresent && !geometryPresent && fragmentPresent ) {
-
970 mRegisterShaderProgram(shaderFilenames[0], shaderFilenames[1], shaderFilenames[2], "", shaderFilenames[3],
-
971 isSeparable);
-
972 } else if( vertexPresent && !tessellationPresent && geometryPresent && !fragmentPresent ) {
-
973 if( !isSeparable ) {
-
974 fprintf(stderr, "[ERROR]: Fragment Shader not present. Program must be separable.\n");
-
975 } else {
-
976 mRegisterShaderProgram(shaderFilenames[0], "", "", shaderFilenames[1], "", isSeparable);
-
977 }
-
978 } else if( vertexPresent && !tessellationPresent && geometryPresent && fragmentPresent ) {
-
979 mRegisterShaderProgram(shaderFilenames[0], "", "", shaderFilenames[1], shaderFilenames[2], isSeparable);
-
980 } else if( vertexPresent && !tessellationPresent && !geometryPresent && fragmentPresent ) {
-
981 mRegisterShaderProgram(shaderFilenames[0], "", "", "", shaderFilenames[1], isSeparable);
-
982 } else if( !vertexPresent && tessellationPresent && !geometryPresent && !fragmentPresent ) {
-
983 if( !isSeparable ) {
-
984 fprintf(stderr, "[ERROR]: Vertex & Fragment Shaders not present. Program must be separable.\n");
-
985 } else {
-
986 mRegisterShaderProgram("", shaderFilenames[0], shaderFilenames[1], "", "", isSeparable);
-
987 }
-
988 } else if( !vertexPresent && tessellationPresent && geometryPresent && !fragmentPresent ) {
-
989 if( !isSeparable ) {
-
990 fprintf(stderr, "[ERROR]: Vertex & Fragment Shaders not present. Program must be separable.\n");
-
991 } else {
-
992 mRegisterShaderProgram("", shaderFilenames[0], shaderFilenames[1], shaderFilenames[2], "", isSeparable);
-
993 }
-
994 } else if( !vertexPresent && tessellationPresent && geometryPresent && fragmentPresent ) {
-
995 if( !isSeparable ) {
-
996 fprintf(stderr, "[ERROR]: Vertex Shader not present. Program must be separable.\n");
-
997 } else {
-
998 mRegisterShaderProgram("", shaderFilenames[0], shaderFilenames[1], shaderFilenames[2], shaderFilenames[3],
-
999 isSeparable);
-
1000 }
-
1001 } else if( !vertexPresent && tessellationPresent && !geometryPresent && fragmentPresent ) {
-
1002 if( !isSeparable ) {
-
1003 fprintf(stderr, "[ERROR]: Vertex Shader not present. Program must be separable.\n");
-
1004 } else {
-
1005 mRegisterShaderProgram("", shaderFilenames[0], shaderFilenames[1], "", shaderFilenames[2], isSeparable);
-
1006 }
-
1007 } else if( !vertexPresent && !tessellationPresent && geometryPresent && !fragmentPresent ) {
-
1008 if( !isSeparable ) {
-
1009 fprintf(stderr, "[ERROR]: Vertex & Fragment Shaders not present. Program must be separable.\n");
-
1010 } else {
-
1011 mRegisterShaderProgram("", "", "", shaderFilenames[0], "", isSeparable);
-
1012 }
-
1013 } else if( !vertexPresent && !tessellationPresent && geometryPresent && fragmentPresent ) {
-
1014 if( !isSeparable ) {
-
1015 fprintf(stderr, "[ERROR]: Vertex Shader not present. Program must be separable.\n");
-
1016 } else {
-
1017 mRegisterShaderProgram("", "", "", shaderFilenames[0], shaderFilenames[1], isSeparable);
-
1018 }
-
1019 } else if( !vertexPresent && !tessellationPresent && !geometryPresent && fragmentPresent ) {
-
1020 if( !isSeparable ) {
-
1021 fprintf(stderr, "[ERROR]: Vertex Shader not present. Program must be separable.\n");
-
1022 } else {
-
1023 mRegisterShaderProgram("", "", "", "", shaderFilenames[0], isSeparable);
-
1024 }
-
1025 } else if( !vertexPresent && !tessellationPresent && !geometryPresent && !fragmentPresent ) {
-
1026 fprintf(stderr, "[ERROR]: At least one shader must be present.\n");
-
1027 } else {
-
1028 fprintf(stderr, "[ERROR]: Unknown state.\n");
-
1029 }
-
1030}
-
1031
-
1032inline bool CSCI441::ShaderProgram::mRegisterShaderProgram(const char *vertexShaderFilename, const char *tessellationControlShaderFilename, const char *tessellationEvaluationShaderFilename, const char *geometryShaderFilename, const char *fragmentShaderFilename, const bool isSeparable ) {
-
1033 GLint major, minor;
-
1034 glGetIntegerv(GL_MAJOR_VERSION, &major);
-
1035 glGetIntegerv(GL_MINOR_VERSION, &minor);
-
1036
-
1037 if( sDEBUG ) printf( "\n[INFO]: /--------------------------------------------------------\\\n");
-
1038
-
1039 /* compile each one of our shaders */
-
1040 if( strcmp( vertexShaderFilename, "" ) != 0 ) {
-
1041 if( sDEBUG ) printf( "[INFO]: | Vertex Shader: %39s |\n", vertexShaderFilename );
-
1042 mVertexShaderHandle = CSCI441_INTERNAL::ShaderUtils::compileShader(vertexShaderFilename, GL_VERTEX_SHADER );
-
1043 } else {
- -
1045 }
-
1046
-
1047 if(strcmp(tessellationControlShaderFilename, "" ) != 0 ) {
-
1048 if( sDEBUG ) printf("[INFO]: | Tess Control Shader: %33s |\n", tessellationControlShaderFilename );
-
1049 if( major < 4 ) {
-
1050 printf( "[ERROR]:| TESSELLATION SHADER NOT SUPPORTED!! UPGRADE TO v4.0+ |\n" );
- -
1052 } else {
-
1053 mTessellationControlShaderHandle = CSCI441_INTERNAL::ShaderUtils::compileShader(tessellationControlShaderFilename, GL_TESS_CONTROL_SHADER );
-
1054 }
-
1055 } else {
- -
1057 }
-
1058
-
1059 if(strcmp(tessellationEvaluationShaderFilename, "" ) != 0 ) {
-
1060 if( sDEBUG ) printf("[INFO]: | Tess Evaluation Shader: %30s |\n", tessellationEvaluationShaderFilename );
-
1061 if( major < 4 ) {
-
1062 printf( "[ERROR]:| TESSELLATION SHADER NOT SUPPORTED!! UPGRADE TO v4.0+ |\n" );
- -
1064 } else {
-
1065 mTessellationEvaluationShaderHandle = CSCI441_INTERNAL::ShaderUtils::compileShader(tessellationEvaluationShaderFilename, GL_TESS_EVALUATION_SHADER );
-
1066 }
-
1067 } else {
- -
1069 }
-
1070
-
1071 if( strcmp( geometryShaderFilename, "" ) != 0 ) {
-
1072 if( sDEBUG ) printf( "[INFO]: | Geometry Shader: %37s |\n", geometryShaderFilename );
-
1073 if( major < 3 || (major == 3 && minor < 2) ) {
-
1074 printf( "[ERROR]:| GEOMETRY SHADER NOT SUPPORTED!!! UPGRADE TO v3.2+ |\n" );
- -
1076 } else {
-
1077 mGeometryShaderHandle = CSCI441_INTERNAL::ShaderUtils::compileShader(geometryShaderFilename, GL_GEOMETRY_SHADER );
-
1078 }
-
1079 } else {
- -
1081 }
-
1082
-
1083 if( strcmp( fragmentShaderFilename, "" ) != 0 ) {
-
1084 if( sDEBUG ) printf( "[INFO]: | Fragment Shader: %37s |\n", fragmentShaderFilename );
-
1085 mFragmentShaderHandle = CSCI441_INTERNAL::ShaderUtils::compileShader(fragmentShaderFilename, GL_FRAGMENT_SHADER );
-
1086 } else {
- -
1088 }
-
1089 /* get a handle to a shader program */
-
1090 mShaderProgramHandle = glCreateProgram();
-
1091
-
1092 /* if program is separable, make it so */
-
1093 if( isSeparable ) {
-
1094 glProgramParameteri(mShaderProgramHandle, GL_PROGRAM_SEPARABLE, GL_TRUE );
-
1095 }
-
1096
-
1097 /* attach the vertex and fragment shaders to the shader program */
-
1098 if(mVertexShaderHandle != 0 ) {
-
1099 glAttachShader(mShaderProgramHandle, mVertexShaderHandle );
-
1100 }
- - -
1103 }
- - -
1106 }
-
1107 if(mGeometryShaderHandle != 0 ) {
- -
1109 }
-
1110 if(mFragmentShaderHandle != 0 ) {
- -
1112 }
-
1113
-
1114 /* link all the programs together on the GPU */
-
1115 glLinkProgram(mShaderProgramHandle );
-
1116
-
1117 if( sDEBUG ) printf( "[INFO]: | Shader Program: %41s", "|\n" );
-
1118
-
1119 /* check the program log */
-
1120 CSCI441_INTERNAL::ShaderUtils::printProgramLog(mShaderProgramHandle );
-
1121
-
1122 /* detach & delete the vertex and fragment shaders to the shader program */
-
1123 if(mVertexShaderHandle != 0 ) {
-
1124 glDetachShader(mShaderProgramHandle, mVertexShaderHandle );
-
1125 glDeleteShader(mVertexShaderHandle );
-
1126 }
- - -
1129 glDeleteShader(mTessellationControlShaderHandle );
-
1130 }
- - -
1133 glDeleteShader(mTessellationEvaluationShaderHandle );
-
1134 }
-
1135 if(mGeometryShaderHandle != 0 ) {
- -
1137 glDeleteShader(mGeometryShaderHandle );
-
1138 }
-
1139 if(mFragmentShaderHandle != 0 ) {
- -
1141 glDeleteShader(mFragmentShaderHandle );
-
1142 }
-
1143
-
1144 // map uniforms
-
1145 mpUniformLocationsMap = new std::map<std::string, GLint>();
-
1146 GLint numUniforms;
-
1147 glGetProgramiv(mShaderProgramHandle, GL_ACTIVE_UNIFORMS, &numUniforms);
-
1148 if( numUniforms > 0 ) {
-
1149 for(GLint i = 0; i < numUniforms; i++) {
-
1150 char name[64];
-
1151 int max_length = 64;
-
1152 int actual_length = 0;
-
1153 int size = 0;
-
1154 GLenum type;
-
1155 glGetActiveUniform(mShaderProgramHandle, i, max_length, &actual_length, &size, &type, name );
-
1156 GLint location = -1;
-
1157 if(size > 1) {
-
1158 for(int j = 0; j < size; j++) {
-
1159 char long_name[64];
-
1160 sprintf(long_name, "%s[%i]", name, j);
-
1161 location = glGetUniformLocation(mShaderProgramHandle, long_name);
-
1162 }
-
1163 } else {
-
1164 location = glGetUniformLocation(mShaderProgramHandle, name);
-
1165 }
-
1166 mpUniformLocationsMap->emplace(name, location );
-
1167 }
-
1168 }
-
1169
-
1170 // map attributes
-
1171 mpAttributeLocationsMap = new std::map<std::string, GLint>();
-
1172 GLint numAttributes;
-
1173 glGetProgramiv(mShaderProgramHandle, GL_ACTIVE_ATTRIBUTES, &numAttributes );
-
1174 if( numAttributes > 0 ) {
-
1175 for(GLint i = 0; i < numAttributes; i++) {
-
1176 char name[64];
-
1177 int max_length = 64;
-
1178 int actual_length = 0;
-
1179 int size = 0;
-
1180 GLenum type;
-
1181 glGetActiveAttrib(mShaderProgramHandle, i, max_length, &actual_length, &size, &type, name );
-
1182 GLint location = -1;
-
1183 if( size > 1 ) {
-
1184 for( int j = 0; j < size; j++ ) {
-
1185 char long_name[64];
-
1186 sprintf( long_name, "%s[%i]", name, j );
-
1187 location = glGetAttribLocation(mShaderProgramHandle, long_name );
-
1188 }
-
1189 } else {
-
1190 location = glGetAttribLocation(mShaderProgramHandle, name );
-
1191 }
-
1192 mpAttributeLocationsMap->emplace(name, location );
-
1193 }
-
1194 }
-
1195
-
1196 GLint separable = GL_FALSE;
-
1197 glGetProgramiv(mShaderProgramHandle, GL_PROGRAM_SEPARABLE, &separable );
-
1198
-
1199 if( sDEBUG ) printf( "[INFO]: | Program Separable: %35s |\n", (separable ? "Yes" : "No"));
-
1200
-
1201 GLint linkStatus;
-
1202 glGetProgramiv(mShaderProgramHandle, GL_LINK_STATUS, &linkStatus );
-
1203
-
1204 /* print shader info for uniforms & attributes */
-
1205 if(linkStatus == 1) {
-
1206 CSCI441_INTERNAL::ShaderUtils::printShaderProgramInfo(mShaderProgramHandle, mVertexShaderHandle != 0,
- - - -
1210 false, true);
-
1211 }
-
1212 /* return handle */
-
1213 return mShaderProgramHandle != 0;
-
1214}
-
1215
-
1216inline GLint CSCI441::ShaderProgram::getUniformLocation( const char *uniformName ) const {
-
1217 GLint uniformLoc = glGetUniformLocation(mShaderProgramHandle, uniformName );
-
1218 if( uniformLoc == -1 )
-
1219 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle );
-
1220 return uniformLoc;
-
1221}
-
1222
-
1223inline GLint CSCI441::ShaderProgram::getUniformBlockIndex( const char *uniformBlockName ) const {
-
1224 GLint uniformBlockLoc = glGetUniformBlockIndex(mShaderProgramHandle, uniformBlockName );
-
1225 if( uniformBlockLoc == -1 )
-
1226 fprintf(stderr, "[ERROR]: Could not find uniform block \"%s\" for Shader Program %u\n", uniformBlockName, mShaderProgramHandle );
-
1227 return uniformBlockLoc;
-
1228}
-
1229
-
1230inline GLint CSCI441::ShaderProgram::getUniformBlockSize( const char *uniformBlockName ) const {
-
1231 GLint blockSize;
-
1232 glGetActiveUniformBlockiv(mShaderProgramHandle, getUniformBlockIndex(uniformBlockName), GL_UNIFORM_BLOCK_DATA_SIZE, &blockSize );
-
1233 return blockSize;
-
1234}
-
1235
-
1236[[maybe_unused]]
-
1237inline GLubyte* CSCI441::ShaderProgram::getUniformBlockBuffer( const char *uniformBlockName ) const {
-
1238 GLubyte *blockBuffer;
-
1239
-
1240 GLint blockSize = getUniformBlockSize( uniformBlockName );
-
1241
-
1242 blockBuffer = (GLubyte*)malloc(blockSize);
-
1243
-
1244 return blockBuffer;
-
1245}
-
1246
-
1247[[maybe_unused]]
-
1248inline GLint* CSCI441::ShaderProgram::getUniformBlockOffsets( const char *uniformBlockName ) const {
-
1249 return getUniformBlockOffsets(getUniformBlockIndex(uniformBlockName));
-
1250}
-
1251
-
1252[[maybe_unused]]
-
1253inline GLint* CSCI441::ShaderProgram::getUniformBlockOffsets( const char *uniformBlockName, const char *names[] ) const {
-
1254 return getUniformBlockOffsets(getUniformBlockIndex(uniformBlockName), names);
-
1255}
-
1256
-
1257inline GLint* CSCI441::ShaderProgram::getUniformBlockOffsets(GLint uniformBlockIndex ) const {
-
1258 GLint numUniforms;
-
1259 glGetActiveUniformBlockiv(mShaderProgramHandle, uniformBlockIndex, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &numUniforms );
-
1260
-
1261 auto indices = (GLuint*)malloc(numUniforms*sizeof(GLuint));
-
1262 glGetActiveUniformBlockiv(mShaderProgramHandle, uniformBlockIndex, GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, (GLint*)indices);
-
1263
-
1264 auto offsets = (GLint*)malloc(numUniforms*sizeof(GLint));
-
1265 glGetActiveUniformsiv(mShaderProgramHandle, numUniforms, indices, GL_UNIFORM_OFFSET, offsets );
-
1266 return offsets;
-
1267}
-
1268
-
1269inline GLint* CSCI441::ShaderProgram::getUniformBlockOffsets(GLint uniformBlockIndex, const char *names[] ) const {
-
1270 GLint numUniforms;
-
1271 glGetActiveUniformBlockiv(mShaderProgramHandle, uniformBlockIndex, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &numUniforms );
-
1272
-
1273 auto indices = (GLuint*)malloc(numUniforms*sizeof(GLuint));
-
1274 glGetUniformIndices(mShaderProgramHandle, numUniforms, names, indices );
-
1275
-
1276 auto offsets = (GLint*)malloc(numUniforms*sizeof(GLint));
-
1277 glGetActiveUniformsiv(mShaderProgramHandle, numUniforms, indices, GL_UNIFORM_OFFSET, offsets );
-
1278 return offsets;
-
1279}
-
1280
-
1281inline void CSCI441::ShaderProgram::setUniformBlockBinding( const char *uniformBlockName, GLuint binding ) const {
-
1282 glUniformBlockBinding(mShaderProgramHandle, getUniformBlockIndex(uniformBlockName), binding );
-
1283}
-
1284
-
1285[[maybe_unused]]
-
1286inline GLint CSCI441::ShaderProgram::getAttributeLocation( const char *attributeName ) const {
-
1287 auto attribIter = mpAttributeLocationsMap->find(attributeName);
-
1288 if(attribIter == mpAttributeLocationsMap->end() ) {
-
1289 fprintf(stderr, "[ERROR]: Could not find attribute \"%s\" for Shader Program %u\n", attributeName, mShaderProgramHandle );
-
1290 return -1;
-
1291 }
-
1292 return attribIter->second;
-
1293}
-
1294
-
1295[[maybe_unused]]
-
1296inline GLuint CSCI441::ShaderProgram::getSubroutineIndex( GLenum shaderStage, const char *subroutineName ) const {
-
1297 GLuint subroutineIndex = glGetSubroutineIndex(mShaderProgramHandle, shaderStage, subroutineName );
-
1298 if( subroutineIndex == GL_INVALID_INDEX )
-
1299 fprintf(stderr, "[ERROR]: Could not find subroutine \"%s\" in %s for Shader Program %u\n", subroutineName, CSCI441_INTERNAL::ShaderUtils::GL_shader_type_to_string(shaderStage), mShaderProgramHandle );
-
1300 return subroutineIndex;
-
1301}
-
1302
-
1303// images are opaque types that are not considered program resources
-
1304[[maybe_unused]]
-
1305inline GLint CSCI441::ShaderProgram::getImageBinding(const char* imageName) const {
-
1306 GLint imageLoc = getUniformLocation(imageName);
-
1307
-
1308 if(imageLoc == -1) {
-
1309 fprintf(stderr, "[ERROR]: Could not find image \"%s\" for Shader Program %u\n", imageName, mShaderProgramHandle);
-
1310 return -1;
-
1311 }
-
1312
-
1313 GLint bindingPoint;
-
1314 glGetUniformiv(mShaderProgramHandle, imageLoc, &bindingPoint);
-
1315
-
1316 return bindingPoint;
-
1317}
-
1318
-
1319[[maybe_unused]]
-
1320inline GLint CSCI441::ShaderProgram::getShaderStorageBlockBinding(const char* ssboName) const {
-
1321 GLuint ssboIndex = glGetProgramResourceIndex(mShaderProgramHandle, GL_SHADER_STORAGE_BLOCK, ssboName);
-
1322
-
1323 if(ssboIndex == GL_INVALID_INDEX) {
-
1324 fprintf(stderr, "[ERROR]: Could not find shader storage block \"%s\" for Shader Program %u\n", ssboName, mShaderProgramHandle);
-
1325 return -1;
-
1326 }
-
1327
-
1328 const int NUM_PROPS = 1;
-
1329 GLenum props[NUM_PROPS] = {GL_BUFFER_BINDING};
-
1330 GLint results[NUM_PROPS];
-
1331 glGetProgramResourceiv(mShaderProgramHandle, GL_SHADER_STORAGE_BLOCK, ssboIndex, NUM_PROPS, props, NUM_PROPS, nullptr, results);
-
1332
-
1333 return results[0];
-
1334}
-
1335
-
1336[[maybe_unused]]
-
1337inline GLint CSCI441::ShaderProgram::getAtomicCounterBufferBinding(const char* atomicName) const {
-
1338 GLuint uniformIndex = glGetProgramResourceIndex(mShaderProgramHandle, GL_UNIFORM, atomicName);
-
1339
-
1340 if(uniformIndex == GL_INVALID_INDEX) {
-
1341 fprintf(stderr, "[ERROR]: Could not find atomic counter \"%s\" for Shader Program %u\n", atomicName, mShaderProgramHandle);
-
1342 return -1;
-
1343 }
-
1344
-
1345 GLenum props = GL_ATOMIC_COUNTER_BUFFER_INDEX;
-
1346 GLint atomicIndex, binding;
-
1347 glGetProgramResourceiv(mShaderProgramHandle, GL_UNIFORM, uniformIndex, 1, &props, 1, nullptr, &atomicIndex);
-
1348 glGetActiveAtomicCounterBufferiv(mShaderProgramHandle, atomicIndex, GL_ATOMIC_COUNTER_BUFFER_BINDING, &binding);
-
1349
-
1350 return binding;
-
1351}
-
1352
-
1353[[maybe_unused]]
-
1354inline GLint CSCI441::ShaderProgram::getAtomicCounterBufferOffset(const char* atomicName) const {
-
1355 GLuint uniformIndex = glGetProgramResourceIndex(mShaderProgramHandle, GL_UNIFORM, atomicName);
-
1356
-
1357 if(uniformIndex == GL_INVALID_INDEX) {
-
1358 fprintf(stderr, "[ERROR]: Could not find atomic counter \"%s\" for Shader Program %u\n", atomicName, mShaderProgramHandle);
-
1359 return -1;
-
1360 }
-
1361
-
1362 GLint offset;
-
1363 glGetActiveUniformsiv(mShaderProgramHandle, 1, &uniformIndex, GL_UNIFORM_OFFSET, &offset);
-
1364 return offset;
-
1365}
-
1366
-
1367[[maybe_unused]]
-
1368inline GLint CSCI441::ShaderProgram::getAtomicCounterBufferSize(const char* atomicName) const {
-
1369 GLuint uniformIndex = glGetProgramResourceIndex(mShaderProgramHandle, GL_UNIFORM, atomicName);
-
1370
-
1371 if(uniformIndex == GL_INVALID_INDEX) {
-
1372 fprintf(stderr, "[ERROR]: Could not find atomic counter \"%s\" for Shader Program %u\n", atomicName, mShaderProgramHandle);
-
1373 return -1;
-
1374 }
-
1375
-
1376 GLenum props = GL_ATOMIC_COUNTER_BUFFER_INDEX;
-
1377 GLint atomicIndex, bufferSize;
-
1378 glGetProgramResourceiv(mShaderProgramHandle, GL_UNIFORM, uniformIndex, 1, &props, 1, nullptr, &atomicIndex);
-
1379 glGetActiveAtomicCounterBufferiv(mShaderProgramHandle, atomicIndex, GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE, &bufferSize);
-
1380
-
1381 return bufferSize;
-
1382}
-
1383
-
1384[[maybe_unused]]
- -
1386 int numUniform = 0;
-
1387 glGetProgramiv(mShaderProgramHandle, GL_ACTIVE_UNIFORMS, &numUniform );
-
1388 return numUniform;
-
1389}
-
1390
-
1391[[maybe_unused]]
- -
1393 int numUniformBlocks = 0;
-
1394 glGetProgramiv(mShaderProgramHandle, GL_ACTIVE_UNIFORM_BLOCKS, &numUniformBlocks );
-
1395 return numUniformBlocks;
-
1396}
-
1397
-
1398[[maybe_unused]]
- -
1400 int numAttr = 0;
-
1401 glGetProgramiv(mShaderProgramHandle, GL_ACTIVE_ATTRIBUTES, &numAttr );
-
1402 return numAttr;
-
1403}
-
1404
- -
1406 return mShaderProgramHandle;
-
1407}
-
1408
-
1409[[maybe_unused]]
- -
1411 glUseProgram(mShaderProgramHandle );
-
1412}
-
1413
-
1414[[maybe_unused]]
-
1415inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, GLfloat v0 ) const {
-
1416 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1417 if(uniformIter != mpUniformLocationsMap->end()) {
-
1418 glProgramUniform1f(mShaderProgramHandle, uniformIter->second, v0 );
-
1419 } else {
-
1420 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1421 }
-
1422}
-
1423
-
1424[[maybe_unused]]
-
1425inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, GLfloat v0, GLfloat v1 ) const {
-
1426 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1427 if(uniformIter != mpUniformLocationsMap->end()) {
-
1428 glProgramUniform2f(mShaderProgramHandle, uniformIter->second, v0, v1 );
-
1429 } else {
-
1430 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1431 }
-
1432}
-
1433
-
1434[[maybe_unused]]
-
1435inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, glm::vec2 value ) const {
-
1436 setProgramUniform( uniformName, 2, 1, &value[0] );
-
1437}
-
1438
-
1439[[maybe_unused]]
-
1440inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, GLfloat v0, GLfloat v1, GLfloat v2 ) const {
-
1441 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1442 if(uniformIter != mpUniformLocationsMap->end()) {
-
1443 glProgramUniform3f(mShaderProgramHandle, uniformIter->second, v0, v1, v2 );
-
1444 } else {
-
1445 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1446 }
-
1447}
-
1448
-
1449[[maybe_unused]]
-
1450inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, glm::vec3 value ) const {
-
1451 setProgramUniform( uniformName, 3, 1, &value[0] );
-
1452}
-
1453
-
1454[[maybe_unused]]
-
1455inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3 ) const {
-
1456 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1457 if(uniformIter != mpUniformLocationsMap->end()) {
-
1458 glProgramUniform4f(mShaderProgramHandle, uniformIter->second, v0, v1, v2, v3 );
-
1459 } else {
-
1460 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1461 }
-
1462}
-
1463
-
1464[[maybe_unused]]
-
1465inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, glm::vec4 value ) const {
-
1466 setProgramUniform( uniformName, 4, 1, &value[0] );
-
1467}
-
1468
-
1469inline void CSCI441::ShaderProgram::setProgramUniform(const char* uniformName, GLuint dim, GLsizei count, const GLfloat *value) const {
-
1470 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1471 if(uniformIter != mpUniformLocationsMap->end()) {
-
1472 switch(dim) {
-
1473 case 1:
-
1474 glProgramUniform1fv(mShaderProgramHandle, uniformIter->second, count, value );
-
1475 break;
-
1476 case 2:
-
1477 glProgramUniform2fv(mShaderProgramHandle, uniformIter->second, count, value );
-
1478 break;
-
1479 case 3:
-
1480 glProgramUniform3fv(mShaderProgramHandle, uniformIter->second, count, value );
-
1481 break;
-
1482 case 4:
-
1483 glProgramUniform4fv(mShaderProgramHandle, uniformIter->second, count, value );
-
1484 break;
-
1485 default:
-
1486 fprintf(stderr, "[ERROR]: invalid dimension %u for uniform %s in Shader Program %u. Dimension must be [1,4]\n", dim, uniformName, mShaderProgramHandle);
-
1487 break;
-
1488 }
-
1489 } else {
-
1490 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1491 }
-
1492}
-
1493
-
1494[[maybe_unused]]
-
1495inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, GLint v0 ) const {
-
1496 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1497 if(uniformIter != mpUniformLocationsMap->end()) {
-
1498 glProgramUniform1i(mShaderProgramHandle, uniformIter->second, v0 );
-
1499 } else {
-
1500 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1501 }
-
1502}
-
1503
-
1504[[maybe_unused]]
-
1505inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, GLint v0, GLint v1 ) const {
-
1506 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1507 if(uniformIter != mpUniformLocationsMap->end()) {
-
1508 glProgramUniform2i(mShaderProgramHandle, uniformIter->second, v0, v1 );
-
1509 } else {
-
1510 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1511 }
-
1512}
-
1513
-
1514[[maybe_unused]]
-
1515inline void CSCI441::ShaderProgram::setProgramUniform(const char* uniformName, glm::ivec2 value) const {
-
1516 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1517 if(uniformIter != mpUniformLocationsMap->end()) {
-
1518 glProgramUniform2iv(mShaderProgramHandle, uniformIter->second, 1, &value[0] );
-
1519 } else {
-
1520 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1521 }
-
1522}
-
1523
-
1524[[maybe_unused]]
-
1525inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, GLint v0, GLint v1, GLint v2 ) const {
-
1526 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1527 if(uniformIter != mpUniformLocationsMap->end()) {
-
1528 glProgramUniform3i(mShaderProgramHandle, uniformIter->second, v0, v1, v2 );
-
1529 } else {
-
1530 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1531 }
-
1532}
-
1533
-
1534[[maybe_unused]]
-
1535inline void CSCI441::ShaderProgram::setProgramUniform(const char* uniformName, glm::ivec3 value) const {
-
1536 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1537 if(uniformIter != mpUniformLocationsMap->end()) {
-
1538 glProgramUniform3iv(mShaderProgramHandle, uniformIter->second, 1, &value[0] );
-
1539 } else {
-
1540 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1541 }
-
1542}
-
1543
-
1544[[maybe_unused]]
-
1545inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, GLint v0, GLint v1, GLint v2, GLint v3 ) const {
-
1546 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1547 if(uniformIter != mpUniformLocationsMap->end()) {
-
1548 glProgramUniform4i(mShaderProgramHandle, uniformIter->second, v0, v1, v2, v3 );
-
1549 } else {
-
1550 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1551 }
-
1552}
-
1553
-
1554[[maybe_unused]]
-
1555inline void CSCI441::ShaderProgram::setProgramUniform(const char* uniformName, glm::ivec4 value) const {
-
1556 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1557 if(uniformIter != mpUniformLocationsMap->end()) {
-
1558 glProgramUniform4iv(mShaderProgramHandle, uniformIter->second, 1, &value[0] );
-
1559 } else {
-
1560 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1561 }
-
1562}
-
1563
-
1564[[maybe_unused]]
-
1565inline void CSCI441::ShaderProgram::setProgramUniform(const char* uniformName, GLuint dim, GLsizei count, const GLint *value) const {
-
1566 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1567 if(uniformIter != mpUniformLocationsMap->end()) {
-
1568 switch(dim) {
-
1569 case 1:
-
1570 glProgramUniform1iv(mShaderProgramHandle, uniformIter->second, count, value );
-
1571 break;
-
1572 case 2:
-
1573 glProgramUniform2iv(mShaderProgramHandle, uniformIter->second, count, value );
-
1574 break;
-
1575 case 3:
-
1576 glProgramUniform3iv(mShaderProgramHandle, uniformIter->second, count, value );
-
1577 break;
-
1578 case 4:
-
1579 glProgramUniform4iv(mShaderProgramHandle, uniformIter->second, count, value );
-
1580 break;
-
1581 default:
-
1582 fprintf(stderr, "[ERROR]: invalid dimension %u for uniform %s in Shader Program %u. Dimension must be [1,4]\n", dim, uniformName, mShaderProgramHandle);
-
1583 break;
-
1584 }
-
1585 } else {
-
1586 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1587 }
-
1588}
-
1589
-
1590[[maybe_unused]]
-
1591inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, GLuint v0 ) const {
-
1592 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1593 if(uniformIter != mpUniformLocationsMap->end()) {
-
1594 glProgramUniform1ui(mShaderProgramHandle, uniformIter->second, v0 );
-
1595 } else {
-
1596 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1597 }
-
1598}
-
1599
-
1600[[maybe_unused]]
-
1601inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, GLuint v0, GLuint v1 ) const {
-
1602 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1603 if(uniformIter != mpUniformLocationsMap->end()) {
-
1604 glProgramUniform2ui(mShaderProgramHandle, uniformIter->second, v0, v1 );
-
1605 } else {
-
1606 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1607 }
-
1608}
-
1609
-
1610[[maybe_unused]]
-
1611inline void CSCI441::ShaderProgram::setProgramUniform(const char* uniformName, glm::uvec2 value) const {
-
1612 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1613 if(uniformIter != mpUniformLocationsMap->end()) {
-
1614 glProgramUniform2uiv(mShaderProgramHandle, uniformIter->second, 1, &value[0] );
-
1615 } else {
-
1616 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1617 }
-
1618}
-
1619
-
1620[[maybe_unused]]
-
1621inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, GLuint v0, GLuint v1, GLuint v2 ) const {
-
1622 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1623 if(uniformIter != mpUniformLocationsMap->end()) {
-
1624 glProgramUniform3ui(mShaderProgramHandle, uniformIter->second, v0, v1, v2 );
-
1625 } else {
-
1626 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1627 }
-
1628}
-
1629
-
1630[[maybe_unused]]
-
1631inline void CSCI441::ShaderProgram::setProgramUniform(const char* uniformName, glm::uvec3 value) const {
-
1632 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1633 if(uniformIter != mpUniformLocationsMap->end()) {
-
1634 glProgramUniform3uiv(mShaderProgramHandle, uniformIter->second, 1, &value[0] );
-
1635 } else {
-
1636 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1637 }
-
1638}
-
1639
-
1640[[maybe_unused]]
-
1641inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, GLuint v0, GLuint v1, GLuint v2, GLuint v3 ) const {
-
1642 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1643 if(uniformIter != mpUniformLocationsMap->end()) {
-
1644 glProgramUniform4ui(mShaderProgramHandle, uniformIter->second, v0, v1, v2, v3 );
-
1645 } else {
-
1646 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1647 }
-
1648}
-
1649
-
1650[[maybe_unused]]
-
1651inline void CSCI441::ShaderProgram::setProgramUniform(const char* uniformName, glm::uvec4 value) const {
-
1652 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1653 if(uniformIter != mpUniformLocationsMap->end()) {
-
1654 glProgramUniform4uiv(mShaderProgramHandle, uniformIter->second, 1, &value[0] );
-
1655 } else {
-
1656 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1657 }
-
1658}
-
1659
-
1660[[maybe_unused]]
-
1661inline void CSCI441::ShaderProgram::setProgramUniform(const char* uniformName, GLuint dim, GLsizei count, const GLuint *value) const {
-
1662 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1663 if(uniformIter != mpUniformLocationsMap->end()) {
-
1664 switch(dim) {
-
1665 case 1:
-
1666 glProgramUniform1uiv(mShaderProgramHandle, uniformIter->second, count, value );
-
1667 break;
-
1668 case 2:
-
1669 glProgramUniform2uiv(mShaderProgramHandle, uniformIter->second, count, value );
-
1670 break;
-
1671 case 3:
-
1672 glProgramUniform3uiv(mShaderProgramHandle, uniformIter->second, count, value );
-
1673 break;
-
1674 case 4:
-
1675 glProgramUniform4uiv(mShaderProgramHandle, uniformIter->second, count, value );
-
1676 break;
-
1677 default:
-
1678 fprintf(stderr, "[ERROR]: invalid dimension %u for uniform %s in Shader Program %u. Dimension must be [1,4]\n", dim, uniformName, mShaderProgramHandle);
-
1679 break;
-
1680 }
-
1681 } else {
-
1682 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1683 }
-
1684}
-
1685
-
1686[[maybe_unused]]
-
1687inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, glm::mat2 mtx ) const {
-
1688 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1689 if(uniformIter != mpUniformLocationsMap->end()) {
-
1690 glProgramUniformMatrix2fv(mShaderProgramHandle, uniformIter->second, 1, GL_FALSE, &mtx[0][0] );
-
1691 } else {
-
1692 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1693 }
-
1694}
-
1695
-
1696[[maybe_unused]]
-
1697inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, glm::mat3 mtx ) const {
-
1698 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1699 if(uniformIter != mpUniformLocationsMap->end()) {
-
1700 glProgramUniformMatrix3fv(mShaderProgramHandle, uniformIter->second, 1, GL_FALSE, &mtx[0][0] );
-
1701 } else {
-
1702 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1703 }
-
1704}
-
1705
-
1706[[maybe_unused]]
-
1707inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, glm::mat4 mtx ) const {
-
1708 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1709 if(uniformIter != mpUniformLocationsMap->end()) {
-
1710 glProgramUniformMatrix4fv(mShaderProgramHandle, uniformIter->second, 1, GL_FALSE, &mtx[0][0] );
-
1711 } else {
-
1712 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1713 }
-
1714}
-
1715
-
1716[[maybe_unused]]
-
1717inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, glm::mat2x3 mtx ) const {
-
1718 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1719 if(uniformIter != mpUniformLocationsMap->end()) {
-
1720 glProgramUniformMatrix2x3fv(mShaderProgramHandle, uniformIter->second, 1, GL_FALSE, &mtx[0][0] );
-
1721 } else {
-
1722 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1723 }
-
1724}
-
1725
-
1726[[maybe_unused]]
-
1727inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, glm::mat3x2 mtx ) const {
-
1728 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1729 if(uniformIter != mpUniformLocationsMap->end()) {
-
1730 glProgramUniformMatrix3x2fv(mShaderProgramHandle, uniformIter->second, 1, GL_FALSE, &mtx[0][0] );
-
1731 } else {
-
1732 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1733 }
-
1734}
-
1735
-
1736[[maybe_unused]]
-
1737inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, glm::mat2x4 mtx ) const {
-
1738 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1739 if(uniformIter != mpUniformLocationsMap->end()) {
-
1740 glProgramUniformMatrix2x4fv(mShaderProgramHandle, uniformIter->second, 1, GL_FALSE, &mtx[0][0] );
-
1741 } else {
-
1742 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1743 }
-
1744}
-
1745
-
1746[[maybe_unused]]
-
1747inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, glm::mat4x2 mtx ) const {
-
1748 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1749 if(uniformIter != mpUniformLocationsMap->end()) {
-
1750 glProgramUniformMatrix4x2fv(mShaderProgramHandle, uniformIter->second, 1, GL_FALSE, &mtx[0][0] );
-
1751 } else {
-
1752 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1753 }
-
1754}
-
1755
-
1756[[maybe_unused]]
-
1757inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, glm::mat3x4 mtx ) const {
-
1758 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1759 if(uniformIter != mpUniformLocationsMap->end()) {
-
1760 glProgramUniformMatrix3x4fv(mShaderProgramHandle, uniformIter->second, 1, GL_FALSE, &mtx[0][0] );
-
1761 } else {
-
1762 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1763 }
-
1764}
-
1765
-
1766[[maybe_unused]]
-
1767inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, glm::mat4x3 mtx ) const {
-
1768 auto uniformIter = mpUniformLocationsMap->find(uniformName);
-
1769 if(uniformIter != mpUniformLocationsMap->end()) {
-
1770 glProgramUniformMatrix4x3fv(mShaderProgramHandle, uniformIter->second, 1, GL_FALSE, &mtx[0][0] );
-
1771 } else {
-
1772 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
-
1773 }
-
1774}
-
1775
-
1776[[maybe_unused]]
-
1777inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, GLfloat v0 ) const {
-
1778 glProgramUniform1f(mShaderProgramHandle, uniformLocation, v0 );
-
1779}
-
1780
-
1781[[maybe_unused]]
-
1782inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, GLfloat v0, GLfloat v1 ) const {
-
1783 glProgramUniform2f(mShaderProgramHandle, uniformLocation, v0, v1 );
-
1784}
-
1785
-
1786[[maybe_unused]]
-
1787inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, glm::vec2 value ) const {
-
1788 setProgramUniform( uniformLocation, 2, 1, &value[0] );
-
1789}
-
1790
-
1791[[maybe_unused]]
-
1792inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, GLfloat v0, GLfloat v1, GLfloat v2 ) const {
-
1793 glProgramUniform3f(mShaderProgramHandle, uniformLocation, v0, v1, v2 );
-
1794}
-
1795
-
1796[[maybe_unused]]
-
1797inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, glm::vec3 value ) const {
-
1798 setProgramUniform( uniformLocation, 3, 1, &value[0] );
-
1799}
-
1800
-
1801[[maybe_unused]]
-
1802inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3 ) const {
-
1803 glProgramUniform4f(mShaderProgramHandle, uniformLocation, v0, v1, v2, v3 );
-
1804}
-
1805
-
1806[[maybe_unused]]
-
1807inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, glm::vec4 value ) const {
-
1808 setProgramUniform( uniformLocation, 4, 1, &value[0] );
-
1809}
-
1810
-
1811inline void CSCI441::ShaderProgram::setProgramUniform(GLint uniformLocation, GLuint dim, GLsizei count, const GLfloat *value) const {
-
1812 switch(dim) {
-
1813 case 1:
-
1814 glProgramUniform1fv(mShaderProgramHandle, uniformLocation, count, value );
-
1815 break;
-
1816 case 2:
-
1817 glProgramUniform2fv(mShaderProgramHandle, uniformLocation, count, value );
-
1818 break;
-
1819 case 3:
-
1820 glProgramUniform3fv(mShaderProgramHandle, uniformLocation, count, value );
-
1821 break;
-
1822 case 4:
-
1823 glProgramUniform4fv(mShaderProgramHandle, uniformLocation, count, value );
-
1824 break;
-
1825 default:
-
1826 fprintf(stderr, "[ERROR]: invalid dimension %u for uniform %i in Shader Program %u. Dimension must be [1,4]\n", dim, uniformLocation, mShaderProgramHandle);
-
1827 break;
-
1828 }
-
1829}
-
1830
-
1831[[maybe_unused]]
-
1832inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, GLint v0 ) const {
-
1833 glProgramUniform1i(mShaderProgramHandle, uniformLocation, v0 );
-
1834}
-
1835
-
1836[[maybe_unused]]
-
1837inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, GLint v0, GLint v1 ) const {
-
1838 glProgramUniform2i(mShaderProgramHandle, uniformLocation, v0, v1 );
-
1839}
-
1840
-
1841[[maybe_unused]]
-
1842inline void CSCI441::ShaderProgram::setProgramUniform(GLint uniformLocation, glm::ivec2 value) const {
-
1843 setProgramUniform(uniformLocation, 2, 1, &value[0]);
-
1844}
-
1845
-
1846[[maybe_unused]]
-
1847inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, GLint v0, GLint v1, GLint v2 ) const {
-
1848 glProgramUniform3i(mShaderProgramHandle, uniformLocation, v0, v1, v2 );
-
1849}
-
1850
-
1851[[maybe_unused]]
-
1852inline void CSCI441::ShaderProgram::setProgramUniform(GLint uniformLocation, glm::ivec3 value) const {
-
1853 setProgramUniform(uniformLocation, 3, 1, &value[0]);
-
1854}
-
1855
-
1856[[maybe_unused]]
-
1857inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, GLint v0, GLint v1, GLint v2, GLint v3 ) const {
-
1858 glProgramUniform4i(mShaderProgramHandle, uniformLocation, v0, v1, v2, v3 );
-
1859}
-
1860
-
1861[[maybe_unused]]
-
1862inline void CSCI441::ShaderProgram::setProgramUniform(GLint uniformLocation, glm::ivec4 value) const {
-
1863 setProgramUniform(uniformLocation, 4, 1, &value[0]);
-
1864}
-
1865
-
1866inline void CSCI441::ShaderProgram::setProgramUniform(GLint uniformLocation, GLuint dim, GLsizei count, const GLint *value) const {
-
1867 switch(dim) {
-
1868 case 1:
-
1869 glProgramUniform1iv(mShaderProgramHandle, uniformLocation, count, value );
-
1870 break;
-
1871 case 2:
-
1872 glProgramUniform2iv(mShaderProgramHandle, uniformLocation, count, value );
-
1873 break;
-
1874 case 3:
-
1875 glProgramUniform3iv(mShaderProgramHandle, uniformLocation, count, value );
-
1876 break;
-
1877 case 4:
-
1878 glProgramUniform4iv(mShaderProgramHandle, uniformLocation, count, value );
-
1879 break;
-
1880 default:
-
1881 fprintf(stderr, "[ERROR]: invalid dimension %u for uniform %i in Shader Program %u. Dimension must be [1,4]\n", dim, uniformLocation, mShaderProgramHandle);
-
1882 break;
-
1883 }
-
1884}
-
1885
-
1886[[maybe_unused]]
-
1887inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, GLuint v0 ) const {
-
1888 glProgramUniform1ui(mShaderProgramHandle, uniformLocation, v0 );
-
1889}
-
1890
-
1891[[maybe_unused]]
-
1892inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, GLuint v0, GLuint v1 ) const {
-
1893 glProgramUniform2ui(mShaderProgramHandle, uniformLocation, v0, v1 );
-
1894}
-
1895
-
1896[[maybe_unused]]
-
1897inline void CSCI441::ShaderProgram::setProgramUniform(GLint uniformLocation, glm::uvec2 value) const {
-
1898 setProgramUniform(uniformLocation, 2, 1, &value[0]);
-
1899}
-
1900
-
1901[[maybe_unused]]
-
1902inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, GLuint v0, GLuint v1, GLuint v2 ) const {
-
1903 glProgramUniform3ui(mShaderProgramHandle, uniformLocation, v0, v1, v2 );
-
1904}
-
1905
-
1906[[maybe_unused]]
-
1907inline void CSCI441::ShaderProgram::setProgramUniform(GLint uniformLocation, glm::uvec3 value) const {
-
1908 setProgramUniform(uniformLocation, 3, 1, &value[0]);
-
1909}
-
1910
-
1911[[maybe_unused]]
-
1912inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, GLuint v0, GLuint v1, GLuint v2, GLuint v3 ) const {
-
1913 glProgramUniform4ui(mShaderProgramHandle, uniformLocation, v0, v1, v2, v3 );
-
1914}
-
1915
-
1916[[maybe_unused]]
-
1917inline void CSCI441::ShaderProgram::setProgramUniform(GLint uniformLocation, glm::uvec4 value) const {
-
1918 setProgramUniform(uniformLocation, 4, 1, &value[0]);
-
1919}
-
1920
-
1921inline void CSCI441::ShaderProgram::setProgramUniform(GLint uniformLocation, GLuint dim, GLsizei count, const GLuint *value) const {
-
1922 switch(dim) {
-
1923 case 1:
-
1924 glProgramUniform1uiv(mShaderProgramHandle, uniformLocation, count, value );
-
1925 break;
-
1926 case 2:
-
1927 glProgramUniform2uiv(mShaderProgramHandle, uniformLocation, count, value );
-
1928 break;
-
1929 case 3:
-
1930 glProgramUniform3uiv(mShaderProgramHandle, uniformLocation, count, value );
-
1931 break;
-
1932 case 4:
-
1933 glProgramUniform4uiv(mShaderProgramHandle, uniformLocation, count, value );
-
1934 break;
-
1935 default:
-
1936 fprintf(stderr, "[ERROR]: invalid dimension %u for uniform %i in Shader Program %u. Dimension must be [1,4]\n", dim, uniformLocation, mShaderProgramHandle);
-
1937 break;
-
1938 }
-
1939}
-
1940
-
1941[[maybe_unused]]
-
1942inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, glm::mat2 mtx ) const {
-
1943 glProgramUniformMatrix2fv(mShaderProgramHandle, uniformLocation, 1, GL_FALSE, &mtx[0][0] );
-
1944}
-
1945
-
1946[[maybe_unused]]
-
1947inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, glm::mat3 mtx ) const {
-
1948 glProgramUniformMatrix3fv(mShaderProgramHandle, uniformLocation, 1, GL_FALSE, &mtx[0][0] );
-
1949}
-
1950
-
1951[[maybe_unused]]
-
1952inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, glm::mat4 mtx ) const {
-
1953 glProgramUniformMatrix4fv(mShaderProgramHandle, uniformLocation, 1, GL_FALSE, &mtx[0][0] );
-
1954}
-
1955
-
1956[[maybe_unused]]
-
1957inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, glm::mat2x3 mtx ) const {
-
1958 glProgramUniformMatrix2x3fv(mShaderProgramHandle, uniformLocation, 1, GL_FALSE, &mtx[0][0] );
-
1959}
-
1960
-
1961[[maybe_unused]]
-
1962inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, glm::mat3x2 mtx ) const {
-
1963 glProgramUniformMatrix3x2fv(mShaderProgramHandle, uniformLocation, 1, GL_FALSE, &mtx[0][0] );
-
1964}
-
1965
-
1966[[maybe_unused]]
-
1967inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, glm::mat2x4 mtx ) const {
-
1968 glProgramUniformMatrix2x4fv(mShaderProgramHandle, uniformLocation, 1, GL_FALSE, &mtx[0][0] );
-
1969}
-
1970
-
1971[[maybe_unused]]
-
1972inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, glm::mat4x2 mtx ) const {
-
1973 glProgramUniformMatrix4x2fv(mShaderProgramHandle, uniformLocation, 1, GL_FALSE, &mtx[0][0] );
-
1974}
-
1975
-
1976[[maybe_unused]]
-
1977inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, glm::mat3x4 mtx ) const {
-
1978 glProgramUniformMatrix3x4fv(mShaderProgramHandle, uniformLocation, 1, GL_FALSE, &mtx[0][0] );
-
1979}
-
1980
-
1981[[maybe_unused]]
-
1982inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, glm::mat4x3 mtx ) const {
-
1983 glProgramUniformMatrix4x3fv(mShaderProgramHandle, uniformLocation, 1, GL_FALSE, &mtx[0][0] );
-
1984}
-
1985
-
1986[[maybe_unused]]
- -
1988 GLbitfield shaderBits = 0;
-
1989 if( mVertexShaderHandle != 0 ) shaderBits |= GL_VERTEX_SHADER_BIT;
-
1990 if( mTessellationControlShaderHandle != 0 ) shaderBits |= GL_TESS_CONTROL_SHADER_BIT;
-
1991 if( mTessellationEvaluationShaderHandle != 0 ) shaderBits |= GL_TESS_EVALUATION_SHADER_BIT;
-
1992 if( mGeometryShaderHandle != 0 ) shaderBits |= GL_GEOMETRY_SHADER_BIT;
-
1993 if( mFragmentShaderHandle != 0 ) shaderBits |= GL_FRAGMENT_SHADER_BIT;
-
1994 return shaderBits;
-
1995}
-
1996
- -
1998 _initialize();
-
1999}
-
2000
-
2001inline void CSCI441::ShaderProgram::_initialize() {
- - - - - - -
2008 mpUniformLocationsMap = nullptr;
-
2009 mpAttributeLocationsMap = nullptr;
-
2010}
-
2011
- -
2013 int status;
-
2014 int infoLogLength = 0;
-
2015 int maxLength = 1000;
-
2016
-
2017 glDeleteProgram(mShaderProgramHandle );
-
2018
-
2019 // create a buffer of designated length
-
2020 char* infoLog = new char[maxLength];
-
2021
-
2022 glGetProgramiv(mShaderProgramHandle, GL_DELETE_STATUS, &status );
-
2023
-
2024 // get the info log for the vertex/tessellation/geometry/fragment/compute shader
-
2025 glGetProgramInfoLog(mShaderProgramHandle, maxLength, &infoLogLength, infoLog );
-
2026
-
2027 if(infoLogLength > 0 ) {
-
2028 // print info to terminal
-
2029 if( sDEBUG ) printf("[INFO]: Program Handle %d Delete Status %s: %s\n", mShaderProgramHandle, (status == GL_TRUE ? "Success" : " Error"), infoLog );
-
2030 }
-
2031
-
2032 delete mpUniformLocationsMap;
- -
2034 delete[] infoLog;
-
2035}
-
2036
-
2037inline bool CSCI441::ShaderProgram::writeShaderProgramBinaryToFile(const char* BINARY_FILE_NAME) const {
-
2038 GLint formats = 0;
-
2039 glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &formats);
-
2040 if( formats < 1 ) {
-
2041 fprintf(stderr, "[ERROR]: Driver does not support any binary formats.\n");
-
2042 return false;
-
2043 }
-
2044
-
2045 // Get the binary length
-
2046 GLint length = 0;
-
2047 glGetProgramiv(mShaderProgramHandle, GL_PROGRAM_BINARY_LENGTH, &length);
-
2048
-
2049 // Retrieve the binary code
-
2050 std::vector<GLubyte> buffer(length);
-
2051 GLenum format = 0;
-
2052 glGetProgramBinary(mShaderProgramHandle, length, nullptr, &format, buffer.data());
-
2053
-
2054 // Write the binary to a file.
-
2055 fprintf(stdout, "[INFO]: Writing to %s, binary format %d\n",BINARY_FILE_NAME, format);
-
2056 std::ofstream out(BINARY_FILE_NAME, std::ios::binary);
-
2057 out.write( reinterpret_cast<char *>(buffer.data()), length );
-
2058 out.close();
-
2059
-
2060 return true;
-
2061}
-
2062
-
2063inline CSCI441::ShaderProgram* CSCI441::ShaderProgram::loadShaderProgramFromBinaryFile(const char* BINARY_FILE_NAME, const GLenum FORMAT) {
-
2064 GLint formats = 0;
-
2065 glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &formats);
-
2066 if( formats < 1 ) {
-
2067 fprintf(stderr, "[ERROR]: Driver does not support any binary formats.\n");
-
2068 return nullptr;
-
2069 }
-
2070
-
2071 GLuint program = glCreateProgram();
-
2072
-
2073 // Load binary from file
-
2074 std::ifstream inputStream(BINARY_FILE_NAME, std::ios::binary);
-
2075 std::istreambuf_iterator<char> startIt(inputStream), endIt;
-
2076 std::vector<char> buffer(startIt, endIt); // Load file
-
2077 inputStream.close();
-
2078
-
2079 // Install shader binary
-
2080 glProgramBinary(program, FORMAT, buffer.data(), buffer.size() );
-
2081
-
2082 // Check for success/failure
-
2083 GLint status;
-
2084 glGetProgramiv(program, GL_LINK_STATUS, &status);
-
2085 if( GL_FALSE == status ) {
-
2086 CSCI441_INTERNAL::ShaderUtils::printProgramLog(program);
-
2087 return nullptr;
-
2088 }
-
2089
-
2090 auto shaderProgram = new CSCI441::ShaderProgram();
-
2091 shaderProgram->mShaderProgramHandle = program;
-
2092 return shaderProgram;
-
2093}
-
2094
-
2095#endif // CSCI441_SHADER_PROGRAM_HPP
+
19#include <glm/gtc/type_ptr.hpp> // for glm::value_ptr()
+
20
+
21#include <cstdlib>
+
22#include <fstream>
+
23#include <map>
+
24#include <string>
+
25#include <vector>
+
26
+
28
+
29namespace CSCI441 {
+
30
+ +
36 public:
+
41 [[maybe_unused]] static void enableDebugMessages();
+
46 [[maybe_unused]] static void disableDebugMessages();
+
47
+
53 ShaderProgram( const char *vertexShaderFilename,
+
54 const char *fragmentShaderFilename );
+
55
+
62 [[maybe_unused]]
+
63 ShaderProgram( const char *vertexShaderFilename,
+
64 const char *fragmentShaderFilename,
+
65 bool isSeparable );
+
66
+
74 [[maybe_unused]]
+
75 ShaderProgram( const char *vertexShaderFilename,
+
76 const char *tessellationControlShaderFilename,
+
77 const char *tessellationEvaluationShaderFilename,
+
78 const char *geometryShaderFilename,
+
79 const char *fragmentShaderFilename );
+
80
+
90 [[maybe_unused]]
+
91 ShaderProgram( const char *vertexShaderFilename,
+
92 const char *tessellationControlShaderFilename,
+
93 const char *tessellationEvaluationShaderFilename,
+
94 const char *geometryShaderFilename,
+
95 const char *fragmentShaderFilename,
+
96 bool isSeparable );
+
97
+
105 [[maybe_unused]]
+
106 ShaderProgram( const char *vertexShaderFilename,
+
107 const char *tessellationControlShaderFilename,
+
108 const char *tessellationEvaluationShaderFilename,
+
109 const char *fragmentShaderFilename );
+
110
+
119 [[maybe_unused]]
+
120 ShaderProgram( const char *vertexShaderFilename,
+
121 const char *tessellationControlShaderFilename,
+
122 const char *tessellationEvaluationShaderFilename,
+
123 const char *fragmentShaderFilename,
+
124 bool isSeparable);
+
125
+
132 ShaderProgram( const char *vertexShaderFilename,
+
133 const char *geometryShaderFilename,
+
134 const char *fragmentShaderFilename );
+
135
+
143 [[maybe_unused]]
+
144 ShaderProgram( const char *vertexShaderFilename,
+
145 const char *geometryShaderFilename,
+
146 const char *fragmentShaderFilename,
+
147 bool isSeparable );
+
148
+
159 [[maybe_unused]]
+
160 ShaderProgram( const char **shaderFilenames,
+
161 bool vertexPresent, bool tessellationPresent, bool geometryPresent, bool fragmentPresent,
+
162 bool isSeparable );
+
163
+
167 virtual ~ShaderProgram();
+
168
+
172 ShaderProgram(const ShaderProgram&) = delete;
+ +
177
+
183 virtual bool writeShaderProgramBinaryToFile(const char* BINARY_FILE_NAME) const final;
+
184
+
191 static ShaderProgram* loadShaderProgramFromBinaryFile(const char* BINARY_FILE_NAME, GLenum format);
+
192
+
199 virtual GLint getUniformLocation( const char *uniformName ) const final;
+
200
+
207 virtual GLint getUniformBlockIndex( const char *uniformBlockName ) const final;
+
214 virtual GLint getUniformBlockSize( const char *uniformBlockName ) const final;
+
221 [[maybe_unused]] virtual GLubyte* getUniformBlockBuffer( const char *uniformBlockName ) const final;
+
228 [[maybe_unused]] virtual GLint* getUniformBlockOffsets( const char *uniformBlockName ) const final;
+
236 [[maybe_unused]] virtual GLint* getUniformBlockOffsets( const char *uniformBlockName, const char *names[] ) const final;
+
243 [[nodiscard]] virtual GLint* getUniformBlockOffsets(GLint uniformBlockIndex ) const final;
+
251 [[nodiscard]] virtual GLint* getUniformBlockOffsets(GLint uniformBlockIndex, const char *names[] ) const final;
+
258 virtual void setUniformBlockBinding( const char *uniformBlockName, GLuint binding ) const final;
+
259
+
266 [[maybe_unused]] virtual GLint getAttributeLocation( const char *attributeName ) const final;
+
267
+
276 [[maybe_unused]] virtual GLuint getSubroutineIndex( GLenum shaderStage, const char *subroutineName ) const final;
+
277
+
284 [[maybe_unused]] virtual GLint getImageBinding(const char* imageName) const final;
+
285
+
292 [[maybe_unused]] virtual GLint getShaderStorageBlockBinding(const char* ssboName) const final;
+
293
+
300 [[maybe_unused]] virtual GLint getAtomicCounterBufferBinding(const char* atomicName) const final;
+
307 [[maybe_unused]] virtual GLint getAtomicCounterBufferOffset(const char* atomicName) const final;
+
314 [[maybe_unused]] virtual GLint getAtomicCounterBufferSize(const char* atomicName) const final;
+
315
+
320 [[maybe_unused]] [[nodiscard]] virtual GLuint getNumUniforms() const final;
+
325 [[maybe_unused]] [[nodiscard]] virtual GLuint getNumUniformBlocks() const final;
+
330 [[maybe_unused]] [[nodiscard]] virtual GLuint getNumAttributes() const final;
+
331
+
336 [[nodiscard]] virtual GLuint getShaderProgramHandle() const final;
+
337
+
341 [[maybe_unused]] virtual void useProgram() const final;
+
342
+
348 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLfloat v0) const final;
+
354 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLint v0) const final;
+
360 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLuint v0) const final;
+
366 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::mat2 mtx) const final;
+
372 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::mat3 mtx) const final;
+
378 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::mat4 mtx) const final;
+
384 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::mat2x3 mtx) const final;
+
390 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::mat3x2 mtx) const final;
+
396 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::mat2x4 mtx) const final;
+
402 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::mat4x2 mtx) const final;
+
408 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::mat3x4 mtx) const final;
+
414 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::mat4x3 mtx) const final;
+
415
+
422 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLfloat v0, GLfloat v1) const final;
+
429 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLint v0, GLint v1) const final;
+
436 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLuint v0, GLuint v1) const final;
+
437
+
445 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLfloat v0, GLfloat v1, GLfloat v2) const final;
+
453 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLint v0, GLint v1, GLint v2) const final;
+
461 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLuint v0, GLuint v1, GLuint v2) const final;
+
462
+
471 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) const final;
+
480 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLint v0, GLint v1, GLint v2, GLint v3) const final;
+
489 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLuint v0, GLuint v1, GLuint v2, GLuint v3) const final;
+
490
+
496 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::vec2 value) const final;
+
502 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::ivec2 value) const final;
+
508 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::uvec2 value) const final;
+
509
+
515 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::vec3 value) const final;
+
521 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::ivec3 value) const final;
+
527 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::uvec3 value) const final;
+
528
+
534 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::vec4 value) const final;
+
540 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::ivec4 value) const final;
+
546 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, glm::uvec4 value) const final;
+
547
+
555 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLuint dim, GLsizei count, const GLfloat *value) const final;
+
563 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLuint dim, GLsizei count, const GLint *value) const final;
+
571 [[maybe_unused]] virtual void setProgramUniform(const char* uniformName, GLuint dim, GLsizei count, const GLuint *value) const final;
+
572
+
578 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, GLfloat v0) const final;
+
584 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, GLint v0) const final;
+
590 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, GLuint v0) const final;
+
596 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::mat2 mtx) const final;
+
602 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::mat3 mtx) const final;
+
608 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::mat4 mtx) const final;
+
614 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::mat2x3 mtx) const final;
+
620 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::mat3x2 mtx) const final;
+
626 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::mat2x4 mtx) const final;
+
632 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::mat4x2 mtx) const final;
+
638 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::mat3x4 mtx) const final;
+
644 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::mat4x3 mtx) const final;
+
645
+
652 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, GLfloat v0, GLfloat v1) const final;
+
659 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, GLint v0, GLint v1) const final;
+
666 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, GLuint v0, GLuint v1) const final;
+
667
+
675 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, GLfloat v0, GLfloat v1, GLfloat v2) const final;
+
683 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, GLint v0, GLint v1, GLint v2) const final;
+
691 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, GLuint v0, GLuint v1, GLuint v2) const final;
+
692
+
701 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) const final;
+
710 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, GLint v0, GLint v1, GLint v2, GLint v3) const final;
+
719 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, GLuint v0, GLuint v1, GLuint v2, GLuint v3) const final;
+
720
+
726 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::vec2 value) const final;
+
732 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::ivec2 value) const final;
+
738 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::uvec2 value) const final;
+
739
+
745 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::vec3 value) const final;
+
751 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::ivec3 value) const final;
+
757 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::uvec3 value) const final;
+
758
+
764 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::vec4 value) const final;
+
770 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::ivec4 value) const final;
+
776 [[maybe_unused]] virtual void setProgramUniform(GLint uniformLocation, glm::uvec4 value) const final;
+
777
+
785 virtual void setProgramUniform(GLint uniformLocation, GLuint dim, GLsizei count, const GLfloat *value) const final;
+
793 virtual void setProgramUniform(GLint uniformLocation, GLuint dim, GLsizei count, const GLint *value) const final;
+
801 virtual void setProgramUniform(GLint uniformLocation, GLuint dim, GLsizei count, const GLuint *value) const final;
+
802
+
807 [[maybe_unused]] [[nodiscard]] virtual GLbitfield getProgramStages() const final;
+
808
+
809 protected:
+ +
814
+
819 static bool sDEBUG;
+
820
+ + + + + +
841
+ +
846
+
850 std::map<std::string, GLint> *mpUniformLocationsMap;
+
854 std::map<std::string, GLint> *mpAttributeLocationsMap;
+
855
+
866 virtual bool mRegisterShaderProgram(const char *vertexShaderFilename,
+
867 const char *tessellationControlShaderFilename,
+
868 const char *tessellationEvaluationShaderFilename,
+
869 const char *geometryShaderFilename,
+
870 const char *fragmentShaderFilename,
+
871 bool isSeparable ) final;
+
872
+
873 private:
+
874 void _initialize();
+
875 };
+
876
+
877}
+
878
+
880
+
881inline bool CSCI441::ShaderProgram::sDEBUG = true;
+
882
+
883[[maybe_unused]]
+ +
885 sDEBUG = true;
+
886}
+
887
+
888[[maybe_unused]]
+ +
890 sDEBUG = false;
+
891}
+
892
+
893inline CSCI441::ShaderProgram::ShaderProgram( const char *vertexShaderFilename, const char *fragmentShaderFilename ) {
+
894 _initialize();
+
895 mRegisterShaderProgram(vertexShaderFilename, "", "", "", fragmentShaderFilename, false);
+
896}
+
897
+
898[[maybe_unused]]
+
899inline CSCI441::ShaderProgram::ShaderProgram( const char *vertexShaderFilename, const char *fragmentShaderFilename, const bool isSeparable ) {
+
900 _initialize();
+
901 mRegisterShaderProgram(vertexShaderFilename, "", "", "", fragmentShaderFilename, isSeparable);
+
902}
+
903
+
904[[maybe_unused]]
+
905inline CSCI441::ShaderProgram::ShaderProgram(const char *vertexShaderFilename, const char *tessellationControlShaderFilename, const char *tessellationEvaluationShaderFilename, const char *geometryShaderFilename, const char *fragmentShaderFilename ) {
+
906 _initialize();
+
907 mRegisterShaderProgram(vertexShaderFilename, tessellationControlShaderFilename, tessellationEvaluationShaderFilename,
+
908 geometryShaderFilename, fragmentShaderFilename, false);
+
909}
+
910
+
911[[maybe_unused]]
+
912inline CSCI441::ShaderProgram::ShaderProgram(const char *vertexShaderFilename, const char *tessellationControlShaderFilename, const char *tessellationEvaluationShaderFilename, const char *geometryShaderFilename, const char *fragmentShaderFilename, bool isSeparable ) {
+
913 _initialize();
+
914 mRegisterShaderProgram(vertexShaderFilename, tessellationControlShaderFilename, tessellationEvaluationShaderFilename,
+
915 geometryShaderFilename, fragmentShaderFilename, isSeparable);
+
916}
+
917
+
918[[maybe_unused]]
+
919inline CSCI441::ShaderProgram::ShaderProgram(const char *vertexShaderFilename, const char *tessellationControlShaderFilename, const char *tessellationEvaluationShaderFilename, const char *fragmentShaderFilename ) {
+
920 _initialize();
+
921 mRegisterShaderProgram(vertexShaderFilename, tessellationControlShaderFilename, tessellationEvaluationShaderFilename,
+
922 "", fragmentShaderFilename, false);
+
923}
+
924
+
925[[maybe_unused]]
+
926inline CSCI441::ShaderProgram::ShaderProgram(const char *vertexShaderFilename, const char *tessellationControlShaderFilename, const char *tessellationEvaluationShaderFilename, const char *fragmentShaderFilename, bool isSeparable ) {
+
927 _initialize();
+
928 mRegisterShaderProgram(vertexShaderFilename, tessellationControlShaderFilename, tessellationEvaluationShaderFilename,
+
929 "", fragmentShaderFilename, isSeparable);
+
930}
+
931
+
932inline CSCI441::ShaderProgram::ShaderProgram( const char *vertexShaderFilename, const char *geometryShaderFilename, const char *fragmentShaderFilename ) {
+
933 _initialize();
+
934 mRegisterShaderProgram(vertexShaderFilename, "", "", geometryShaderFilename, fragmentShaderFilename, false);
+
935}
+
936
+
937[[maybe_unused]]
+
938inline CSCI441::ShaderProgram::ShaderProgram( const char *vertexShaderFilename, const char *geometryShaderFilename, const char *fragmentShaderFilename, bool isSeparable ) {
+
939 _initialize();
+
940 mRegisterShaderProgram(vertexShaderFilename, "", "", geometryShaderFilename, fragmentShaderFilename, isSeparable);
+
941}
+
942
+
943[[maybe_unused]]
+
944inline CSCI441::ShaderProgram::ShaderProgram( const char **shaderFilenames,
+
945 const bool vertexPresent, const bool tessellationPresent, const bool geometryPresent, const bool fragmentPresent,
+
946 const bool isSeparable ) {
+
947 _initialize();
+
948 if( vertexPresent && !tessellationPresent && !geometryPresent && !fragmentPresent ) {
+
949 if( !isSeparable ) {
+
950 fprintf(stderr, "[ERROR]: Fragment Shader not present. Program must be separable.\n");
+
951 } else {
+
952 mRegisterShaderProgram(shaderFilenames[0], "", "", "", "", isSeparable);
+
953 }
+
954 } else if( vertexPresent && tessellationPresent && !geometryPresent && !fragmentPresent ) {
+
955 if( !isSeparable ) {
+
956 fprintf(stderr, "[ERROR]: Fragment Shader not present. Program must be separable.\n");
+
957 } else {
+
958 mRegisterShaderProgram(shaderFilenames[0], shaderFilenames[1], shaderFilenames[2], "", "", isSeparable);
+
959 }
+
960 } else if( vertexPresent && tessellationPresent && geometryPresent && !fragmentPresent ) {
+
961 if( !isSeparable ) {
+
962 fprintf(stderr, "[ERROR]: Fragment Shader not present. Program must be separable.\n");
+
963 } else {
+
964 mRegisterShaderProgram(shaderFilenames[0], shaderFilenames[1], shaderFilenames[2], shaderFilenames[3], "",
+
965 isSeparable);
+
966 }
+
967 } else if( vertexPresent && tessellationPresent && geometryPresent && fragmentPresent ) {
+
968 mRegisterShaderProgram(shaderFilenames[0], shaderFilenames[1], shaderFilenames[2], shaderFilenames[3],
+
969 shaderFilenames[4], isSeparable);
+
970 } else if( vertexPresent && tessellationPresent && !geometryPresent && fragmentPresent ) {
+
971 mRegisterShaderProgram(shaderFilenames[0], shaderFilenames[1], shaderFilenames[2], "", shaderFilenames[3],
+
972 isSeparable);
+
973 } else if( vertexPresent && !tessellationPresent && geometryPresent && !fragmentPresent ) {
+
974 if( !isSeparable ) {
+
975 fprintf(stderr, "[ERROR]: Fragment Shader not present. Program must be separable.\n");
+
976 } else {
+
977 mRegisterShaderProgram(shaderFilenames[0], "", "", shaderFilenames[1], "", isSeparable);
+
978 }
+
979 } else if( vertexPresent && !tessellationPresent && geometryPresent && fragmentPresent ) {
+
980 mRegisterShaderProgram(shaderFilenames[0], "", "", shaderFilenames[1], shaderFilenames[2], isSeparable);
+
981 } else if( vertexPresent && !tessellationPresent && !geometryPresent && fragmentPresent ) {
+
982 mRegisterShaderProgram(shaderFilenames[0], "", "", "", shaderFilenames[1], isSeparable);
+
983 } else if( !vertexPresent && tessellationPresent && !geometryPresent && !fragmentPresent ) {
+
984 if( !isSeparable ) {
+
985 fprintf(stderr, "[ERROR]: Vertex & Fragment Shaders not present. Program must be separable.\n");
+
986 } else {
+
987 mRegisterShaderProgram("", shaderFilenames[0], shaderFilenames[1], "", "", isSeparable);
+
988 }
+
989 } else if( !vertexPresent && tessellationPresent && geometryPresent && !fragmentPresent ) {
+
990 if( !isSeparable ) {
+
991 fprintf(stderr, "[ERROR]: Vertex & Fragment Shaders not present. Program must be separable.\n");
+
992 } else {
+
993 mRegisterShaderProgram("", shaderFilenames[0], shaderFilenames[1], shaderFilenames[2], "", isSeparable);
+
994 }
+
995 } else if( !vertexPresent && tessellationPresent && geometryPresent && fragmentPresent ) {
+
996 if( !isSeparable ) {
+
997 fprintf(stderr, "[ERROR]: Vertex Shader not present. Program must be separable.\n");
+
998 } else {
+
999 mRegisterShaderProgram("", shaderFilenames[0], shaderFilenames[1], shaderFilenames[2], shaderFilenames[3],
+
1000 isSeparable);
+
1001 }
+
1002 } else if( !vertexPresent && tessellationPresent && !geometryPresent && fragmentPresent ) {
+
1003 if( !isSeparable ) {
+
1004 fprintf(stderr, "[ERROR]: Vertex Shader not present. Program must be separable.\n");
+
1005 } else {
+
1006 mRegisterShaderProgram("", shaderFilenames[0], shaderFilenames[1], "", shaderFilenames[2], isSeparable);
+
1007 }
+
1008 } else if( !vertexPresent && !tessellationPresent && geometryPresent && !fragmentPresent ) {
+
1009 if( !isSeparable ) {
+
1010 fprintf(stderr, "[ERROR]: Vertex & Fragment Shaders not present. Program must be separable.\n");
+
1011 } else {
+
1012 mRegisterShaderProgram("", "", "", shaderFilenames[0], "", isSeparable);
+
1013 }
+
1014 } else if( !vertexPresent && !tessellationPresent && geometryPresent && fragmentPresent ) {
+
1015 if( !isSeparable ) {
+
1016 fprintf(stderr, "[ERROR]: Vertex Shader not present. Program must be separable.\n");
+
1017 } else {
+
1018 mRegisterShaderProgram("", "", "", shaderFilenames[0], shaderFilenames[1], isSeparable);
+
1019 }
+
1020 } else if( !vertexPresent && !tessellationPresent && !geometryPresent && fragmentPresent ) {
+
1021 if( !isSeparable ) {
+
1022 fprintf(stderr, "[ERROR]: Vertex Shader not present. Program must be separable.\n");
+
1023 } else {
+
1024 mRegisterShaderProgram("", "", "", "", shaderFilenames[0], isSeparable);
+
1025 }
+
1026 } else if( !vertexPresent && !tessellationPresent && !geometryPresent && !fragmentPresent ) {
+
1027 fprintf(stderr, "[ERROR]: At least one shader must be present.\n");
+
1028 } else {
+
1029 fprintf(stderr, "[ERROR]: Unknown state.\n");
+
1030 }
+
1031}
+
1032
+
1033inline bool CSCI441::ShaderProgram::mRegisterShaderProgram(const char *vertexShaderFilename, const char *tessellationControlShaderFilename, const char *tessellationEvaluationShaderFilename, const char *geometryShaderFilename, const char *fragmentShaderFilename, const bool isSeparable ) {
+
1034 GLint major, minor;
+
1035 glGetIntegerv(GL_MAJOR_VERSION, &major);
+
1036 glGetIntegerv(GL_MINOR_VERSION, &minor);
+
1037
+
1038 if( sDEBUG ) printf( "\n[INFO]: /--------------------------------------------------------\\\n");
+
1039
+
1040 /* compile each one of our shaders */
+
1041 if( strcmp( vertexShaderFilename, "" ) != 0 ) {
+
1042 if( sDEBUG ) printf( "[INFO]: | Vertex Shader: %39s |\n", vertexShaderFilename );
+
1043 mVertexShaderHandle = CSCI441_INTERNAL::ShaderUtils::compileShader(vertexShaderFilename, GL_VERTEX_SHADER );
+
1044 } else {
+ +
1046 }
+
1047
+
1048 if(strcmp(tessellationControlShaderFilename, "" ) != 0 ) {
+
1049 if( sDEBUG ) printf("[INFO]: | Tess Control Shader: %33s |\n", tessellationControlShaderFilename );
+
1050 if( major < 4 ) {
+
1051 printf( "[ERROR]:| TESSELLATION SHADER NOT SUPPORTED!! UPGRADE TO v4.0+ |\n" );
+ +
1053 } else {
+
1054 mTessellationControlShaderHandle = CSCI441_INTERNAL::ShaderUtils::compileShader(tessellationControlShaderFilename, GL_TESS_CONTROL_SHADER );
+
1055 }
+
1056 } else {
+ +
1058 }
+
1059
+
1060 if(strcmp(tessellationEvaluationShaderFilename, "" ) != 0 ) {
+
1061 if( sDEBUG ) printf("[INFO]: | Tess Evaluation Shader: %30s |\n", tessellationEvaluationShaderFilename );
+
1062 if( major < 4 ) {
+
1063 printf( "[ERROR]:| TESSELLATION SHADER NOT SUPPORTED!! UPGRADE TO v4.0+ |\n" );
+ +
1065 } else {
+
1066 mTessellationEvaluationShaderHandle = CSCI441_INTERNAL::ShaderUtils::compileShader(tessellationEvaluationShaderFilename, GL_TESS_EVALUATION_SHADER );
+
1067 }
+
1068 } else {
+ +
1070 }
+
1071
+
1072 if( strcmp( geometryShaderFilename, "" ) != 0 ) {
+
1073 if( sDEBUG ) printf( "[INFO]: | Geometry Shader: %37s |\n", geometryShaderFilename );
+
1074 if( major < 3 || (major == 3 && minor < 2) ) {
+
1075 printf( "[ERROR]:| GEOMETRY SHADER NOT SUPPORTED!!! UPGRADE TO v3.2+ |\n" );
+ +
1077 } else {
+
1078 mGeometryShaderHandle = CSCI441_INTERNAL::ShaderUtils::compileShader(geometryShaderFilename, GL_GEOMETRY_SHADER );
+
1079 }
+
1080 } else {
+ +
1082 }
+
1083
+
1084 if( strcmp( fragmentShaderFilename, "" ) != 0 ) {
+
1085 if( sDEBUG ) printf( "[INFO]: | Fragment Shader: %37s |\n", fragmentShaderFilename );
+
1086 mFragmentShaderHandle = CSCI441_INTERNAL::ShaderUtils::compileShader(fragmentShaderFilename, GL_FRAGMENT_SHADER );
+
1087 } else {
+ +
1089 }
+
1090 /* get a handle to a shader program */
+
1091 mShaderProgramHandle = glCreateProgram();
+
1092
+
1093 /* if program is separable, make it so */
+
1094 if( isSeparable ) {
+
1095 glProgramParameteri(mShaderProgramHandle, GL_PROGRAM_SEPARABLE, GL_TRUE );
+
1096 }
+
1097
+
1098 /* attach the vertex and fragment shaders to the shader program */
+
1099 if(mVertexShaderHandle != 0 ) {
+
1100 glAttachShader(mShaderProgramHandle, mVertexShaderHandle );
+
1101 }
+ + +
1104 }
+ + +
1107 }
+
1108 if(mGeometryShaderHandle != 0 ) {
+ +
1110 }
+
1111 if(mFragmentShaderHandle != 0 ) {
+ +
1113 }
+
1114
+
1115 /* link all the programs together on the GPU */
+
1116 glLinkProgram(mShaderProgramHandle );
+
1117
+
1118 if( sDEBUG ) printf( "[INFO]: | Shader Program: %41s", "|\n" );
+
1119
+
1120 /* check the program log */
+
1121 CSCI441_INTERNAL::ShaderUtils::printProgramLog(mShaderProgramHandle );
+
1122
+
1123 /* detach & delete the vertex and fragment shaders to the shader program */
+
1124 if(mVertexShaderHandle != 0 ) {
+
1125 glDetachShader(mShaderProgramHandle, mVertexShaderHandle );
+
1126 glDeleteShader(mVertexShaderHandle );
+
1127 }
+ + +
1130 glDeleteShader(mTessellationControlShaderHandle );
+
1131 }
+ + +
1134 glDeleteShader(mTessellationEvaluationShaderHandle );
+
1135 }
+
1136 if(mGeometryShaderHandle != 0 ) {
+ +
1138 glDeleteShader(mGeometryShaderHandle );
+
1139 }
+
1140 if(mFragmentShaderHandle != 0 ) {
+ +
1142 glDeleteShader(mFragmentShaderHandle );
+
1143 }
+
1144
+
1145 // map uniforms
+
1146 mpUniformLocationsMap = new std::map<std::string, GLint>();
+
1147 GLint numUniforms;
+
1148 glGetProgramiv(mShaderProgramHandle, GL_ACTIVE_UNIFORMS, &numUniforms);
+
1149 if( numUniforms > 0 ) {
+
1150 for(GLint i = 0; i < numUniforms; i++) {
+
1151 char name[64];
+
1152 int max_length = 64;
+
1153 int actual_length = 0;
+
1154 int size = 0;
+
1155 GLenum type;
+
1156 glGetActiveUniform(mShaderProgramHandle, i, max_length, &actual_length, &size, &type, name );
+
1157 GLint location = -1;
+
1158 if(size > 1) {
+
1159 for(int j = 0; j < size; j++) {
+
1160 char long_name[64];
+
1161 sprintf(long_name, "%s[%i]", name, j);
+
1162 location = glGetUniformLocation(mShaderProgramHandle, long_name);
+
1163 }
+
1164 } else {
+
1165 location = glGetUniformLocation(mShaderProgramHandle, name);
+
1166 }
+
1167 mpUniformLocationsMap->emplace(name, location );
+
1168 }
+
1169 }
+
1170
+
1171 // map attributes
+
1172 mpAttributeLocationsMap = new std::map<std::string, GLint>();
+
1173 GLint numAttributes;
+
1174 glGetProgramiv(mShaderProgramHandle, GL_ACTIVE_ATTRIBUTES, &numAttributes );
+
1175 if( numAttributes > 0 ) {
+
1176 for(GLint i = 0; i < numAttributes; i++) {
+
1177 char name[64];
+
1178 int max_length = 64;
+
1179 int actual_length = 0;
+
1180 int size = 0;
+
1181 GLenum type;
+
1182 glGetActiveAttrib(mShaderProgramHandle, i, max_length, &actual_length, &size, &type, name );
+
1183 GLint location = -1;
+
1184 if( size > 1 ) {
+
1185 for( int j = 0; j < size; j++ ) {
+
1186 char long_name[64];
+
1187 sprintf( long_name, "%s[%i]", name, j );
+
1188 location = glGetAttribLocation(mShaderProgramHandle, long_name );
+
1189 }
+
1190 } else {
+
1191 location = glGetAttribLocation(mShaderProgramHandle, name );
+
1192 }
+
1193 mpAttributeLocationsMap->emplace(name, location );
+
1194 }
+
1195 }
+
1196
+
1197 GLint separable = GL_FALSE;
+
1198 glGetProgramiv(mShaderProgramHandle, GL_PROGRAM_SEPARABLE, &separable );
+
1199
+
1200 if( sDEBUG ) printf( "[INFO]: | Program Separable: %35s |\n", (separable ? "Yes" : "No"));
+
1201
+
1202 GLint linkStatus;
+
1203 glGetProgramiv(mShaderProgramHandle, GL_LINK_STATUS, &linkStatus );
+
1204
+
1205 /* print shader info for uniforms & attributes */
+
1206 if(linkStatus == 1) {
+
1207 CSCI441_INTERNAL::ShaderUtils::printShaderProgramInfo(mShaderProgramHandle, mVertexShaderHandle != 0,
+ + + +
1211 false, true);
+
1212 }
+
1213 /* return handle */
+
1214 return mShaderProgramHandle != 0;
+
1215}
+
1216
+
1217inline GLint CSCI441::ShaderProgram::getUniformLocation( const char *uniformName ) const {
+
1218 GLint uniformLoc = glGetUniformLocation(mShaderProgramHandle, uniformName );
+
1219 if( uniformLoc == -1 )
+
1220 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle );
+
1221 return uniformLoc;
+
1222}
+
1223
+
1224inline GLint CSCI441::ShaderProgram::getUniformBlockIndex( const char *uniformBlockName ) const {
+
1225 GLint uniformBlockLoc = glGetUniformBlockIndex(mShaderProgramHandle, uniformBlockName );
+
1226 if( uniformBlockLoc == -1 )
+
1227 fprintf(stderr, "[ERROR]: Could not find uniform block \"%s\" for Shader Program %u\n", uniformBlockName, mShaderProgramHandle );
+
1228 return uniformBlockLoc;
+
1229}
+
1230
+
1231inline GLint CSCI441::ShaderProgram::getUniformBlockSize( const char *uniformBlockName ) const {
+
1232 GLint blockSize;
+
1233 glGetActiveUniformBlockiv(mShaderProgramHandle, getUniformBlockIndex(uniformBlockName), GL_UNIFORM_BLOCK_DATA_SIZE, &blockSize );
+
1234 return blockSize;
+
1235}
+
1236
+
1237[[maybe_unused]]
+
1238inline GLubyte* CSCI441::ShaderProgram::getUniformBlockBuffer( const char *uniformBlockName ) const {
+
1239 GLubyte *blockBuffer;
+
1240
+
1241 GLint blockSize = getUniformBlockSize( uniformBlockName );
+
1242
+
1243 blockBuffer = (GLubyte*)malloc(blockSize);
+
1244
+
1245 return blockBuffer;
+
1246}
+
1247
+
1248[[maybe_unused]]
+
1249inline GLint* CSCI441::ShaderProgram::getUniformBlockOffsets( const char *uniformBlockName ) const {
+
1250 return getUniformBlockOffsets(getUniformBlockIndex(uniformBlockName));
+
1251}
+
1252
+
1253[[maybe_unused]]
+
1254inline GLint* CSCI441::ShaderProgram::getUniformBlockOffsets( const char *uniformBlockName, const char *names[] ) const {
+
1255 return getUniformBlockOffsets(getUniformBlockIndex(uniformBlockName), names);
+
1256}
+
1257
+
1258inline GLint* CSCI441::ShaderProgram::getUniformBlockOffsets(GLint uniformBlockIndex ) const {
+
1259 GLint numUniforms;
+
1260 glGetActiveUniformBlockiv(mShaderProgramHandle, uniformBlockIndex, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &numUniforms );
+
1261
+
1262 auto indices = (GLuint*)malloc(numUniforms*sizeof(GLuint));
+
1263 glGetActiveUniformBlockiv(mShaderProgramHandle, uniformBlockIndex, GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, (GLint*)indices);
+
1264
+
1265 auto offsets = (GLint*)malloc(numUniforms*sizeof(GLint));
+
1266 glGetActiveUniformsiv(mShaderProgramHandle, numUniforms, indices, GL_UNIFORM_OFFSET, offsets );
+
1267 return offsets;
+
1268}
+
1269
+
1270inline GLint* CSCI441::ShaderProgram::getUniformBlockOffsets(GLint uniformBlockIndex, const char *names[] ) const {
+
1271 GLint numUniforms;
+
1272 glGetActiveUniformBlockiv(mShaderProgramHandle, uniformBlockIndex, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &numUniforms );
+
1273
+
1274 auto indices = (GLuint*)malloc(numUniforms*sizeof(GLuint));
+
1275 glGetUniformIndices(mShaderProgramHandle, numUniforms, names, indices );
+
1276
+
1277 auto offsets = (GLint*)malloc(numUniforms*sizeof(GLint));
+
1278 glGetActiveUniformsiv(mShaderProgramHandle, numUniforms, indices, GL_UNIFORM_OFFSET, offsets );
+
1279 return offsets;
+
1280}
+
1281
+
1282inline void CSCI441::ShaderProgram::setUniformBlockBinding( const char *uniformBlockName, GLuint binding ) const {
+
1283 glUniformBlockBinding(mShaderProgramHandle, getUniformBlockIndex(uniformBlockName), binding );
+
1284}
+
1285
+
1286[[maybe_unused]]
+
1287inline GLint CSCI441::ShaderProgram::getAttributeLocation( const char *attributeName ) const {
+
1288 auto attribIter = mpAttributeLocationsMap->find(attributeName);
+
1289 if(attribIter == mpAttributeLocationsMap->end() ) {
+
1290 fprintf(stderr, "[ERROR]: Could not find attribute \"%s\" for Shader Program %u\n", attributeName, mShaderProgramHandle );
+
1291 return -1;
+
1292 }
+
1293 return attribIter->second;
+
1294}
+
1295
+
1296[[maybe_unused]]
+
1297inline GLuint CSCI441::ShaderProgram::getSubroutineIndex( GLenum shaderStage, const char *subroutineName ) const {
+
1298 GLuint subroutineIndex = glGetSubroutineIndex(mShaderProgramHandle, shaderStage, subroutineName );
+
1299 if( subroutineIndex == GL_INVALID_INDEX )
+
1300 fprintf(stderr, "[ERROR]: Could not find subroutine \"%s\" in %s for Shader Program %u\n", subroutineName, CSCI441_INTERNAL::ShaderUtils::GL_shader_type_to_string(shaderStage), mShaderProgramHandle );
+
1301 return subroutineIndex;
+
1302}
+
1303
+
1304// images are opaque types that are not considered program resources
+
1305[[maybe_unused]]
+
1306inline GLint CSCI441::ShaderProgram::getImageBinding(const char* imageName) const {
+
1307 GLint imageLoc = getUniformLocation(imageName);
+
1308
+
1309 if(imageLoc == -1) {
+
1310 fprintf(stderr, "[ERROR]: Could not find image \"%s\" for Shader Program %u\n", imageName, mShaderProgramHandle);
+
1311 return -1;
+
1312 }
+
1313
+
1314 GLint bindingPoint;
+
1315 glGetUniformiv(mShaderProgramHandle, imageLoc, &bindingPoint);
+
1316
+
1317 return bindingPoint;
+
1318}
+
1319
+
1320[[maybe_unused]]
+
1321inline GLint CSCI441::ShaderProgram::getShaderStorageBlockBinding(const char* ssboName) const {
+
1322 GLuint ssboIndex = glGetProgramResourceIndex(mShaderProgramHandle, GL_SHADER_STORAGE_BLOCK, ssboName);
+
1323
+
1324 if(ssboIndex == GL_INVALID_INDEX) {
+
1325 fprintf(stderr, "[ERROR]: Could not find shader storage block \"%s\" for Shader Program %u\n", ssboName, mShaderProgramHandle);
+
1326 return -1;
+
1327 }
+
1328
+
1329 const int NUM_PROPS = 1;
+
1330 GLenum props[NUM_PROPS] = {GL_BUFFER_BINDING};
+
1331 GLint results[NUM_PROPS];
+
1332 glGetProgramResourceiv(mShaderProgramHandle, GL_SHADER_STORAGE_BLOCK, ssboIndex, NUM_PROPS, props, NUM_PROPS, nullptr, results);
+
1333
+
1334 return results[0];
+
1335}
+
1336
+
1337[[maybe_unused]]
+
1338inline GLint CSCI441::ShaderProgram::getAtomicCounterBufferBinding(const char* atomicName) const {
+
1339 GLuint uniformIndex = glGetProgramResourceIndex(mShaderProgramHandle, GL_UNIFORM, atomicName);
+
1340
+
1341 if(uniformIndex == GL_INVALID_INDEX) {
+
1342 fprintf(stderr, "[ERROR]: Could not find atomic counter \"%s\" for Shader Program %u\n", atomicName, mShaderProgramHandle);
+
1343 return -1;
+
1344 }
+
1345
+
1346 GLenum props = GL_ATOMIC_COUNTER_BUFFER_INDEX;
+
1347 GLint atomicIndex, binding;
+
1348 glGetProgramResourceiv(mShaderProgramHandle, GL_UNIFORM, uniformIndex, 1, &props, 1, nullptr, &atomicIndex);
+
1349 glGetActiveAtomicCounterBufferiv(mShaderProgramHandle, atomicIndex, GL_ATOMIC_COUNTER_BUFFER_BINDING, &binding);
+
1350
+
1351 return binding;
+
1352}
+
1353
+
1354[[maybe_unused]]
+
1355inline GLint CSCI441::ShaderProgram::getAtomicCounterBufferOffset(const char* atomicName) const {
+
1356 GLuint uniformIndex = glGetProgramResourceIndex(mShaderProgramHandle, GL_UNIFORM, atomicName);
+
1357
+
1358 if(uniformIndex == GL_INVALID_INDEX) {
+
1359 fprintf(stderr, "[ERROR]: Could not find atomic counter \"%s\" for Shader Program %u\n", atomicName, mShaderProgramHandle);
+
1360 return -1;
+
1361 }
+
1362
+
1363 GLint offset;
+
1364 glGetActiveUniformsiv(mShaderProgramHandle, 1, &uniformIndex, GL_UNIFORM_OFFSET, &offset);
+
1365 return offset;
+
1366}
+
1367
+
1368[[maybe_unused]]
+
1369inline GLint CSCI441::ShaderProgram::getAtomicCounterBufferSize(const char* atomicName) const {
+
1370 GLuint uniformIndex = glGetProgramResourceIndex(mShaderProgramHandle, GL_UNIFORM, atomicName);
+
1371
+
1372 if(uniformIndex == GL_INVALID_INDEX) {
+
1373 fprintf(stderr, "[ERROR]: Could not find atomic counter \"%s\" for Shader Program %u\n", atomicName, mShaderProgramHandle);
+
1374 return -1;
+
1375 }
+
1376
+
1377 GLenum props = GL_ATOMIC_COUNTER_BUFFER_INDEX;
+
1378 GLint atomicIndex, bufferSize;
+
1379 glGetProgramResourceiv(mShaderProgramHandle, GL_UNIFORM, uniformIndex, 1, &props, 1, nullptr, &atomicIndex);
+
1380 glGetActiveAtomicCounterBufferiv(mShaderProgramHandle, atomicIndex, GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE, &bufferSize);
+
1381
+
1382 return bufferSize;
+
1383}
+
1384
+
1385[[maybe_unused]]
+ +
1387 int numUniform = 0;
+
1388 glGetProgramiv(mShaderProgramHandle, GL_ACTIVE_UNIFORMS, &numUniform );
+
1389 return numUniform;
+
1390}
+
1391
+
1392[[maybe_unused]]
+ +
1394 int numUniformBlocks = 0;
+
1395 glGetProgramiv(mShaderProgramHandle, GL_ACTIVE_UNIFORM_BLOCKS, &numUniformBlocks );
+
1396 return numUniformBlocks;
+
1397}
+
1398
+
1399[[maybe_unused]]
+ +
1401 int numAttr = 0;
+
1402 glGetProgramiv(mShaderProgramHandle, GL_ACTIVE_ATTRIBUTES, &numAttr );
+
1403 return numAttr;
+
1404}
+
1405
+ +
1407 return mShaderProgramHandle;
+
1408}
+
1409
+
1410[[maybe_unused]]
+ +
1412 glUseProgram(mShaderProgramHandle );
+
1413}
+
1414
+
1415[[maybe_unused]]
+
1416inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, GLfloat v0 ) const {
+
1417 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1418 if(uniformIter != mpUniformLocationsMap->end()) {
+
1419 glProgramUniform1f(mShaderProgramHandle, uniformIter->second, v0 );
+
1420 } else {
+
1421 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1422 }
+
1423}
+
1424
+
1425[[maybe_unused]]
+
1426inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, GLfloat v0, GLfloat v1 ) const {
+
1427 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1428 if(uniformIter != mpUniformLocationsMap->end()) {
+
1429 glProgramUniform2f(mShaderProgramHandle, uniformIter->second, v0, v1 );
+
1430 } else {
+
1431 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1432 }
+
1433}
+
1434
+
1435[[maybe_unused]]
+
1436inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, glm::vec2 value ) const {
+
1437 setProgramUniform( uniformName, 2, 1, glm::value_ptr(value) );
+
1438}
+
1439
+
1440[[maybe_unused]]
+
1441inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, GLfloat v0, GLfloat v1, GLfloat v2 ) const {
+
1442 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1443 if(uniformIter != mpUniformLocationsMap->end()) {
+
1444 glProgramUniform3f(mShaderProgramHandle, uniformIter->second, v0, v1, v2 );
+
1445 } else {
+
1446 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1447 }
+
1448}
+
1449
+
1450[[maybe_unused]]
+
1451inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, glm::vec3 value ) const {
+
1452 setProgramUniform( uniformName, 3, 1, glm::value_ptr(value) );
+
1453}
+
1454
+
1455[[maybe_unused]]
+
1456inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3 ) const {
+
1457 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1458 if(uniformIter != mpUniformLocationsMap->end()) {
+
1459 glProgramUniform4f(mShaderProgramHandle, uniformIter->second, v0, v1, v2, v3 );
+
1460 } else {
+
1461 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1462 }
+
1463}
+
1464
+
1465[[maybe_unused]]
+
1466inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, glm::vec4 value ) const {
+
1467 setProgramUniform( uniformName, 4, 1, glm::value_ptr(value) );
+
1468}
+
1469
+
1470inline void CSCI441::ShaderProgram::setProgramUniform(const char* uniformName, GLuint dim, GLsizei count, const GLfloat *value) const {
+
1471 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1472 if(uniformIter != mpUniformLocationsMap->end()) {
+
1473 switch(dim) {
+
1474 case 1:
+
1475 glProgramUniform1fv(mShaderProgramHandle, uniformIter->second, count, value );
+
1476 break;
+
1477 case 2:
+
1478 glProgramUniform2fv(mShaderProgramHandle, uniformIter->second, count, value );
+
1479 break;
+
1480 case 3:
+
1481 glProgramUniform3fv(mShaderProgramHandle, uniformIter->second, count, value );
+
1482 break;
+
1483 case 4:
+
1484 glProgramUniform4fv(mShaderProgramHandle, uniformIter->second, count, value );
+
1485 break;
+
1486 default:
+
1487 fprintf(stderr, "[ERROR]: invalid dimension %u for uniform %s in Shader Program %u. Dimension must be [1,4]\n", dim, uniformName, mShaderProgramHandle);
+
1488 break;
+
1489 }
+
1490 } else {
+
1491 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1492 }
+
1493}
+
1494
+
1495[[maybe_unused]]
+
1496inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, GLint v0 ) const {
+
1497 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1498 if(uniformIter != mpUniformLocationsMap->end()) {
+
1499 glProgramUniform1i(mShaderProgramHandle, uniformIter->second, v0 );
+
1500 } else {
+
1501 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1502 }
+
1503}
+
1504
+
1505[[maybe_unused]]
+
1506inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, GLint v0, GLint v1 ) const {
+
1507 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1508 if(uniformIter != mpUniformLocationsMap->end()) {
+
1509 glProgramUniform2i(mShaderProgramHandle, uniformIter->second, v0, v1 );
+
1510 } else {
+
1511 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1512 }
+
1513}
+
1514
+
1515[[maybe_unused]]
+
1516inline void CSCI441::ShaderProgram::setProgramUniform(const char* uniformName, glm::ivec2 value) const {
+
1517 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1518 if(uniformIter != mpUniformLocationsMap->end()) {
+
1519 glProgramUniform2iv(mShaderProgramHandle, uniformIter->second, 1, glm::value_ptr(value) );
+
1520 } else {
+
1521 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1522 }
+
1523}
+
1524
+
1525[[maybe_unused]]
+
1526inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, GLint v0, GLint v1, GLint v2 ) const {
+
1527 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1528 if(uniformIter != mpUniformLocationsMap->end()) {
+
1529 glProgramUniform3i(mShaderProgramHandle, uniformIter->second, v0, v1, v2 );
+
1530 } else {
+
1531 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1532 }
+
1533}
+
1534
+
1535[[maybe_unused]]
+
1536inline void CSCI441::ShaderProgram::setProgramUniform(const char* uniformName, glm::ivec3 value) const {
+
1537 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1538 if(uniformIter != mpUniformLocationsMap->end()) {
+
1539 glProgramUniform3iv(mShaderProgramHandle, uniformIter->second, 1, glm::value_ptr(value) );
+
1540 } else {
+
1541 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1542 }
+
1543}
+
1544
+
1545[[maybe_unused]]
+
1546inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, GLint v0, GLint v1, GLint v2, GLint v3 ) const {
+
1547 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1548 if(uniformIter != mpUniformLocationsMap->end()) {
+
1549 glProgramUniform4i(mShaderProgramHandle, uniformIter->second, v0, v1, v2, v3 );
+
1550 } else {
+
1551 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1552 }
+
1553}
+
1554
+
1555[[maybe_unused]]
+
1556inline void CSCI441::ShaderProgram::setProgramUniform(const char* uniformName, glm::ivec4 value) const {
+
1557 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1558 if(uniformIter != mpUniformLocationsMap->end()) {
+
1559 glProgramUniform4iv(mShaderProgramHandle, uniformIter->second, 1, glm::value_ptr(value) );
+
1560 } else {
+
1561 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1562 }
+
1563}
+
1564
+
1565[[maybe_unused]]
+
1566inline void CSCI441::ShaderProgram::setProgramUniform(const char* uniformName, GLuint dim, GLsizei count, const GLint *value) const {
+
1567 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1568 if(uniformIter != mpUniformLocationsMap->end()) {
+
1569 switch(dim) {
+
1570 case 1:
+
1571 glProgramUniform1iv(mShaderProgramHandle, uniformIter->second, count, value );
+
1572 break;
+
1573 case 2:
+
1574 glProgramUniform2iv(mShaderProgramHandle, uniformIter->second, count, value );
+
1575 break;
+
1576 case 3:
+
1577 glProgramUniform3iv(mShaderProgramHandle, uniformIter->second, count, value );
+
1578 break;
+
1579 case 4:
+
1580 glProgramUniform4iv(mShaderProgramHandle, uniformIter->second, count, value );
+
1581 break;
+
1582 default:
+
1583 fprintf(stderr, "[ERROR]: invalid dimension %u for uniform %s in Shader Program %u. Dimension must be [1,4]\n", dim, uniformName, mShaderProgramHandle);
+
1584 break;
+
1585 }
+
1586 } else {
+
1587 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1588 }
+
1589}
+
1590
+
1591[[maybe_unused]]
+
1592inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, GLuint v0 ) const {
+
1593 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1594 if(uniformIter != mpUniformLocationsMap->end()) {
+
1595 glProgramUniform1ui(mShaderProgramHandle, uniformIter->second, v0 );
+
1596 } else {
+
1597 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1598 }
+
1599}
+
1600
+
1601[[maybe_unused]]
+
1602inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, GLuint v0, GLuint v1 ) const {
+
1603 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1604 if(uniformIter != mpUniformLocationsMap->end()) {
+
1605 glProgramUniform2ui(mShaderProgramHandle, uniformIter->second, v0, v1 );
+
1606 } else {
+
1607 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1608 }
+
1609}
+
1610
+
1611[[maybe_unused]]
+
1612inline void CSCI441::ShaderProgram::setProgramUniform(const char* uniformName, glm::uvec2 value) const {
+
1613 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1614 if(uniformIter != mpUniformLocationsMap->end()) {
+
1615 glProgramUniform2uiv(mShaderProgramHandle, uniformIter->second, 1, glm::value_ptr(value) );
+
1616 } else {
+
1617 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1618 }
+
1619}
+
1620
+
1621[[maybe_unused]]
+
1622inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, GLuint v0, GLuint v1, GLuint v2 ) const {
+
1623 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1624 if(uniformIter != mpUniformLocationsMap->end()) {
+
1625 glProgramUniform3ui(mShaderProgramHandle, uniformIter->second, v0, v1, v2 );
+
1626 } else {
+
1627 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1628 }
+
1629}
+
1630
+
1631[[maybe_unused]]
+
1632inline void CSCI441::ShaderProgram::setProgramUniform(const char* uniformName, glm::uvec3 value) const {
+
1633 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1634 if(uniformIter != mpUniformLocationsMap->end()) {
+
1635 glProgramUniform3uiv(mShaderProgramHandle, uniformIter->second, 1, glm::value_ptr(value) );
+
1636 } else {
+
1637 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1638 }
+
1639}
+
1640
+
1641[[maybe_unused]]
+
1642inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, GLuint v0, GLuint v1, GLuint v2, GLuint v3 ) const {
+
1643 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1644 if(uniformIter != mpUniformLocationsMap->end()) {
+
1645 glProgramUniform4ui(mShaderProgramHandle, uniformIter->second, v0, v1, v2, v3 );
+
1646 } else {
+
1647 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1648 }
+
1649}
+
1650
+
1651[[maybe_unused]]
+
1652inline void CSCI441::ShaderProgram::setProgramUniform(const char* uniformName, glm::uvec4 value) const {
+
1653 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1654 if(uniformIter != mpUniformLocationsMap->end()) {
+
1655 glProgramUniform4uiv(mShaderProgramHandle, uniformIter->second, 1, glm::value_ptr(value) );
+
1656 } else {
+
1657 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1658 }
+
1659}
+
1660
+
1661[[maybe_unused]]
+
1662inline void CSCI441::ShaderProgram::setProgramUniform(const char* uniformName, GLuint dim, GLsizei count, const GLuint *value) const {
+
1663 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1664 if(uniformIter != mpUniformLocationsMap->end()) {
+
1665 switch(dim) {
+
1666 case 1:
+
1667 glProgramUniform1uiv(mShaderProgramHandle, uniformIter->second, count, value );
+
1668 break;
+
1669 case 2:
+
1670 glProgramUniform2uiv(mShaderProgramHandle, uniformIter->second, count, value );
+
1671 break;
+
1672 case 3:
+
1673 glProgramUniform3uiv(mShaderProgramHandle, uniformIter->second, count, value );
+
1674 break;
+
1675 case 4:
+
1676 glProgramUniform4uiv(mShaderProgramHandle, uniformIter->second, count, value );
+
1677 break;
+
1678 default:
+
1679 fprintf(stderr, "[ERROR]: invalid dimension %u for uniform %s in Shader Program %u. Dimension must be [1,4]\n", dim, uniformName, mShaderProgramHandle);
+
1680 break;
+
1681 }
+
1682 } else {
+
1683 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1684 }
+
1685}
+
1686
+
1687[[maybe_unused]]
+
1688inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, glm::mat2 mtx ) const {
+
1689 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1690 if(uniformIter != mpUniformLocationsMap->end()) {
+
1691 glProgramUniformMatrix2fv(mShaderProgramHandle, uniformIter->second, 1, GL_FALSE, glm::value_ptr(mtx) );
+
1692 } else {
+
1693 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1694 }
+
1695}
+
1696
+
1697[[maybe_unused]]
+
1698inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, glm::mat3 mtx ) const {
+
1699 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1700 if(uniformIter != mpUniformLocationsMap->end()) {
+
1701 glProgramUniformMatrix3fv(mShaderProgramHandle, uniformIter->second, 1, GL_FALSE, glm::value_ptr(mtx) );
+
1702 } else {
+
1703 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1704 }
+
1705}
+
1706
+
1707[[maybe_unused]]
+
1708inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, glm::mat4 mtx ) const {
+
1709 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1710 if(uniformIter != mpUniformLocationsMap->end()) {
+
1711 glProgramUniformMatrix4fv(mShaderProgramHandle, uniformIter->second, 1, GL_FALSE, glm::value_ptr(mtx) );
+
1712 } else {
+
1713 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1714 }
+
1715}
+
1716
+
1717[[maybe_unused]]
+
1718inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, glm::mat2x3 mtx ) const {
+
1719 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1720 if(uniformIter != mpUniformLocationsMap->end()) {
+
1721 glProgramUniformMatrix2x3fv(mShaderProgramHandle, uniformIter->second, 1, GL_FALSE, glm::value_ptr(mtx) );
+
1722 } else {
+
1723 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1724 }
+
1725}
+
1726
+
1727[[maybe_unused]]
+
1728inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, glm::mat3x2 mtx ) const {
+
1729 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1730 if(uniformIter != mpUniformLocationsMap->end()) {
+
1731 glProgramUniformMatrix3x2fv(mShaderProgramHandle, uniformIter->second, 1, GL_FALSE, glm::value_ptr(mtx) );
+
1732 } else {
+
1733 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1734 }
+
1735}
+
1736
+
1737[[maybe_unused]]
+
1738inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, glm::mat2x4 mtx ) const {
+
1739 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1740 if(uniformIter != mpUniformLocationsMap->end()) {
+
1741 glProgramUniformMatrix2x4fv(mShaderProgramHandle, uniformIter->second, 1, GL_FALSE, glm::value_ptr(mtx) );
+
1742 } else {
+
1743 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1744 }
+
1745}
+
1746
+
1747[[maybe_unused]]
+
1748inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, glm::mat4x2 mtx ) const {
+
1749 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1750 if(uniformIter != mpUniformLocationsMap->end()) {
+
1751 glProgramUniformMatrix4x2fv(mShaderProgramHandle, uniformIter->second, 1, GL_FALSE, glm::value_ptr(mtx) );
+
1752 } else {
+
1753 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1754 }
+
1755}
+
1756
+
1757[[maybe_unused]]
+
1758inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, glm::mat3x4 mtx ) const {
+
1759 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1760 if(uniformIter != mpUniformLocationsMap->end()) {
+
1761 glProgramUniformMatrix3x4fv(mShaderProgramHandle, uniformIter->second, 1, GL_FALSE, glm::value_ptr(mtx) );
+
1762 } else {
+
1763 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1764 }
+
1765}
+
1766
+
1767[[maybe_unused]]
+
1768inline void CSCI441::ShaderProgram::setProgramUniform( const char *uniformName, glm::mat4x3 mtx ) const {
+
1769 auto uniformIter = mpUniformLocationsMap->find(uniformName);
+
1770 if(uniformIter != mpUniformLocationsMap->end()) {
+
1771 glProgramUniformMatrix4x3fv(mShaderProgramHandle, uniformIter->second, 1, GL_FALSE, glm::value_ptr(mtx) );
+
1772 } else {
+
1773 fprintf(stderr, "[ERROR]: Could not find uniform \"%s\" for Shader Program %u\n", uniformName, mShaderProgramHandle);
+
1774 }
+
1775}
+
1776
+
1777[[maybe_unused]]
+
1778inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, GLfloat v0 ) const {
+
1779 glProgramUniform1f(mShaderProgramHandle, uniformLocation, v0 );
+
1780}
+
1781
+
1782[[maybe_unused]]
+
1783inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, GLfloat v0, GLfloat v1 ) const {
+
1784 glProgramUniform2f(mShaderProgramHandle, uniformLocation, v0, v1 );
+
1785}
+
1786
+
1787[[maybe_unused]]
+
1788inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, glm::vec2 value ) const {
+
1789 setProgramUniform( uniformLocation, 2, 1, glm::value_ptr(value) );
+
1790}
+
1791
+
1792[[maybe_unused]]
+
1793inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, GLfloat v0, GLfloat v1, GLfloat v2 ) const {
+
1794 glProgramUniform3f(mShaderProgramHandle, uniformLocation, v0, v1, v2 );
+
1795}
+
1796
+
1797[[maybe_unused]]
+
1798inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, glm::vec3 value ) const {
+
1799 setProgramUniform( uniformLocation, 3, 1, glm::value_ptr(value) );
+
1800}
+
1801
+
1802[[maybe_unused]]
+
1803inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3 ) const {
+
1804 glProgramUniform4f(mShaderProgramHandle, uniformLocation, v0, v1, v2, v3 );
+
1805}
+
1806
+
1807[[maybe_unused]]
+
1808inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, glm::vec4 value ) const {
+
1809 setProgramUniform( uniformLocation, 4, 1, glm::value_ptr(value) );
+
1810}
+
1811
+
1812inline void CSCI441::ShaderProgram::setProgramUniform(GLint uniformLocation, GLuint dim, GLsizei count, const GLfloat *value) const {
+
1813 switch(dim) {
+
1814 case 1:
+
1815 glProgramUniform1fv(mShaderProgramHandle, uniformLocation, count, value );
+
1816 break;
+
1817 case 2:
+
1818 glProgramUniform2fv(mShaderProgramHandle, uniformLocation, count, value );
+
1819 break;
+
1820 case 3:
+
1821 glProgramUniform3fv(mShaderProgramHandle, uniformLocation, count, value );
+
1822 break;
+
1823 case 4:
+
1824 glProgramUniform4fv(mShaderProgramHandle, uniformLocation, count, value );
+
1825 break;
+
1826 default:
+
1827 fprintf(stderr, "[ERROR]: invalid dimension %u for uniform %i in Shader Program %u. Dimension must be [1,4]\n", dim, uniformLocation, mShaderProgramHandle);
+
1828 break;
+
1829 }
+
1830}
+
1831
+
1832[[maybe_unused]]
+
1833inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, GLint v0 ) const {
+
1834 glProgramUniform1i(mShaderProgramHandle, uniformLocation, v0 );
+
1835}
+
1836
+
1837[[maybe_unused]]
+
1838inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, GLint v0, GLint v1 ) const {
+
1839 glProgramUniform2i(mShaderProgramHandle, uniformLocation, v0, v1 );
+
1840}
+
1841
+
1842[[maybe_unused]]
+
1843inline void CSCI441::ShaderProgram::setProgramUniform(GLint uniformLocation, glm::ivec2 value) const {
+
1844 setProgramUniform(uniformLocation, 2, 1, glm::value_ptr(value));
+
1845}
+
1846
+
1847[[maybe_unused]]
+
1848inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, GLint v0, GLint v1, GLint v2 ) const {
+
1849 glProgramUniform3i(mShaderProgramHandle, uniformLocation, v0, v1, v2 );
+
1850}
+
1851
+
1852[[maybe_unused]]
+
1853inline void CSCI441::ShaderProgram::setProgramUniform(GLint uniformLocation, glm::ivec3 value) const {
+
1854 setProgramUniform(uniformLocation, 3, 1, glm::value_ptr(value));
+
1855}
+
1856
+
1857[[maybe_unused]]
+
1858inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, GLint v0, GLint v1, GLint v2, GLint v3 ) const {
+
1859 glProgramUniform4i(mShaderProgramHandle, uniformLocation, v0, v1, v2, v3 );
+
1860}
+
1861
+
1862[[maybe_unused]]
+
1863inline void CSCI441::ShaderProgram::setProgramUniform(GLint uniformLocation, glm::ivec4 value) const {
+
1864 setProgramUniform(uniformLocation, 4, 1, glm::value_ptr(value));
+
1865}
+
1866
+
1867inline void CSCI441::ShaderProgram::setProgramUniform(GLint uniformLocation, GLuint dim, GLsizei count, const GLint *value) const {
+
1868 switch(dim) {
+
1869 case 1:
+
1870 glProgramUniform1iv(mShaderProgramHandle, uniformLocation, count, value );
+
1871 break;
+
1872 case 2:
+
1873 glProgramUniform2iv(mShaderProgramHandle, uniformLocation, count, value );
+
1874 break;
+
1875 case 3:
+
1876 glProgramUniform3iv(mShaderProgramHandle, uniformLocation, count, value );
+
1877 break;
+
1878 case 4:
+
1879 glProgramUniform4iv(mShaderProgramHandle, uniformLocation, count, value );
+
1880 break;
+
1881 default:
+
1882 fprintf(stderr, "[ERROR]: invalid dimension %u for uniform %i in Shader Program %u. Dimension must be [1,4]\n", dim, uniformLocation, mShaderProgramHandle);
+
1883 break;
+
1884 }
+
1885}
+
1886
+
1887[[maybe_unused]]
+
1888inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, GLuint v0 ) const {
+
1889 glProgramUniform1ui(mShaderProgramHandle, uniformLocation, v0 );
+
1890}
+
1891
+
1892[[maybe_unused]]
+
1893inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, GLuint v0, GLuint v1 ) const {
+
1894 glProgramUniform2ui(mShaderProgramHandle, uniformLocation, v0, v1 );
+
1895}
+
1896
+
1897[[maybe_unused]]
+
1898inline void CSCI441::ShaderProgram::setProgramUniform(GLint uniformLocation, glm::uvec2 value) const {
+
1899 setProgramUniform(uniformLocation, 2, 1, glm::value_ptr(value));
+
1900}
+
1901
+
1902[[maybe_unused]]
+
1903inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, GLuint v0, GLuint v1, GLuint v2 ) const {
+
1904 glProgramUniform3ui(mShaderProgramHandle, uniformLocation, v0, v1, v2 );
+
1905}
+
1906
+
1907[[maybe_unused]]
+
1908inline void CSCI441::ShaderProgram::setProgramUniform(GLint uniformLocation, glm::uvec3 value) const {
+
1909 setProgramUniform(uniformLocation, 3, 1, glm::value_ptr(value));
+
1910}
+
1911
+
1912[[maybe_unused]]
+
1913inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, GLuint v0, GLuint v1, GLuint v2, GLuint v3 ) const {
+
1914 glProgramUniform4ui(mShaderProgramHandle, uniformLocation, v0, v1, v2, v3 );
+
1915}
+
1916
+
1917[[maybe_unused]]
+
1918inline void CSCI441::ShaderProgram::setProgramUniform(GLint uniformLocation, glm::uvec4 value) const {
+
1919 setProgramUniform(uniformLocation, 4, 1, glm::value_ptr(value));
+
1920}
+
1921
+
1922inline void CSCI441::ShaderProgram::setProgramUniform(GLint uniformLocation, GLuint dim, GLsizei count, const GLuint *value) const {
+
1923 switch(dim) {
+
1924 case 1:
+
1925 glProgramUniform1uiv(mShaderProgramHandle, uniformLocation, count, value );
+
1926 break;
+
1927 case 2:
+
1928 glProgramUniform2uiv(mShaderProgramHandle, uniformLocation, count, value );
+
1929 break;
+
1930 case 3:
+
1931 glProgramUniform3uiv(mShaderProgramHandle, uniformLocation, count, value );
+
1932 break;
+
1933 case 4:
+
1934 glProgramUniform4uiv(mShaderProgramHandle, uniformLocation, count, value );
+
1935 break;
+
1936 default:
+
1937 fprintf(stderr, "[ERROR]: invalid dimension %u for uniform %i in Shader Program %u. Dimension must be [1,4]\n", dim, uniformLocation, mShaderProgramHandle);
+
1938 break;
+
1939 }
+
1940}
+
1941
+
1942[[maybe_unused]]
+
1943inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, glm::mat2 mtx ) const {
+
1944 glProgramUniformMatrix2fv(mShaderProgramHandle, uniformLocation, 1, GL_FALSE, glm::value_ptr(mtx) );
+
1945}
+
1946
+
1947[[maybe_unused]]
+
1948inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, glm::mat3 mtx ) const {
+
1949 glProgramUniformMatrix3fv(mShaderProgramHandle, uniformLocation, 1, GL_FALSE, glm::value_ptr(mtx) );
+
1950}
+
1951
+
1952[[maybe_unused]]
+
1953inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, glm::mat4 mtx ) const {
+
1954 glProgramUniformMatrix4fv(mShaderProgramHandle, uniformLocation, 1, GL_FALSE, glm::value_ptr(mtx) );
+
1955}
+
1956
+
1957[[maybe_unused]]
+
1958inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, glm::mat2x3 mtx ) const {
+
1959 glProgramUniformMatrix2x3fv(mShaderProgramHandle, uniformLocation, 1, GL_FALSE, glm::value_ptr(mtx) );
+
1960}
+
1961
+
1962[[maybe_unused]]
+
1963inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, glm::mat3x2 mtx ) const {
+
1964 glProgramUniformMatrix3x2fv(mShaderProgramHandle, uniformLocation, 1, GL_FALSE, glm::value_ptr(mtx) );
+
1965}
+
1966
+
1967[[maybe_unused]]
+
1968inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, glm::mat2x4 mtx ) const {
+
1969 glProgramUniformMatrix2x4fv(mShaderProgramHandle, uniformLocation, 1, GL_FALSE, glm::value_ptr(mtx) );
+
1970}
+
1971
+
1972[[maybe_unused]]
+
1973inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, glm::mat4x2 mtx ) const {
+
1974 glProgramUniformMatrix4x2fv(mShaderProgramHandle, uniformLocation, 1, GL_FALSE, glm::value_ptr(mtx) );
+
1975}
+
1976
+
1977[[maybe_unused]]
+
1978inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, glm::mat3x4 mtx ) const {
+
1979 glProgramUniformMatrix3x4fv(mShaderProgramHandle, uniformLocation, 1, GL_FALSE, glm::value_ptr(mtx) );
+
1980}
+
1981
+
1982[[maybe_unused]]
+
1983inline void CSCI441::ShaderProgram::setProgramUniform( GLint uniformLocation, glm::mat4x3 mtx ) const {
+
1984 glProgramUniformMatrix4x3fv(mShaderProgramHandle, uniformLocation, 1, GL_FALSE, glm::value_ptr(mtx) );
+
1985}
+
1986
+
1987[[maybe_unused]]
+ +
1989 GLbitfield shaderBits = 0;
+
1990 if( mVertexShaderHandle != 0 ) shaderBits |= GL_VERTEX_SHADER_BIT;
+
1991 if( mTessellationControlShaderHandle != 0 ) shaderBits |= GL_TESS_CONTROL_SHADER_BIT;
+
1992 if( mTessellationEvaluationShaderHandle != 0 ) shaderBits |= GL_TESS_EVALUATION_SHADER_BIT;
+
1993 if( mGeometryShaderHandle != 0 ) shaderBits |= GL_GEOMETRY_SHADER_BIT;
+
1994 if( mFragmentShaderHandle != 0 ) shaderBits |= GL_FRAGMENT_SHADER_BIT;
+
1995 return shaderBits;
+
1996}
+
1997
+ +
1999 _initialize();
+
2000}
+
2001
+
2002inline void CSCI441::ShaderProgram::_initialize() {
+ + + + + + +
2009 mpUniformLocationsMap = nullptr;
+
2010 mpAttributeLocationsMap = nullptr;
+
2011}
+
2012
+ +
2014 int status;
+
2015 int infoLogLength = 0;
+
2016 int maxLength = 1000;
+
2017
+
2018 glDeleteProgram(mShaderProgramHandle );
+
2019
+
2020 // create a buffer of designated length
+
2021 char* infoLog = new char[maxLength];
+
2022
+
2023 glGetProgramiv(mShaderProgramHandle, GL_DELETE_STATUS, &status );
+
2024
+
2025 // get the info log for the vertex/tessellation/geometry/fragment/compute shader
+
2026 glGetProgramInfoLog(mShaderProgramHandle, maxLength, &infoLogLength, infoLog );
+
2027
+
2028 if(infoLogLength > 0 ) {
+
2029 // print info to terminal
+
2030 if( sDEBUG ) printf("[INFO]: Program Handle %d Delete Status %s: %s\n", mShaderProgramHandle, (status == GL_TRUE ? "Success" : " Error"), infoLog );
+
2031 }
+
2032
+
2033 delete mpUniformLocationsMap;
+ +
2035 delete[] infoLog;
+
2036}
+
2037
+
2038inline bool CSCI441::ShaderProgram::writeShaderProgramBinaryToFile(const char* BINARY_FILE_NAME) const {
+
2039 GLint formats = 0;
+
2040 glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &formats);
+
2041 if( formats < 1 ) {
+
2042 fprintf(stderr, "[ERROR]: Driver does not support any binary formats.\n");
+
2043 return false;
+
2044 }
+
2045
+
2046 // Get the binary length
+
2047 GLint length = 0;
+
2048 glGetProgramiv(mShaderProgramHandle, GL_PROGRAM_BINARY_LENGTH, &length);
+
2049
+
2050 // Retrieve the binary code
+
2051 std::vector<GLubyte> buffer(length);
+
2052 GLenum format = 0;
+
2053 glGetProgramBinary(mShaderProgramHandle, length, nullptr, &format, buffer.data());
+
2054
+
2055 // Write the binary to a file.
+
2056 fprintf(stdout, "[INFO]: Writing to %s, binary format %d\n",BINARY_FILE_NAME, format);
+
2057 std::ofstream out(BINARY_FILE_NAME, std::ios::binary);
+
2058 out.write( reinterpret_cast<char *>(buffer.data()), length );
+
2059 out.close();
+
2060
+
2061 return true;
+
2062}
+
2063
+
2064inline CSCI441::ShaderProgram* CSCI441::ShaderProgram::loadShaderProgramFromBinaryFile(const char* BINARY_FILE_NAME, const GLenum FORMAT) {
+
2065 GLint formats = 0;
+
2066 glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &formats);
+
2067 if( formats < 1 ) {
+
2068 fprintf(stderr, "[ERROR]: Driver does not support any binary formats.\n");
+
2069 return nullptr;
+
2070 }
+
2071
+
2072 GLuint program = glCreateProgram();
+
2073
+
2074 // Load binary from file
+
2075 std::ifstream inputStream(BINARY_FILE_NAME, std::ios::binary);
+
2076 std::istreambuf_iterator<char> startIt(inputStream), endIt;
+
2077 std::vector<char> buffer(startIt, endIt); // Load file
+
2078 inputStream.close();
+
2079
+
2080 // Install shader binary
+
2081 glProgramBinary(program, FORMAT, buffer.data(), buffer.size() );
+
2082
+
2083 // Check for success/failure
+
2084 GLint status;
+
2085 glGetProgramiv(program, GL_LINK_STATUS, &status);
+
2086 if( GL_FALSE == status ) {
+
2087 CSCI441_INTERNAL::ShaderUtils::printProgramLog(program);
+
2088 return nullptr;
+
2089 }
+
2090
+
2091 auto shaderProgram = new CSCI441::ShaderProgram();
+
2092 shaderProgram->mShaderProgramHandle = program;
+
2093 return shaderProgram;
+
2094}
+
2095
+
2096#endif // CSCI441_SHADER_PROGRAM_HPP
Helper functions to work with OpenGL Shaders.
-
Handles registration and compilation of Shaders.
Definition: ShaderProgram.hpp:34
-
GLuint mTessellationEvaluationShaderHandle
handle to the tessellation evaluation shader stage
Definition: ShaderProgram.hpp:831
-
virtual GLint getAtomicCounterBufferOffset(const char *atomicName) const final
Returns the offset into the buffer for the corresponding atomic counter buffer.
Definition: ShaderProgram.hpp:1354
-
GLuint mVertexShaderHandle
handle to the vertex shader stage
Definition: ShaderProgram.hpp:823
-
static ShaderProgram * loadShaderProgramFromBinaryFile(const char *BINARY_FILE_NAME, GLenum format)
loads precompiled shader program binary from external file
Definition: ShaderProgram.hpp:2063
-
virtual GLint getAtomicCounterBufferBinding(const char *atomicName) const final
Returns the binding point for the corresponding atomic counter buffer.
Definition: ShaderProgram.hpp:1337
-
GLuint mShaderProgramHandle
handle to the shader program
Definition: ShaderProgram.hpp:844
-
GLuint mTessellationControlShaderHandle
handle to the tessellation control shader stage
Definition: ShaderProgram.hpp:827
-
virtual void useProgram() const final
Sets the Shader Program to be active.
Definition: ShaderProgram.hpp:1410
-
virtual GLuint getNumAttributes() const final
Returns the number of active attributes in this shader program.
Definition: ShaderProgram.hpp:1399
-
std::map< std::string, GLint > * mpUniformLocationsMap
caches locations of uniform names within shader program
Definition: ShaderProgram.hpp:849
+
Handles registration and compilation of Shaders.
Definition: ShaderProgram.hpp:35
+
GLuint mTessellationEvaluationShaderHandle
handle to the tessellation evaluation shader stage
Definition: ShaderProgram.hpp:832
+
virtual GLint getAtomicCounterBufferOffset(const char *atomicName) const final
Returns the offset into the buffer for the corresponding atomic counter buffer.
Definition: ShaderProgram.hpp:1355
+
GLuint mVertexShaderHandle
handle to the vertex shader stage
Definition: ShaderProgram.hpp:824
+
static ShaderProgram * loadShaderProgramFromBinaryFile(const char *BINARY_FILE_NAME, GLenum format)
loads precompiled shader program binary from external file
Definition: ShaderProgram.hpp:2064
+
virtual GLint getAtomicCounterBufferBinding(const char *atomicName) const final
Returns the binding point for the corresponding atomic counter buffer.
Definition: ShaderProgram.hpp:1338
+
GLuint mShaderProgramHandle
handle to the shader program
Definition: ShaderProgram.hpp:845
+
GLuint mTessellationControlShaderHandle
handle to the tessellation control shader stage
Definition: ShaderProgram.hpp:828
+
virtual void useProgram() const final
Sets the Shader Program to be active.
Definition: ShaderProgram.hpp:1411
+
virtual GLuint getNumAttributes() const final
Returns the number of active attributes in this shader program.
Definition: ShaderProgram.hpp:1400
+
std::map< std::string, GLint > * mpUniformLocationsMap
caches locations of uniform names within shader program
Definition: ShaderProgram.hpp:850
ShaderProgram & operator=(const ShaderProgram &)=delete
do not allow shader programs to be copied
-
virtual GLbitfield getProgramStages() const final
returns a single value corresponding to which shader stages are present in this shader program
Definition: ShaderProgram.hpp:1987
-
virtual GLuint getNumUniforms() const final
Returns the number of active uniforms in this shader program.
Definition: ShaderProgram.hpp:1385
-
virtual GLubyte * getUniformBlockBuffer(const char *uniformBlockName) const final
Returns an allocated buffer for the given uniform block in this shader program.
Definition: ShaderProgram.hpp:1237
-
virtual GLint getImageBinding(const char *imageName) const final
Returns the binding point for the corresponding image uniform.
Definition: ShaderProgram.hpp:1305
-
virtual GLint getUniformLocation(const char *uniformName) const final
Returns the location of the given uniform in this shader program.
Definition: ShaderProgram.hpp:1216
-
virtual ~ShaderProgram()
Clean up memory associated with the Shader Program.
Definition: ShaderProgram.hpp:2012
-
virtual GLuint getShaderProgramHandle() const final
Returns the handle for this shader program.
Definition: ShaderProgram.hpp:1405
-
GLuint mGeometryShaderHandle
handle to the geometry shader stage
Definition: ShaderProgram.hpp:835
-
virtual GLuint getSubroutineIndex(GLenum shaderStage, const char *subroutineName) const final
Returns the index of the given subroutine for a shader stage in this shader program.
Definition: ShaderProgram.hpp:1296
-
virtual GLint getAttributeLocation(const char *attributeName) const final
Returns the location of the given attribute in this shader program.
Definition: ShaderProgram.hpp:1286
-
static bool sDEBUG
if DEBUG information should be printed or not
Definition: ShaderProgram.hpp:818
-
virtual bool writeShaderProgramBinaryToFile(const char *BINARY_FILE_NAME) const final
writes precompiled shader program binary to external file
Definition: ShaderProgram.hpp:2037
-
static void disableDebugMessages()
Disables debug messages from Shader Program functions.
Definition: ShaderProgram.hpp:888
-
static void enableDebugMessages()
Enables debug messages from Shader Program functions.
Definition: ShaderProgram.hpp:883
-
virtual GLint getAtomicCounterBufferSize(const char *atomicName) const final
Returns the full buffer size for the corresponding atomic counter buffer.
Definition: ShaderProgram.hpp:1368
-
std::map< std::string, GLint > * mpAttributeLocationsMap
caches locations of attribute names within shader program
Definition: ShaderProgram.hpp:853
-
virtual void setProgramUniform(const char *uniformName, GLfloat v0) const final
sets the program uniform consisting of one float
Definition: ShaderProgram.hpp:1415
-
virtual GLuint getNumUniformBlocks() const final
Returns the number of active uniform blocks in this shader program.
Definition: ShaderProgram.hpp:1392
+
virtual GLbitfield getProgramStages() const final
returns a single value corresponding to which shader stages are present in this shader program
Definition: ShaderProgram.hpp:1988
+
virtual GLuint getNumUniforms() const final
Returns the number of active uniforms in this shader program.
Definition: ShaderProgram.hpp:1386
+
virtual GLubyte * getUniformBlockBuffer(const char *uniformBlockName) const final
Returns an allocated buffer for the given uniform block in this shader program.
Definition: ShaderProgram.hpp:1238
+
virtual GLint getImageBinding(const char *imageName) const final
Returns the binding point for the corresponding image uniform.
Definition: ShaderProgram.hpp:1306
+
virtual GLint getUniformLocation(const char *uniformName) const final
Returns the location of the given uniform in this shader program.
Definition: ShaderProgram.hpp:1217
+
virtual ~ShaderProgram()
Clean up memory associated with the Shader Program.
Definition: ShaderProgram.hpp:2013
+
virtual GLuint getShaderProgramHandle() const final
Returns the handle for this shader program.
Definition: ShaderProgram.hpp:1406
+
GLuint mGeometryShaderHandle
handle to the geometry shader stage
Definition: ShaderProgram.hpp:836
+
virtual GLuint getSubroutineIndex(GLenum shaderStage, const char *subroutineName) const final
Returns the index of the given subroutine for a shader stage in this shader program.
Definition: ShaderProgram.hpp:1297
+
virtual GLint getAttributeLocation(const char *attributeName) const final
Returns the location of the given attribute in this shader program.
Definition: ShaderProgram.hpp:1287
+
static bool sDEBUG
if DEBUG information should be printed or not
Definition: ShaderProgram.hpp:819
+
virtual bool writeShaderProgramBinaryToFile(const char *BINARY_FILE_NAME) const final
writes precompiled shader program binary to external file
Definition: ShaderProgram.hpp:2038
+
static void disableDebugMessages()
Disables debug messages from Shader Program functions.
Definition: ShaderProgram.hpp:889
+
static void enableDebugMessages()
Enables debug messages from Shader Program functions.
Definition: ShaderProgram.hpp:884
+
virtual GLint getAtomicCounterBufferSize(const char *atomicName) const final
Returns the full buffer size for the corresponding atomic counter buffer.
Definition: ShaderProgram.hpp:1369
+
std::map< std::string, GLint > * mpAttributeLocationsMap
caches locations of attribute names within shader program
Definition: ShaderProgram.hpp:854
+
virtual void setProgramUniform(const char *uniformName, GLfloat v0) const final
sets the program uniform consisting of one float
Definition: ShaderProgram.hpp:1416
+
virtual GLuint getNumUniformBlocks() const final
Returns the number of active uniform blocks in this shader program.
Definition: ShaderProgram.hpp:1393
ShaderProgram(const ShaderProgram &)=delete
do not allow shader programs to be copied
-
virtual void setUniformBlockBinding(const char *uniformBlockName, GLuint binding) const final
Set the binding point for the given uniform block in this shader program.
Definition: ShaderProgram.hpp:1281
-
virtual GLint getUniformBlockSize(const char *uniformBlockName) const final
Returns the size of the given uniform block in this shader program.
Definition: ShaderProgram.hpp:1230
-
GLuint mFragmentShaderHandle
handle to the fragment shader stage
Definition: ShaderProgram.hpp:839
-
virtual GLint * getUniformBlockOffsets(const char *uniformBlockName) const final
Returns an array of offsets into the buffer for the given uniform block in this shader program.
Definition: ShaderProgram.hpp:1248
-
virtual GLint getUniformBlockIndex(const char *uniformBlockName) const final
Returns the index of the given uniform block in this shader program.
Definition: ShaderProgram.hpp:1223
-
ShaderProgram()
creates an empty shader program object
Definition: ShaderProgram.hpp:1997
-
virtual bool mRegisterShaderProgram(const char *vertexShaderFilename, const char *tessellationControlShaderFilename, const char *tessellationEvaluationShaderFilename, const char *geometryShaderFilename, const char *fragmentShaderFilename, bool isSeparable) final
registers a shader program with the GPU
Definition: ShaderProgram.hpp:1032
-
virtual GLint getShaderStorageBlockBinding(const char *ssboName) const final
Returns the binding point for the corresponding shader storage block.
Definition: ShaderProgram.hpp:1320
+
virtual void setUniformBlockBinding(const char *uniformBlockName, GLuint binding) const final
Set the binding point for the given uniform block in this shader program.
Definition: ShaderProgram.hpp:1282
+
virtual GLint getUniformBlockSize(const char *uniformBlockName) const final
Returns the size of the given uniform block in this shader program.
Definition: ShaderProgram.hpp:1231
+
GLuint mFragmentShaderHandle
handle to the fragment shader stage
Definition: ShaderProgram.hpp:840
+
virtual GLint * getUniformBlockOffsets(const char *uniformBlockName) const final
Returns an array of offsets into the buffer for the given uniform block in this shader program.
Definition: ShaderProgram.hpp:1249
+
virtual GLint getUniformBlockIndex(const char *uniformBlockName) const final
Returns the index of the given uniform block in this shader program.
Definition: ShaderProgram.hpp:1224
+
ShaderProgram()
creates an empty shader program object
Definition: ShaderProgram.hpp:1998
+
virtual bool mRegisterShaderProgram(const char *vertexShaderFilename, const char *tessellationControlShaderFilename, const char *tessellationEvaluationShaderFilename, const char *geometryShaderFilename, const char *fragmentShaderFilename, bool isSeparable) final
registers a shader program with the GPU
Definition: ShaderProgram.hpp:1033
+
virtual GLint getShaderStorageBlockBinding(const char *ssboName) const final
Returns the binding point for the corresponding shader storage block.
Definition: ShaderProgram.hpp:1321
CSCI441 Helper Functions for OpenGL.
Definition: ArcballCam.hpp:17
diff --git a/docs/_shader_program_pipeline_8hpp.html b/docs/_shader_program_pipeline_8hpp.html index bdd777dc..6386860a 100644 --- a/docs/_shader_program_pipeline_8hpp.html +++ b/docs/_shader_program_pipeline_8hpp.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_shader_program_pipeline_8hpp_source.html b/docs/_shader_program_pipeline_8hpp_source.html index fbefaa02..33608879 100644 --- a/docs/_shader_program_pipeline_8hpp_source.html +++ b/docs/_shader_program_pipeline_8hpp_source.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
@@ -188,9 +188,9 @@
172
173#endif// CSCI441_SHADER_PROGRAM_PIPELINE_HPP
Class to work with OpenGL 4.0+ Shaders.
-
Handles registration and compilation of Shaders.
Definition: ShaderProgram.hpp:34
-
virtual GLbitfield getProgramStages() const final
returns a single value corresponding to which shader stages are present in this shader program
Definition: ShaderProgram.hpp:1987
-
virtual GLuint getShaderProgramHandle() const final
Returns the handle for this shader program.
Definition: ShaderProgram.hpp:1405
+
Handles registration and compilation of Shaders.
Definition: ShaderProgram.hpp:35
+
virtual GLbitfield getProgramStages() const final
returns a single value corresponding to which shader stages are present in this shader program
Definition: ShaderProgram.hpp:1988
+
virtual GLuint getShaderProgramHandle() const final
Returns the handle for this shader program.
Definition: ShaderProgram.hpp:1406
Handles registration and compilation of Shader Program Pipelines.
Definition: ShaderProgramPipeline.hpp:26
ShaderProgramPipeline(const ShaderProgramPipeline &)=delete
do not allow shader program pipelines to be copied
void useProgramStages(GLbitfield programStages, const ShaderProgram *shaderProgram) const
adds shader program stages to pipeline
Definition: ShaderProgramPipeline.hpp:121
diff --git a/docs/_shader_utils_8hpp.html b/docs/_shader_utils_8hpp.html index c23b3751..9a397ae6 100644 --- a/docs/_shader_utils_8hpp.html +++ b/docs/_shader_utils_8hpp.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_shader_utils_8hpp_source.html b/docs/_shader_utils_8hpp_source.html index 7e462a02..59d60151 100644 --- a/docs/_shader_utils_8hpp_source.html +++ b/docs/_shader_utils_8hpp_source.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_simple_shader_8hpp.html b/docs/_simple_shader_8hpp.html index 734ba5f9..65d75a25 100644 --- a/docs/_simple_shader_8hpp.html +++ b/docs/_simple_shader_8hpp.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_simple_shader_8hpp_source.html b/docs/_simple_shader_8hpp_source.html index 7f96ebce..e6e5d647 100644 --- a/docs/_simple_shader_8hpp_source.html +++ b/docs/_simple_shader_8hpp_source.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_texture_utils_8hpp.html b/docs/_texture_utils_8hpp.html index 82599613..64ef1b40 100644 --- a/docs/_texture_utils_8hpp.html +++ b/docs/_texture_utils_8hpp.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
@@ -101,12 +101,12 @@ bool CSCI441::TextureUtils::loadPPM (const char *filename, int &imageWidth, int &imageHeight, unsigned char *&imageData)  loads a PPM into memory
  -GLuint CSCI441::TextureUtils::loadAndRegisterTexture (const char *filename, GLint minFilter=GL_LINEAR, GLint magFilter=GL_LINEAR, GLint wrapS=GL_REPEAT, GLint wrapT=GL_REPEAT, GLboolean flipOnY=GL_TRUE) - loads and registers a texture into memory returning a texture handle
-  -GLuint CSCI441::TextureUtils::loadAndRegister2DTexture (const char *filename, GLint minFilter=GL_LINEAR, GLint magFilter=GL_LINEAR, GLint wrapS=GL_REPEAT, GLint wrapT=GL_REPEAT, GLboolean flipOnY=GL_TRUE) - loads and registers a texture into memory returning a texture handle
-  +GLuint CSCI441::TextureUtils::loadAndRegisterTexture (const char *filename, GLint minFilter=GL_LINEAR, GLint magFilter=GL_LINEAR, GLint wrapS=GL_REPEAT, GLint wrapT=GL_REPEAT, GLboolean flipOnY=GL_TRUE, GLboolean printAllMessages=GL_TRUE) + loads and registers a texture into memory returning a texture handle
+  +GLuint CSCI441::TextureUtils::loadAndRegister2DTexture (const char *filename, GLint minFilter=GL_LINEAR, GLint magFilter=GL_LINEAR, GLint wrapS=GL_REPEAT, GLint wrapT=GL_REPEAT, GLboolean flipOnY=GL_TRUE, GLboolean printAllMessages=GL_TRUE) + loads and registers a texture into memory returning a texture handle
+  void CSCI441::TextureUtils::loadCubeMapFaceTexture (GLint cubeMapFace, const char *filename)  loads a texture into memory of a cube face
  @@ -120,8 +120,8 @@
This header file depends upon stb_image

Function Documentation

- -

◆ loadAndRegister2DTexture()

+ +

◆ loadAndRegister2DTexture()

@@ -163,7 +163,13 @@

GLboolean  - flipOnY = GL_TRUE  + flipOnY = GL_TRUE, + + + + + GLboolean  + printAllMessages = GL_TRUE  @@ -185,11 +191,9 @@

minFilterminification filter to apply (default: GL_LINEAR) magFiltermagnification filter to apply (default: GL_LINEAR) wrapSwrapping to apply to S coordinate (default: GL_REPEAT) - wrapTwrapping to apply to T coordinate (default: GL_REPEAT)
    -
  • -
- + wrapTwrapping to apply to T coordinate (default: GL_REPEAT) flipOnYflip the image along the vertical on load (default: GL_TRUE) + printAllMessagesprints debug/error messages to terminal (default: GL_TRUE) @@ -197,8 +201,8 @@

-

◆ loadAndRegisterTexture()

+ +

◆ loadAndRegisterTexture()

@@ -240,7 +244,13 @@

GLboolean  - flipOnY = GL_TRUE  + flipOnY = GL_TRUE, + + + + + GLboolean  + printAllMessages = GL_TRUE  @@ -265,6 +275,7 @@

wrapSwrapping to apply to S coordinate (default: GL_REPEAT) wrapTwrapping to apply to T coordinate (default: GL_REPEAT) flipOnYflip the image along the vertical on load (default: GL_TRUE) + printAllMessagesprints debug/error messages to terminal (default: GL_TRUE) diff --git a/docs/_texture_utils_8hpp_source.html b/docs/_texture_utils_8hpp_source.html index ca9904ce..664f7a45 100644 --- a/docs/_texture_utils_8hpp_source.html +++ b/docs/_texture_utils_8hpp_source.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
@@ -97,123 +97,125 @@
38
57 bool loadPPM( const char *filename, int &imageWidth, int &imageHeight, unsigned char* &imageData );
58
-
70 [[maybe_unused]] GLuint loadAndRegisterTexture( const char *filename,
-
71 GLint minFilter = GL_LINEAR,
-
72 GLint magFilter = GL_LINEAR,
-
73 GLint wrapS = GL_REPEAT,
-
74 GLint wrapT = GL_REPEAT,
-
75 GLboolean flipOnY = GL_TRUE );
-
76
-
90 GLuint loadAndRegister2DTexture( const char *filename,
-
91 GLint minFilter = GL_LINEAR,
-
92 GLint magFilter = GL_LINEAR,
-
93 GLint wrapS = GL_REPEAT,
-
94 GLint wrapT = GL_REPEAT,
-
95 GLboolean flipOnY = GL_TRUE );
-
96
-
103 [[maybe_unused]] void loadCubeMapFaceTexture(GLint cubeMapFace, const char* filename);
-
104 }
-
105}
-
106
-
107//**********************************************************************************
-
108// Outward facing function implementations
-
109
-
110inline bool CSCI441::TextureUtils::loadPPM( const char *filename, int &imageWidth, int &imageHeight, unsigned char* &imageData ) {
-
111 FILE *fp = fopen(filename, "r");
-
112 int temp, maxValue;
-
113 fscanf(fp, "P%d", &temp);
-
114 if(temp != 3) {
-
115 fprintf(stderr, "[ERROR]: CSCI441::TextureUtils::loadPPM(): PPM file is not of correct format! (Must be P3, is P%d.)\n", temp);
-
116 fclose(fp);
-
117 return false;
-
118 }
-
119
-
120 //got the file header right...
-
121 fscanf(fp, "%d", &imageWidth);
-
122 fscanf(fp, "%d", &imageHeight);
-
123 fscanf(fp, "%d", &maxValue);
-
124
-
125 //now that we know how big it is, allocate the buffer...
-
126 imageData = new unsigned char[imageWidth*imageHeight*3];
-
127 if(!imageData) {
-
128 fprintf(stderr, "[ERROR]: CSCI441::TextureUtils::loadPPM(): couldn't allocate image memory. Dimensions: %d x %d.\n", imageWidth, imageHeight);
-
129 fclose(fp);
-
130 return false;
-
131 }
-
132
-
133 //and read the data in.
-
134 for(int j = 0; j < imageHeight; j++) {
-
135 for(int i = 0; i < imageWidth; i++) {
-
136 int r, g, b;
-
137 fscanf(fp, "%d", &r);
-
138 fscanf(fp, "%d", &g);
-
139 fscanf(fp, "%d", &b);
-
140
-
141 imageData[(j*imageWidth+i)*3+0] = r;
-
142 imageData[(j*imageWidth+i)*3+1] = g;
-
143 imageData[(j*imageWidth+i)*3+2] = b;
-
144 }
-
145 }
-
146
-
147 fclose(fp);
-
148 return true;
-
149}
+
71 [[maybe_unused]] GLuint loadAndRegisterTexture( const char *filename,
+
72 GLint minFilter = GL_LINEAR,
+
73 GLint magFilter = GL_LINEAR,
+
74 GLint wrapS = GL_REPEAT,
+
75 GLint wrapT = GL_REPEAT,
+
76 GLboolean flipOnY = GL_TRUE,
+
77 GLboolean printAllMessages = GL_TRUE);
+
78
+
93 GLuint loadAndRegister2DTexture( const char *filename,
+
94 GLint minFilter = GL_LINEAR,
+
95 GLint magFilter = GL_LINEAR,
+
96 GLint wrapS = GL_REPEAT,
+
97 GLint wrapT = GL_REPEAT,
+
98 GLboolean flipOnY = GL_TRUE,
+
99 GLboolean printAllMessages = GL_TRUE);
+
100
+
107 [[maybe_unused]] void loadCubeMapFaceTexture(GLint cubeMapFace, const char* filename);
+
108 }
+
109}
+
110
+
111//**********************************************************************************
+
112// Outward facing function implementations
+
113
+
114inline bool CSCI441::TextureUtils::loadPPM( const char *filename, int &imageWidth, int &imageHeight, unsigned char* &imageData ) {
+
115 FILE *fp = fopen(filename, "r");
+
116 int temp, maxValue;
+
117 fscanf(fp, "P%d", &temp);
+
118 if(temp != 3) {
+
119 fprintf(stderr, "[ERROR]: CSCI441::TextureUtils::loadPPM(): PPM file is not of correct format! (Must be P3, is P%d.)\n", temp);
+
120 fclose(fp);
+
121 return false;
+
122 }
+
123
+
124 //got the file header right...
+
125 fscanf(fp, "%d", &imageWidth);
+
126 fscanf(fp, "%d", &imageHeight);
+
127 fscanf(fp, "%d", &maxValue);
+
128
+
129 //now that we know how big it is, allocate the buffer...
+
130 imageData = new unsigned char[imageWidth*imageHeight*3];
+
131 if(!imageData) {
+
132 fprintf(stderr, "[ERROR]: CSCI441::TextureUtils::loadPPM(): couldn't allocate image memory. Dimensions: %d x %d.\n", imageWidth, imageHeight);
+
133 fclose(fp);
+
134 return false;
+
135 }
+
136
+
137 //and read the data in.
+
138 for(int j = 0; j < imageHeight; j++) {
+
139 for(int i = 0; i < imageWidth; i++) {
+
140 int r, g, b;
+
141 fscanf(fp, "%d", &r);
+
142 fscanf(fp, "%d", &g);
+
143 fscanf(fp, "%d", &b);
+
144
+
145 imageData[(j*imageWidth+i)*3+0] = r;
+
146 imageData[(j*imageWidth+i)*3+1] = g;
+
147 imageData[(j*imageWidth+i)*3+2] = b;
+
148 }
+
149 }
150
-
151[[maybe_unused]]
-
152inline GLuint CSCI441::TextureUtils::loadAndRegisterTexture( const char *filename, const GLint minFilter, const GLint magFilter, const GLint wrapS, const GLint wrapT, const GLboolean flipOnY ) {
-
153 return loadAndRegister2DTexture( filename, minFilter, magFilter, wrapS, wrapT, flipOnY );
-
154}
-
155
-
156inline GLuint CSCI441::TextureUtils::loadAndRegister2DTexture( const char *filename, const GLint minFilter, const GLint magFilter, const GLint wrapS, const GLint wrapT, const GLboolean flipOnY ) {
-
157 int imageWidth, imageHeight, imageChannels;
-
158 GLuint texHandle = 0;
-
159 stbi_set_flip_vertically_on_load(flipOnY);
-
160 unsigned char *data = stbi_load( filename, &imageWidth, &imageHeight, &imageChannels, 0);
-
161
-
162 if( !data ) {
-
163 if( strstr(filename, ".ppm") != NULL ) {
-
164 loadPPM(filename, imageWidth, imageHeight, data);
-
165 imageChannels = 3;
-
166 }
-
167 if( !data ) {
-
168 printf( "[ERROR]: CSCI441::TextureUtils::loadAndRegister2DTexture(): Could not load texture \"%s\"\n", filename );
-
169 return texHandle;
+
151 fclose(fp);
+
152 return true;
+
153}
+
154
+
155[[maybe_unused]]
+
156inline GLuint CSCI441::TextureUtils::loadAndRegisterTexture( const char *filename, const GLint minFilter, const GLint magFilter, const GLint wrapS, const GLint wrapT, const GLboolean flipOnY, const GLboolean printAllMessages ) {
+
157 return loadAndRegister2DTexture( filename, minFilter, magFilter, wrapS, wrapT, flipOnY, printAllMessages );
+
158}
+
159
+
160inline GLuint CSCI441::TextureUtils::loadAndRegister2DTexture( const char *filename, const GLint minFilter, const GLint magFilter, const GLint wrapS, const GLint wrapT, const GLboolean flipOnY, const GLboolean printAllMessages ) {
+
161 int imageWidth, imageHeight, imageChannels;
+
162 GLuint texHandle = 0;
+
163 stbi_set_flip_vertically_on_load(flipOnY);
+
164 unsigned char *data = stbi_load( filename, &imageWidth, &imageHeight, &imageChannels, 0);
+
165
+
166 if( !data ) {
+
167 if( strstr(filename, ".ppm") != NULL ) {
+
168 loadPPM(filename, imageWidth, imageHeight, data);
+
169 imageChannels = 3;
170 }
-
171 }
-
172
-
173 glGenTextures(1, &texHandle );
-
174 glBindTexture( GL_TEXTURE_2D, texHandle );
-
175 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter );
-
176 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter );
-
177 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapS );
-
178 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapT );
-
179 const GLint STORAGE_TYPE = (imageChannels == 4 ? GL_RGBA : GL_RGB);
-
180 glTexImage2D( GL_TEXTURE_2D, 0, STORAGE_TYPE, imageWidth, imageHeight, 0, STORAGE_TYPE, GL_UNSIGNED_BYTE, data);
-
181 glGenerateMipmap(GL_TEXTURE_2D);
-
182 printf( "[INFO]: Successfully loaded texture \"%s\" with handle %d\n", filename, texHandle );
-
183
-
184 return texHandle;
-
185}
-
186
-
187[[maybe_unused]]
-
188inline void CSCI441::TextureUtils::loadCubeMapFaceTexture(const GLint cubeMapFace, const char* FILENAME) {
-
189 int imageWidth, imageHeight, imageChannels;
-
190 unsigned char *data = stbi_load( FILENAME, &imageWidth, &imageHeight, &imageChannels, 0);
-
191
-
192 if( data ) {
-
193 const GLint STORAGE_TYPE = (imageChannels == 4 ? GL_RGBA : GL_RGB);
-
194 glTexImage2D(cubeMapFace, 0, STORAGE_TYPE, imageWidth, imageHeight, 0, STORAGE_TYPE, GL_UNSIGNED_BYTE, data);
-
195 stbi_image_free(data);
-
196 } else {
-
197 fprintf( stderr, "[ERROR]: CSCI441::TextureUtils::loadCubeMapFaceTexture(): Could not load texture map \"%s\"\n", FILENAME );
-
198 }
-
199}
-
200
-
201#endif // CSCI441_TEXTURE_UTILS_HPP
-
void loadCubeMapFaceTexture(GLint cubeMapFace, const char *filename)
loads a texture into memory of a cube face
Definition: TextureUtils.hpp:188
-
bool loadPPM(const char *filename, int &imageWidth, int &imageHeight, unsigned char *&imageData)
loads a PPM into memory
Definition: TextureUtils.hpp:110
-
GLuint loadAndRegister2DTexture(const char *filename, GLint minFilter=GL_LINEAR, GLint magFilter=GL_LINEAR, GLint wrapS=GL_REPEAT, GLint wrapT=GL_REPEAT, GLboolean flipOnY=GL_TRUE)
loads and registers a texture into memory returning a texture handle
Definition: TextureUtils.hpp:156
-
GLuint loadAndRegisterTexture(const char *filename, GLint minFilter=GL_LINEAR, GLint magFilter=GL_LINEAR, GLint wrapS=GL_REPEAT, GLint wrapT=GL_REPEAT, GLboolean flipOnY=GL_TRUE)
loads and registers a texture into memory returning a texture handle
Definition: TextureUtils.hpp:152
+
171 if( !data ) {
+
172 if(printAllMessages) printf( "[ERROR]: CSCI441::TextureUtils::loadAndRegister2DTexture(): Could not load texture \"%s\"\n", filename );
+
173 return texHandle;
+
174 }
+
175 }
+
176
+
177 glGenTextures(1, &texHandle );
+
178 glBindTexture( GL_TEXTURE_2D, texHandle );
+
179 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter );
+
180 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter );
+
181 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapS );
+
182 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapT );
+
183 const GLint STORAGE_TYPE = (imageChannels == 4 ? GL_RGBA : GL_RGB);
+
184 glTexImage2D( GL_TEXTURE_2D, 0, STORAGE_TYPE, imageWidth, imageHeight, 0, STORAGE_TYPE, GL_UNSIGNED_BYTE, data);
+
185 glGenerateMipmap(GL_TEXTURE_2D);
+
186 printf( "[INFO]: Successfully loaded texture \"%s\" with handle %d\n", filename, texHandle );
+
187
+
188 return texHandle;
+
189}
+
190
+
191[[maybe_unused]]
+
192inline void CSCI441::TextureUtils::loadCubeMapFaceTexture(const GLint cubeMapFace, const char* FILENAME) {
+
193 int imageWidth, imageHeight, imageChannels;
+
194 unsigned char *data = stbi_load( FILENAME, &imageWidth, &imageHeight, &imageChannels, 0);
+
195
+
196 if( data ) {
+
197 const GLint STORAGE_TYPE = (imageChannels == 4 ? GL_RGBA : GL_RGB);
+
198 glTexImage2D(cubeMapFace, 0, STORAGE_TYPE, imageWidth, imageHeight, 0, STORAGE_TYPE, GL_UNSIGNED_BYTE, data);
+
199 stbi_image_free(data);
+
200 } else {
+
201 fprintf( stderr, "[ERROR]: CSCI441::TextureUtils::loadCubeMapFaceTexture(): Could not load texture map \"%s\"\n", FILENAME );
+
202 }
+
203}
+
204
+
205#endif // CSCI441_TEXTURE_UTILS_HPP
+
void loadCubeMapFaceTexture(GLint cubeMapFace, const char *filename)
loads a texture into memory of a cube face
Definition: TextureUtils.hpp:192
+
GLuint loadAndRegisterTexture(const char *filename, GLint minFilter=GL_LINEAR, GLint magFilter=GL_LINEAR, GLint wrapS=GL_REPEAT, GLint wrapT=GL_REPEAT, GLboolean flipOnY=GL_TRUE, GLboolean printAllMessages=GL_TRUE)
loads and registers a texture into memory returning a texture handle
Definition: TextureUtils.hpp:156
+
bool loadPPM(const char *filename, int &imageWidth, int &imageHeight, unsigned char *&imageData)
loads a PPM into memory
Definition: TextureUtils.hpp:114
+
GLuint loadAndRegister2DTexture(const char *filename, GLint minFilter=GL_LINEAR, GLint magFilter=GL_LINEAR, GLint wrapS=GL_REPEAT, GLint wrapT=GL_REPEAT, GLboolean flipOnY=GL_TRUE, GLboolean printAllMessages=GL_TRUE)
loads and registers a texture into memory returning a texture handle
Definition: TextureUtils.hpp:160
CSCI441 Helper Functions for OpenGL.
Definition: ArcballCam.hpp:17
OpenGL Texture Utility functions.

diff --git a/docs/_uniform_buffer_object_8hpp.html b/docs/_uniform_buffer_object_8hpp.html index 24db739c..0db672c6 100644 --- a/docs/_uniform_buffer_object_8hpp.html +++ b/docs/_uniform_buffer_object_8hpp.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/_uniform_buffer_object_8hpp_source.html b/docs/_uniform_buffer_object_8hpp_source.html index 29772896..f19b1c8a 100644 --- a/docs/_uniform_buffer_object_8hpp_source.html +++ b/docs/_uniform_buffer_object_8hpp_source.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
@@ -212,10 +212,10 @@
191
192#endif //CSCI441_UNIFORM_BUFFER_OBJECT_HPP
Class to work with OpenGL 4.0+ Shaders.
-
Handles registration and compilation of Shaders.
Definition: ShaderProgram.hpp:34
-
virtual GLuint getShaderProgramHandle() const final
Returns the handle for this shader program.
Definition: ShaderProgram.hpp:1405
-
virtual void setUniformBlockBinding(const char *uniformBlockName, GLuint binding) const final
Set the binding point for the given uniform block in this shader program.
Definition: ShaderProgram.hpp:1281
-
virtual GLint getUniformBlockSize(const char *uniformBlockName) const final
Returns the size of the given uniform block in this shader program.
Definition: ShaderProgram.hpp:1230
+
Handles registration and compilation of Shaders.
Definition: ShaderProgram.hpp:35
+
virtual GLuint getShaderProgramHandle() const final
Returns the handle for this shader program.
Definition: ShaderProgram.hpp:1406
+
virtual void setUniformBlockBinding(const char *uniformBlockName, GLuint binding) const final
Set the binding point for the given uniform block in this shader program.
Definition: ShaderProgram.hpp:1282
+
virtual GLint getUniformBlockSize(const char *uniformBlockName) const final
Returns the size of the given uniform block in this shader program.
Definition: ShaderProgram.hpp:1231
Storage of UBO related data.
Definition: UniformBufferObject.hpp:34
void bindBuffer() const
binds UBO object to UBO buffer
Definition: UniformBufferObject.hpp:183
~UniformBufferObject()
Deletes the UBO from the GPU and frees all memory on the CPU.
Definition: UniformBufferObject.hpp:131
diff --git a/docs/annotated.html b/docs/annotated.html index 54c35037..c0b686e9 100644 --- a/docs/annotated.html +++ b/docs/annotated.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_arcball_cam-members.html b/docs/class_c_s_c_i441_1_1_arcball_cam-members.html index 930844ce..37b4b388 100644 --- a/docs/class_c_s_c_i441_1_1_arcball_cam-members.html +++ b/docs/class_c_s_c_i441_1_1_arcball_cam-members.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_arcball_cam.html b/docs/class_c_s_c_i441_1_1_arcball_cam.html index ab2bc061..0d508778 100644 --- a/docs/class_c_s_c_i441_1_1_arcball_cam.html +++ b/docs/class_c_s_c_i441_1_1_arcball_cam.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_camera-members.html b/docs/class_c_s_c_i441_1_1_camera-members.html index dbced3a7..d7075419 100644 --- a/docs/class_c_s_c_i441_1_1_camera-members.html +++ b/docs/class_c_s_c_i441_1_1_camera-members.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_camera.html b/docs/class_c_s_c_i441_1_1_camera.html index 2601b285..4cb754b7 100644 --- a/docs/class_c_s_c_i441_1_1_camera.html +++ b/docs/class_c_s_c_i441_1_1_camera.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_compute_shader_program-members.html b/docs/class_c_s_c_i441_1_1_compute_shader_program-members.html index 95e4b470..2481bcd3 100644 --- a/docs/class_c_s_c_i441_1_1_compute_shader_program-members.html +++ b/docs/class_c_s_c_i441_1_1_compute_shader_program-members.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_compute_shader_program.html b/docs/class_c_s_c_i441_1_1_compute_shader_program.html index de5891d4..371a0fa9 100644 --- a/docs/class_c_s_c_i441_1_1_compute_shader_program.html +++ b/docs/class_c_s_c_i441_1_1_compute_shader_program.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_fixed_cam-members.html b/docs/class_c_s_c_i441_1_1_fixed_cam-members.html index cca63eac..fb19d1c9 100644 --- a/docs/class_c_s_c_i441_1_1_fixed_cam-members.html +++ b/docs/class_c_s_c_i441_1_1_fixed_cam-members.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_fixed_cam.html b/docs/class_c_s_c_i441_1_1_fixed_cam.html index 6a7af2b6..b5d07fc7 100644 --- a/docs/class_c_s_c_i441_1_1_fixed_cam.html +++ b/docs/class_c_s_c_i441_1_1_fixed_cam.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_free_cam-members.html b/docs/class_c_s_c_i441_1_1_free_cam-members.html index 58e10263..8565678d 100644 --- a/docs/class_c_s_c_i441_1_1_free_cam-members.html +++ b/docs/class_c_s_c_i441_1_1_free_cam-members.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_free_cam.html b/docs/class_c_s_c_i441_1_1_free_cam.html index 247e9f23..9d98d696 100644 --- a/docs/class_c_s_c_i441_1_1_free_cam.html +++ b/docs/class_c_s_c_i441_1_1_free_cam.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_h_u_d_camera-members.html b/docs/class_c_s_c_i441_1_1_h_u_d_camera-members.html index 3c128946..17c70608 100644 --- a/docs/class_c_s_c_i441_1_1_h_u_d_camera-members.html +++ b/docs/class_c_s_c_i441_1_1_h_u_d_camera-members.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_h_u_d_camera.html b/docs/class_c_s_c_i441_1_1_h_u_d_camera.html index a8fda3b9..de440093 100644 --- a/docs/class_c_s_c_i441_1_1_h_u_d_camera.html +++ b/docs/class_c_s_c_i441_1_1_h_u_d_camera.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_m_d5_camera-members.html b/docs/class_c_s_c_i441_1_1_m_d5_camera-members.html index be22fb2b..b18c76e2 100644 --- a/docs/class_c_s_c_i441_1_1_m_d5_camera-members.html +++ b/docs/class_c_s_c_i441_1_1_m_d5_camera-members.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_m_d5_camera.html b/docs/class_c_s_c_i441_1_1_m_d5_camera.html index 099607b5..53bfd306 100644 --- a/docs/class_c_s_c_i441_1_1_m_d5_camera.html +++ b/docs/class_c_s_c_i441_1_1_m_d5_camera.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_m_d5_model-members.html b/docs/class_c_s_c_i441_1_1_m_d5_model-members.html index 769a5d6a..2154b409 100644 --- a/docs/class_c_s_c_i441_1_1_m_d5_model-members.html +++ b/docs/class_c_s_c_i441_1_1_m_d5_model-members.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_m_d5_model.html b/docs/class_c_s_c_i441_1_1_m_d5_model.html index 3461edc5..9f08ed19 100644 --- a/docs/class_c_s_c_i441_1_1_m_d5_model.html +++ b/docs/class_c_s_c_i441_1_1_m_d5_model.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_model_loader-members.html b/docs/class_c_s_c_i441_1_1_model_loader-members.html index 43e2a944..9ce478e6 100644 --- a/docs/class_c_s_c_i441_1_1_model_loader-members.html +++ b/docs/class_c_s_c_i441_1_1_model_loader-members.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_model_loader.html b/docs/class_c_s_c_i441_1_1_model_loader.html index 891b2326..040a304b 100644 --- a/docs/class_c_s_c_i441_1_1_model_loader.html +++ b/docs/class_c_s_c_i441_1_1_model_loader.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_open_g_l3_d_engine-members.html b/docs/class_c_s_c_i441_1_1_open_g_l3_d_engine-members.html index ce9d4136..44588a75 100644 --- a/docs/class_c_s_c_i441_1_1_open_g_l3_d_engine-members.html +++ b/docs/class_c_s_c_i441_1_1_open_g_l3_d_engine-members.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_open_g_l3_d_engine.html b/docs/class_c_s_c_i441_1_1_open_g_l3_d_engine.html index 1fce2c02..23360187 100644 --- a/docs/class_c_s_c_i441_1_1_open_g_l3_d_engine.html +++ b/docs/class_c_s_c_i441_1_1_open_g_l3_d_engine.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_open_g_l_engine-members.html b/docs/class_c_s_c_i441_1_1_open_g_l_engine-members.html index 1cabc49f..9db64096 100644 --- a/docs/class_c_s_c_i441_1_1_open_g_l_engine-members.html +++ b/docs/class_c_s_c_i441_1_1_open_g_l_engine-members.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_open_g_l_engine.html b/docs/class_c_s_c_i441_1_1_open_g_l_engine.html index 0df81984..a7d158f2 100644 --- a/docs/class_c_s_c_i441_1_1_open_g_l_engine.html +++ b/docs/class_c_s_c_i441_1_1_open_g_l_engine.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_orthographic_camera-members.html b/docs/class_c_s_c_i441_1_1_orthographic_camera-members.html index 30be05ca..a58b5372 100644 --- a/docs/class_c_s_c_i441_1_1_orthographic_camera-members.html +++ b/docs/class_c_s_c_i441_1_1_orthographic_camera-members.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_orthographic_camera.html b/docs/class_c_s_c_i441_1_1_orthographic_camera.html index db755c9b..9099c816 100644 --- a/docs/class_c_s_c_i441_1_1_orthographic_camera.html +++ b/docs/class_c_s_c_i441_1_1_orthographic_camera.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_perspective_camera-members.html b/docs/class_c_s_c_i441_1_1_perspective_camera-members.html index 3a65d40f..1bc64524 100644 --- a/docs/class_c_s_c_i441_1_1_perspective_camera-members.html +++ b/docs/class_c_s_c_i441_1_1_perspective_camera-members.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_perspective_camera.html b/docs/class_c_s_c_i441_1_1_perspective_camera.html index c3d43dab..b7a4fc95 100644 --- a/docs/class_c_s_c_i441_1_1_perspective_camera.html +++ b/docs/class_c_s_c_i441_1_1_perspective_camera.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_shader_program-members.html b/docs/class_c_s_c_i441_1_1_shader_program-members.html index 430b811a..af5cfcc6 100644 --- a/docs/class_c_s_c_i441_1_1_shader_program-members.html +++ b/docs/class_c_s_c_i441_1_1_shader_program-members.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_shader_program.html b/docs/class_c_s_c_i441_1_1_shader_program.html index 73f9e005..9e615d31 100644 --- a/docs/class_c_s_c_i441_1_1_shader_program.html +++ b/docs/class_c_s_c_i441_1_1_shader_program.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_shader_program_pipeline-members.html b/docs/class_c_s_c_i441_1_1_shader_program_pipeline-members.html index c4dee8e2..dd4039fd 100644 --- a/docs/class_c_s_c_i441_1_1_shader_program_pipeline-members.html +++ b/docs/class_c_s_c_i441_1_1_shader_program_pipeline-members.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_shader_program_pipeline.html b/docs/class_c_s_c_i441_1_1_shader_program_pipeline.html index b9b2a412..d49f184e 100644 --- a/docs/class_c_s_c_i441_1_1_shader_program_pipeline.html +++ b/docs/class_c_s_c_i441_1_1_shader_program_pipeline.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_uniform_buffer_object-members.html b/docs/class_c_s_c_i441_1_1_uniform_buffer_object-members.html index 93685528..ccce2a14 100644 --- a/docs/class_c_s_c_i441_1_1_uniform_buffer_object-members.html +++ b/docs/class_c_s_c_i441_1_1_uniform_buffer_object-members.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/class_c_s_c_i441_1_1_uniform_buffer_object.html b/docs/class_c_s_c_i441_1_1_uniform_buffer_object.html index 8d3f7573..db451f05 100644 --- a/docs/class_c_s_c_i441_1_1_uniform_buffer_object.html +++ b/docs/class_c_s_c_i441_1_1_uniform_buffer_object.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/classes.html b/docs/classes.html index def5dc30..94cdeb68 100644 --- a/docs/classes.html +++ b/docs/classes.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/files.html b/docs/files.html index c9f9b000..a83ef999 100644 --- a/docs/files.html +++ b/docs/files.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions.html b/docs/functions.html index 64bbf60c..668f0035 100644 --- a/docs/functions.html +++ b/docs/functions.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_b.html b/docs/functions_b.html index 4af04ed1..80306da3 100644 --- a/docs/functions_b.html +++ b/docs/functions_b.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_c.html b/docs/functions_c.html index 9178d39d..ece9ab1c 100644 --- a/docs/functions_c.html +++ b/docs/functions_c.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_d.html b/docs/functions_d.html index a28eabbe..ba34b323 100644 --- a/docs/functions_d.html +++ b/docs/functions_d.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_e.html b/docs/functions_e.html index a5fc41aa..b66c3be0 100644 --- a/docs/functions_e.html +++ b/docs/functions_e.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_enum.html b/docs/functions_enum.html index 3baf7957..f05973a8 100644 --- a/docs/functions_enum.html +++ b/docs/functions_enum.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_eval.html b/docs/functions_eval.html index 0819a5ae..fdacd8ee 100644 --- a/docs/functions_eval.html +++ b/docs/functions_eval.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_f.html b/docs/functions_f.html index 428c1877..7c391362 100644 --- a/docs/functions_f.html +++ b/docs/functions_f.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_func.html b/docs/functions_func.html index 8f917c40..be1c67fe 100644 --- a/docs/functions_func.html +++ b/docs/functions_func.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_func_b.html b/docs/functions_func_b.html index 5addd9cf..957caad4 100644 --- a/docs/functions_func_b.html +++ b/docs/functions_func_b.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_func_c.html b/docs/functions_func_c.html index 002a1a39..e89f8594 100644 --- a/docs/functions_func_c.html +++ b/docs/functions_func_c.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_func_d.html b/docs/functions_func_d.html index 78c790c8..58fe8dcf 100644 --- a/docs/functions_func_d.html +++ b/docs/functions_func_d.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_func_e.html b/docs/functions_func_e.html index a704c574..ed45c07c 100644 --- a/docs/functions_func_e.html +++ b/docs/functions_func_e.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_func_f.html b/docs/functions_func_f.html index 19e61d8c..24465cc2 100644 --- a/docs/functions_func_f.html +++ b/docs/functions_func_f.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_func_g.html b/docs/functions_func_g.html index a37722bf..47187849 100644 --- a/docs/functions_func_g.html +++ b/docs/functions_func_g.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_func_h.html b/docs/functions_func_h.html index bd1c04d9..8f91e503 100644 --- a/docs/functions_func_h.html +++ b/docs/functions_func_h.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_func_i.html b/docs/functions_func_i.html index feac57e9..ca1ea640 100644 --- a/docs/functions_func_i.html +++ b/docs/functions_func_i.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_func_l.html b/docs/functions_func_l.html index 64cc3e2e..84a5b321 100644 --- a/docs/functions_func_l.html +++ b/docs/functions_func_l.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_func_m.html b/docs/functions_func_m.html index 14c690d5..751e34c1 100644 --- a/docs/functions_func_m.html +++ b/docs/functions_func_m.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_func_o.html b/docs/functions_func_o.html index 0666699d..1bb2f0d8 100644 --- a/docs/functions_func_o.html +++ b/docs/functions_func_o.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_func_p.html b/docs/functions_func_p.html index 0b78fb08..ad2008c9 100644 --- a/docs/functions_func_p.html +++ b/docs/functions_func_p.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_func_r.html b/docs/functions_func_r.html index fe47b8ef..c53ca98f 100644 --- a/docs/functions_func_r.html +++ b/docs/functions_func_r.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_func_s.html b/docs/functions_func_s.html index 62ae4dc9..70b9a4aa 100644 --- a/docs/functions_func_s.html +++ b/docs/functions_func_s.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_func_t.html b/docs/functions_func_t.html index 7cdeb876..b9de389b 100644 --- a/docs/functions_func_t.html +++ b/docs/functions_func_t.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_func_u.html b/docs/functions_func_u.html index 50500174..ab685c2b 100644 --- a/docs/functions_func_u.html +++ b/docs/functions_func_u.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_func_v.html b/docs/functions_func_v.html index 3debce3b..59ae51ef 100644 --- a/docs/functions_func_v.html +++ b/docs/functions_func_v.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_func_w.html b/docs/functions_func_w.html index a48ccdd7..5b0ab017 100644 --- a/docs/functions_func_w.html +++ b/docs/functions_func_w.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_func_~.html b/docs/functions_func_~.html index 347cc7c0..11d95bbf 100644 --- a/docs/functions_func_~.html +++ b/docs/functions_func_~.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_g.html b/docs/functions_g.html index 0deeacd4..b559f612 100644 --- a/docs/functions_g.html +++ b/docs/functions_g.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_h.html b/docs/functions_h.html index 5d9e1c74..f59c4124 100644 --- a/docs/functions_h.html +++ b/docs/functions_h.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_i.html b/docs/functions_i.html index a47cec4c..651a2816 100644 --- a/docs/functions_i.html +++ b/docs/functions_i.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_j.html b/docs/functions_j.html index 7e030ae6..90ba3247 100644 --- a/docs/functions_j.html +++ b/docs/functions_j.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_l.html b/docs/functions_l.html index 1c658fec..3c339829 100644 --- a/docs/functions_l.html +++ b/docs/functions_l.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_m.html b/docs/functions_m.html index c22cf316..5ed1cdfc 100644 --- a/docs/functions_m.html +++ b/docs/functions_m.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_n.html b/docs/functions_n.html index c9bbec8f..6017489b 100644 --- a/docs/functions_n.html +++ b/docs/functions_n.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_o.html b/docs/functions_o.html index 93d4f5ec..f445948d 100644 --- a/docs/functions_o.html +++ b/docs/functions_o.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_p.html b/docs/functions_p.html index 9611282f..4290d0e2 100644 --- a/docs/functions_p.html +++ b/docs/functions_p.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_r.html b/docs/functions_r.html index cd5285c6..431eec03 100644 --- a/docs/functions_r.html +++ b/docs/functions_r.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_s.html b/docs/functions_s.html index 4b01890b..9383b1f8 100644 --- a/docs/functions_s.html +++ b/docs/functions_s.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_t.html b/docs/functions_t.html index 6064de16..eaf21a19 100644 --- a/docs/functions_t.html +++ b/docs/functions_t.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_u.html b/docs/functions_u.html index 571b36ab..e1584004 100644 --- a/docs/functions_u.html +++ b/docs/functions_u.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_v.html b/docs/functions_v.html index c893c4b4..fca359f3 100644 --- a/docs/functions_v.html +++ b/docs/functions_v.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_vars.html b/docs/functions_vars.html index 3e94e4ca..63279064 100644 --- a/docs/functions_vars.html +++ b/docs/functions_vars.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_w.html b/docs/functions_w.html index 34c6d2f6..dbfb8e05 100644 --- a/docs/functions_w.html +++ b/docs/functions_w.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/functions_~.html b/docs/functions_~.html index 56a93d62..7a210b3b 100644 --- a/docs/functions_~.html +++ b/docs/functions_~.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/hierarchy.html b/docs/hierarchy.html index be9f95f9..ca8f9520 100644 --- a/docs/hierarchy.html +++ b/docs/hierarchy.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/index.html b/docs/index.html index 0aed7c7a..ca5a401f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
diff --git a/docs/materials_8hpp.html b/docs/materials_8hpp.html index 512e08e6..a4a98062 100644 --- a/docs/materials_8hpp.html +++ b/docs/materials_8hpp.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
@@ -80,7 +80,8 @@

Predefined material properties. More...

-
#include <glm/vec4.hpp>
+
#include <glad/gl.h>
+#include <glm/vec4.hpp>
#include <glm/gtc/type_ptr.hpp>

Go to the source code of this file.

diff --git a/docs/materials_8hpp_source.html b/docs/materials_8hpp_source.html index ec85a523..cc38709c 100644 --- a/docs/materials_8hpp_source.html +++ b/docs/materials_8hpp_source.html @@ -21,7 +21,7 @@ -
CSCI441 OpenGL Library 5.4.1 +
CSCI441 OpenGL Library 5.5.0
CS@Mines CSCI441 Computer Graphics Course Library
@@ -77,97 +77,99 @@
10#ifndef CSCI441_MATERIALS_HPP
11#define CSCI441_MATERIALS_HPP
12
-
13#include <glm/vec4.hpp>
-
14#include <glm/gtc/type_ptr.hpp>
-
15
-
16namespace CSCI441 {
+
13#include <glad/gl.h>
+
14
+
15#include <glm/vec4.hpp>
+
16#include <glm/gtc/type_ptr.hpp>
17
-
22 namespace Materials {
-
23
-
27 struct Material {
-
31 [[maybe_unused]] GLfloat diffuse[4];
-
36 [[maybe_unused]] [[nodiscard]] glm::vec4 getDiffuse() const { return glm::make_vec4(diffuse); }
-
40 [[maybe_unused]] GLfloat specular[4];
-
45 [[maybe_unused]] [[nodiscard]] glm::vec4 getSpecular() const { return glm::make_vec4(specular); }
-
49 [[maybe_unused]] GLfloat shininess;
-
53 [[maybe_unused]] GLfloat ambient[4];
-
58 [[maybe_unused]] [[nodiscard]] glm::vec4 getAmbient() const { return glm::make_vec4(ambient); }
-
59 };
-
60
-
64 [[maybe_unused]] constexpr Material BRASS = { {0.780392f, 0.568627f, 0.113725f, 1.0f}, {0.992157f, 0.941176f, 0.807843f, 1.0f},27.8974f, {0.329412f, 0.223529f, 0.027451f, 1.0f} };
-
68 [[maybe_unused]] constexpr Material BLACK_PLASTIC = { {0.01f, 0.01f, 0.01f, 1.0f}, {0.50f, 0.50f, 0.50f, 1.0f},32.0f, {0.0f, 0.0f, 0.0f, 1.0f} };
-
72 [[maybe_unused]] constexpr Material BLACK_RUBBER = { {0.01f, 0.01f, 0.01f, 1.0f}, {0.4f, 0.4f, 0.4f, 1.0f},10.0f, {0.02f, 0.02f, 0.02f, 1.0f} };
-
76 [[maybe_unused]] constexpr Material BRONZE = { {0.714f, 0.4284f, 0.18144f, 1.0f}, {0.393548f, 0.271906f, 0.166721f, 1.0f},25.6f, {0.2125f, 0.1275f, 0.054f, 1.0f} };
-
80 [[maybe_unused]] constexpr Material BRONZE_POLISHED = { {0.4f, 0.2368f, 0.1036f, 1.0f}, {0.774597f, 0.458561f, 0.200621f, 1.0f},76.8f, {0.25f, 0.148f, 0.06475f, 1.0f} };
-
84 [[maybe_unused]] constexpr Material CHROME = { {0.4f, 0.4f, 0.4f, 1.0f}, {0.774597f, 0.774597f, 0.774597f, 1.0f},76.8f, {0.25f, 0.25f, 0.25f, 1.0f} };
-
88 [[maybe_unused]] constexpr Material COPPER = { {0.7038f, 0.27048f, 0.0828f, 1.0f}, {0.256777f, 0.137622f, 0.086014f, 1.0f},12.8f, {0.19125f, 0.0735f, 0.0225f, 1.0f} };
-
92 [[maybe_unused]] constexpr Material COPPER_POLISHED = { {0.5508f, 0.2118f, 0.066f, 1.0f}, {0.580594f, 0.223257f, 0.0695701f, 1.0f},51.2f, {0.2295f, 0.08825f, 0.0275f, 1.0f} };
-
96 [[maybe_unused]] constexpr Material CYAN_PLASTIC = { {0.0f, 0.50980392f,0.50980392f,1.0f}, {0.50196078f,0.50196078f,0.50196078f,1.0f},32.0f, {0.0f, 0.1f, 0.06f , 1.0f} };
-
100 [[maybe_unused]] constexpr Material CYAN_RUBBER = { {0.4f, 0.5f, 0.5f, 1.0f}, {0.04f, 0.7f, 0.7f, 1.0f},10.0f, {0.0f, 0.05f, 0.05f, 1.0f} };
-
104 [[maybe_unused]] constexpr Material EMERALD = { {0.07568f, 0.61424f, 0.07568f, 1.0f}, {0.633f, 0.727811f, 0.633f, 1.0f},76.8f, {0.0215f, 0.1745f, 0.0215f, 1.0f} };
-
108 [[maybe_unused]] constexpr Material GOLD = { {0.75164f, 0.60648f, 0.22648f, 1.0f}, {0.628281f, 0.555802f, 0.366065f, 1.0f},51.2f, {0.24725f, 0.1995f, 0.0745f, 1.0f} };
-
112 [[maybe_unused]] constexpr Material GOLD_POLISHED = { {0.34615f, 0.3143f, 0.0903f, 1.0f}, {0.797357f, 0.723991f, 0.208006f, 1.0f},83.2f, {0.24725f, 0.2245f, 0.0645f, 1.0f} };
-
116 [[maybe_unused]] constexpr Material GREEN_PLASTIC = { {0.1f, 0.35f, 0.1f, 1.0f}, {0.45f, 0.55f, 0.45f, 1.0f},32.0f, {0.0f, 0.0f, 0.0f, 1.0f} };
-
120 [[maybe_unused]] constexpr Material GREEN_RUBBER = { {0.4f, 0.5f, 0.4f, 1.0f}, {0.04f, 0.7f, 0.04f, 1.0f},10.0f, {0.0f, 0.05f, 0.0f, 1.0f} };
-
124 [[maybe_unused]] constexpr Material JADE = { {0.54f, 0.89f, 0.63f, 1.0f}, {0.316228f, 0.316228f, 0.316228f, 1.0f},12.8f, {0.135f, 0.2225f, 0.1575f, 1.0f} };
-
128 [[maybe_unused]] constexpr Material OBSIDIAN = { {0.18275f, 0.17f, 0.22525f, 1.0f}, {0.331741f, 0.328634f, 0.346435f, 1.0f},38.4f, {0.05365f, 0.05f, 0.06625f, 1.0f} };
-
132 [[maybe_unused]] constexpr Material PEARL = { {1.0f, 0.829f, 0.829f, 1.0f}, {0.296648f, 0.296648f, 0.296648f, 1.0f},11.264f, {0.25f, 0.20725f, 0.20725f, 1.0f} };
-
136 [[maybe_unused]] constexpr Material PEWTER = { {0.427451f, 0.470588f, 0.541176f, 1.0f}, {0.333333f, 0.333333f, 0.521569f, 1.0f},9.84615f, {0.105882f, 0.058824f, 0.113725f, 1.0f} };
-
140 [[maybe_unused]] constexpr Material RED_PLASTIC = { {0.5f, 0.0f, 0.0f, 1.0f}, {0.7f, 0.6f, 0.6f, 1.0f},32.0f, {0.0f, 0.0f, 0.0f, 1.0f} };
-
144 [[maybe_unused]] constexpr Material REB_RUBBER = { {0.5f, 0.4f, 0.4f, 1.0f}, {0.7f, 0.04f, 0.04f, 1.0f},10.0f, {0.05f, 0.0f, 0.0f, 1.0f} };
-
148 [[maybe_unused]] constexpr Material RUBY = { {0.61424f, 0.04136f, 0.04136f, 1.0f}, {0.727811f, 0.626959f, 0.626959f, 1.0f},76.8f, {0.1745f, 0.01175f, 0.01175f, 1.0f} };
-
152 [[maybe_unused]] constexpr Material SILVER = { {0.50754f, 0.50754f, 0.50754f, 1.0f}, {0.508273f, 0.508273f, 0.508273f, 1.0f},51.2f, {0.19225f, 0.19225f, 0.19225f, 1.0f} };
-
156 [[maybe_unused]] constexpr Material SILVER_POLISHED = { {0.2775f, 0.2775f, 0.2775f, 1.0f}, {0.773911f, 0.773911f, 0.773911f, 1.0f},89.6f, {0.23125f, 0.23125f, 0.23125f, 1.0f} };
-
160 [[maybe_unused]] constexpr Material TIN = { {0.427451f, 0.470588f, 0.541176f, 1.0f}, {0.333333f, 0.333333f, 0.521569f, 1.0f},9.84615f, {0.105882f, 0.058824f, 0.113725f, 1.0f} };
-
164 [[maybe_unused]] constexpr Material TURQUOISE = { {0.396f, 0.74151f, 0.69102f, 1.0f}, {0.297254f, 0.30829f, 0.306678f, 1.0f},12.8f, {0.1f, 0.18725f, 0.1745f, 1.0f} };
-
168 [[maybe_unused]] constexpr Material WHITE_PLASTIC = { {0.55f, 0.55f, 0.55f, 1.0f}, {0.70f, 0.70f, 0.70f, 1.0f},32.0f, {0.0f, 0.0f, 0.0f, 1.0f} };
-
172 [[maybe_unused]] constexpr Material WHITE_RUBBER = { {0.5f, 0.5f, 0.5f, 1.0f}, {0.7f, 0.7f, 0.7f, 1.0f},10.0f, {0.05f, 0.05f, 0.05f, 1.0f} };
-
176 [[maybe_unused]] constexpr Material YELLOW_PLASTIC = { {0.5f, 0.5f, 0.0f, 1.0f}, {0.60f, 0.60f, 0.50f, 1.0f},32.0f, {0.0f, 0.0f, 0.0f, 1.0f} };
-
180 [[maybe_unused]] constexpr Material YELLOW_RUBBER = { {0.5f, 0.5f, 0.4f, 1.0f}, {0.7f, 0.7f, 0.04f, 1.0f},10.0f, {0.05f, 0.05f, 0.0f, 1.0f} };
-
181 }
-
182}
-
183
-
184#endif // CSCI441_MATERIALS_HPP
-
constexpr Material BRASS
brass material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free....
Definition: materials.hpp:64
-
constexpr Material BLACK_PLASTIC
plastic black material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:68
-
constexpr Material JADE
jade material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free....
Definition: materials.hpp:124
-
constexpr Material BLACK_RUBBER
black rubber material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:72
-
constexpr Material GOLD_POLISHED
polished gold material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:112
-
constexpr Material TIN
tin material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free.fr/cours/opengl/mate...
Definition: materials.hpp:160
-
constexpr Material GOLD
gold material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free....
Definition: materials.hpp:108
-
constexpr Material RUBY
ruby material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free....
Definition: materials.hpp:148
-
constexpr Material YELLOW_PLASTIC
plastic yellow material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:176
-
constexpr Material OBSIDIAN
obsidian material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free....
Definition: materials.hpp:128
-
constexpr Material REB_RUBBER
red rubber material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:144
-
constexpr Material TURQUOISE
turquoise material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:164
-
constexpr Material GREEN_PLASTIC
plastic green material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:116
-
constexpr Material COPPER
copper material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free....
Definition: materials.hpp:88
-
constexpr Material SILVER
silver material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free....
Definition: materials.hpp:152
-
constexpr Material SILVER_POLISHED
polished silver material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:156
-
constexpr Material WHITE_PLASTIC
plastic white material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:168
-
constexpr Material WHITE_RUBBER
white rubber material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:172
-
constexpr Material PEWTER
pewter material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free....
Definition: materials.hpp:136
-
constexpr Material BRONZE
bronze material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free....
Definition: materials.hpp:76
-
constexpr Material RED_PLASTIC
plastic red material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:140
-
constexpr Material COPPER_POLISHED
polished copper material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:92
-
constexpr Material YELLOW_RUBBER
yellow rubber material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:180
-
constexpr Material CYAN_RUBBER
cyan rubber material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:100
-
constexpr Material EMERALD
emerald material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free....
Definition: materials.hpp:104
-
constexpr Material CHROME
chrome material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free....
Definition: materials.hpp:84
-
constexpr Material CYAN_PLASTIC
plastic cyan material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:96
-
constexpr Material BRONZE_POLISHED
polished bronze material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:80
-
constexpr Material PEARL
pearl material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free....
Definition: materials.hpp:132
-
constexpr Material GREEN_RUBBER
green rubber material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:120
+
18namespace CSCI441 {
+
19
+
24 namespace Materials {
+
25
+
29 struct Material {
+
33 [[maybe_unused]] GLfloat diffuse[4];
+
38 [[maybe_unused]] [[nodiscard]] glm::vec4 getDiffuse() const { return glm::make_vec4(diffuse); }
+
42 [[maybe_unused]] GLfloat specular[4];
+
47 [[maybe_unused]] [[nodiscard]] glm::vec4 getSpecular() const { return glm::make_vec4(specular); }
+
51 [[maybe_unused]] GLfloat shininess;
+
55 [[maybe_unused]] GLfloat ambient[4];
+
60 [[maybe_unused]] [[nodiscard]] glm::vec4 getAmbient() const { return glm::make_vec4(ambient); }
+
61 };
+
62
+
66 [[maybe_unused]] constexpr Material BRASS = { {0.780392f, 0.568627f, 0.113725f, 1.0f}, {0.992157f, 0.941176f, 0.807843f, 1.0f},27.8974f, {0.329412f, 0.223529f, 0.027451f, 1.0f} };
+
70 [[maybe_unused]] constexpr Material BLACK_PLASTIC = { {0.01f, 0.01f, 0.01f, 1.0f}, {0.50f, 0.50f, 0.50f, 1.0f},32.0f, {0.0f, 0.0f, 0.0f, 1.0f} };
+
74 [[maybe_unused]] constexpr Material BLACK_RUBBER = { {0.01f, 0.01f, 0.01f, 1.0f}, {0.4f, 0.4f, 0.4f, 1.0f},10.0f, {0.02f, 0.02f, 0.02f, 1.0f} };
+
78 [[maybe_unused]] constexpr Material BRONZE = { {0.714f, 0.4284f, 0.18144f, 1.0f}, {0.393548f, 0.271906f, 0.166721f, 1.0f},25.6f, {0.2125f, 0.1275f, 0.054f, 1.0f} };
+
82 [[maybe_unused]] constexpr Material BRONZE_POLISHED = { {0.4f, 0.2368f, 0.1036f, 1.0f}, {0.774597f, 0.458561f, 0.200621f, 1.0f},76.8f, {0.25f, 0.148f, 0.06475f, 1.0f} };
+
86 [[maybe_unused]] constexpr Material CHROME = { {0.4f, 0.4f, 0.4f, 1.0f}, {0.774597f, 0.774597f, 0.774597f, 1.0f},76.8f, {0.25f, 0.25f, 0.25f, 1.0f} };
+
90 [[maybe_unused]] constexpr Material COPPER = { {0.7038f, 0.27048f, 0.0828f, 1.0f}, {0.256777f, 0.137622f, 0.086014f, 1.0f},12.8f, {0.19125f, 0.0735f, 0.0225f, 1.0f} };
+
94 [[maybe_unused]] constexpr Material COPPER_POLISHED = { {0.5508f, 0.2118f, 0.066f, 1.0f}, {0.580594f, 0.223257f, 0.0695701f, 1.0f},51.2f, {0.2295f, 0.08825f, 0.0275f, 1.0f} };
+
98 [[maybe_unused]] constexpr Material CYAN_PLASTIC = { {0.0f, 0.50980392f,0.50980392f,1.0f}, {0.50196078f,0.50196078f,0.50196078f,1.0f},32.0f, {0.0f, 0.1f, 0.06f , 1.0f} };
+
102 [[maybe_unused]] constexpr Material CYAN_RUBBER = { {0.4f, 0.5f, 0.5f, 1.0f}, {0.04f, 0.7f, 0.7f, 1.0f},10.0f, {0.0f, 0.05f, 0.05f, 1.0f} };
+
106 [[maybe_unused]] constexpr Material EMERALD = { {0.07568f, 0.61424f, 0.07568f, 1.0f}, {0.633f, 0.727811f, 0.633f, 1.0f},76.8f, {0.0215f, 0.1745f, 0.0215f, 1.0f} };
+
110 [[maybe_unused]] constexpr Material GOLD = { {0.75164f, 0.60648f, 0.22648f, 1.0f}, {0.628281f, 0.555802f, 0.366065f, 1.0f},51.2f, {0.24725f, 0.1995f, 0.0745f, 1.0f} };
+
114 [[maybe_unused]] constexpr Material GOLD_POLISHED = { {0.34615f, 0.3143f, 0.0903f, 1.0f}, {0.797357f, 0.723991f, 0.208006f, 1.0f},83.2f, {0.24725f, 0.2245f, 0.0645f, 1.0f} };
+
118 [[maybe_unused]] constexpr Material GREEN_PLASTIC = { {0.1f, 0.35f, 0.1f, 1.0f}, {0.45f, 0.55f, 0.45f, 1.0f},32.0f, {0.0f, 0.0f, 0.0f, 1.0f} };
+
122 [[maybe_unused]] constexpr Material GREEN_RUBBER = { {0.4f, 0.5f, 0.4f, 1.0f}, {0.04f, 0.7f, 0.04f, 1.0f},10.0f, {0.0f, 0.05f, 0.0f, 1.0f} };
+
126 [[maybe_unused]] constexpr Material JADE = { {0.54f, 0.89f, 0.63f, 1.0f}, {0.316228f, 0.316228f, 0.316228f, 1.0f},12.8f, {0.135f, 0.2225f, 0.1575f, 1.0f} };
+
130 [[maybe_unused]] constexpr Material OBSIDIAN = { {0.18275f, 0.17f, 0.22525f, 1.0f}, {0.331741f, 0.328634f, 0.346435f, 1.0f},38.4f, {0.05365f, 0.05f, 0.06625f, 1.0f} };
+
134 [[maybe_unused]] constexpr Material PEARL = { {1.0f, 0.829f, 0.829f, 1.0f}, {0.296648f, 0.296648f, 0.296648f, 1.0f},11.264f, {0.25f, 0.20725f, 0.20725f, 1.0f} };
+
138 [[maybe_unused]] constexpr Material PEWTER = { {0.427451f, 0.470588f, 0.541176f, 1.0f}, {0.333333f, 0.333333f, 0.521569f, 1.0f},9.84615f, {0.105882f, 0.058824f, 0.113725f, 1.0f} };
+
142 [[maybe_unused]] constexpr Material RED_PLASTIC = { {0.5f, 0.0f, 0.0f, 1.0f}, {0.7f, 0.6f, 0.6f, 1.0f},32.0f, {0.0f, 0.0f, 0.0f, 1.0f} };
+
146 [[maybe_unused]] constexpr Material REB_RUBBER = { {0.5f, 0.4f, 0.4f, 1.0f}, {0.7f, 0.04f, 0.04f, 1.0f},10.0f, {0.05f, 0.0f, 0.0f, 1.0f} };
+
150 [[maybe_unused]] constexpr Material RUBY = { {0.61424f, 0.04136f, 0.04136f, 1.0f}, {0.727811f, 0.626959f, 0.626959f, 1.0f},76.8f, {0.1745f, 0.01175f, 0.01175f, 1.0f} };
+
154 [[maybe_unused]] constexpr Material SILVER = { {0.50754f, 0.50754f, 0.50754f, 1.0f}, {0.508273f, 0.508273f, 0.508273f, 1.0f},51.2f, {0.19225f, 0.19225f, 0.19225f, 1.0f} };
+
158 [[maybe_unused]] constexpr Material SILVER_POLISHED = { {0.2775f, 0.2775f, 0.2775f, 1.0f}, {0.773911f, 0.773911f, 0.773911f, 1.0f},89.6f, {0.23125f, 0.23125f, 0.23125f, 1.0f} };
+
162 [[maybe_unused]] constexpr Material TIN = { {0.427451f, 0.470588f, 0.541176f, 1.0f}, {0.333333f, 0.333333f, 0.521569f, 1.0f},9.84615f, {0.105882f, 0.058824f, 0.113725f, 1.0f} };
+
166 [[maybe_unused]] constexpr Material TURQUOISE = { {0.396f, 0.74151f, 0.69102f, 1.0f}, {0.297254f, 0.30829f, 0.306678f, 1.0f},12.8f, {0.1f, 0.18725f, 0.1745f, 1.0f} };
+
170 [[maybe_unused]] constexpr Material WHITE_PLASTIC = { {0.55f, 0.55f, 0.55f, 1.0f}, {0.70f, 0.70f, 0.70f, 1.0f},32.0f, {0.0f, 0.0f, 0.0f, 1.0f} };
+
174 [[maybe_unused]] constexpr Material WHITE_RUBBER = { {0.5f, 0.5f, 0.5f, 1.0f}, {0.7f, 0.7f, 0.7f, 1.0f},10.0f, {0.05f, 0.05f, 0.05f, 1.0f} };
+
178 [[maybe_unused]] constexpr Material YELLOW_PLASTIC = { {0.5f, 0.5f, 0.0f, 1.0f}, {0.60f, 0.60f, 0.50f, 1.0f},32.0f, {0.0f, 0.0f, 0.0f, 1.0f} };
+
182 [[maybe_unused]] constexpr Material YELLOW_RUBBER = { {0.5f, 0.5f, 0.4f, 1.0f}, {0.7f, 0.7f, 0.04f, 1.0f},10.0f, {0.05f, 0.05f, 0.0f, 1.0f} };
+
183 }
+
184}
+
185
+
186#endif // CSCI441_MATERIALS_HPP
+
constexpr Material BRASS
brass material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free....
Definition: materials.hpp:66
+
constexpr Material BLACK_PLASTIC
plastic black material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:70
+
constexpr Material JADE
jade material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free....
Definition: materials.hpp:126
+
constexpr Material BLACK_RUBBER
black rubber material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:74
+
constexpr Material GOLD_POLISHED
polished gold material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:114
+
constexpr Material TIN
tin material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free.fr/cours/opengl/mate...
Definition: materials.hpp:162
+
constexpr Material GOLD
gold material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free....
Definition: materials.hpp:110
+
constexpr Material RUBY
ruby material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free....
Definition: materials.hpp:150
+
constexpr Material YELLOW_PLASTIC
plastic yellow material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:178
+
constexpr Material OBSIDIAN
obsidian material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free....
Definition: materials.hpp:130
+
constexpr Material REB_RUBBER
red rubber material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:146
+
constexpr Material TURQUOISE
turquoise material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:166
+
constexpr Material GREEN_PLASTIC
plastic green material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:118
+
constexpr Material COPPER
copper material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free....
Definition: materials.hpp:90
+
constexpr Material SILVER
silver material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free....
Definition: materials.hpp:154
+
constexpr Material SILVER_POLISHED
polished silver material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:158
+
constexpr Material WHITE_PLASTIC
plastic white material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:170
+
constexpr Material WHITE_RUBBER
white rubber material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:174
+
constexpr Material PEWTER
pewter material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free....
Definition: materials.hpp:138
+
constexpr Material BRONZE
bronze material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free....
Definition: materials.hpp:78
+
constexpr Material RED_PLASTIC
plastic red material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:142
+
constexpr Material COPPER_POLISHED
polished copper material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:94
+
constexpr Material YELLOW_RUBBER
yellow rubber material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:182
+
constexpr Material CYAN_RUBBER
cyan rubber material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:102
+
constexpr Material EMERALD
emerald material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free....
Definition: materials.hpp:106
+
constexpr Material CHROME
chrome material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free....
Definition: materials.hpp:86
+
constexpr Material CYAN_PLASTIC
plastic cyan material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:98
+
constexpr Material BRONZE_POLISHED
polished bronze material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:82
+
constexpr Material PEARL
pearl material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay.free....
Definition: materials.hpp:134
+
constexpr Material GREEN_RUBBER
green rubber material from teapots.c demo SGI 1994, Mark J. Kilgard (http://devernay....
Definition: materials.hpp:122
CSCI441 Helper Functions for OpenGL.
Definition: ArcballCam.hpp:17
Material Helpers for Phong Reflectance Model.
-
stores material properties used within the Phong Reflectance Model
Definition: materials.hpp:27
-
GLfloat shininess
Shininess value to control exponential falloff of Specular Reflectance.
Definition: materials.hpp:49
-
glm::vec4 getSpecular() const
RGBA values for Specular Reflectance.
Definition: materials.hpp:45
-
glm::vec4 getAmbient() const
RGBA values for Ambient Reflectance.
Definition: materials.hpp:58
-
GLfloat diffuse[4]
RGBA values for Diffuse (Lambertian) Reflectance.
Definition: materials.hpp:31
-
GLfloat ambient[4]
RGBA values for Ambient Illumination.
Definition: materials.hpp:53
-
GLfloat specular[4]
RGBA values for Specular Reflectance.
Definition: materials.hpp:40
-
glm::vec4 getDiffuse() const
RGBA values for Diffuse Reflectance.
Definition: materials.hpp:36
+
stores material properties used within the Phong Reflectance Model
Definition: materials.hpp:29
+
GLfloat shininess
Shininess value to control exponential falloff of Specular Reflectance.
Definition: materials.hpp:51
+
glm::vec4 getSpecular() const
RGBA values for Specular Reflectance.
Definition: materials.hpp:47
+
glm::vec4 getAmbient() const
RGBA values for Ambient Reflectance.
Definition: materials.hpp:60
+
GLfloat diffuse[4]
RGBA values for Diffuse (Lambertian) Reflectance.
Definition: materials.hpp:33
+
GLfloat ambient[4]
RGBA values for Ambient Illumination.
Definition: materials.hpp:55
+
GLfloat specular[4]
RGBA values for Specular Reflectance.
Definition: materials.hpp:42
+
glm::vec4 getDiffuse() const
RGBA values for Diffuse Reflectance.
Definition: materials.hpp:38