简体   繁体   English

如何在OpenGL GLSL中导入库

[英]How to import libraries in OpenGL GLSL

My question is - how to import a library into OpenGL GLSL shader? 我的问题是 - 如何将库导入OpenGL GLSL着色器? I mean - is there a way that is supported by OpenGL itself, not a facade over the API which concatenates strings in order to mix shader code with a library code. 我的意思是 - 有一种方法是由OpenGL本身支持的,而不是API的连接,它连接字符串以便将着色器代码与库代码混合。

There is no way that is supported by OpenGL itself without extensions. 如果没有扩展,OpenGL本身就无法支持。 Many engines that wrap OpenGL add their own preprocessor to handle #include macros to solve this problem, but this qualifies as "a facade over the API which concatenates strings in order to mix shader code with a library code." 许多包装OpenGL的引擎都添加了自己的预处理器来处理#include宏来解决这个问题,但是它有资格作为“连接字符串以便将着色器代码与库代码混合在一起的API的外观”。

The ARB_shading_language_include extension provides an OpenGL version of this functionality, but may not be available on your particular machine. ARB_shading_language_include扩展提供此功能的OpenGL版本,但可能在您的特定计算机上不可用。 For an overview on this extension, see this question: How to Using the #include in glsl support ARB_shading_language_include 有关此扩展的概述,请参阅此问题: 如何在glsl支持中使用#include ARB_shading_language_include

There exists no real solution. 没有真正的解决方案。

But I think I know what the problem is: 但我想我知道问题是什么:

The problem is that every shader is completely associated to its client code: Every shader program makes absolutely no sense without its client program. 问题是每个着色器都与其客户端代码完全关联:如果没有客户端程序,每个着色器程序都没有意义。

Looks like declarative languages integration into OOP or whatever langiage. 看起来像声明性语言集成到OOP或任何langiage。

So it's not the problem of GLSL it's a problem of the client language eg C++, Java (Android) to solve that issue. 所以这不是GLSL的问题,它是客户端语言的问题,例如C ++,Java(Android)来解决这个问题。 But just my opinion. 但只是我的意见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM