[osg-users] Support for Windows Universal Platform

Thomas Hogarth thomas.hogarth at gmail.com
Fri Apr 21 16:08:07 PDT 2017


So I've been tasked to add UWP/Angle support to OSG working with Chris Hanson. I have it pretty much working, it's rendering a cube, and just wanted a little guidance on a few issues before I submit any changes.

So firstly to the main CMakeLists.txt file I've added a OSG_BUILD_PLATFORM_UWP flag, this only does one thing on the CMake side. It adds a preprocessor define to all targets 'OSG_UWP' this is used in the code to hash def out a few unsupported features.

Also in the osgViewer CMake I have added support to Win32 path to set the Window System type, it defaults to Win32 which will behave as usual and any other value just doesn't add the Win32 graphics window implementation files. Maybe later we could add an EGL implementation but for now we just don't want the Win32 version and then we use setupViewerAsEmbedded.

I've hash defed out the plugin loading code on Win32 for now and have built osg as static as it uses a few functions not available on UWP, however later we could get that working I think as I've got GLExtensions code to work with a different function for loading the dll module.

OpenThreads had a few functions not available but none of them are show stoppers. The micoSleep function used some stuff not available so I made it fall back on standard sleep just as older windows versions do. You can't set process affinity on UWP so that function call does nothing, and you can't force terminate a thread, but you can cancel them so the fail safe terminate is just excluded.

The real issue at the moment is the use of getenv. That's used in a lot of places and is a handy bit of code for config type stuff so I didn't really want to add hash defs all over the place where ever it's used. So for now I made a dummy implementation that just returns 0, but the only place I could find to put it that is included globally was in the Notify header which is far from ideal. Does anyone have any thoughts or feedback on where I could place a dummy function like that that kind of needs to be used anywhere without people having to add a new include?

Here's an example CMake command that will generate a UWP visual studio project

"C:/Program Files/CMake/bin/cmake.exe" ./ -G "Visual Studio 14 2015 Win64" -DCMAKE_SYSTEM_NAME:STRING="WindowsStore" -DCMAKE_SYSTEM_VERSION:STRING="10.0" ^
-DOPENGL_INCLUDE_DIR:PATH="C:/Work/AlphaPixel/osgUWP-Port/angle/include" ^
-DOPENGL_HEADER1:STRING="#include <GLES2/gl2.h>" ^
-DOPENGL_gl_LIBRARY:STRING="C:/Work/AlphaPixel/osgUWP-Port/angle/winrt/10/src/Release_x64/lib/libGLESv2.lib" ^
-DEGL_INCLUDE_DIR:PATH="C:/Work/AlphaPixel/osgUWP-Port/angle/include" ^

Once I have a solution to this getenv thing and done some more testing I'll look at doing a pull request.


It's currently in a private repo

Read this topic online here:

More information about the osg-users mailing list