Skip to content

Commit 44017c1

Browse files
committed
Updated readme and documentation
1 parent 870aecc commit 44017c1

File tree

6 files changed

+72
-9
lines changed

6 files changed

+72
-9
lines changed

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
cmake_minimum_required(VERSION 3.10)
22

33
set(emscripten-glfw_RELEASE_YEAR "2025")
4-
set(emscripten-glfw_RELEASE_MONTH "06" )
5-
set(emscripten-glfw_RELEASE_DAY "07" )
4+
set(emscripten-glfw_RELEASE_MONTH "08" )
5+
set(emscripten-glfw_RELEASE_DAY "24" )
66

77
set(emscripten-glfw_GLFW_VERSION "3.4.0")
88

@@ -57,7 +57,7 @@ if(NOT EMSCRIPTEN_GLFW3_DISABLE_JOYSTICK)
5757
endif()
5858

5959
# Update the version appropriately
60-
configure_file("${CMAKE_CURRENT_LIST_DIR}/version.h.in" "${CMAKE_CURRENT_BINARY_DIR}/emscripten_glfw3_version.h" @ONLY)
60+
configure_file("${CMAKE_CURRENT_LIST_DIR}/version.h.in" "${CMAKE_CURRENT_LIST_DIR}/include/GLFW/emscripten_glfw3_version.h" @ONLY)
6161

6262
macro(add_glfw_lib LIBRARY_NAME)
6363
add_library(${LIBRARY_NAME} ${glfw3_sources})

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ Introduction
44
This project is an Emscripten port of GLFW written in C++ for the web/wasm platform. The currently supported
55
GLFW API is 3.4.
66

