# GLFW 3.4 / External platform

**URL:** <https://discourse.glfw.org/t/glfw-3-4-external-platform/2572>\
**Category:** support\
**Created:** [February 24, 2024, 8:54pm UTC](https://discourse.glfw.org/t/glfw-3-4-external-platform/2572 "2024-02-24T20:54:00Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ypujante](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/ypujante/32/795_2.png) [@ypujante](https://discourse.glfw.org/u/ypujante)\
**Post date:** [February 24, 2024, 8:54pm UTC](https://discourse.glfw.org/t/glfw-3-4-external-platform/2572/1 "2024-02-24T20:54:00Z")

</div>

I was looking at the 3.4 release and the concept of platform that was introduced. Having worked on the GLFW3 emscripten implementation, I am not too sure how I would implement the `glfwGetPlatform()` API since none of the defines make sense: the code runs in the browser so the platform is “web” or “emscripten”?

I understand that this platform is not part of the official distribution, but GLFW in the browser is a reality… Would it make sense to add a new define for this purpose?

```c
// one of these?
#define GLFW_PLATFORM_WEB 0x00060006
#define GLFW_PLATFORM_EMSCRIPTEN 0x00060006

```

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [February 25, 2024, 7:02pm UTC](https://discourse.glfw.org/t/glfw-3-4-external-platform/2572/2 "2024-02-25T19:02:01Z")

</div>

I think that would make sense, and personally I would choose `GLFW_PLATFORM_EMSCRIPTEN`.

---

<div class="post-metadata">

**Author:** ![ypujante](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/ypujante/32/795_2.png) [@ypujante](https://discourse.glfw.org/u/ypujante)\
**Post date:** [February 25, 2024, 7:13pm UTC](https://discourse.glfw.org/t/glfw-3-4-external-platform/2572/3 "2024-02-25T19:13:45Z")

</div>

Is the right approach to submit a pull request on GitHub?

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [February 26, 2024, 12:08pm UTC](https://discourse.glfw.org/t/glfw-3-4-external-platform/2572/4 "2024-02-26T12:08:31Z")

</div>

The official GLFW repository cannot add this platform define because it doesn’t have the emscripten platform, and I don’t think we can take on an emscripten platform at the moment.

So you should just add this define to your own project: [GitHub - pongasoft/emscripten-glfw: This project is an emscripten port of glfw written in C++ for the web/webassembly platform #wasm](https://github.com/pongasoft/emscripten-glfw)

---

<div class="post-metadata">

**Author:** ![elmindreda](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/elmindreda/32/26_2.png) [@elmindreda](https://discourse.glfw.org/u/elmindreda)\
**Post date:** [February 26, 2024, 12:28pm UTC](https://discourse.glfw.org/t/glfw-3-4-external-platform/2572/5 "2024-02-26T12:28:47Z")

</div>

What we can do is reserve that platform ID for Emscripten, even if it isn’t currently part of the official repository.

---

<div class="post-metadata">

**Author:** ![ypujante](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/ypujante/32/795_2.png) [@ypujante](https://discourse.glfw.org/u/ypujante)\
**Post date:** [February 26, 2024, 12:54pm UTC](https://discourse.glfw.org/t/glfw-3-4-external-platform/2572/6 "2024-02-26T12:54:35Z")

</div>

@dougbinks I know I can add this define to my project (and the emscripten built-in project) and I would be fine doing that, but what if in GLFW 3.5, this value is used for some other platform officially supported by GLFW?

As @elmindreda suggested, it would be great if there was a platform ID reserved for Emscripten.

I suppose an alternative would be to have an official platform ID for “other” (`GLFW_PLATFORM_OTHER`) which could be returned by other platforms not part of the official distribution.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [February 26, 2024, 2:57pm UTC](https://discourse.glfw.org/t/glfw-3-4-external-platform/2572/7 "2024-02-26T14:57:35Z")

</div>

A reserved platform Id for Emscripten is a good idea, though we have to be careful to ensure people don’t think this means they can use GLFW with Emscripten out of the box.

If we go that route I can see some other unofficial platforms wanting to add their defines. If we didn’t want to open up that capability then `GLFW_PLATFORM_OTHER` is a decent alternative. It might be best to offer a range of defines for ports which support multiple platforms (`GLFW_PLATFORM_OTHER_START` to `GLFW_PLATFORM_OTHER_MAX` or similar).

---

<div class="post-metadata">

**Author:** ![ypujante](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/ypujante/32/795_2.png) [@ypujante](https://discourse.glfw.org/u/ypujante)\
**Post date:** [February 26, 2024, 3:28pm UTC](https://discourse.glfw.org/t/glfw-3-4-external-platform/2572/8 "2024-02-26T15:28:38Z")

</div>

I am up for whatever solution makes the most sense for GLFW. Just let me know which way you want to go.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [February 27, 2024, 5:39pm UTC](https://discourse.glfw.org/t/glfw-3-4-external-platform/2572/9 "2024-02-27T17:39:14Z")

</div>

Our current plan is to reserve a define and add a comment in the header that this is reserved.

For example:

```auto
/*! @addtogroup init
 * @{ */
/*! @brief Hint value that enables automatic platform selection.
 *
 * Hint value for @ref GLFW_PLATFORM that enables automatic platform selection.
 */
#define GLFW_ANY_PLATFORM 0x00060000
#define GLFW_PLATFORM_WIN32 0x00060001
#define GLFW_PLATFORM_COCOA 0x00060002
#define GLFW_PLATFORM_WAYLAND 0x00060003
#define GLFW_PLATFORM_X11 0x00060004
#define GLFW_PLATFORM_NULL 0x00060005
/*! @} */

/* Reserved platform define for external Emscripten port: 0x00060006
 * See https://github.com/pongasoft/emscripten-glfw 
 */

```

So you should be able to go ahead and use `0x00060006`.

Does that work for you?

---

<div class="post-metadata">

**Author:** ![ypujante](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/ypujante/32/795_2.png) [@ypujante](https://discourse.glfw.org/u/ypujante)\
**Post date:** [February 27, 2024, 6:27pm UTC](https://discourse.glfw.org/t/glfw-3-4-external-platform/2572/10 "2024-02-27T18:27:46Z")

</div>

Absolutely. This is awesome and would work perfectly!

I am also planning to add support for this new (platform) API to the built-in (javascript) implementations that comes packaged with emscripten since I did some work on it recently. Although they are different implementation (one is C++, the other javascript), they represent the **same** platform. So maybe the comments could be:

```c
/* Reserved platform define for external Emscripten ports: 0x00060006
 * See https://github.com/pongasoft/emscripten-glfw
 * See https://emscripten.org/docs/tools_reference/settings_reference.html?#use-glfw
 */

```

But either way, knowing that this value is reserved is enough for me to move forward with implementation! Thank you so much.

---

<div class="post-metadata">

**Author:** ![ypujante](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/ypujante/32/795_2.png) [@ypujante](https://discourse.glfw.org/u/ypujante)\
**Post date:** [January 30, 2026, 6:14pm UTC](https://discourse.glfw.org/t/glfw-3-4-external-platform/2572/11 "2026-01-30T18:14:40Z")

</div>

Seeing that now GLFW progress is marked as 55%, I just want to make sure that, in the next release, this blurb about the EMSCRIPTEN platforms makes it.

Is the right approach for me to submit a PR for the [GitHub](https://github.com/glfw/glfw) project?

Thanks

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [February 15, 2026, 11:32am UTC](https://discourse.glfw.org/t/glfw-3-4-external-platform/2572/12 "2026-02-15T11:32:58Z")

</div>

Yes I think a PR would be the best way to handle this.
