本文介绍了如何在Mac OSX上将OpenGL从2.1升级到3.3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Macbook Pro上用C对OpenGL 3进行编程.

我的图形卡是NVIDIA GeForce 320M 256 MB,但是我有OpenGL 2.1,根据维基百科,我应该能够使用OpenGL 3.3:

但是,当我运行glxinfo | grep -i opengl时,会得到OpenGL version string: 2.1 NVIDIA-8.24.16 310.90.9.05f01.
我该如何升级呢?我在跑小牛.

解决方案

从技术上讲,您不能仅在OS X上使用C语言获得(窗口式)OpenGL 3.2上下文编程.

您必须使用称为NSOpenGL的Cocoa(Objective-C框架)的一部分; AGL(不推荐使用的基于C的API)以及真正古老的X服务器实现(XQuartz)永远限于OpenGL 2.1.

Apple自己的GLUT实现包装NSOpenGL(FreeGLUT不包装),GLFW,SDL等也是如此.它们有很小的一部分用Objective-C编写,可以与NSOpenGL交互,这使他们可以创建基于窗口的OpenGL即使在C软件中,3.2 +的渲染上下文也是如此.


现在,这里的问题实际上是glxinfo使用不支持OpenGL 3.2+的XQuartz.我建议您使用 OpenGL扩展查看器如果需要有关OpenGL功能的详细信息,请在Mac App Store上找到.

由于您刚开始在OS X上进行OpenGL开发,因此我也建议您看看此处,以快速概览各种API.

I am trying to program OpenGL 3 in C on my Macbook Pro.

My graphics card is NVIDIA GeForce 320M 256 MB, but I have OpenGL 2.1 According to wikipedia, I should be able to use OpenGL 3.3:

However, when I run glxinfo | grep -i opengl, I get OpenGL version string: 2.1 NVIDIA-8.24.16 310.90.9.05f01.
How do I go about upgrading it? I am running Mavericks.

解决方案

Technically, you cannot get a (windowed) OpenGL 3.2 context programming purely in C on OS X.

You have to use part of Cocoa (an Objective-C framework) called NSOpenGL; AGL (deprecated C-based API) as well as the really old X server implementation (XQuartz) are perpetually limited to OpenGL 2.1.

Apple's own implementation of GLUT wraps NSOpenGL (FreeGLUT does not), and so do GLFW, SDL, etc. They have small portions that are written in Objective-C to interface with NSOpenGL and this allows them to create window-based OpenGL 3.2+ render contexts even in C software.


Now, the problem here is actually that glxinfo uses XQuartz, which does not support OpenGL 3.2+. I would suggest you use the OpenGL Extension Viewer on the Mac App store if you want detailed info about your OpenGL capabilities.

Since you're just starting out with OpenGL development on OS X, I would also suggest you have a look here for a quick overview of the various APIs.

这篇关于如何在Mac OSX上将OpenGL从2.1升级到3.3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 14:41