Session Title -

Session Title -

Leveraging C++11 for Better, Faster, Easier Windows Phone 8 Game Development James Robertson National Oilwell Varco David Cravey Clear Measure 1 Welcome to Houston TechFest Thank you for being a part of the 7th Annual Houston TechFest! Please turn off all electronic devices or set them to vibrate. If you must take a phone call, please do so in the lobby so as not

to disturb others. Thanks to our Diamond Sponsors: 2 Information Speaker presentation slides will be available at within a week Dont forget to complete the Bingo card to be eligible for door prizes 3 Agenda

Speaker Introductions Why develop for Windows Phone? Windows Phone Development Overview Demo C++ 11 Language Features in VS2012/VS2013 you should care about Demo What next? 4

Speaker Introductions David Cravey Senior Software Architect at Clear Measure David Cravey is a Senior Architect for Clear Measure in Austin, TX. David has a love for software design, and a passion for sharing this love with the community. As a C++ enthusiast David has been awarded a Microsoft Visual C++ MVP for 3 years, and this year received the VC++ MVP of the year award. He is the leader of several C++ User Groups including: the Houston C++ User Group, DFW C++ User Group, the San Antonio C++ User Group, and the new C++ Brown Bag (weekly online lunchtime presentation). James Robertson Programmer/QA at National Oilwell Varco James Robertson lives and works in the Houston area. He is a C++

programmer who has been working for National Oilwell Varco for the last 2 years. Affiliated with the Houston C++ User Group he frequently talks on technology topics that interest him. 5 Why develop for Windows Phone? The same DirectX programming model as the Desktop Currently there are a few libraries that are not allowed: Direct2D, DirectWrite, XInput, Windows Imaging Components. Note, at least Direct2D has been tested to work but is not (at least not yet) allowed in the store

Share a code base with easily with Windows Store and with a little effort the Windows Desktop. Can you think of any other reason? 6 Windows Phone 8 (Native) Development Options DirectX 11 (directly) DirectX TK (wrapper) Currently there is no XAML support for C++ Apps, but it is easy to integrate C++ and .NET in a single application. 7

Windows Phone Emulator Requires a Hyper Visor enabled CPU Requires the Hyper Visor to not be in use Works with Windows Hyper-V VM Ware Workstation provides an unsupported feature that many have made work Virtual Box is the odd man out, uses the Hyper Visor, but does not want to share So if you (like me) enjoy Virtual Box then develop/ test against your phone! 8

Unlocking Your Windows Phone Windows Phones can be unlocked for development for free. Use the Windows Phone Developer Registration tool. TIP: Use your start menu search feature. If you are still having problems then Unregister Your Device and use the tool to register again. ndows-phone-8-for-development-and-deploying-a pps / 9 Unlocking Your Windows Phone This section of the text

is dynamic, so watch for changes! There is only one button, but it not only changes its text, but also its behavior! 10 Windows Phone Unlock Demo DEMO TIME 11

DirectX Graphics Diagnostics Uses the REFERENCE driver (all software) to enable debugging at the graphics level. Press Print Screen on your keyboard to capture a frame. Captured frames can be inspected to determine how each pixel came into being. With Visual Studio 2013 this is included in the Store Express version. TIP: If you do not have Pro, and you would like to debug a Desktop DirectX application, you can launch your Desktop Express application in the Store Express IDE. 12 DirectTK Targets

Free wrapper for DirectX, makes life better Develop using VS 2010/2012/2013 Can Target: Win2008Sp2/Win2008R2/VistaSp2/Win7/Win8.x Destkop/Win8.xStore/Win2012/Win2012R2 ting%20from%20D3DX&referringTitle=Documenta tion 13 DirectTK Headers

SpriteBatch.h - simple & efficient 2D sprite rendering SpriteFont.h - bitmap based text rendering Effects.h - set of built-in shaders for common rendering tasks PrimitiveBatch.h - simple and efficient way to draw user primitives GeometricPrimitive.h - draws basic shapes such as cubes and spheres

