mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-20 07:11:12 -06:00 
			
		
		
		
	Introduction of classes ColorRGB and ColorRGBA to unify color data definition and manipulation
(cherry picked from commit prusa3d/PrusaSlicer@d0bff2d996 )
This commit is contained in:
		
							parent
							
								
									36ffb18059
								
							
						
					
					
						commit
						28d0147d09
					
				
					 60 changed files with 1290 additions and 1174 deletions
				
			
		|  | @ -4,6 +4,7 @@ | |||
| #include "3DScene.hpp" | ||||
| #include "libslic3r/Utils.hpp" | ||||
| #include "libslic3r/format.hpp" | ||||
| #include "libslic3r/Color.hpp" | ||||
| 
 | ||||
| #include <boost/nowide/fstream.hpp> | ||||
| #include <GL/glew.h> | ||||
|  | @ -206,154 +207,114 @@ void GLShaderProgram::stop_using() const | |||
|     glsafe(::glUseProgram(0)); | ||||
| } | ||||
| 
 | ||||
| bool GLShaderProgram::set_uniform(const char* name, int value) const | ||||
| void GLShaderProgram::set_uniform(int id, int value) const | ||||
| { | ||||
|     int id = get_uniform_location(name); | ||||
|     if (id >= 0) { | ||||
|         glsafe(::glUniform1i(id, static_cast<GLint>(value))); | ||||
|         return true; | ||||
|     } | ||||
|     return false; | ||||
|     if (id >= 0) | ||||
|         glsafe(::glUniform1i(id, value)); | ||||
| } | ||||
| 
 | ||||
| bool GLShaderProgram::set_uniform(const char* name, bool value) const | ||||
| void GLShaderProgram::set_uniform(int id, bool value) const | ||||
| { | ||||
|     return set_uniform(name, value ? 1 : 0); | ||||
|     set_uniform(id, value ? 1 : 0); | ||||
| } | ||||
| 
 | ||||
| bool GLShaderProgram::set_uniform(const char* name, float value) const | ||||
| void GLShaderProgram::set_uniform(int id, float value) const | ||||
| { | ||||
|     int id = get_uniform_location(name); | ||||
|     if (id >= 0) { | ||||
|         glsafe(::glUniform1f(id, static_cast<GLfloat>(value))); | ||||
|         return true; | ||||
|     } | ||||
|     return false; | ||||
|     if (id >= 0) | ||||
|         glsafe(::glUniform1f(id, value)); | ||||
| } | ||||
| 
 | ||||
| bool GLShaderProgram::set_uniform(const char* name, double value) const | ||||
| void GLShaderProgram::set_uniform(int id, double value) const | ||||
| { | ||||
|     return set_uniform(name, static_cast<float>(value)); | ||||
|     set_uniform(id, static_cast<float>(value)); | ||||
| } | ||||
| 
 | ||||
| bool GLShaderProgram::set_uniform(const char* name, const std::array<int, 2>& value) const | ||||
| void GLShaderProgram::set_uniform(int id, const std::array<int, 2>& value) const | ||||
| { | ||||
|     int id = get_uniform_location(name); | ||||
|     if (id >= 0) { | ||||
|     if (id >= 0) | ||||
|         glsafe(::glUniform2iv(id, 1, static_cast<const GLint*>(value.data()))); | ||||
|         return true; | ||||
|     } | ||||
|     return false; | ||||
| } | ||||
| 
 | ||||
| bool GLShaderProgram::set_uniform(const char* name, const std::array<int, 3>& value) const | ||||
| void GLShaderProgram::set_uniform(int id, const std::array<int, 3>& value) const | ||||
| { | ||||
|     int id = get_uniform_location(name); | ||||
|     if (id >= 0) { | ||||
|     if (id >= 0) | ||||
|         glsafe(::glUniform3iv(id, 1, static_cast<const GLint*>(value.data()))); | ||||
|         return true; | ||||
|     } | ||||
|     return false; | ||||
| } | ||||
| 
 | ||||
| bool GLShaderProgram::set_uniform(const char* name, const std::array<int, 4>& value) const | ||||
| void GLShaderProgram::set_uniform(int id, const std::array<int, 4>& value) const | ||||
| { | ||||
|     int id = get_uniform_location(name); | ||||
|     if (id >= 0) { | ||||
|     if (id >= 0) | ||||
|         glsafe(::glUniform4iv(id, 1, static_cast<const GLint*>(value.data()))); | ||||
|         return true; | ||||
|     } | ||||
|     return false; | ||||
| } | ||||
| 
 | ||||
| bool GLShaderProgram::set_uniform(const char* name, const std::array<float, 2>& value) const | ||||
| void GLShaderProgram::set_uniform(int id, const std::array<float, 2>& value) const | ||||
| { | ||||
|     int id = get_uniform_location(name); | ||||
|     if (id >= 0) { | ||||
|     if (id >= 0) | ||||
|         glsafe(::glUniform2fv(id, 1, static_cast<const GLfloat*>(value.data()))); | ||||
|         return true; | ||||
|     } | ||||
|     return false; | ||||
| } | ||||
| 
 | ||||
| bool GLShaderProgram::set_uniform(const char* name, const std::array<float, 3>& value) const | ||||
| void GLShaderProgram::set_uniform(int id, const std::array<float, 3>& value) const | ||||
| { | ||||
|     int id = get_uniform_location(name); | ||||
|     if (id >= 0) { | ||||
|     if (id >= 0) | ||||
|         glsafe(::glUniform3fv(id, 1, static_cast<const GLfloat*>(value.data()))); | ||||
|         return true; | ||||
|     } | ||||
|     return false; | ||||
| } | ||||
| 
 | ||||
