2024

icon emscripten-glfw
2024-10-04

Released emscripten-glfw 3.4.0.20241004 with the following changes:

  • Implemented custom cursors (glfwCreateCursor)
    • uses a canvas to draw the cursor image into it and convert it into a URL (canvas.toDataURL())
    • uses the CSS property syntax: cursor: url(xxx) xhot yhot, auto when calling glfwSetCursor with a custom cursor
icon emscripten-glfw
2024-09-12

Published a blog post properly introducing emscripten-glfw.

You can read about the history of the project and some of the primary features.

An application built with emscripten-glfw

icon emscripten-glfw
2024-09-07

Released emscripten-glfw 3.4.0.20240907 with the following changes:

  • Fixed Meta/Super key workaround to also handle the rare (but possible) use-case of having other keys down before pressing the Meta/Super key
icon emscripten-glfw
2024-08-17

Released emscripten-glfw 3.4.0.20240817 with the following changes:

  • Major clipboard changes: the clipboard now uses the browser events to handle cut, copy and paste
  • Added a way to tweak the timeouts for the Super + Key workaround (Super is also known as Meta or Cmd)
  • Added a way to set which keys are allowed to be handled by the browser
  • Added a convenient API to open a URL (emscripten::glfw3::OpenURL)
  • Added a convenient API to detect if the runtime platform is Apple (emscripten::glfw3::IsRuntimePlatformApple), mostly used for keyboard shortcuts (Ctrl vs. Cmd).
  • Added GLFW/emscripten_glfw3_version.h with EMSCRIPTEN_GLFW_VERSION define for compilation time version detection
  • EMSCRIPTEN_USE_PORT_CONTRIB_GLFW3 port define now also contains the version

Breaking changes:

  • The clipboard async API has been removed.
  • Check the Clipboard support section for details on how to deal with the clipboard in your application.
icon emscripten-glfw
2024-08-04

Released emscripten-glfw 3.4.0.20240804 with the following changes:

  • Fixed nullptr issue when clipboard is empty
  • Fixed the internal clipboard being wiped on asynchronous callback error
icon emscripten-glfw
2024-07-31

Released emscripten-glfw 3.4.0.20240731 with the following changes:

  • Added emscripten_glfw_get_clipboard_string the C version of emscripten::glfw3::GetClipboardString to retrieve the clipboard asynchronously
  • Added a helper class emscripten::glfw3::FutureClipboardString to greatly simplify the more frequent use-cases
  • GetClipboardString::value() now returns the internal clipboard in case of error, instead of throwing exception
  • Added optimizationLevel option to the emscripten port
icon emscripten-glfw
2024-07-27

Released emscripten-glfw 3.4.0.20240727 with the following release notes:

  • Introduced C++ API (namespace emscripten::glfw3) included with GLFW3/emscripten_glfw3.h:
    • provides a more correct API with sensible defaults (ex: std::string_view / std::optional<std::string_view> vs char const * which may or may not be nullptr)
    • allow for C++ only API (ex: std::future)
    • the C API is still available if you would rather stick to it
  • Implemented emscripten::glfw3::GetClipboardString (C++ only) which provides a way of fetching the global clipboard in a browser environment (glfwGetClipboardString is not the right API due to the asynchronous nature of the underlying platform API).
  • The cursor position is no longer clamped to the window size, and as a result, can have negative values or values greater than the window size. Note that GLFW implements a similar behavior on the macOS desktop platform.
  • Implemented glfwSetWindowPosCallback
  • Added support for GLFW Window Attribute GLFW_HOVERED
  • Fixed #6: emscripten_glfw_make_canvas_resizable does not clean up properly.
  • Fixed an issue with opacity: when using opacity, the handle is not working unless its z-index is higher than the canvas z-index
icon emscripten-glfw
2024-06-25

Released emscripten-glfw 3.4.0.20240625 with the following release notes:

  • Implemented workaround for #4: Using Super + “Key” on macOS results in “Key” not being released. Due to the broken state of javascript handling the Super/Meta key, there is no good solution. The workaround implemented, releases all keys when Super is released. Although not a perfect solution, it guarantees that the state is eventually consistent:
    • if “Key” was released while “Super” was held, then when “Super” gets released, “Key” is released (later than when actually released, final state is consistent: “Key” in Release state)
    • if “Key” is still held when “Super” is released, “Key” is released when “Super” gets released, but immediately gets a down event (Up/Down event, final state is consistent”: “Key” in Pressed state)
icon emscripten-glfw
2024-06-17

