• <bdo id='kusUI'></bdo><ul id='kusUI'></ul>
      <legend id='kusUI'><style id='kusUI'><dir id='kusUI'><q id='kusUI'></q></dir></style></legend>
      <i id='kusUI'><tr id='kusUI'><dt id='kusUI'><q id='kusUI'><span id='kusUI'><b id='kusUI'><form id='kusUI'><ins id='kusUI'></ins><ul id='kusUI'></ul><sub id='kusUI'></sub></form><legend id='kusUI'></legend><bdo id='kusUI'><pre id='kusUI'><center id='kusUI'></center></pre></bdo></b><th id='kusUI'></th></span></q></dt></tr></i><div id='kusUI'><tfoot id='kusUI'></tfoot><dl id='kusUI'><fieldset id='kusUI'></fieldset></dl></div>
    1. <tfoot id='kusUI'></tfoot>

      <small id='kusUI'></small><noframes id='kusUI'>

        GCC、字符串化和内联 GLSL?

        时间:2023-09-19

          <i id='6Yshm'><tr id='6Yshm'><dt id='6Yshm'><q id='6Yshm'><span id='6Yshm'><b id='6Yshm'><form id='6Yshm'><ins id='6Yshm'></ins><ul id='6Yshm'></ul><sub id='6Yshm'></sub></form><legend id='6Yshm'></legend><bdo id='6Yshm'><pre id='6Yshm'><center id='6Yshm'></center></pre></bdo></b><th id='6Yshm'></th></span></q></dt></tr></i><div id='6Yshm'><tfoot id='6Yshm'></tfoot><dl id='6Yshm'><fieldset id='6Yshm'></fieldset></dl></div>

          1. <legend id='6Yshm'><style id='6Yshm'><dir id='6Yshm'><q id='6Yshm'></q></dir></style></legend>
          2. <small id='6Yshm'></small><noframes id='6Yshm'>

                <tbody id='6Yshm'></tbody>
                <bdo id='6Yshm'></bdo><ul id='6Yshm'></ul>
                  <tfoot id='6Yshm'></tfoot>
                  本文介绍了GCC、字符串化和内联 GLSL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想使用宏字符串化内联声明 GLSL 着色器字符串:

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

                  #define STRINGIFY(A)  #A
                  const GLchar* vert = STRINGIFY(
                  #version 120
                  
                  attribute vec2 position;
                  void main()
                  {
                      gl_Position = vec4( position, 0.0, 1.0 );
                  }
                  );
                  

                  使用 VS2010 构建并运行良好,但无法在 gcc 上编译:

                  This builds and runs fine using VS2010 but fails to compile on gcc with:

                  error: invalid preprocessing directive #version
                  

                  有没有办法以可移植的方式使用这样的字符串化?

                  Is there a way to use stringification like this in a portable manner?

                  我试图避免每行引号:

                  const GLchar* vert = 
                  "#version 120
                  "
                  "attribute vec2 position;"
                  "void main()"
                  "{"
                  "    gl_Position = vec4( position, 0.0, 1.0 );"
                  "}"
                  ;
                  

                  ...和/或续行:

                  const GLchar* vert = "
                  #version 120
                                                   
                  attribute vec2 position;                       
                  void main()                                    
                  {                                              
                      gl_Position = vec4( position, 0.0, 1.0 );  
                  }                                              
                  ";
                  

                  推荐答案

                  你会使用 C++11 吗?如果是这样,您可以使用 原始字符串文字:

                  Can you use C++11? If so you could use raw string literals:

                  const GLchar* vert = R"END(
                  #version 120
                  attribute vec2 position;
                  void main()
                  {
                      gl_Position = vec4( position, 0.0, 1.0 );
                  }
                  )END";
                  

                  无需转义或显式换行.这些字符串以 R(或 r)开头.您需要在引号和第一个括号之间使用分隔符(我选择了 END)来转义代码片段中的括号.

                  No need for escapes or explicit newlines. These strings start with an R (or r). You need a delimiter (I chose END) between the quote and the first parenthesis to escape parenthesis which you have in the code snippet.

                  这篇关于GCC、字符串化和内联 GLSL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:从 char** 到 const char** 的隐式转换 下一篇:如何让 GCC 将 .text 部分编译为可写在 ELF 二进制文

                  相关文章

                  最新文章

                1. <legend id='B3jRa'><style id='B3jRa'><dir id='B3jRa'><q id='B3jRa'></q></dir></style></legend>
                2. <i id='B3jRa'><tr id='B3jRa'><dt id='B3jRa'><q id='B3jRa'><span id='B3jRa'><b id='B3jRa'><form id='B3jRa'><ins id='B3jRa'></ins><ul id='B3jRa'></ul><sub id='B3jRa'></sub></form><legend id='B3jRa'></legend><bdo id='B3jRa'><pre id='B3jRa'><center id='B3jRa'></center></pre></bdo></b><th id='B3jRa'></th></span></q></dt></tr></i><div id='B3jRa'><tfoot id='B3jRa'></tfoot><dl id='B3jRa'><fieldset id='B3jRa'></fieldset></dl></div>
                  <tfoot id='B3jRa'></tfoot>

                    • <bdo id='B3jRa'></bdo><ul id='B3jRa'></ul>

                      <small id='B3jRa'></small><noframes id='B3jRa'>