| bool GLShaderProgram::set_uniform(const char* name, const std::array<float, 4>& value) const | ||||
| void GLShaderProgram::set_uniform(int id, const std::array<float, 4>& value) const | ||||
| { | ||||
|     int id = get_uniform_location(name); | ||||
|     if (id >= 0) { | ||||
|     if (id >= 0) | ||||
|         glsafe(::glUniform4fv(id, 1, static_cast<const GLfloat*>(value.data()))); | ||||
|         return true; | ||||
|     } | ||||
|     return false; | ||||
| } | ||||
| 
 | ||||
| bool GLShaderProgram::set_uniform(const char* name, const float* value, size_t size) const | ||||
| void GLShaderProgram::set_uniform(int id, const float* value, size_t size) const | ||||
| { | ||||
|     if (size == 1) | ||||
|         return set_uniform(name, value[0]); | ||||
|     else if (size < 5) { | ||||
|         int id = get_uniform_location(name); | ||||
|         if (id >= 0) { | ||||
|             if (size == 2) | ||||
|                 glsafe(::glUniform2fv(id, 1, static_cast<const GLfloat*>(value))); | ||||
|             else if (size == 3) | ||||
|                 glsafe(::glUniform3fv(id, 1, static_cast<const GLfloat*>(value))); | ||||
|             else | ||||
|                 glsafe(::glUniform4fv(id, 1, static_cast<const GLfloat*>(value))); | ||||
| 
 | ||||
|             return true; | ||||
|         } | ||||
|     } | ||||
|     return false; | ||||
| } | ||||
| 
 | ||||
| bool GLShaderProgram::set_uniform(const char* name, const Transform3f& value) const | ||||
| { | ||||
|     int id = get_uniform_location(name); | ||||
|     if (id >= 0) { | ||||
|         if (size == 1) | ||||
|             set_uniform(id, value[0]); | ||||
|         else if (size == 2) | ||||
|             glsafe(::glUniform2fv(id, 1, static_cast<const GLfloat*>(value))); | ||||
|         else if (size == 3) | ||||
|             glsafe(::glUniform3fv(id, 1, static_cast<const GLfloat*>(value))); | ||||
|         else if (size == 4) | ||||
|             glsafe(::glUniform4fv(id, 1, static_cast<const GLfloat*>(value))); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void GLShaderProgram::set_uniform(int id, const Transform3f& value) const | ||||
| { | ||||
|     if (id >= 0) | ||||
|         glsafe(::glUniformMatrix4fv(id, 1, GL_FALSE, static_cast<const GLfloat*>(value.matrix().data()))); | ||||
|         return true; | ||||
|     } | ||||
|     return false; | ||||
| } | ||||
| 
 | ||||
| bool GLShaderProgram::set_uniform(const char* name, const Transform3d& value) const | ||||
| void GLShaderProgram::set_uniform(int id, const Transform3d& value) const | ||||
| { | ||||
|     return set_uniform(name, value.cast<float>()); | ||||
|     set_uniform(id, value.cast<float>()); | ||||
| } | ||||
| 
 | ||||
| bool GLShaderProgram::set_uniform(const char* name, const Matrix3f& value) const | ||||
| void GLShaderProgram::set_uniform(int id, const Matrix3f& value) const | ||||
| { | ||||
|     int id = get_uniform_location(name); | ||||
|     if (id >= 0) { | ||||
|     if (id >= 0) | ||||
|         glsafe(::glUniformMatrix3fv(id, 1, GL_FALSE, static_cast<const GLfloat*>(value.data()))); | ||||
|         return true; | ||||
|     } | ||||
|     return false; | ||||
| } | ||||
| 
 | ||||
| bool GLShaderProgram::set_uniform(const char* name, const Vec3f& value) const | ||||
| void GLShaderProgram::set_uniform(int id, const Vec3f& value) const | ||||
| { | ||||
|     int id = get_uniform_location(name); | ||||
|     if (id >= 0) { | ||||
|     if (id >= 0) | ||||
|         glsafe(::glUniform3fv(id, 1, static_cast<const GLfloat*>(value.data()))); | ||||
|         return true; | ||||
|     } | ||||
|     return false; | ||||
| } | ||||
| 
 | ||||
| bool GLShaderProgram::set_uniform(const char* name, const Vec3d& value) const | ||||
| void GLShaderProgram::set_uniform(int id, const Vec3d& value) const | ||||
| { | ||||
|     return set_uniform(name, static_cast<Vec3f>(value.cast<float>())); | ||||
|     set_uniform(id, static_cast<Vec3f>(value.cast<float>())); | ||||
| } | ||||
| 
 | ||||
| void GLShaderProgram::set_uniform(int id, const ColorRGB& value) const | ||||
| { | ||||
|     set_uniform(id, value.data(), 3); | ||||
| } | ||||
| 
 | ||||
| void GLShaderProgram::set_uniform(int id, const ColorRGBA& value) const | ||||
| { | ||||
|     set_uniform(id, value.data(), 4); | ||||
| } | ||||
| 
 | ||||
| int GLShaderProgram::get_attrib_location(const char* name) const | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 enricoturri1966
						enricoturri1966