const char svShaderHightLight[]字符串怎么声明成全局的数组?

mirroatl187 2014-11-24 04:35:05

#ifndef GLSLPROGRAM_HPP_
#define GLSLPROGRAM_HPP_

static const char svShaderHightLight[]={};

#endif



const char svShaderHightLight[] =
"precision mediump float;\n"
"varying mediump vec2 texcoord; \n"
"void main() \n"
"{ \n"
" texcoord = gl_MultiTexCoord0.st;\n"
" gl_Position = ftransform(); \n"
"} \n";
...全文
98 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
schlafenhamster 2014-11-26
  • 打赏
  • 举报
回复
const char svShaderHightLight[] = "precision mediump float;\n" "varying mediump vec2 texcoord;\n" "void main()\n" "{\n" " texcoord = gl_MultiTexCoord0.st;\n" " gl_Position = ftransform();\n" "}\n"; 只是一个字符串而已, 非 字符串 数组。
「已注销」 2014-11-26
  • 打赏
  • 举报
回复
经测试,赵忠的办法不行。extern 后不能加 static。
// 在源文件中定义
const char svShaderHightLight[] =
    "precision mediump float;\n"
    "varying mediump vec2 texcoord;\n"
    "void main()\n"
    "{\n"
    "    texcoord = gl_MultiTexCoord0.st;\n"
    "    gl_Position = ftransform();\n"
    "}\n";

// 在头文件中声明
extern const char svShaderHightLight[];
然后包含头文件,直接使用 svShaderHightLight 即可。
熊熊大叔 2014-11-25
  • 打赏
  • 举报
回复
extern const char svShaderHightLight[]; const char svShaderHightLight[] = "precision mediump float;\n" "varying mediump vec2 texcoord; \n" "void main() \n" "{ \n" " texcoord = gl_MultiTexCoord0.st;\n" " gl_Position = ftransform(); \n" "} \n";
schlafenhamster 2014-11-25
  • 打赏
  • 举报
回复
svShaderHightLight[][260]=
schlafenhamster 2014-11-25
  • 打赏
  • 举报
回复
CStringArray
赵4老师 2014-11-24
  • 打赏
  • 举报
回复
extern static const char svShaderHightLight[512]; public const char svShaderHightLight[] = "precision mediump float;\n" "varying mediump vec2 texcoord; \n" "void main() \n" "{ \n" " texcoord = gl_MultiTexCoord0.st;\n" " gl_Position = ftransform(); \n" "} \n";
ytfhwfnh 2014-11-24
  • 打赏
  • 举报
回复
把下面的代码直接丢到上面头文件里,或者头文件声明static const char svShaderHightLight[7];,程序启动时,写代码赋值。

64,637

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