Jump to content
  • Advertisement
Sign in to follow this  
Gazoo101

OpenGL Include directive functionality in GLSL

This topic is 2647 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey GameDev,

I see we have a new forum. Just goes to show I haven't been here for a while. Ok, I got a question -- and I am a little surprised that this topic doesn't pop up more often, or at least that it hasn't been better covered when searching google.

I'm looking for something that will give me the same behavior as the "include" directive in C++, in GLSL. By scowering "teh interwebz" I have found out that there apparently is an existing definition for the functionality in OpenGL called "[font="monospace"]ARB_shading_language_include[/font]", but according to various posts, it seems as though it might - as of right now - still be unimplemented? The specification for this extension can be found here:

http://www.opengl.or...age_include.txt

where it also specifies that "[font="monospace"]This extension is written against the OpenGL 3.2 (Core Profile) and[/font][font="monospace"] OpenGL Shading Language 1.50 Specifications.[/font]". Does this mean that if I use the compatibility profile I am screwed? If so, can someone suggest an easy and painless alternative? I have some GLSL code I'd prefer to keep in "#version 120" since I like using some of the fixed functionality's pipeline to perform transformations. I'd also prefer if the solution does not require keeping all my GLSL code inside pre-defined strings as I love syntax highlighting.

So... I guess the straight forward question is: Does anyone have a simple solution which provides the same functionality as the include directive from C++ in the compatibility profile while still allowing me to see syntax highlighted GLSL code?

Regards,

Gazoo

Share this post


Link to post
Share on other sites
Advertisement
It will probably be available in compatibility profile as well since both AMD and nVidia are committed to it. Sorry, I don't know of any tutorials on this extension.

Share this post


Link to post
Share on other sites
It's best (and really quite easy) to just do it yourself. Use the #pragma directive in GLSL with your own unique identifier (e.g. #pragma myinclude "stuff") and just pass it through a preprocessor of your own design before sending it to the GL. Scan for your custom pragma in the source string, then either replace it with the included source, or better yet simply leave the pragma as is and pass the included source as another string to glShaderSource. This is safe since according to the GL spec, any pragma directive which isn't recognized is simply ignored without error.

Share this post


Link to post
Share on other sites

By scowering "teh interwebz" I have found out that there apparently is an existing definition for the functionality in OpenGL called "[font="monospace"]ARB_shading_language_include[/font]", but according to various posts, it seems as though it might - as of right now - still be unimplemented?




ARB_shading_language_include is implemented in NV drivers since 265.90 (maybe even earlier, but I don't have information about all drivers releases. I have a precision of about a month. ;) In 260.99 this extension is missing). I'm not sure if AMD implements it.


...where it also specifies that "[font="monospace"]This extension is written against the OpenGL 3.2 (Core Profile) and[/font][font="monospace"] OpenGL Shading Language 1.50 Specifications.[/font]". Does this mean that if I use the compatibility profile I am screwed?



That means ARB_shading_language_include is written as an extension of GL 3.2 Core spec. Paragraphs and sections from ARB_shading_language_include should be inserted into GL 3.2 core spec to have a complete overview. Compatibility profile enables full backward compatibility, so there is no problem in using ARB_shading_language_include. Just one more comment, ARB_shading_language_include is a part of GL 3.3 Core spec, although it is relatively recently implemented (9 months after the spec).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!