New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Contradiction In OpenGLShader::PreProcess #120
Comments
You should make a PR which implements this. |
Inside the while loop:
See my explanation above (number 4), it can never be npos as it would've been asserted before.
If the file would end with the Am I missing something here (as in, is there an actual bug), or did I clearify the inner workings a bit more in depth? Since I won't take a conclusion now, I won't mark this as a bug, nor closing it as not a bug (for now). Kind regards |
@LovelySanta Ok, so thank you for trying to explain this to me.
The initial reason for me creating this issue was rooted in the I said It seems you can't pass Secondly. I do believe that Just for reference this is how it would be written for me. size_t nextLinePos = source.find_first_not_of("\r\n", eol);
HZ_ASSERT(nextLinePos != std::string::npos, "Syntax Error");
pos = source.find(typeToken, nextLinePos);
shaderSources[ShaderTypeFromString(type)] = source.substr(nextLinePos, (pos == std::string::npos ? source.size() - nextLinePos : pos - nextLinePos)); |
Two things:
pos = source.find(typeToken, nextLinePos);
shaderSources[ShaderTypeFromString(type)] = source.substr(nextLinePos, (pos == std::string::npos ? source.size() - 1 : pos) - nextLinePos);
The first is an issue for sure, the 2nd is more a suggestion. I'll mark this as a bug, and feel free to make a PR to implement both. |
In
PreProcess
function, inside the while loop on the lastsubstr
. The second parameter checks to see ifnextLinePos == std::string::npos
and returnssource.size() - 1
. I'm not sure how this makes sense, furthermore we are passing nextLinePos as the first parameter; It seems if you passstd::string::npos
as the first parameter ofsubstr
the program crashes, the second parameter checking fornextLinePos == std::string::npos
doesn't make sense. but I've not hard anyone complaining about this so maybe I don't understand what is really going on here?If you create a shader that specifies a tokenType like
#vertex
and the file ends on that line I think the program would crash. I would ASSERT this and throw a syntax error message for this as well.The text was updated successfully, but these errors were encountered: