-2

我正在尝试从该站点运行 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
4

2 回答 2

1

我认为您应该退后几步,阅读http://www.arcsynthesis.org/gltut/。它有教程和关于如何构建它们的章节。

于 2013-04-13T13:01:02.257 回答
0

有这样的错误

main.cpp:72:30: error: 'GLchar' does not name a type

我首先将正确的包含指令添加到我的源代码中。如果没有您发布一些实际的源代码,我无法告诉您更多信息。

更新

在链接的源代码中有这样的:

#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() after glutCreateWindow(…)的调用。

于 2013-04-13T12:58:41.757 回答