I am using Visual Studio 2022. I am trying to create a program that can read file like shaders. It would allow me not to have every single piece of code in the same file...
So, to clarify what I am trying to do:
- I have written a shader in a separate file
- I want to read this file
- Then I want to build the shader from the file I just read
For that I tried to play around with "string", "stringstream"... I manage to get that :
std::string readShader(const char* path){
std::string shader;
std::ifstream file;
file.open(path, std::ios::in);
if (file.is_open()) {
std::stringstream code;
code << file.rdbuf();
shader = code.str();
file.close();
}
return shader;
}
I am not sure of the issue, but I was not able to build the shader.
In fact, I tried to print what I get by reading the file...
Sometimes I get the shader and it is amazing but... I also get that kind of thing : ázý▓l☻
So, it surely is the issue.
I mean, what is that: ázý▓l☻
?
Why do I get that?
That is not the content of my file!
I think it is because my function "return" something that end up deleted (or a part of it...).
Could you explain me what is the issue? how to solve it? and also why do I get that?