Skip to content
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

Please ignore Raw string literals. #126

Closed
DaveHoskins opened this issue Aug 27, 2018 · 5 comments
Closed

Please ignore Raw string literals. #126

DaveHoskins opened this issue Aug 27, 2018 · 5 comments

Comments

@DaveHoskins
Copy link

Hi, I'd like to #include my shaders with my source code, unfortunately I can't put
R"( and )" around my shader because the syntax high-lighting gets completely removed.
Is there anyway it can just ignore the R"( at the start of the code?
Thanks.

@DaveHoskins DaveHoskins changed the title Please ignore Raw string literals? Please ignore Raw string literals. Aug 27, 2018
@tgjones
Copy link
Owner

tgjones commented Jul 3, 2019

Do you mean you're adding R"( and )" in HLSL code, or C++ code? I didn't think HLSL supports raw string literals, so I'm closing this for now, but please re-open if it does in fact support raw string literals.

@tgjones tgjones closed this as completed Jul 3, 2019
@DaveHoskins
Copy link
Author

Do you mean you're adding R"( and )" in HLSL code, or C++ code? I didn't think HLSL supports raw string literals, so I'm closing this for now, but please re-open if it does in fact support raw string literals.

This is in C++, I'm including the HLSL code as an 'h' file but with the appropriate file extension. To do that in C++ you have to have those simbols around the code..Like so...

R"(

#version 120
uniform sampler2D texture0;
varying vec2 texCoord;
void main(void)
{
vec3 col = texture2D(texture0, texCoord).xyz;
gl_FragDepth = 1.0;
gl_FragColor = vec4(col, 1.0);
}
)"

@PathogenDavid
Copy link

PathogenDavid commented Jul 4, 2019

I get what you're trying to do, but that's pretty strange. Those aren't valid HLSL files anymore.

I feel like most large/medium-scale projects precompile their shaders and load them from the filesystem. If you really want to avoid that for whatever reason, you should embed them as resources in the executable.

@tgjones
Copy link
Owner

tgjones commented Jul 4, 2019

@DaveHoskins can you #include the shader code like this, so that you can still edit the shader as a standalone file?

R"(
#include "myshader"
)"

By the way, the shader code you included is GLSL, but maybe that was just as an example.

@DaveHoskins
Copy link
Author

Nevermind, it's part of c++11, a feature called raw string literals. Like I said, nevermind, I'll do it another way. : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants