Lecture 11: App window

Computer graphics in Game development

Ivan Belyavtsev

20.11.2020

Ray tracing labs

  • Official due date: Saturday, 21 November 2020, 12:00 AM
  • Feel free to ask questions via Telegram

Pre requirements

  • Windows 10 (at least VM)
  • Visual Studio
  • WinSDK

Template for the third part of labs

TODO: Add a repo

github.com/djbelyak/

Check your installation

  1. Get the repo and dependencies
  2. Make the solution (premake vs2019)
  3. Build the solution
  4. Run DX12 installation check project

ComObj

The Microsoft Component Object Model (COM) is a platform-independent, distributed, object-oriented system for creating binary software components that can interact[1].

IUnknown interface

All COM interfaces inherit from the IUnknown interface.

IUnknown interface has the next functions:

  • QueryInterface
  • AddRef
  • Release [1]

IID_PPV_ARGS macro

AwesomeFunction(
    ...
    REFIID    riid,
    LPVOID    *ppv
)

Use the IID_PPV_ARGS macro to get both arguments

ComPtr

Microsoft::WRL::ComPtr is a C++ template smart-pointer for COM objects that is used extensively in Windows Runtime (WinRT) C++ programming.

  • include wrl/client.h
  • use namespace Microsoft::WRL::ComPtr
  • use instead of raw Com objects [2]

Creating the window

  1. Create WNDCLASS or WNDCLASSEX instance
  2. Register the instance with RegisterClass or RegisterClassEx call
  3. Call CreateWindow or CreateWindowEx and keep HWND results
  4. Call ShowWindows to present [3]

Event loop

  1. Take the message via GetMessage or PeekMessage
  2. Run TranslateMessage to make the message readable
  3. Call DispatchMessage to handling (DispatchMessage calls the windows procedure from WNDCLASS) [3]

References

1.
Satran M. The component object model [Electronic resource]. 2018. URL: https://docs.microsoft.com/en-us/windows/win32/com/the-component-object-model.
2.
Walbourn C. ComPtr [Electronic resource]. 2019. URL: https://github.com/Microsoft/DirectXTK/wiki/ComPtr.
3.
Satran M., Jacobs M. Get started with Win32 and c++ [Electronic resource]. 2018. URL: https://docs.microsoft.com/en-us/windows/win32/learnwin32/learn-to-program-for-windows.
// reveal.js plugins