在Maverick上使用GLFW3的C ++代码:glShaderSource没有匹配功能 [英] C++ code using GLFW3 on Maverick: glShaderSource no matching function
问题描述
我正在尝试使用Mac上的GLFW3库来编译一个相当简单的C ++程序.操作系统为OS 10.9.3(Maverick).在我尝试使用glSLderSource等GLSL函数之前,它可以正常编译.
I am trying to compile a fairly simple C++ program using the library GLFW3 on Mac. The OS is OS 10.9.3 (Maverick). It compiles fine until I try to use GLSL functions such as glShaderSource, etc.
以下是我使用的包含文件:
Here are the include files I use:
#include <GLFW/glfw3.h>
#include <cstdlib>
#include <cstdio>
我正在使用OpenGL3.2:
I am using OpenGL3.2:
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
以下是用于编译程序的命令行:
Here is the command line to compile the program:
clang++ -o xxxx xxxx.cpp -framework Cocoa -framework OpenGL -Wall -lglfw3 -I/usr/local/include/ -L/usr/local/lib -framework Quartz -framework IOKit
现在出现错误:
xxxx:38:5: error: no matching function for call to 'glShaderSource'
glShaderSource(vertexShader, 1, &vertexSource, NULL);
我确定我缺少一些基本的知识,但是呢?谢谢你的帮助.我担心它与glext有关,但不确定该怎么做.我在网上的Stackoverflow上找不到任何东西.
I am sure I missing something basic but what? Thanks for your help. I fear it has something to do with glext but not sure what to do really. I couldn't find anything on Stackoverflow on the web.
推荐答案
在OS X上,您需要包括<OpenGL/gl3.h>
以获得GL3 +级别入口点的定义.
On OS X, you need to include <OpenGL/gl3.h>
to get definitions for GL3+ level entry points.
在GLFW文档中,在构建使用GLFX的程序"页面上, ( http://www.glfw.org/docs/latest/build.html),有一个名为"GLFW标头选项宏"的部分.相关部分为:
In the GLFW documentation, on the page "Building programs that use GLFX" (http://www.glfw.org/docs/latest/build.html), there is a section named "GLFW header option macros". The relevant sections are:
这些宏可能在包含GLFW标头之前定义,并且会影响标头的行为.
These macros may be defined before the inclusion of the GLFW header and affect the behavior of the header.
GLFW_INCLUDE_GLCOREARB使标头包含现代的GL/glcorearb.h标头(在OS X上为OpenGL/gl3.h),而不是常规的OpenGL标头.
GLFW_INCLUDE_GLCOREARB makes the header include the modern GL/glcorearb.h header (OpenGL/gl3.h on OS X) instead of the regular OpenGL header.
因此,以下方法可以解决问题:
So the following should do the trick:
#define GLFW_INCLUDE_GLCOREARB
#include <GLFW/glfw3.h>
查看glfw3.h
标头( http://www.glfw.org/docs/latest/glfw3_8h_source.html )确认此附加定义中将包含<OpenGL/gl3.h>
.
Looking at the glfw3.h
header (http://www.glfw.org/docs/latest/glfw3_8h_source.html) confirms that it will include <OpenGL/gl3.h>
with this additional define.
这篇关于在Maverick上使用GLFW3的C ++代码:glShaderSource没有匹配功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!