Closed Senryoku closed 10 years ago
Hi, thanks for reporting this.
Could you try the following and let me know if it worked?
In include/oglplus/auxiliary/glsl_source.hpp
replace std::istream
by std::ifstream
in InputStreamGLSLSrcWrap
constructor and _check_and_get_size
and do the same also in
implement/oglplus/auxiliary/glsl_source.ipp
. Checking the size of a file stream IMO should be reliable.
Thanks for the quick answer ! Same problem using an ifstream. CRLF seems to mess it up : I think each new line is counted twice. (I'm using MinGW btw). (see http://stackoverflow.com/questions/1631288/better-way-to-determine-length-of-a-stdistream)
Hmm, that's strange. I get what the problem can be with a stdin, pipe or socket istreams, but WTH does it not work with regular files? Anyway, I'll reimplement it during the weekend and let you know.
OK, I've done the following: The size is determined as before, but the data are not read by a single call to istream::read but instead by using std::istreambuf_iterator. This should be both efficient if the size can be determined reliably and robust even if it cannot. The change has been push to develop (commit f3285562dcc5321b09da5c439abd524e290ae0dc).
HTH
I've made some further changes to _check_and_get_size
, hopefully it'll work now with any istream properly.
Your changes did the trick, loading from a file seems to work flawlessly for me now. Thanks a lot !
Hi, I am new to oglplus, and having some troubles with GLSLSource::FromFile(), the resulting GLSLSource instance doesn't appear to be valid : I get a compilation error for the shader after passing it to ShaderOps::Source(). However this issue only appears on one computer (Windows 7 with AMD GPU), after some research and digging into the sources, it seems that the value returned by
and therefore GLSLSource::Lengths() is wrong : Using an hard coded value for the length and manually passing the tree arguments to ShaderOps::Source solves the problem.
The original source looks like this :
I read that counting characters from an istream cannot be completely reliable, could this be a bug, or am I doing something wrong ? (I checked my shader file, rewrote it from scratch to avoid any copy/paste bull**\ etc...)
Thanks !