Linux checking opengl version

How can i know which opengl version is supported by my system

Know that versions are mostly a collection of required extensions for a vendor to implement. You are unlikely to use every function a version has to offer anyway so focus on checking the extensions for the functions you use.

2 Answers 2

GLFW_CONTEXT_VERSION_MAJOR and GLFW_CONTEXT_VERSION_MINOR specify the client API version that the created context must be compatible with. The exact behavior of these hints depend on the requested client API.

OpenGL: GLFW_CONTEXT_VERSION_MAJOR and GLFW_CONTEXT_VERSION_MINOR are not hard constraints, but creation will fail if the OpenGL version of the created context is less than the one requested. It is therefore perfectly safe to use the default of version 1.0 for legacy code and you will still get backwards-compatible contexts of version 3.0 and above when available.

While there is no way to ask the driver for a context of the highest supported version, GLFW will attempt to provide this when you ask for a version 1.0 context, which is the default for these hints.

This means, if you want to get the highest possible OpenGL context, then you can completely skip glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, ) and glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, ) .

After you have created a context, you can ask for the context version, with glGetString(GL_VERSION) .

But if your application requires a minimum OpenGL version, you need to tell that to GLFW, with:

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, required_major); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, required_minor); 

glfwCreateWindow will fail, if the requirements cannot be fulfilled.

The answer to your question

How can i know which opengl version is supported by my system?

You have to create an OpenGL context first, then you can ask for the version by glGetString(GL_VERSION) .

Correction to the answer

As mentioned in the comment, this approach is going to fail when you try to create a core profile context.

This means you cannot use:

glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); 

In practice, this approach is going to fail when one is trying to create a core profile context.

Well, it is also not wrong, especially in the context given where the user doesn’t create a core profile. With the remark from the update, I don’t see any reason to delete it. Also note that the downvote is not from me.

Читайте также:  Linux конвертировать имена файлов

Actually, trying to query the highest supported GL version is quite useless. You should just ask for the lowest GL version (and the most strict profile) your code can work with, and if that is not available, it is not going to work anyway.

If you want to optionally support some features, use of the extension mechanism is the way to go.

If you really want some higher version context on some machines, and a lower one on others, the only reliable way will be to iteratively try to create the context, backwards from the highest version your code can make use of, to the lowest, and just stop when the creation succeeds. You won’t get any unknown newer version that way, but since the rest of your code won’t make use of any newer features, it is a moot point.

The only reason I can see why you might want some «unknown» newer GL version would be the case of a library, where you create the context and do not know what is to be done with it — like it’s the case with GLFW itself. But GLFW has the same issue. There is simply no reliable API to query the highest supported GL version. The recommendation in the GLFW docs, mentioned in @Rabbid76’s answer will only provide you the highest available legacy GL version (which limits you to 2.1 on OSX and 3.0 on mesa/linux). It won’t work for core profiles, but core profiles are the only reliable way to get modern GL on all platforms.

Having said that all that, I have to admit that I did see code before, which actually iteratively tried the contexts, but started with 5.something, while at the time of writing this answer, the highest existing GL spec was 4.6. Not sure what they were trying to do there, and also no idea which x for 4.x they did start with, after 5.0 failed.

Источник

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

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 have you figured out the solution yourself and forgot about your question or do you still have some unclarities? In the former case just abandoning a question is extremely bad practice and in the latter case feel free to ask any further questions about existing answers or even post your own answer if different from the already existing ones.

Читайте также:  Astra linux установка сертификатов crt

If you want to check GLEW version on Linux from terminal, you can install glew-utils and run visualinfo | grep «OpenGL version» .

1 Answer 1

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.

Источник

How can I find out my OpenGL version on Ubuntu 13.04

Does this question even make sense? SFML 2.0 has added a feature whereby you can specify an OpenGL version to use. Is there a terminal command I can run (or otherwise) to find out what version I should be using?

@EdwardBird: Then your question is poorly phrased. If you wanted to know what the highest version of OpenGL supported by a system is, you should have asked for that. So fix your question.

2 Answers 2

To know your OpenGL version in Ubuntu,

$sudo apt-get install mesa-utils 
$glxinfo | grep "OpenGL version" 

You will get the output as follows,

glxinfo | grep "OpenGL version" OpenGL version string: 1.4 (2.1 Mesa 7.7.1) 

There is no «should be using». The version you «should» be using is the minimum version that you want to support. What version that is depends on what hardware you want your program to execute on. If the hardware can’t support that version, then your code simply won’t run on it. And if you want your code to run on lower versions, then you should have asked for that version and written your application against that lower version.

Читайте также:  Аппаратный raid массив linux

Well GTX 670MX supports 4.1, but clearly the information you give is not correct, because running SFML with version 3.2 specified causes problems.

@EdwardBird: What kind of problems? Nicol Bolas is right, and whatever’s broken, it should not be due to a higher version being supported than what’s requested.

Источник

How to Check OpenGL version?

how-to-check-opengl-version

LinuxStoney

Today we learn How to Check OpenGL version? OpenGL (Open Graphics Library) is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics. The API is typically used to interact with a graphics processing unit (GPU), to achieve hardware-accelerated rendering.

How To Check OpenGL Version,

glxinfo | grep «OpenGL version»

You will get the output as follows,

glxinfo | grep "OpenGL version" OpenGL version string: 1.4 (2.1 Mesa 7.7.1)

You may have better luck with modern OpenGL just grepping for “version” instead of “OpenGL version” given the differences between the core and compat profiles, as well as the various GLSL and GLES versions:

glxinfo | grep 'version' server glx version string: 1.4 client glx version string: 1.4 GLX version: 1.4 Max core profile version: 4.1 Max compat profile version: 3.0 Max GLES1 profile version: 1.1 Max GLES[23] profile version: 3.0 OpenGL core profile version string: 4.1 (Core Profile) Mesa 11.1.2 OpenGL core profile shading language version string: 4.10 OpenGL version string: 3.0 Mesa 11.1.2 OpenGL shading language version string: 1.30 OpenGL ES profile version string: OpenGL ES 3.0 Mesa 11.1.2 OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00

Notice that the actual version is presented by the “core profile version” (4.1), whereas the “OpenGL version” is presented as 3.0.

Источник

Оцените статью
Adblock
detector