如何在 Windows 中运行基本的“Hello World”GLSL 程序? [关闭]
Posted
技术标签:
【中文标题】如何在 Windows 中运行基本的“Hello World”GLSL 程序? [关闭]【英文标题】:How to run a basic "Hello World" GLSL program in windows? [closed] 【发布时间】:2013-04-13 12:50:33 【问题描述】:我正在尝试从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
【问题讨论】:
【参考方案1】:我认为你应该退后几步,阅读http://www.arcsynthesis.org/gltut/。它有教程和如何构建它们的章节。
【讨论】:
【参考方案2】:出现这样的错误
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()
的调用之后 glutCreateWindow(…)
。
【讨论】:
我已经链接了我从中获取的代码。 @2vision2:查看我的更新以上是关于如何在 Windows 中运行基本的“Hello World”GLSL 程序? [关闭]的主要内容,如果未能解决你的问题,请参考以下文章
Windows10 IoT开发系列“Hello,World!”指导
在 Windows 的 Eclipse C++ 中运行 Hello World 应用程序