我正在主计算机上使用小型游戏引擎,但是当我在笔记本电脑上克隆该项目时,我收到很多错误消息并显示空白屏幕。
这是我从调用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版本,我认为这可能是某些依赖项版本之间的差异?
提前谢谢大家!
您正在创建OpenGL Core Profile上下文,但是代码使用的是旧式固定功能的东西,例如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);