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

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

问题描述

我不想使用#include宏在glsl中包含着色器文件,而且我听说有一个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?

推荐答案

关于 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天全站免登陆