其他分享
首页 > 其他分享> > c – OpenGL中出现奇怪的GL_INVALID_OPERATION错误

c – OpenGL中出现奇怪的GL_INVALID_OPERATION错误

作者:互联网

glClearColor( 1.0f, 1.0f, 1.0f, 1.0f );

AttachVertexShader( shader, "szescian_vs.glsl" );
AttachFragmentShader( shader, "szescian_fs.glsl" );
LinkProgram( shader );

glBindVertexArray( vertexVAO );

glGenBuffers( 1, &positionBuffer );

glGenBuffers( 1, &positionBuffer );
glBindBuffer( GL_ARRAY_BUFFER, positionBuffer );
glBufferData( GL_ARRAY_BUFFER, sizeof( position ), position, GL_STATIC_DRAW );
positionLoc = glGetAttribLocation( shader, "inPosition" );
glEnableVertexAttribArray ( positionLoc );
glVertexAttribPointer ( positionLoc, 3, GL_FLOAT, GL_FALSE, 0, ( void* ) 0 ); //here gDEBugger GL breaks on OpenGL Error

这是我的初始化函数的一部分,我真的不知道为什么gDEBugger打破了它,有人可以为我解释一下吗?

Break Reason OpenGL Error Breaked-on glVertexAttribPointer(0 , 3
, GL_FLOAT , FALSE , 0 , 0x00000000) Error-Code
GL_INVALID_OPERATION Error-Description The specified operation is
not allowed in the current state. The offending function is ignored,
having no side effect other than to set the error flag.
* Stopped before function execution

这是休息信息.

解决方法:

glVertexAttribPointer()生成的可能GL_INVALID_OPERATION错误:

>如果尺寸为GL_BGRA且类型不是,则生成GL_INVALID_OPERATION
GL_UNSIGNED_BYTE,GL_INT_2_10_10_10_REV或GL_UNSIGNED_INT_2_10_10_10_REV.
>如果类型为GL_INT_2_10_10_10_REV,则生成GL_INVALID_OPERATION
或GL_UNSIGNED_INT_2_10_10_10_REV且尺寸不是4或GL_BGRA.
>如果type为,则生成GL_INVALID_OPERATION
GL_UNSIGNED_INT_10F_11F_11F_REV且大小不是3.
> GL_INVALID_OPERATION由glVertexAttribPointer生成(如果大小)
是GL_BGRA,noramlized是GL_FALSE.
>如果零绑定到,则生成GL_INVALID_OPERATION
GL_ARRAY_BUFFER缓冲区对象绑定点和指针参数
不是NULL.

http://www.opengl.org/sdk/docs/man/xhtml/glVertexAttribPointer.xml

标签:opengl-3,c,opengl
来源: https://codeday.me/bug/20190825/1720129.html