Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ifdef out GL_FRAMEBUFFER_UNDEFINED from webgl builds #933

Closed
wants to merge 1 commit into from

Conversation

danielchasehooper
Copy link
Contributor

GL_FRAMEBUFFER_UNDEFINED doesn't exist in webgl2, ifdef it out.

GL_FRAMEBUFFER_UNDEFINED doesn't exist in webgl2, ifdef it out.
@danielchasehooper
Copy link
Contributor Author

Not sure if #if !defined(SOKOL_GLES3) would be better? Not that it matters right now, but maybe that would be more robust to future gl versions?

@floooh
Copy link
Owner

floooh commented Nov 1, 2023

Strange, sokol_gfx.h includes GLES3/gl3.h on Emscripten:

sokol/sokol_gfx.h

Lines 4217 to 4221 in bd7fa93

#elif defined(__EMSCRIPTEN__) || defined(__ANDROID__)
#if defined(SOKOL_GLES3)
#include <GLES3/gl3.h>
#endif
#elif defined(__linux__) || defined(__unix__)

...and this includes the definition:

https://github.com/emscripten-core/emscripten/blob/4de99429ecb854e346b32edc04cfa261c37b05d9/system/include/GLES3/gl3.h#L830

The Emscripten builds are also working fine in CI (and of course locally on my machine):

https://github.com/floooh/sokol-samples/actions/runs/6697850493

https://github.com/floooh/sokol/actions/runs/6697703312

No idea how it could fail tbh...

PS: ignore the confusion with the various edits of this comment, I was confusing OpenGL's GL_FRAMEBUFFER_UNDEFINED, with sokol_gfx.h's GL_FRAMEBUFFER_STATUS_UNDEFINED.

But still, GL_FRAMEBUFFER_UNDEFINED is defined in GLES3/gl3.h, ...so I still don't have any idea what could go wrong :)

What's you Emscripten SDK version?

@floooh
Copy link
Owner

floooh commented Nov 1, 2023

Ah, now I see, the WebGL2 spec removed it (see: https://registry.khronos.org/webgl/specs/latest/2.0/)

5.8 Default Framebuffer
WebGL always has a default framebuffer. The FRAMEBUFFER_UNDEFINED enumerant is removed from the WebGL 2.0 API.

Since Emscripten uses the GLES3/gl3.h header it compiles though even if WebGL2 doesn't have that error value. Are you using different headers than what Emscripten provides?

(apart from that, the best define to check for would probably be __EMSCRIPTEN__, since it's purely a WebGL2 thing, but only if there are headers flying around for WebGL2 C shims which differ from the GLES3 headers)

@danielchasehooper
Copy link
Contributor Author

Ah, yeah we're not using emscripten. we use clang's wasm target directly and wrote our own webgl headers and javascript glue. I guess we'll go the route of matching GLES3 headers. Thanks for the comments!

@floooh
Copy link
Owner

floooh commented Feb 26, 2024

FYI I have solved this a bit differently (will be part of #985):

#if defined(SOKOL_GLES3)
    // on WebGL2, GL_FRAMEBUFFER_UNDEFINED technically doesn't exist (it is defined
    // in the Emscripten headers, but may not exist in other WebGL2 shims)
    // see: https://github.com/floooh/sokol/pull/933
    #ifndef GL_FRAMEBUFFER_UNDEFINED
    #define GL_FRAMEBUFFER_UNDEFINED 0x8219
    #endif
#endi

(the WebGL2 APIs will never return GL_FRAMEBUFFER_UNDEFINED, so the define just exists to make the code compile, even if that specific error code will never be returned)

@floooh floooh closed this Feb 26, 2024
@danielchasehooper danielchasehooper deleted the patch-1 branch February 26, 2024 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants