From f2647da50ff9e96e337adbc20ceed35b5e324817 Mon Sep 17 00:00:00 2001 From: rexim Date: Thu, 5 Dec 2019 06:12:50 +0700 Subject: [PATCH] (#26) Add experimental Live Update feature --- README.md | 12 ++++++++++++ src/boomer.nim | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/README.md b/README.md index 1a86673..f1f8c81 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,16 @@ $ ln -s /path/to/boomer/overlay/ boomer $ nix-env -iA nixos.boomer ``` +## Experimental Live Update + +See issue [#26]. For an experimental Live Update feature compile the application with the following flags: + +```console +$ nimble build -d:live +``` + +The feature is really unstable and experimental, so use it at your own risk. + ## References - https://github.com/nim-lang/x11/blob/bf9dc74dd196a98b7c2a2beea4d92640734f7c60/examples/x11ex.nim @@ -46,3 +56,5 @@ You can support my work via - Twitch channel: https://www.twitch.tv/subs/tsoding - Patreon: https://www.patreon.com/tsoding + +[#26]: https://github.com/tsoding/boomer/issues/26 diff --git a/src/boomer.nim b/src/boomer.nim index bbb18bc..a93f87d 100644 --- a/src/boomer.nim +++ b/src/boomer.nim @@ -393,4 +393,24 @@ proc main() = glXSwapBuffers(display, win) glFinish() + when defined(live): + screenshot = XGetSubImage(display, root, + 0, 0, + screenshot.width.cuint, + screenshot.height.cuint, + AllPlanes, + ZPixmap, + screenshot, + 0, 0) + glTexImage2D(GL_TEXTURE_2D, + 0, + GL_RGB.GLint, + screenshot.width, + screenshot.height, + 0, + # TODO(#13): the texture format is hardcoded + GL_BGRA, + GL_UNSIGNED_BYTE, + screenshot.data) + main()