Well I've been trying to read a .cso file to use as a shader for a DirectX program I'm currently making.
Problem is no matter how I implemented a way to read the file it never worked. And after fidgeting around I discover that it's only the .cso files I can't read.
I can read anything else (which means it works) even their .hlsl files. Which is strange because the .hlsl (high level shader language) files are supposed to turn into .cso (compiled shader object) files.
What I'm currently doing is:
vector<byte> Read(string File){
vector<byte> Text;
fstream file(File, ios::in | ios::ate | ios::binary);
if(file.is_open()){
Text.resize(file.tellg());
file.seekg(0 , ios::beg);
file.read(reinterpret_cast<char*>(&Text[0]), Text.size());
file.close();
}
return Text;
};
If I then implement it.
Read("VertexShader.hlsl"); //Works
Read("VertexShader.cso"); //Doesn't Works?!?!
And I need the .cso version of the shader to draw my sexy triangles. Without it my life and application will never continue and I have no idea what could be wrong.
EDIT #1: When I read the .hlsl file the vector get's filled whit what was written in the file. For the .cso ones the function doesn't even pass the "if(file.is_open)" test and stays empty.
ios::ate
to thefstream
constructor, instead open the file, thenseekg
to the end to figure out the size? \$\endgroup\$