locked
2D Polygon tessellation in Direct3D 11

    Question

  • I'd like to know what are D3D11 equivalent of GLU tessellation routines (gluNewTess, gluTessBeginPolygon, gluTessBeginContour, gluTessVertex etc.). I want to draw a world map that consists of quite a few concave polygons. Transforming concave polygons into convex ones is exactly what GLU tessellation routines accomplish. After reading D3D11 tessellation documentation on MSDN (e.g. http://msdn.microsoft.com/en-us/library/windows/desktop/ff476340(v=vs.85).aspx), I find D3D11 tessellation is all about enhancing surface details and smoothness, and not quite identical to GLU tessellation. We used to link GLU static library glu32.lib in our D3D10 project to do polygon tessellation, but glu32.lib is no longer provided in VS2012 RC Express. In all my questions are:

    1. Can I use glu32.lib provided in earlier version of VS (e.g. VS2008) in my Metro project? or is glu32.lib provided in VS2012 commerical SKUs?

    2. If glu32.lib is not allowed, would D3D11 tessellation satisfy my need?

    3. If D3D11 tessellation is not designed for 2D polygon tessellation, then how to do it in D3D11?


    • Edited by Leonard Monday, July 30, 2012 4:29 PM
    Monday, July 30, 2012 4:27 PM

Answers

All replies

  • OpenGL is not supported for Metro style apps. That is why glu32.lib is not included in the "Metro" Windows SDK--it is still in the 'full' Windows 8.0 SDK for Win32 desktop apps.  You likely need some software-based tessellation algorithm that will generate standard polygons to render via Direct3D 11. Using the OpenGL GLU32.LIB is not going to work for Metro style apps.

    D3D11 tessellation is a hardware tessellation feature that requires Feature Level 11.0 or 11.1 hardware. It is not supported by older 10.0, 10.1, or 10level9 (i.e. Direct3D 9) hardware. You can learn more about this feature from links at http://blogs.msdn.com/b/chuckw/archive/2010/07/19/direct3d-11-tessellation.aspx

    • Marked as answer by Leonard Monday, July 30, 2012 11:20 PM
    Monday, July 30, 2012 8:09 PM
  • Thank you for the response, Chuck. I'll try some software polygon tessellation solution.

    You answer raises my concern about the compatibility of my application to Metro. Will VS2012 tell me my app is no longer compatible to Metro and refuse to launch my app if I link GLU32.lib to the executable? And how can I tell my app will be deployed successfully in Windows RT? For now, my application can run from VS2012 RC express in full screen mode, does this guarantee my app is Metro compatible?


    • Edited by Leonard Monday, July 30, 2012 11:21 PM
    Monday, July 30, 2012 11:20 PM
  • hi,Leonard,I also use gluNewTess, gluTessBeginPolygon, gluTessBeginContour, gluTessVertex etc..these glu function to do software polygon tessellation.you can download the source code and compile them into Metro Style dll or lib without comsume windows runtime extension, because c file can not be compiled in such condition (sadly..)and also you should remove some function that must use gl functions ^_^.at last ,you can use it in winRT or Metro Style App, good luck~
    Tuesday, July 31, 2012 3:02 AM
  • Hi ahzhe, many thanks for your help.

    Could you tell me where can I download the source code for GLU tessellation routine?

    Tuesday, July 31, 2012 3:10 AM
  • I used this one : http://code.google.com/p/glues/

    and also you can find libtess source code  in other open source graphic library's code package such as OSG and Mesa,too.

    at here

    http://www.openscenegraph.org/projects/osg/browser/OpenSceneGraph/trunk/src/osg/glu and here

    http://downloads.openmoko.org/developer/sources/cvs/mesa/Mesa/src/glu/sgi/libtess/

    hope this can help you.

    • Marked as answer by Leonard Tuesday, July 31, 2012 1:45 PM
    Tuesday, July 31, 2012 6:06 AM
  • VS 2012 will generally let you build stuff, and as long as the libraries you are using only use 'Metro safe' APIs it will work fine. You can force VS 2012 to build with non Metro safe APIs and it may or may not work depending on the exact interactions with the App Container security context. However, when you submit such an application to the Windows Store or when you use the Windows App Certification Kit, your app will fail because it is pulling in APIs that are not "Metro safe".
    Wednesday, August 01, 2012 12:04 AM
  • VS 2012 will generally let you build stuff, and as long as the libraries you are using only use 'Metro safe' APIs it will work fine. You can force VS 2012 to build with non Metro safe APIs and it may or may not work depending on the exact interactions with the App Container security context. However, when you submit such an application to the Windows Store or when you use the Windows App Certification Kit, your app will fail because it is pulling in APIs that are not "Metro safe".

    Thanks Chuck for the explanation. I wish VS2012 can provide the feature of Metro-compatibility check.
    Wednesday, August 01, 2012 1:26 AM
  • Hi,Chuck, I see you underline the word "Metro safe APIs", do you mean the APIs list in there http://msdn.microsoft.com/library/windows/apps/br211369?

    Especially, I used C++ as the main developing language,so I should use the APIs list in "For Metro style apps in C++" section, if I want to submit my app to the Windows Store?

    thanks.

    Wednesday, August 01, 2012 3:03 AM
  • By default when building Metro style apps, the VS 2012 projects for Metro will make sure to set the Windows API Familiy to "Metro" rather than "Desktop". This ensures that only the "Metro safe" APIs are actually defined so you get compile errors if you try to use other APIs. My point was that you can technically use "unsafe" APIs in your app through various means in C++, get it it to build, and maybe even run succesfully but it will fail to pass the WACK certification tool which is required to submit to the Windows Store.

    Thursday, August 02, 2012 6:11 PM
  • By default when building Metro style apps, the VS 2012 projects for Metro will make sure to set the Windows API Familiy to "Metro" rather than "Desktop". This ensures that only the "Metro safe" APIs are actually defined so you get compile errors if you try to use other APIs. My point was that you can technically use "unsafe" APIs in your app through various means in C++, get it it to build, and maybe even run succesfully but it will fail to pass the WACK certification tool which is required to submit to the Windows Store.


    I'd like to how to tell which Windows API family is used in my project. Is there any compiler flags like /metro or predefined macro like WINDOWS_API_FAMILY_METRO?
    Friday, August 03, 2012 2:49 AM
  • In VS 2012, most of the information here is controlled by MSBuild .props triggered from the <AppContainer>true</AppContainer> tag in your VCXPROJ. This implicitly sets WINAPI_FAMILY=WINAPI_PARTITION_APP. You should also not change _WIN32_WINNT which defaults to Windows 8 (0x0602) for Metro style apps.

    You can try adding the following to your code to see if it triggers either error...

    #include <windows.h>
    
    #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
    #error Using the Desktop API familiy
    #endif
    
    #if (_WIN32_WINNT < 0x0602)
    #error Not using Windows 8 APIs
    #endif

    Tuesday, August 14, 2012 9:49 PM
  • Hi ahzhe,

    I failed to build any libraries you recommended without error. The first one (glues) requires OpenGL ES headers, and the latter two require OpenGL 1.3 and above. But none of the requirements are available on Windows 8, though Windows SDK distributes OpenGL 1.1.


    • Edited by Leonard Friday, August 24, 2012 12:27 PM
    Friday, August 24, 2012 12:17 PM