【问题标题】:SFML and OpenGL causes GL_INVALID_OPERATIONS when calling the draw functionSFML 和 OpenGL 在调用绘图函数时会导致 GL_INVALID_OPERATIONS
【发布时间】:2020-03-06 08:41:20
【问题描述】:

我正在我的主计算机上开发一个小型游戏引擎,但是当我在笔记本电脑上克隆项目时,我收到了很多错误消息并显示一个空白屏幕。

以下是我在调用 SFML 绘图函数时收到的每一帧的一些错误消息:

Warning: The created OpenGL context does not fully meet the settings that were requested
Requested: version = 4.4 ; depth bits = 24 ; stencil bits = 8 ; AA level = 1 ; core = false ; debug = false ; sRGB = false
Created: version = 4.5 ; depth bits = 24 ; stencil bits = 8 ; AA level = 4 ; core = true ; debug = false ; sRGB = false
An internal OpenGL call failed in RenderTarget.cpp(369).
Expression:
   GLEXT_glClientActiveTexture(GLEXT_GL_TEXTURE0)
Error description:
   GL_INVALID_OPERATION
   The specified operation is not allowed in the current state.

An internal OpenGL call failed in RenderTarget.cpp(375).
Expression:
   glDisable(GL_LIGHTING)
Error description:
   GL_INVALID_ENUM
   An unacceptable value has been specified for an enumerated argument.

An internal OpenGL call failed in RenderTarget.cpp(377).
Expression:
   glDisable(GL_ALPHA_TEST)
Error description:
   GL_INVALID_ENUM
   An unacceptable value has been specified for an enumerated argument.

An internal OpenGL call failed in RenderTarget.cpp(378).
Expression:
   glEnable(GL_TEXTURE_2D)
Error description:
   GL_INVALID_ENUM
   An unacceptable value has been specified for an enumerated argument.

An internal OpenGL call failed in RenderTarget.cpp(380).
Expression:
   glMatrixMode(GL_MODELVIEW)
Error description:
   GL_INVALID_OPERATION
   The specified operation is not allowed in the current state.

An internal OpenGL call failed in RenderTarget.cpp(381).
Expression:
   glEnableClientState(GL_VERTEX_ARRAY)
Error description:
   GL_INVALID_OPERATION
   The specified operation is not allowed in the current state.

我只是在菜单屏幕中绘制精灵和纹理,似乎即使是 OpenGL 函数绘制也会产生错误。这是我的 github 仓库的链接:https://github.com/ZzkilzZ/mfengine

我在我的两台计算机上都运行 Ubuntu 的 LTS 版本,我认为这可能是某些依赖项的版本存在差异?

编辑: 这些是我的 glxinfo 结果:

OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Haswell Mobile 
OpenGL core profile version string: 4.5 (Core Profile) Mesa 19.0.8
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 19.0.8
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.1 Mesa 19.0.8
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10
OpenGL ES profile extensions:

我正在运行 Ubuntu 18.4 LTS

【问题讨论】:

  • 你在什么 GPU 和操作系统上运行?
  • 我添加了 glxinfo 的结果,我应该可以使用 4.5 :/
  • 表示可以使用4.5 Core Profile,不兼容。
  • 在我的另一台运行良好的计算机上,除了 4.6 之外,它说的相同:/

标签: c++ opengl sfml


【解决方案1】:

感谢@SurvivalMachine 和@derhass 的帮助! 我最终将 opengl 降级到 3.0 版,将 glsl 降级到 130 核心,并让菜单屏幕再次工作。它会加载除着色器以外的所有内容,但我怀疑这是我使用更现代功能的结果。我正在放弃旧电脑,这对于 2015 年的电脑来说似乎是太大的牺牲:D

【讨论】:

    【解决方案2】:

    您正在创建一个 OpenGL 核心配置文件上下文,但代码使用了旧版固定功能的东西,例如 glDisable(GL_LIGHTING)。解决方案是在创建上下文时请求兼容性配置文件。如果兼容性配置文件可用,这取决于您的 OpenGL 实现。我建议你找一个更现代的示例代码。

    看起来兼容配置文件可以在 SFML 的sf::ContextSettings::attributeFlags 中设置或

    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR,4);
    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR,5);
    glfwOpenWindowHint(GLFW_OPENGL_PROFILE,GLFW_OPENGL_COMPAT_PROFILE);
    

    【讨论】:

    • 好像是 SFML 调用了这些函数……谢谢,我试试看!
    • 为什么我只在一台计算机上得到错误,而不是在另一台计算机上?
    • @ZzkilzZ 可能您的其他计算机的 OpenGL 实现默认为兼容性配置文件。
    • 您知道是否有任何方法可以强制使用不同的配置文件?有没有办法在我的 glew 初始化期间请求其他配置文件?
    • @ZzkilzZ 我扩展了我的答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-07-02
    • 1970-01-01
    • 1970-01-01
    • 2013-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多