Lecture 11: App window

Computer graphics in Game development

Ivan Belyavtsev

19.02.2021

Graphics APIs

  • Vintage:
    • OpenGL
    • DirectX 9
    • DirectX 11
    • Mantle
  • Modern:
    • Metal
    • DirectX 12
    • Vulkan

What is our choose?

  • Metal: Apple only
  • Vulkan: open-source, well-documented, overcomplicated
  • DirectX 12: Microsoft, less documentation, simpler

Notification

This part of course is going to be boring. There is plenty of preliminary work. We’ll get a somehow working application tomorrow

Pre requirements

Plan

  • Create a window
  • Initialize DX12
  • Create and setup resources
  • Create and setup the rendering pipeline
  • Add per frame updates

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(REFIID riid, LPVOID *ppv)
  • 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]

Review: App windows

Lab: Render init

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