<small id='w3mLO'></small><noframes id='w3mLO'>

<i id='w3mLO'><tr id='w3mLO'><dt id='w3mLO'><q id='w3mLO'><span id='w3mLO'><b id='w3mLO'><form id='w3mLO'><ins id='w3mLO'></ins><ul id='w3mLO'></ul><sub id='w3mLO'></sub></form><legend id='w3mLO'></legend><bdo id='w3mLO'><pre id='w3mLO'><center id='w3mLO'></center></pre></bdo></b><th id='w3mLO'></th></span></q></dt></tr></i><div id='w3mLO'><tfoot id='w3mLO'></tfoot><dl id='w3mLO'><fieldset id='w3mLO'></fieldset></dl></div>
  • <legend id='w3mLO'><style id='w3mLO'><dir id='w3mLO'><q id='w3mLO'></q></dir></style></legend>
    • <bdo id='w3mLO'></bdo><ul id='w3mLO'></ul>
    1. <tfoot id='w3mLO'></tfoot>

        Qt5 OpenGL GLSL 版本错误

        时间:2023-09-17

          1. <tfoot id='cNFo7'></tfoot>
            <legend id='cNFo7'><style id='cNFo7'><dir id='cNFo7'><q id='cNFo7'></q></dir></style></legend>
            • <small id='cNFo7'></small><noframes id='cNFo7'>

                <tbody id='cNFo7'></tbody>

                <bdo id='cNFo7'></bdo><ul id='cNFo7'></ul>
                <i id='cNFo7'><tr id='cNFo7'><dt id='cNFo7'><q id='cNFo7'><span id='cNFo7'><b id='cNFo7'><form id='cNFo7'><ins id='cNFo7'></ins><ul id='cNFo7'></ul><sub id='cNFo7'></sub></form><legend id='cNFo7'></legend><bdo id='cNFo7'><pre id='cNFo7'><center id='cNFo7'></center></pre></bdo></b><th id='cNFo7'></th></span></q></dt></tr></i><div id='cNFo7'><tfoot id='cNFo7'></tfoot><dl id='cNFo7'><fieldset id='cNFo7'></fieldset></dl></div>

                1. 本文介绍了Qt5 OpenGL GLSL 版本错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我开始在 Qt 和着色器中使用 OpenGL(我有 OpenGL 经验,但还没有使用着色器)

                  I'm starting out on using OpenGL with Qt, and with Shaders (I have OpenGL experience, but not with shaders yet)

                  我正在学习本教程:http://releases.qt-project.org/learning/developerguides/qtopengltutorial/OpenGLTutorial.pdf(Qt5 OpenGL 官方教程).

                  I'm following this tutorial: http://releases.qt-project.org/learning/developerguides/qtopengltutorial/OpenGLTutorial.pdf (the official Qt5 OpenGL tutorial).

                  问题是,当我尝试运行我的程序时,出现黑屏并显示以下错误消息:

                  The problem is, that when I try to run my program, I get a black screen and the following error messages:

                  QGLShader::compile(Vertex): ERROR: 0:1: '' :  version '130' is not supported
                  
                  QGLShader::compile(Fragment): ERROR: 0:1: '' :  version '130' is not supported
                  

                  我的程序基于 QGLWidget

                  My program is based on a QGLWidget

                  通过在互联网上的一些浏览,我发现我需要使用 OpenGL 3.2 上下文,但 Qt 喜欢使用 OpenGL 2.x

                  With some browsing on the interwebs I found out that I need to use an OpenGL 3.2 context, but that Qt likes to use OpenGL 2.x

                  我的电脑:

                  • MacBook Pro Retina '15,2012 年末
                  • 英特尔 HD 4000
                  • NVIDIA GeForce 650M

                  那么,我怎样才能做到这一点?

                  So, how can I make this work?

                  我的版本是 3.2(通过 QGLFormat 设置),没有指定格式它使用 2.0

                  My version is 3.2 (set through QGLFormat), without a specified format it uses 2.0

                  fragmentShader.frag:

                  fragmentShader.frag:

                  #version 130
                  
                  uniform vec4 color;
                  
                  out vec4 fragColor;
                  
                  void main(void)
                  {
                      fragColor = color;
                  }
                  

                  vertexShader.vert:

                  vertexShader.vert:

                  #version 130
                  
                  uniform mat4 mvpMatrix;
                  
                  in vec4 vertex;
                  
                  void main(void)
                  {
                      gl_Position = mvpMatrix * vertex;
                  }
                  

                  错误(格式,OpenGL 3.2):

                  Errors (with format, OpenGL 3.2):

                  QGLShaderProgram: shader programs are not supported 
                  QGLShaderProgram::uniformLocation( mvpMatrix ): shader program is not linked 
                  The program has unexpectedly finished.
                  

                  错误(无格式,OpenGL 2.0):

                  Errors (without format, OpenGL 2.0):

                  QGLShader::compile(Vertex): ERROR: 0:1: '' :  version '130' is not supported
                  
                  QGLShader::compile(Fragment): ERROR: 0:1: '' :  version '130' is not supported
                  

                  推荐答案

                  较新的 QOpenGLWidget 不支持任何带有 QGLFormat 的构造函数.相反,在您的 main.cpp 中,为所有 QOpenGLWidgetQOpenGLContext 指定默认的 QSurfaceFormat 如下:

                  Newer QOpenGLWidget doesn't support any constructor with QGLFormat. Instead, in your main.cpp, specify the default QSurfaceFormat for all QOpenGLWidget and QOpenGLContext as following:

                  // main.cpp
                  QSurfaceFormat glFormat;
                  glFormat.setVersion(3, 3);
                  glFormat.setProfile(QSurfaceFormat::CoreProfile);
                  QSurfaceFormat::setDefaultFormat(glFormat);
                  

                  现在你应该可以在你的着色器中使用类似 #version 330 core 的东西了.

                  Now you should be able to use something like #version 330 core in your shader.

                  这篇关于Qt5 OpenGL GLSL 版本错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:对 `_imp__glewInit@0' 的未定义引用 下一篇:OpenGL GLFW:对“glfwInit"的未定义引用

                  相关文章

                  最新文章

                  <i id='kPJDN'><tr id='kPJDN'><dt id='kPJDN'><q id='kPJDN'><span id='kPJDN'><b id='kPJDN'><form id='kPJDN'><ins id='kPJDN'></ins><ul id='kPJDN'></ul><sub id='kPJDN'></sub></form><legend id='kPJDN'></legend><bdo id='kPJDN'><pre id='kPJDN'><center id='kPJDN'></center></pre></bdo></b><th id='kPJDN'></th></span></q></dt></tr></i><div id='kPJDN'><tfoot id='kPJDN'></tfoot><dl id='kPJDN'><fieldset id='kPJDN'></fieldset></dl></div>

                    <bdo id='kPJDN'></bdo><ul id='kPJDN'></ul>
                2. <small id='kPJDN'></small><noframes id='kPJDN'>

                    <tfoot id='kPJDN'></tfoot>
                    1. <legend id='kPJDN'><style id='kPJDN'><dir id='kPJDN'><q id='kPJDN'></q></dir></style></legend>