我正在尝试从this site运行GLSL程序,并收到如下错误。除了opengl,我需要安装哪些基本库?我在Windows机器上需要这个。
main.cpp:72:30: error: 'GLchar' does not name a type
main.cpp:72:38: warning: ISO C++ forbids declaration of 'vShaderFile' with no type [-fpermissive]
main.cpp:72:57: error: 'GLchar' does not name a type
main.cpp:72:65: warning: ISO C++ forbids declaration of 'fShaderFile' with no type [-fpermissive]
main.cpp: In function 'void initShader(const int*, const int*)':
main.cpp:75:5: error: 'GLchar' was not declared in this scope
main.cpp:75:13: error: 'vSource' was not declared in this scope
main.cpp:75:23: error: 'fSource' was not declared in this scope
main.cpp:80:43: error: cannot convert 'const int*' to 'const char*' for argument '1' to 'char* readShaderSource(const char*)'
main.cpp:83:43: error: cannot convert 'const int*' to 'const char*' for argument '1' to 'char* readShaderSource(const char*)'
main.cpp:88:30: error: 'GL_VERTEX_SHADER' was not declared in this scope
main.cpp:88:46: error: 'glCreateShader' was not declared in this scope
main.cpp:89:30: error: 'GL_FRAGMENT_SHADER' was not declared in this scope
main.cpp:90:31: error: 'glCreateProgram' was not declared in this scope
main.cpp:94:36: error: 'glAttachShader' was not declared in this scope
main.cpp:99:39: warning: ISO C++ forbids declaration of 'type name' with no type [-fpermissive]
main.cpp:99:39: warning: ISO C++ forbids declaration of 'type name' with no type [-fpermissive]
main.cpp:99:33: error: expected primary-expression before 'const'
main.cpp:99:33: error: expected ')' before 'const'
main.cpp:100:39: warning: ISO C++ forbids declaration of 'type name' with no type [-fpermissive]
main.cpp:100:39: warning: ISO C++ forbids declaration of 'type name' with no type [-fpermissive]
main.cpp:100:33: error: expected primary-expression before 'const'
main.cpp:100:33: error: expected ')' before 'const'
main.cpp:104:28: error: 'glCompileShader' was not declared in this scope
main.cpp:109:28: error: 'GL_COMPILE_STATUS' was not declared in this scope
main.cpp:109:54: error: 'glGetShaderiv' was not declared in this scope
main.cpp:117:26: error: 'glLinkProgram' was not declared in this scope
main.cpp:118:28: error: 'GL_LINK_STATUS' was not declared in this scope
main.cpp:123:25: error: 'glUseProgram' was not declared in this scope
答案 0 :(得分:1)
我认为你应该退一步,阅读http://www.arcsynthesis.org/gltut/。它有教程和关于如何构建它们的章节。
答案 1 :(得分:0)
有这样的错误
main.cpp:72:30: error: 'GLchar' does not name a type
我首先在我的源代码中添加正确的include指令。如果没有发布一些实际的源代码,我不能告诉你更多。
在链接的源代码中有这样的:
#include <GLUT/glut.h>
GLUT/glut.h
不是GLUT标头的标准位置,因此所有这些错误。如果我必须做出有根据的猜测,那么这个程序是在MacOS X上编写的。只有在MacOS X上你可以使用更新的OpenGL函数(比如着色器)而不会跳过一些箍(在运行时加载扩展和更新的版本函数), MacOS X的成本并没有真正跟上新的OpenGL版本。
我建议安装GLEW(可从http://glew.sf.net获得)并替换以下
#include <GL/glew.h>
#include <GL/glut.h>
在 glewInit()
之后添加对glutCreateWindow(…)
的调用。