#pragma once // Untextured quads on the UI's Direct3D 7 device (the argument of the UI's // render methods, vf14). #include #include namespace game { constexpr int kDeviceDrawPrimitive = 25; // IDirect3DDevice7 vtable slots constexpr int kDeviceSetTexture = 35; constexpr DWORD kTriangleStrip = 5; constexpr DWORD kFvfScreenColourTexture = 0x1c4; // XYZRHW | DIFFUSE | SPECULAR | TEX1 struct ScreenVertex { float x, y, z, rhw; uint32_t diffuse, specular; float u, v; }; // Fills (x0, y0)-(x1, y1) with the ARGB colour `color`. inline void FillRect(void* device, float x0, float y0, float x1, float y1, uint32_t color) { void** vtable = *static_cast(device); using SetTextureFn = HRESULT(__stdcall*)(void*, DWORD, void*); using DrawPrimitiveFn = HRESULT(__stdcall*)(void*, DWORD, DWORD, void*, DWORD, DWORD); reinterpret_cast(vtable[kDeviceSetTexture])(device, 0, nullptr); ScreenVertex quad[4] = {{x0, y0, 0, 1, color, 0, 0, 0}, {x1, y0, 0, 1, color, 0, 1, 0}, {x0, y1, 0, 1, color, 0, 0, 1}, {x1, y1, 0, 1, color, 0, 1, 1}}; reinterpret_cast(vtable[kDeviceDrawPrimitive])(device, kTriangleStrip, kFvfScreenColourTexture, quad, 4, 0); } } // namespace game