Released emscripten-glfw 3.4.0.20240617 with the following release notes:

  • Fixed #3: glfwGetKey must return one of GLFW_PRESS or GLFW_RELEASE
icon emscripten-glfw
2024-06-16

Released emscripten-glfw 3.4.0.20240616 with the following release notes:

  • Implemented glfwGetClipboardString. Note that due to the async (and restrictive) nature of the navigator.clipboard.readText call, this synchronous API returns whatever was set via a previous call to glfwSetClipboardString and ignores the external clipboard entirely.
icon emscripten-glfw
2024-06-01

Released emscripten-glfw 3.4.0.20240601 with the following release notes:

  • Fixed #2: Dynamically changing HiDPI awareness does not trigger content callback
icon emscripten-glfw
2024-05-24

Released emscripten-glfw 3.4.0.20240514 with the following release notes:

  • Implemented glfwSetClipboardString
icon emscripten-glfw
2024-05-01

Released emscripten-glfw 3.4.0.20240501 with the following release notes:

  • Fixed issue when calling glfwGetWindowContentScale with nullptr
  • Renamed javascript api/impl since these names are not unique to avoid potential conflicts
  • Added glfw3native.h to GLFW. Although not used (at this moment) by this implementation, this allows calling code to include it if necessary since it is part of a normal GLFW installation.
icon emscripten-glfw
2024-03-18

Released emscripten-glfw 3.4.0.20240318 with the following release notes:

  • Fixed joystick/gamepad code that was improperly mapping GLFW_GAMEPAD_AXIS_LEFT_TRIGGER GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER, GLFW_GAMEPAD_BUTTON_LEFT_THUMB and GLFW_GAMEPAD_BUTTON_RIGHT_THUMB
  • GLFW_GAMEPAD_AXIS_LEFT_TRIGGER and GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER are now properly represented as an analog value in the range [-1.0, +1.0]
  • Please note the change in version numbering which from now on will be tied to the GLFW version implemented + date of release of this port to avoid confusion
icon emscripten-glfw
2024-02-29

I released emscripten-glfw 1.1.0 which implements GLFW 3.4 APIs:

  • Upgraded to GLFW 3.4
  • GLFW 3.4 features implemented
    • glfwGetPlatform and glfwPlatformSupported uses the GLFW_PLATFORM_EMSCRIPTEN constant defined in emscripten-glfw3.h (officially reserved value is 0x00060006)
    • glfwInitHint supports the new hint GLFW_PLATFORM
    • Supports all 10 cursors
    • Implemented glfwGetWindowTitle
    • Use GLFW_SCALE_FRAMEBUFFER to enable (resp. disable) Hi DPI support
    • Changed the functions that can report GLFW_FEATURE_UNAVAILABLE failure to report this error instead of a warning
  • GLFW 3.4 features not implemented
    • GLFW_MOUSE_PASSTHROUGH is not supported
    • GLFW_CURSOR_CAPTURED cursor input mode is not supported (not possible in a browser context)
    • glfwInitAllocator is implemented as noop (could be supported for the C++ part only if there is demand, not javascript)
    • GLFW_POSITION_X and GLFW_POSITION_Y are not supported (same as glfwSetWindowPos)
    • GLFW_ANGLE_PLATFORM_TYPE is not supported (no direct access in browser, but implementation is most likely using it anyway)
  • Since GLFW 3.4 introduces a proper constant to handle Hi DPI Awareness (GLFW_SCALE_FRAMEBUFFER), the prior constant used by this port (GLFW_SCALE_TO_MONITOR) is still accepted, but it is now deprecated. In addition, due to the fact that GLFW_SCALE_FRAMEBUFFER defaults to GLFW_TRUE, this port is now Hi DPI aware by default and needs to be explicitly turned off (glfwWindowHint(GLFW_SCALE_FRAMEBUFFER, GLFW_FALSE)) if this is the desired behavior.

Note: These changes are available in emscripten 3.1.56 (released on 2024/03/14) via the contrib port contrib.glfw3

icon emscripten-glfw
2024-02-19

I released emscripten-glfw 1.0.5 with a critical bug fix:

  • Fixed memory corruption with joystick

Note: These changes are available in emscripten 3.1.55 (released on 2024/03/01) via the contrib port contrib.glfw3

icon emscripten-glfw
2024-01-22

I am very happy to announce the 1.0 release of my new free and open source project emscripten-glfw which is a port of glfw written in C++ for the web/webassembly platform.

Check out the live demo. Screenshot