Context & stateGL 1.0

glGetString

Returns text describing the driver: version, GPU name, vendor, GLSL version.

Part of the family glGet*

Signature

const GLubyte *glGetString(GLenum name);

How it works

Useful right after creating the context, to log which GPU and OpenGL version you actually got. On laptops with two GPUs, this is how you find out the program is running on the integrated one.

Parameters

nameGLenum

Which string to return.

Common values

GL_VERSION
e.g. "4.6.0 NVIDIA 551.23".
GL_RENDERER
GPU name.
GL_VENDOR
Driver vendor.
GL_SHADING_LANGUAGE_VERSION
Highest supported GLSL version.

Return value

A static, null-terminated string owned by the driver. Do not free it. Returns nullptr if there is no current context.

Errors

When the call is invalid it does nothing and sets an error, which glGetError returns:

GL_INVALID_ENUM
name is not accepted.

Example

example.cpp
1std::printf("GPU:    %s\n", glGetString(GL_RENDERER));
2std::printf("OpenGL: %s\n", glGetString(GL_VERSION));
Official Khronos documentation