Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
585 views
in Technique[技术] by (71.8m points)

opengl - How to Using the #include in glsl support ARB_shading_language_include

I wan't to use the #include macro to include shader files in glsl, and I heard there is a ARB_shading_language_include extension support the #include macro. Is there anyone can give me a code snippet showing how to use the #include macro?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The first thing you need to understand about shading_language_include is what it isn't. It is not "I #include a file from the disk." OpenGL doesn't know what files are; it has no concept of the file system.

Instead, you must pre-load all of the files you might want to include. So you have a shader string and a filename that you loaded the string from. Essentially, you must build a virtual filesystem within OpenGL.

You use glNamedStringARB to upload a string to the virtual filesystem. The name of the string is its full pathname.

Once you've built your virtual filesystem, you must then, for each shader you compile, initialize the extension.

#version MY_OPENGL_VERSION //Whatever version you're using.
#extension GL_ARB_shading_language_include : require

After the #extension statement, you may #include as you see fit.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...