FosterFramework / Foster

A small C# game framework
MIT License
422 stars 37 forks source link

Avoid GL_INVALID_ENUM generation by glDrawBuffers #53

Closed andymandias closed 6 months ago

andymandias commented 6 months ago

When running Celeste64 from the command line a bunch of errors are generated of the form GL (ERROR:HIGH) GL_INVALID_ENUM in glDrawBuffers(invalid buffer GL_BACK). I don't believe there's any meaningful impact on the rendering being done, but for the sake of a tidy command line this tiny patch addresses that error message.

References I used: https://registry.khronos.org/OpenGL-Refpages/gl4/html/glDrawBuffers.xhtml https://www.khronos.org/opengl/wiki/Default_Framebuffer https://registry.khronos.org/OpenGL/api/GL/glcorearb.h

NoelFB commented 6 months ago

Thanks! I noticed some reports of this so definitely want to fix it and will merge this in ... but do you know the actual difference between GL_BACK_LEFT and GL_BACK? I figured that GL_BACK would be the correct case since we want to draw to the backbuffer.

andymandias commented 6 months ago

My understanding is that GL_BACK, in the context of Framebuffer Objects, is an alias for both the GL_BACK_LEFT and GL_BACK_RIGHT buffers. This is in contrast to the default framebuffer context, where GL_BACK refers to the (singular) back buffer. The multiple buffers are for the possibility of stereoscopic rendering, but when you're not rendering in stereo then GL_BACK_LEFT (and GL_FRONT_LEFT) are the only active buffers. I believe the way this is squared is that when GL_BACK_RIGHT is not active (i.e. when not rendering in stereo), GL_BACK works as an alias to GL_BACK_LEFT only; in effect, GL_BACK_LEFT and GL_BACK are equivalent. Why that wasn't extended to allow GL_BACK as an input to glDrawBuffers, I can only speculate.

NoelFB commented 6 months ago

That makes sense, thanks for the insights and digging into solving this! :)

andymandias commented 6 months ago

Thanks! Huge fan of your work.