1, glGetAttribLocation返回-1
如果在顶点着色器中定义了attribute,但glGetAttribLocation返回-1,其中一个原因是这个attribute没有使用
If the named attribute variable is not an active attribute in the specified program object or if name starts with the reserved prefix "gl_", a value of -1 is returned.
2, shader创建失败
if必须加花括号,否则某些设备上会创建shader会失败
if()
return ;
必须写成
if()
{
return
}
else
{return ;
}
GPU里面shader注意一下
本文探讨了在使用OpenGL着色语言(GLSL)进行图形编程时遇到的两个常见问题:一是当调用glGetAttribLocation函数时返回-1的情况及原因;二是关于着色器(shader)创建失败的问题,特别是涉及if语句的正确使用。
1333

被折叠的 条评论
为什么被折叠?



