Create OpenGL fragment and vertex shaders

Qt supports integration with OpenGL implementations on all platforms, so you can display hardware accelerated 3D graphics alongside a more conventional user interface. For more information, see Qt GUI.

You can use the QOpenGLShader class to compile OpenGL shaders written in the OpenGL Shading Language (GLSL) and in the OpenGL/ES Shading Language (GLSL/ES). QOpenGLShader and QOpenGLShaderProgram shelter you from the details of compiling and linking vertex and fragment shaders.

To create OpenGL shaders:

  1. Select File > New File > GLSL.

    {New OpenGL file wizard}

  2. Select the type of the shader to create, and then select Choose.
  3. Follow the instructions of the wizard to create the shader file.
  4. Open the shader file in the code editor, and write the shader code in GLSL or GLSL/ES. The code editor offers syntax highlighting and code completion for the files.

See also Create files and Use project wizards.

© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.