Model.h - draws simple meshes loaded from .CMO or .SDKMESH files CommonStates.h - factory providing commonly used D3D state objects VertexTypes.h - structures for commonly used vertex data formats DDSTextureLoader.h - light-weight DDS file texture loader WICTextureLoader.h - WIC-based image file texture loader ScreenGrab.h - light-weight screen shot saver SimpleMath.h - simplified C++ wrapper for DirectXMath 14 Windows Phone Development Demo DEMO TIME 15 Highlighted C++11 Features in VS2012/2013

Library Features Hash Tables unordered_set, unordered_map RAII Wrappers unique_ptr, shared_ptr, weak_ptr Atomic Variables Threading (but, consider PPL and task oriented programming) Language Features R-Value References && (move semantics & perfect forwarding) Local type deduction

auto, auto&, const auto& Range For Lambdas Inline functors Variadic Templates, Initializer Lists, & Uniform Initialization (new with VS2013) 16 R-Value References In C++98/03 a reference could only bind to an lvalue* (there are some special rules for temporary values) int& x = 1; // Error, 1 is an l-value (has no name)

int& x = y; // In C++13 an r-value reference can bind to an r-value or an l-value** (this topic can take atleast one entire talk) This powers 2 important technologies Move Semantics (gut stealing) Perfect Forwarding (simplifies wrappers/libraries/etc) 17 Local Type Deduction Simply looks up the type of a variable Many forms, all involve the keyword auto auto x = 1; int x = 1;

const auto const int x = 1; auto & int& x = y; // 1 would be illegal here as 1 is an r-value const auto& const int& x = y; auto&& Binds to either an l-value reference, or an r-value reference. Scott Meyers calls this a universal reference, see his GN2013 talk. Uses template type deduction rules

18 How many ways to loop in C++98/03? Given int myData[MaxMyData]; For loop using an index variable for (int x = 0; x < MaxMyData; ++x) { /*...*/ } For loop using an iterator int*begin =&myData[MaxMyData]; int*end =&myData[MaxMyData]; for (int* it = begin; *it != end; ++it) { /**/ } Using for each

std::for_each(myData, &myData[MaxMyData], myFunction){} Plus While Loops, Recursion, May be considered harmful goto, Template Meta Programming, Function Pointers, and many more 19 C++11 Range For Simplified access, that actually tell the compiler more about what you are doing Typical example when you dont want to change the element (i.e. only observe): int myData[MaxMyData]; for (const auto& i : myData) { /**/ } If you want to change the element (i.e. mutate it):

for (auto& i : myData) { /**/ } If you want a copy you can change: for (auto i : myData) { /**/ } 20 C++11 Lambdas C++11 Lambdas provide a convenient syntax to define anonymous functors inline. Functors are function objects (i.e. overload the function object) Lambdas can capture variables (note, this does not extend their lifetimes) Lambdas that dont capture variables can be used with old fashioned standard C/C++ function pointers. Lambdas love to inline, thus they can run very fast!

Lambdas make the STL algorithms much more palatable 21 C++11 Lambda Expression Syntax [captureList](parameterList)->returnType{lambdaBody} captureList Optional (can be empty) [=] captures by value (const unless lambda defined as mutable) [&] captures by reference [x,&y] captures x by value and y by reference [x,y, &] captures x and y by value, and all others by reference 22

