Merging vertex shader in fragment shader

Is it possible to merge vertex shader into a fragment shader file ?


Yes. Have done that. And it definitely simplifies maintenance.
Do something like this:



Now in your program after you load this file before you compile it, simply prepend a short preamble with the #version and the #define to indicate which shader you’re compiling. For example:

#version 300


before you throw this at glCompileShader. You can do that either by manually prepending this string to the loaded shader source before feeding it to glShaderSource, or you can just feed these in as separate strings to glShaderSource and let the GLSL compiler do this internally.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.