7-
[![emscripten - 4.0.11](https://img.shields.io/badge/emscripten-4.0.11-blue)](https://emscripten.org)
8-
[![contrib.glfw3 - 3.4.0.20250607](https://img.shields.io/badge/contrib.glfw3-3.4.0.20250607-blue)](https://github.com/pongasoft/emscripten-glfw/releases/latest)
7+
[![emscripten - TBD](https://img.shields.io/badge/emscripten-TBD-blue)](https://emscripten.org)
8+
[![contrib.glfw3 - 3.4.0.20250824](https://img.shields.io/badge/contrib.glfw3-3.4.0.20250824-blue)](https://github.com/pongasoft/emscripten-glfw/releases/latest)
99
[![GLFW - 3.4.0](https://img.shields.io/badge/GLFW-3.4.0-blue)](https://www.glfw.org/)
1010
[![License](https://img.shields.io/badge/License-Apache%20License%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
1111
![Compiles](https://github.com/pongasoft/emscripten-glfw/actions/workflows/main.yml/badge.svg)
1212

13+
[![emscripten - 4.0.11](https://img.shields.io/badge/emscripten-4.0.11-blue)](https://emscripten.org)
14+
[![contrib.glfw3 - 3.4.0.20250607](https://img.shields.io/badge/contrib.glfw3-3.4.0.20250607-blue)](https://github.com/pongasoft/emscripten-glfw/releases/latest)
15+
[![GLFW - 3.4.0](https://img.shields.io/badge/GLFW-3.4.0-blue)](https://www.glfw.org/)
16+
1317
Goal
1418
----
1519

@@ -209,6 +213,7 @@ emcc --use-port=contrib.glfw3:disableWarning=true:disableMultiWindow=true main.c
209213
> #### Note about availability in Emscripten
210214
> | Emscripten | this port |
211215
> |------------|----------------|
216+
> | TBD | 3.4.0.20250824 |
212217
> | 4.0.11 | 3.4.0.20250607 |
213218
> | 4.0.5 | 3.4.0.20250305 |
214219
> | 4.0.4 | 3.4.0.20250209 |
@@ -243,6 +248,14 @@ Check the [Building](docs/Building.md) page for details on how to build this pro
243248
244249
Release Notes
245250
-------------
251+
#### 3.4.0.20250824 - 2025-08-24 | Emscripten TBD
252+
253+
- The code has been optimized for size
254+
- Fixed [#21](https://github.com/pongasoft/emscripten-glfw/issues/21): Flicker when resizing
255+
- to fix this issue, resizing (when the handle is moved or the window resized) is now delayed until `glfwPollEvents()`
256+
is called. Make sure to call `glfwPollEvents()` at the beginning of the loop to ensure a flicker-free experience.
257+
See [Events & Main loop](docs/Usage.md#events--main-loop) for more details.
258+
246259
#### 3.4.0.20250607 - 2025-06-07 | Emscripten 4.0.11
247260
248261
- The main port file has been simplified and is now using the new (as of 4.0.10) "external port file" Emscripten feature

archive.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ src/cpp/emscripten/glfw3/Cursor.h
1212
src/cpp/emscripten/glfw3/ErrorHandler.cpp
1313
src/cpp/emscripten/glfw3/ErrorHandler.h
1414
src/cpp/emscripten/glfw3/Events.h
15+
src/cpp/emscripten/glfw3/Events.cpp
1516
src/cpp/emscripten/glfw3/Joystick.cpp
1617
src/cpp/emscripten/glfw3/Joystick.h
1718
src/cpp/emscripten/glfw3/Keyboard.cpp

docs/Usage.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,55 @@ emscripten::glfw3::MakeCanvasResizable(window, "#canvas1-container", "canvas1-ha
165165
> If you do not want the canvas to be resizable by the user, you can simply set its size during window creation
166166
> (`glfwCreateWindow`) or with `glfwSetWindowSize` and don't do anything else.
167167
168+
## Events & Main loop
169+
170+
It is strongly recommended to use the `emscripten_set_main_loop` (or `emscripten_set_main_loop_arg`) API
171+
provided by Emscripten to run the main loop.
172+
173+
Here is an example:
174+
175+
```cpp
176+
//! The main loop (called by emscripten for each frame)
177+
void main_loop(void *user_data)
178+
{
179+
auto window = reinterpret_cast<GLFWwindow *>(user_data);
180+
if(!glfwWindowShouldClose(window))
181+
{
182+
glfwPollEvents();
183+
184+
// render frame
185+
// ...
186+
}
187+
else
188+
{
189+
// done => terminating
190+
glfwTerminate();
191+
emscripten_cancel_main_loop();
192+
}
193+
}
194+
195+
//! main
196+
int main()
197+
{
198+
// create the window...
199+
// auto window = glfwCreateWindow(...);
200+
201+
// tell emscripten to use "main_loop" as the main loop (window is user data)
202+
emscripten_set_main_loop_arg(main_loop, window, 0, GLFW_FALSE);
203+
}
204+
```
205+
206+
This ensures that the `requestAnimationFrame` mechanism of the browser is used
207+
(see [documentation](https://emscripten.org/docs/api_reference/emscripten.h.html#c.emscripten_set_main_loop)).
208+
209+
> [!Note]
210+
> `glfwPollEvents()` is called at the beginning of the loop because it processes the events that are necessary
211+
> for rendering the frame. In particular, it applies any window resize request, which triggers the canvas to be
212+
> resized. When the canvas gets resized, the browser paints it black, which is why the "render frame" section
213+
> needs to re-render the content (using the new size).
214+
215+
216+
168217
## Fullscreen support
169218

170219
GLFW has a concept of a fullscreen window.

include/GLFW/emscripten_glfw3_version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
// #if EMSCRIPTEN_GLFW_VERSION >= 3'4'0'20240801
2525
// .... code that can be used past a certain release
2626
// #endif
27-
#define EMSCRIPTEN_GLFW_VERSION 3'4'0'20250607
27+
#define EMSCRIPTEN_GLFW_VERSION 3'4'0'20250824
2828

29-
#define EMSCRIPTEN_GLFW_FULL_VERSION_STR "3.4.0.20250607"
29+
#define EMSCRIPTEN_GLFW_FULL_VERSION_STR "3.4.0.20250824"
3030

3131
#endif

port/emscripten-glfw3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
#
1515
# @author Yan Pujante
1616

17-
TAG = '3.4.0.20250607'
17+
TAG = '3.4.0.20250824'
1818

1919
EXTERNAL_PORT = f'https://github.com/pongasoft/emscripten-glfw/releases/download/v{TAG}/emscripten-glfw3-{TAG}.zip'
20-
SHA512 = '1b264ac8891ffff51b899ca5853d4f945294dde9a9191eb5df9dd4cb26a4b27c5e7dac99cad42466833e9aae76d450de8a4b84381a63214321dc0427fd054f1b'
20+
SHA512 = 'b5b3670b80c87571ea56a54e701874d6b2323f74e359782a15c9ae0a931341fb05e4c778945950f8846aef66c7cc48556d30c8cc5939c87e3091c8be63856a1a'
2121
PORT_FILE = 'port/glfw3.py'
2222

2323
# contrib port information (required)

0 commit comments

Comments
 (0)