Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I know which version of OpenGL I am using?

Tags:

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: 

So is OpenGL 3.3 automatically being used ?

like image 826
Trt Trt Avatar asked Oct 26 '11 21:10

Trt Trt


People also ask

How do I check my OpenGL version?

Procedure. Follow the instructions provided to check the type of graphics card installed on the system and the version of OpenGL running. Check the graphics card type (Windows): Click Start, type dxdiag, and press Enter to access a diagnostic tool listing the graphics card information.

What is the current version of OpenGL?

OpenGL 4.6 (2017)

How do I find my OpenGL drivers?

On the official site, navigate to the graphics driver and choose your operating system. Download the latest drivers for your graphics card and install it to your computer. This will also update the OpenGL on your computer.

Does Windows 10 have OpenGL?

Microsoft releases OpenCL and OpenGL Compatibility Pack for Windows 10 PCs. Microsoft has released a compatibility pack that allows you to run any OpenCL and OpenGL apps on a Windows 10 PC that doesn't have OpenCL and OpenGL hardware drivers installed by default.


1 Answers

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)); 

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.

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.

like image 55
Christian Rau Avatar answered Oct 19 '22 07:10

Christian Rau