在Mac OSX 10.8.4上带有GLFW3的现代OpenGL-缺少glGenVertexArrays()和glBindVertexArray()吗? [英] Modern OpenGL with GLFW3 on Mac OSX 10.8.4 - missing glGenVertexArrays() and glBindVertexArray()?
问题描述
我正在尝试为Xcode 5(Mac OSX 10.8.4)上的OpenGL项目设置GLFW3.我已经成功安装了项目并将其链接到GLFW3没问题.我什至在该项目中成功创建了一个窗口,并且能够通过该窗口检测鼠标和键盘输入,因此我相信我正确连接了GLFW3(或者至少看起来如此).
I'm trying to setup GLFW3 for my OpenGL project on Xcode 5 (Mac OSX 10.8.4). I have successfully installed and linked my project to GLFW3 no problem. I even got a window successfully created with the project, and I were able to detect mouse and keyboard inputs with the window, so I believe that I got GLFW3 hooked up correctly (or at least it seemed so).
但是,当我尝试绘制对象时出现了问题.这是显示错误的代码段:
However, the problem occured when I tried to draw an object. This was the code snippet where the error showed up:
#include <GLFW/glfw3.h>
void LoadObject()
{
glGenVertexArrays(1, &VAO_myObj); // ERROR : Use of undeclared identifier 'glGenVertexArrays'
glBindVertexArray(VAO_myObj); // ERROR : Use of undeclared identifier 'glBindVertexArray'
glGenBuffers(1, &VBO_myObj); // No error
glBindBuffer(GL_ARRAY_BUFFER, VBO_myObj); // No error
glBufferData(blah blah blah); // No error
glEnableVertexAttribArray(0); // No error
glVertexAttribPointer(blah); // No error
glBindBuffer(GL_ARRAY_BUFFER, 0); // No error
glBindVertexArray(0); // ERROR : Use of undeclared identifier 'glBindVertexArray'
}
因此,这使我相信GLFW3无法以某种方式链接到那些功能(?).当我在Xcode中键入"glGen ..."时,我在弹出窗口中仅看到以下4个函数:
So, this led me to believe that somehow GLFW3 failed to link to those functions (?). When I typed "glGen..." to Xcode, I only saw the following 4 functions on the popup window:
void glGenBuffers(GLsizei n, GLuint * buffers)
GLuint glGenLists(GLsizei range)
void glGenQueries(GLsizei n, GLuint * ids)
void glGenTextures(GLsizei n, GLuint * textures)
因此,很可能库中确实缺少glGenVertexArrays().
So, it was most likely that glGenVertexArrays() was indeed missing from the library.
与"glBind ..."类似,当我将名称键入Xcode时,只有这些出现在弹出窗口中:
Similarly for "glBind...", when I type the name to Xcode, only these showed up on the popup window:
void glBindAttribLocation(GLuint program, GLuint index, const GLchar * name)
void glBindBuffer(GLenum target, GLuint buffer)
void glBindTexture(GLenum target, GLuint texture)
不,我在列表的哪里看到glBindVertexArray().
No where did I see the glBindVertexArray() on the list.
因此,似乎缺少glGenVertexArrays()和glBindVertexArray().但是他们怎么会错过如此重要的职能呢?因此,我自己很可能在这里错过了一些东西.
So, it seems that glGenVertexArrays() and glBindVertexArray() are missing. But how could they have missed such important functions? So, it's most likely that I myself am missing something here.
我只是想知道以前是否有人在带有Xcode 5的GLFW3上遇到过此问题?顺便说一句,我没有使用glew或任何其他OpenGL支持的东西.我只使用GLFW3.
I'm just wondering if any one has encountered this issue with GLFW3 with Xcode 5 before? By the way, I'm not using glew or any other OpenGL support stuff. I'm only using GLFW3.
对于此问题的任何提示或提示,我们将不胜感激.
I would appreciate any hint or pointer regarding this issue.
请注意,您建议使用哪种工具(在glfw旁边)在Mac上打开一个窗口(用于基于着色器的现代项目)?
On the side note, which tool (beside glfw) would you recommend to get a window up on a Mac for a modern (shader-based) OpenGL project?
预先感谢您的帮助.
推荐答案
您需要在OS X上包含<OpenGL/gl3.h>
才能使用OpenGL 3.2核心API调用.请注意,如果同时包含<OpenGL/gl.h>
和<OpenGL/gl3.h>
,则可能会收到编译器警告,这是因为gl3.h
具有两个目的:
You need to include <OpenGL/gl3.h>
on OS X in order to use OpenGL 3.2 core API calls. Be aware that if you include both <OpenGL/gl.h>
and <OpenGL/gl3.h>
you may receive a compiler warning, this is because gl3.h
serves two purposes:
- 提供核心OpenGL 3.2的功能,枚举和类型定义
- 消除在核心OpenGL 3.2中无效的不推荐使用的函数,枚举和类型定义
它们实际上是互斥的,正确的标头取决于您使用的上下文版本:
They are effectively mutually exclusive, the proper header depends on the context version you are using:
- MacOS X 10.7 + :( OpenGL: 2.1 )
-
#include <OpenGL/gl.h>
- MacOS X 10.7+: (OpenGL: 2.1)
#include <OpenGL/gl.h>
-
#include <OpenGL/gl3.h>
这篇关于在Mac OSX 10.8.4上带有GLFW3的现代OpenGL-缺少glGenVertexArrays()和glBindVertexArray()吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
-