如何在 glsl 支持中使用#include ARB_shading_language_include [英] How to Using the #include in glsl support ARB_shading_language_include

查看:29
本文介绍了如何在 glsl 支持中使用#include ARB_shading_language_include的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不想使用 #include 宏在 glsl 中包含着色器文件,我听说有一个 ARB_shading_language_include extension 支持 #include 宏.有没有人可以给我一个代码片段,展示如何使用 #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?

推荐答案

关于 shading_language_include不是.它不是我#include 一个文件 来自磁盘".OpenGL 不知道文件是什么;它没有文件系统的概念.

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.

相反,您必须预加载您可能想要包含的所有文件.所以你有一个着色器字符串和一个从中加载字符串的文件名.本质上,您必须在 OpenGL 中构建一个虚拟文件系统.

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.

您使用 glNamedStringARB 将字符串上传到虚拟文件系统.字符串的名称是其完整路径名.

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

#extension 语句之后,您可以根据需要#include.

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

这篇关于如何在 glsl 支持中使用#include ARB_shading_language_include的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