From eaf60b41011c7d44412098ed48068fafa8ffd5aa Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Sat, 5 Oct 2024 10:45:17 -0400 Subject: [PATCH] note about buffer swapping --- simpledisplay.d | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/simpledisplay.d b/simpledisplay.d index 5e707e9..a188007 100644 --- a/simpledisplay.d +++ b/simpledisplay.d @@ -3272,11 +3272,18 @@ class SimpleWindow : CapableOfHandlingNativeEvent, CapableOfBeingDrawnUpon { /++ simpledisplay always uses double buffering, usually automatically. This - manually swaps the OpenGL buffers. + manually swaps the OpenGL buffers. You should only use this if you are NOT + using the [redrawOpenGlScene] delegate. - You should not need to call this yourself because simpledisplay will do it - for you after calling your `redrawOpenGlScene`. + You must not this yourself if you use [redrawOpenGlScene] because simpledisplay will do it + for you after calling your `redrawOpenGlScene`. Please note that once you swap + buffers, the contents become undefined - the implementation, in the OpenGL driver + or the desktop compositor, may not actually just swap two buffers. The back buffer's + contents are $(B undefined) after calling this function. + + See: https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-swapbuffers + and https://linux.die.net/man/3/glxswapbuffers Remember that this may throw an exception, which you can catch in a multithreaded application to keep your thread from dying from an unhandled exception.