Capture by reference, and returning a value Lambda Transformed Lambda Expression Equivalent Functor int x = 123; class unspeakableName { private: int& x; auto lambda = [&x](long y){ return x + y };

// Same as auto lambda = [&x](long y)->long { return x + y }; public: unspeakableName(int& x_) :x(x_) {} long operator()(long y){return x + y;} } lambda; 23 Variadic Templates Variadic Templates can take any number of parameters, when combined with Perfect

Forwarding they allow library designers to make better interfaces (faster, more consise, etc): Examples: auto myPair = std::make_pair(1,2.0); auto myData = std::make_unique(1.0); std::vector myWidgets(Widget); myVector.emplace_back(Houston Techfest, 2013); 24 Initializer Lists & Uniform Initialization Initializer lists pack list of a single data type to be passed as a parameter (typically a constructor/factory) std::vector myInts = {1,2,3,4,5,6};

Uniform initialization is a combination of features to make variable initialization uniform. int x { 1 }; Widget w { Houston Techfest, Rocks, 2013 }; Note, Uniform initialization will default to using the constructor arguments, but if overrode they can make things better: std::vector myInts { 2, 4 }; 25 Windows Phone Development Demo DEMO TIME 26

Pluralsight Learning Resources (30 day trial in the bag you received this morning) C Programming Language Fundamentals C++ Fundamentals (Parts 1 & 2) C++ Language Changes in the VS 2013 Preview Direct2D Fundamentals (Parts 1 & 2) Modern C++ Libraries The Essentials of COM (Parts 1 & 2) C++ Advanced Topics 27 Recommended Books Beginner

Programming 2D Games Introduction to 3D Game Programming with DirectX11 Intermediate/Advanced Practical Rendering and Computation with Direct3D 11 ShaderX Books (9 of them) GPU Pro series (0 of them, was ShaderX) 28 Samples/Templates to Get You Going Built Into Visual Studio Windows Phone Direct3D App (Native Only)

For download (within Visual Studio) DirectXTK Simple Windows Phone Sample Windows SDK Samples Older DirectX SDK Samples NVidia SDK Samples AMD Radeon SDK Samples 29

Windows Phone 8 Additional Learning Resources Excellent tutorial!!! ($50 one-time payment) I have heard good things, and its FREE! Houston C++ User Group While not focused on Game Development, we cover a large range of C++ topics (from Phone to Cloud ) Meets each month on the 4th Thursday of the month (except November and December, and for Tech Fest )

30 Visual C++ Libraries Survey Microsoft would like your feedback about what libraries you use! (to help guide their investments in Visual Studio tooling) https://illumew ollector/Survey. ashx?Name=Nu GetLibs 31 Thanks to all our Sponsors!

32 Please Leave Feedback During Q&A If you leave session feedback and provide contact information, you will be qualified for a prize Scan the QR code to the right or go to 33

Recently Viewed Presentations

  • The Big Picture about Small Markets: The Growing

    The Big Picture about Small Markets: The Growing

    The Big Picture about Small Markets: The Growing Success Story of License-Exempt Wireless Broadband in Rural America June 2002 Patrick Leary
  • Plainview ISD Supplimental Benefits

    Plainview ISD Supplimental Benefits

    Pre-paid Legal - LegalShield. Everyone deserves equal access to the justice system and now with LegalShield, everyone can have it! From the trivial to the traumatic, LegalShield helps protect your rights so you can worry less and live more! Identity...
  • Talk for Monica/Earl - Stanford University

    Talk for Monica/Earl - Stanford University

    Processing packets in packet switches CS343 May 7th 2003 Nick McKeown Professor of Electrical Engineering and Computer Science, Stanford University
  • Speciation Activity Descriptions

    Speciation Activity Descriptions

    There is a small population of arctic foxes and penguin-like birds. However, it is difficult to hunt them during the winter months. Ice-fishing allows for most of the food supply. Vegetation can only be found during summer months.
  • Gnutella2: A Better Gnutella? - Carleton University

    Gnutella2: A Better Gnutella? - Carleton University

    Gnutella2: A Better Gnutella? COMP 5204: Data Networks Julie Thorpe School of Computer Science Carleton University Introduction Gnutella and Gnutella2 are P2P application protocols. Gnutella has an interesting history - essentially a reverse engineered Beta version. Changes governed by Gnutella...
  • Back to school night -

    Back to school night -

    This PowerPoint can be found on my LCPS webpage! Back to school night. Potomac Falls HS 2018 - 2019. Conceptual & Academic Physics - Dylan Mercer. Team Teacher (2. nd & 3. rd) - Chris Parks. Notecard (Optional) Student Name....
  • How Much Access

    How Much Access

    Knowledge Transfer. knowledge transfer by supporting schemes and activities to transfer good ideas, research results and skills between, for example, universities and other research organisations, business, the third sector, public sector and/or the wider community.. Knowledge Based Economy
  • Improved Health. Its Here. Audit Reports Guide Table

    Improved Health. Its Here. Audit Reports Guide Table

    Attestation of Audit Reports. Consent Sample Report - this report is a sample of patient consents in place for your organization.. YOUR ACTIONS: You are required to locate the consent forms for the first 5 entries and return a copy...