Skip to content

Commit

Permalink
Set icon for dxgi window
Browse files Browse the repository at this point in the history
  • Loading branch information
Spodi committed Feb 23, 2025
1 parent 02bb77e commit 8dbbf7f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/graphic/Fast3D/gfx_dxgi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,19 @@ static LRESULT CALLBACK gfx_dxgi_wnd_proc(HWND h_wnd, UINT message, WPARAM w_par
return 0;
}

static BOOL CALLBACK WIN_ResourceNameCallback(HMODULE hModule, LPCTSTR lpType, LPTSTR lpName, LONG_PTR lParam) {
WNDCLASSEX* wcex = (WNDCLASSEX*)lParam;

(void)lpType; /* We already know that the resource type is RT_GROUP_ICON. */

/* We leave hIconSm as NULL as it will allow Windows to automatically
choose the appropriate small icon size to suit the current DPI. */
wcex->hIcon = LoadIcon(hModule, lpName);

/* Do not bother enumerating any more. */
return FALSE;
}

void gfx_dxgi_init(const char* game_name, const char* gfx_api_name, bool start_in_fullscreen, uint32_t width,
uint32_t height, int32_t posX, int32_t posY) {
LARGE_INTEGER qpc_init, qpc_freq;
Expand Down Expand Up @@ -510,14 +523,17 @@ void gfx_dxgi_init(const char* game_name, const char* gfx_api_name, bool start_i
wcex.lpfnWndProc = gfx_dxgi_wnd_proc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = nullptr;
wcex.hInstance = GetModuleHandle(nullptr);
wcex.hIcon = nullptr;
wcex.hIconSm = nullptr;
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wcex.lpszMenuName = nullptr;
wcex.lpszClassName = WINCLASS_NAME;
wcex.hIconSm = nullptr;

EnumResourceNames(wcex.hInstance, RT_GROUP_ICON, WIN_ResourceNameCallback, (LONG_PTR)&wcex);

ATOM winclass = RegisterClassExW(&wcex);

RECT wr = { 0, 0, width, height };
Expand Down

0 comments on commit 8dbbf7f

Please sign in to comment.