ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
NativeWin32.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #include <GLFW/glfw3.h>
9 
10 #include "Native.h"
11 #define GLFW_EXPOSE_NATIVE_WIN32 1
12 #include <GLFW/glfw3native.h>
13 #include <winuser.h>
14 
15 namespace cloudViewer {
16 namespace visualization {
17 namespace gui {
18 
19 void* GetNativeDrawable(GLFWwindow* glfw_window) {
20  return glfwGetWin32Window(glfw_window);
21 }
22 
23 void PostNativeExposeEvent(GLFWwindow* glfw_window) {
24  InvalidateRect(glfwGetWin32Window(glfw_window), NULL, FALSE);
25  // InvalidateRect() does not actually post an event to the message queue.
26  // The way paint events work on Windows is that the window gets marked
27  // as dirty, then the next time GetMessage() is called and there isn't
28  // an actual event and the window is dirty, then a paint event is
29  // synthesized and the wndproc called. For some reason, a paint event
30  // is never actually generated. I suspect it is because Filament's
31  // render thread finishes and presumably buffer swap validates the
32  // window, erasing the dirty flag, before the event queue has time to
33  // notice that the window was marked as dirty. So force an update.
34  // Unfortunately, this draws *now*, so we have to wait until we are
35  // done drawing, which needs to be done at a higher level.
36  UpdateWindow(glfwGetWin32Window(glfw_window));
37 }
38 
39 void ShowNativeAlert(const char* message) {
40  MessageBox(NULL, "Alert", message, MB_OK | MB_ICONEXCLAMATION);
41 }
42 
43 } // namespace gui
44 } // namespace visualization
45 } // namespace cloudViewer
#define NULL
#define FALSE
Definition: lsd.c:115
void ShowNativeAlert(const char *message)
Definition: NativeLinux.cpp:55
void PostNativeExposeEvent(GLFWwindow *glfw_window)
Definition: NativeLinux.cpp:38
void * GetNativeDrawable(GLFWwindow *glfw_window)
Definition: NativeLinux.cpp:23
Generic file read and write utility for python interface.