Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Using the #include in glsl support ARB_shading_language_include

Tags:

opengl

glsl

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?

like image 239
toolchainX Avatar asked Oct 04 '22 07:10

toolchainX


People also ask

What are the rules for using the?

“The” is typically used in accompaniment with any noun with a specific meaning, or a noun referring to a single thing. The important distinction is between countable and non-countable nouns: if the noun is something that can't be counted or something singular, then use “the”, if it can be counted, then us “a” or “an”.

How do you use the word the?

Every singular noun (phrase) must be preceded by one and only one singular determiner. When a speaker places the before a noun, he is generally sending a signal to the user that the noun marked with the is something that he believes the listener already knows about.

Why do you use the?

The is the definite article. The definite article is used with singular and plural nouns. It is used both with countable nouns and uncountable nouns: to make definite or specific reference to a person or a thing that has already been referred to.


1 Answers

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.

like image 61
Nicol Bolas Avatar answered Oct 12 '22 02:10

Nicol Bolas