8 const std::string& _fragmentShader)
9 : program_handle(0), vertex_shader_handle(0), fragment_shader_handle(0), shader_in_use(false)
15 std::cout <<
"Could not create shader program!" << std::endl;
50 GLuint& _shaderHandle)
52 std::ifstream shader_file(_path_to_shader);
53 if (shader_file.good())
56 std::string str_code = std::string( std::istreambuf_iterator<char>(shader_file),
57 std::istreambuf_iterator<char>());
61 _shaderHandle = glCreateShader(_shaderType);
62 if (_shaderHandle == 0)
64 std::cout <<
"Failed to create shader handle!" << std::endl;
70 const char* code_Ptr = str_code.c_str();
71 glShaderSource(_shaderHandle,1,&code_Ptr,NULL);
72 glCompileShader(_shaderHandle);
76 glGetShaderiv(_shaderHandle,GL_COMPILE_STATUS,&success);
77 if (success == GL_FALSE || !glIsShader(_shaderHandle))
81 glGetShaderiv(_shaderHandle,GL_INFO_LOG_LENGTH,&log_size);
82 GLchar* log_content_Ptr =
new char[log_size];
84 glGetShaderInfoLog(_shaderHandle,log_size,NULL,log_content_Ptr);
85 std::cout <<
"Failed to compile shader:\n" << log_content_Ptr << std::endl;
87 delete [] log_content_Ptr;
95 std::cout <<
"Failed to open shader source code file \"" << _path_to_shader <<
"\" !" << std::endl;
123 glGetProgramiv(this->
program_handle,GL_INFO_LOG_LENGTH,&log_size);
125 GLchar* log_content_Ptr =
new char[log_size];
126 glGetProgramInfoLog(this->
program_handle,log_size,NULL,log_content_Ptr);
128 std::cout <<
"Failed to link shader program:\n" << log_content_Ptr << std::endl;
130 delete [] log_content_Ptr;