Search code examples
windowswindows-8direct2d

Where to start with Direct2d?


Interested in learning Direct2d to create a Windows 8 app, but after 2 hours of research I'm thoroughly confused. Samples like this (Creating a Simple Direct2D Application) seem to assume you know what an HWND and HRESULT is, and how the Windows API works in general.

My question is this: do you need an understanding of the Win API, COM, OLE, and all this other Windows stuff in order to get a good grasp on Direct2d/3d?

All the other barebones tutorials assume that you know all this stuff and I don't really know where to start. The startup D2D project in VS 2012 gives you a bunch of files but there's no main or WinMain... How does this program even start?


Solution

  • The API is COM-based, so you will have to get familiar with COM basics to move on. You actually don't need to know a lot from the start, perhaps just COM interfaces concept with reference counting, instantiation and implementing an interface. It might be simpler than it seems. UI windows in Windnows have handles, so HWND is definitely something to understand.

    The sample you are referring to actually has WinMain. Have a look at full tutorial code, and you will find it there:

    #include "DemoApp.h"
    
    // Provides the application entry point.
    int WINAPI WinMain(
        HINSTANCE /* hInstance */,