OpenGL renderer: handling subwindow messages

On windows we need to have a thread on the renderer process
which handles windows messages sent to the subwindow
we are creating during framebuffer initialization.
We run this message pump in the main renderer thread
and the server listener on a seperate thread.
diff --git a/tools/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h b/tools/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h
index 3e3e2e2..4d80f74 100644
--- a/tools/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h
+++ b/tools/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h
@@ -73,7 +73,7 @@
 
     EGLDisplay getDisplay() const { return m_eglDisplay; }
     EGLContext getContext() const { return m_eglContext; }
-
+    EGLNativeWindowType getSubWindow() const { return m_subWin; }
     bool bind_locked();
     bool unbind_locked();
 
diff --git a/tools/emulator/opengl/host/renderer/main.cpp b/tools/emulator/opengl/host/renderer/main.cpp
index 5f338b4..709ed75 100644
--- a/tools/emulator/opengl/host/renderer/main.cpp
+++ b/tools/emulator/opengl/host/renderer/main.cpp
@@ -125,7 +125,32 @@
         return -1;
     }
 
+#ifndef _WIN32
+    //
+    // run the server listener loop
+    //
     server->Main(); // never returns
+#else
+    //
+    // on windows we need to handle messages for the
+    // created subwindow. So we run the server on a seperate
+    // thread and running the windows message pump loop
+    // in this main thread.
+    //
+    server->start();
+
+    //
+    // Dispatch events for the subwindow
+    //
+    MSG msg;
+    HWND hWnd = FrameBuffer::getFB()->getSubWindow();
+    bool done = 0;
+    while(!done) {
+        GetMessage(&msg, hWnd, 0, 0);
+        TranslateMessage(&msg);
+        DispatchMessage(&msg);
+    }
+#endif
 
     return 0;
 }