我怎么知道我正在使用哪个版本的OpenGL? [英] How do I know which version of OpenGL I am using?

查看:176
本文介绍了我怎么知道我正在使用哪个版本的OpenGL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在开始使用GLFW和OpenGL用C编写程序.我的问题是,我怎么知道我的程序将使用哪个版本的OpenGL?我的笔记本电脑说我的视频卡具有OpenGL 3.3.键入"glxinfo | grep -i opengl"将返回:

I started writing programs, in C (for now) using GLFW and OpenGL. The question I have is that, how do I know which version of OpenGL my program will use? My laptop says that my video card has OpenGL 3.3. Typing "glxinfo | grep -i opengl" returns:

OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce 9600M GT/PCI/SSE2
OpenGL version string: 3.3.0 NVIDIA 285.05.09
OpenGL shading language version string: 3.30 NVIDIA via Cg compiler
OpenGL extensions:

那么会自动使用OpenGL 3.3吗?

So is OpenGL 3.3 automatically being used ?

推荐答案

只需调用glGetString(GL_VERSION)(当然,一旦上下文被初始化)并输出结果(我想实际上与glxinfo相同) :

Just call glGetString(GL_VERSION) (once the context is initialized, of course) and put out the result (which is actually the same that glxinfo does, I suppose):

printf("%s\n", glGetString(GL_VERSION));

您的程序应自动使用硬件和驱动程序支持的最高版本,在您看来,该版本为3.3.但是,要为OpenGL 3+创建一个核心配置文件上下文(已完全弃用了已弃用的功能),则必须采取特殊措施.但是从2.7版开始,GLFW具有使用glfwOpenWindowHint函数执行此操作的方法.但是,如果您不想明确禁止已弃用的功能,则可以使用GLFW的默认上下文创建功能为您提供的上下文,该功能将支持您的硬件和驱动程序的最高版本.

Your program should automatically use the highest possible version your hardware and driver support, which in your case seems to be 3.3. But for creating a core-profile context for OpenGL 3+ (one where deprecated functionality has been completely removed) you have to take special measures. But since version 2.7 GLFW has means for doing this, using the glfwOpenWindowHint function. But if you don't want to explicitly disallow deprecated functionality, you can just use the context given to you by the default context creation functions of GLFW, which will as said support the highest possible version for your hardware and drivers.

但还请记住,要使用高于1.1版的OpenGL功能,您需要检索相应的函数指针或使用为您处理该函数的库,例如

But also keep in mind that for using OpenGL functionality higher than version 1.1 you need to retrieve the corresponding function pointers or use a library that handles this for you, like GLEW.

这篇关于我怎么知道我正在使用哪个版本的OpenGL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