Thank you for your quick answer. I started with const char* because this is what compileShader() is expecting. Following your advice, I replaced it by std::string. Here below is what I am doing now, so it can help someone else. No more memory leaks, feeling great!
bool Shader::loadShader(std::string shaderName, ShaderType shaderType, std::string vertexShaderFile, std::string fragmentShaderFile) {
GLuint vertexShaderID, fragmentShaderID;
m_shaderID = glCreateProgram();
m_shaderType = shaderType;
compileShader(vertexShaderID, GL_VERTEX_SHADER, readShader(vertexShaderFile).c_str());
compileShader(fragmentShaderID, GL_FRAGMENT_SHADER, readShader(fragmentShaderFile).c_str());
linkShader(m_shaderID, vertexShaderID, fragmentShaderID);
glDeleteShader(vertexShaderID);
glDeleteShader(fragmentShaderID);
glUseProgram(0);
return true;
}
std::string Shader::readShader(std::string shaderFile) {
std::ifstream shaderStream;
std::stringstream stringStream;
shaderStream.open(shaderFile);
stringStream << shaderStream.rdbuf();//read the file
shaderStream.close();
std::string shaderSource = stringStream.str();//str holds the content of the file
logFileStderr(VERBOSE, "Code shader program \"%s\"...\n", shaderSource.c_str());
return shaderSource;
}