Skip to content

Commit 3c6bc5a

Browse files
Improve performance
Drop manually swapping buffers to reduce CPU overhead
1 parent 017325c commit 3c6bc5a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/framework/platform/browserwindow.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ void BrowserWindow::terminate() {
154154
emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, EM_TRUE, nullptr);
155155
emscripten_set_focus_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, EM_TRUE, nullptr);
156156
emscripten_set_blur_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, EM_TRUE, nullptr);
157+
emscripten_set_touchend_callback("#canvas", this, EM_TRUE, nullptr);
158+
emscripten_set_touchstart_callback("#canvas", this, EM_TRUE, nullptr);
159+
emscripten_set_touchmove_callback("#canvas", this, EM_TRUE, nullptr);
157160
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_get_current_context();
158161
emscripten_webgl_destroy_context(ctx);
159162

@@ -170,10 +173,8 @@ void BrowserWindow::internalInitGL() {
170173

171174
EmscriptenWebGLContextAttributes attr;
172175
emscripten_webgl_init_context_attributes(&attr);
173-
attr.explicitSwapControl = 1;
174-
attr.renderViaOffscreenBackBuffer = 1;
175176
attr.majorVersion = 2;
176-
attr.alpha = attr.depth = attr.stencil = attr.antialias = attr.preserveDrawingBuffer = attr.failIfMajorPerformanceCaveat = 0;
177+
attr.renderViaOffscreenBackBuffer = attr.explicitSwapControl = attr.alpha = attr.depth = attr.stencil = attr.antialias = attr.preserveDrawingBuffer = attr.failIfMajorPerformanceCaveat = 0;
177178
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_create_context("#canvas", &attr);
178179
emscripten_webgl_make_context_current(ctx);
179180

@@ -492,7 +493,7 @@ void BrowserWindow::handleFocusCallback(int eventType, const EmscriptenFocusEven
492493
}
493494

494495
void BrowserWindow::swapBuffers() {
495-
emscripten_webgl_commit_frame();
496+
// emscripten_webgl_commit_frame(); // removed to improve performance (reduce CPU overhead)
496497
}
497498

498499
void BrowserWindow::setVerticalSync(bool enable) {

0 commit comments

Comments
 (0)