GCC, stringification, and inline GLSL?

前端 未结 5 977
孤城傲影
孤城傲影 2020-11-29 08:37

I\'d like to declare GLSL shader strings inline using macro stringification:

#define STRINGIFY(A)  #A
const GLchar* vert = STRINGIFY(
#version 120\\n
attribu         


        
5条回答
  •  盖世英雄少女心
    2020-11-29 08:59

    To achieve this purpose I used sed. I have seperate files with GLSL which I edit (with proper syntax highlighting), and in the same time GLSL in inlined in C++. Not very cross platform, but with msys it works under windows.

    In C++ code:

    const GLchar* vert = 
    #include "shader_processed.vert"
    ;
    

    In Makefile:

    shader_processed.vert: shader.vert
        sed -f shader.sed shader.vert > shader_processed.vert
    
    programm: shader_processed.vert main.cpp
        g++ ...
    

    shader.sed

    s|\\|\\\\|g
    s|"|\\"|g
    s|$|\\n"|g
    s|^|"|g
    

提交回复
热议问题