原因是什么?

这个错误只出现一次,并且是在第一帧时出现。
Warning: detected OpenGL error 'invalid operation' after applying attribute Viewport 04292398

应该是执行报错

osg/Viewport.cpp
void Viewport::apply(State&) const
{
glViewport( static_cast<GLint>(_x),static_cast<GLint>(_y),
static_cast<GLsizei>(_width),static_cast<GLsizei>(_height) );
}
pState->setCheckForGLErrors(osg::State::CheckForGLErrors::ONCE_PER_ATTRIBUTE)
osg/State
enum CheckForGLErrors
{
/** NEVER_CHECK_GL_ERRORS hints that OpenGL need not be checked for, this
is the fastest option since checking for errors does incur a small overhead.*/
NEVER_CHECK_GL_ERRORS,
/** ONCE_PER_FRAME means that OpenGL errors will be checked for once per
frame, the overhead is still small, but at least OpenGL errors that are occurring
will be caught, the reporting isn't fine grained enough for debugging purposes.*/
ONCE_PER_FRAME,
/** ONCE_PER_ATTRIBUTE means that OpenGL errors will be checked for after
every attribute is applied, allow errors to be directly associated with
particular operations which makes debugging much easier.*/
ONCE_PER_ATTRIBUTE
};
默认为:ONCE_PER_FRAME
在osg学习中遇到一个问题,在第一帧渲染时警告显示OpenGL错误'invalid operation'。该错误只出现一次,通常与Viewport设置有关。通过查阅资料,发现可能的原因是配置不当导致的,可以参考相关论坛讨论进行调试。建议修改osg::State的CheckForGLErrors设置为ONCE_PER_ATTRIBUTE以定位问题。

被折叠的 条评论
为什么被折叠?



