Kei*_*ker 7 c++ opengl performance shader glsl
用 GLSL 等编写的着色器通常在运行时加载到图形应用程序中。我想知道为什么不直接使用着色器编译应用程序,这样以后就不必加载它们了。像这样:
#define glsl(version, glsl) "#version " #version "\n" #glsl
namespace glsl { namespace vs {
//VERTEX SHADERS
//=========================
// simple VS
//=========================
constexpr GLchar * const simple = glsl(450 core,
layout(location = 0) in vec3 position;
void main() {
gl_Position = vec4(position, 1.0f);
}
);
} namespace fs {
//FRAGMENT SHADERS
//=========================
// simple FS
//=========================
constexpr GLchar * const simple = glsl(450 core,
out vec4 color;
void main() {
color = vec4(1.0f, 0.0f, 0.0f, 1.0f);
}
);
} }
Run Code Online (Sandbox Code Playgroud)
我不认为这会导致 exe 文件太大并且会加快加载时间;除非我错误地理解了典型图形应用程序使用了多少个着色器。我知道您可能想在编译后更新着色器,但这真的会发生吗?
我有什么理由不想这样做吗?
有几个原因:
归档时间: |
|
查看次数: |
1761 次 |
最近记录: |