List of 5 questions about programing MetroRT and C++/CX or whatever

Dang it, been avoiding C++ long enough that the Win8 reintroduction of C++ is actually interesting.  Like mowing the lawn on a warm day, interesting enough to go get a book and read it instead of mowing the lawn.  Well that is why I live in a Condo, just lazy I guess.

Can you use XAML and C++? Yes, there are templates included with the Visual Studio 11 Express Beta for Windows 8, so for sure.

No, wait, I meant can you do something useful with XAML and C++?  Yes

Oh that wasn’t an open question, was it? No, that’s three questions

Can you use XAML and C++ with Direct2 or Direct3? Yep

How?  Seriously, are you ready?  How about we start with the Direct2 template.

Start Visual Studio 11 Express Beta, select the Direct2 template from the C++ list of templates.

Run it.

Boring, but it does a DirectWrite with something like “Hello, Direct2D”.  Now you are a C++ programmer!

No you are not!  But you might be if you find this code in the Direct2Application1.cpp file (or whatever you named the project), change the text “Hello, Direct2D!” to something profound, if not profane (but not so it insults anyone, right?), don’t copy the code:

 

 oid Direct2DApplication1::CreateWindowSizeDependentResources()
 {
     DirectXBase::CreateWindowSizeDependentResources();
  
     const wchar_t* text = L"Hello, Direct2D";
  
     // Create a DirectWrite Text Layout object.
     DX::ThrowIfFailed(
         m_dwriteFactory->CreateTextLayout(

Once you do that, now change the background color, select CornflowerBlue and the second colon, hit the colon on your keyboard and you will see a list of colors, pick something other than CornflowerBlue, something light in color, it’s been a depressing week:

 void Direct2DApplication1::Render()
 {
     m_d2dContext->BeginDraw();
  
     m_d2dContext->Clear(D2D1::ColorF(D2D1::ColorF::CornflowerBlue));
     m_d2dContext->SetTransform(D2D1::Matrix3x2F::Identity());
  
     m_d2dContext->DrawTextLayout(
         D2D1::Point2F(0.0f, 0.0f),

Now run your program.  Wasn’t that awesome?  Be Happy, you are on your way. 

 

LikeMyHat