Musa-Cpp-Lib-V2/src/Base_Entry_Point.cpp
2025-12-18 21:28:17 -05:00

60 lines
1.7 KiB
C++

internal void Main_Entry_Point (int argc, WCHAR **argv);
#if OS_WINDOWS
#if BUILD_CONSOLE_INTERFACE
int wmain(int argc, WCHAR **argv) {
Main_Entry_Point(argc, argv);
return 0;
}
#else
#pragma comment(linker, "/SUBSYSTEM:WINDOWS")
#include <cstdlib> // globals __argc, __wargv
int wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd) {
Main_Entry_Point(__argc, __wargv);
return 0;
}
#endif
#endif
internal void Main_Entry_Point (int argc, WCHAR **argv) { // #entry_point: Main + Context Setup
// #TODO: Check if base frequency is even available.
u32 base_frequency = (u32)CPU_Base_Frequency();
set_cpu_base_frequency(base_frequency); // REQUIRED FOR TIMING MODULE! will depend on CPU
#if BASE_RUN_TESTS
run_pre_setup_tests(); // #no_context: context will not be initialized at this point.
#endif
// #NOTE: Be careful using a timing or auto-release macros
// before setting up the thread context!
Bootstrap_Main_Thread_Context();
stack_trace(); // #stack_trace: #entry_point (first stack trace)
#if OS_WINDOWS
Win32_Entry_Point(argc, argv);
#endif
#if OS_LINUX
// Linux_Entry_Point(argc, argv);
#endif
#if BASE_RUN_TESTS
run_post_setup_tests();
#endif
#if BUILD_EXPLORER_APP_WIN32 // #entry_point: Custom program
Explorer_ImGui_Application_Win32(); // #rename
#endif
#if BUILD_CUSTOM_GUI
// Custom GUI based on Vik's prototype [WIP]
/* Alternative if we're using OpenGL.
graphics_set_render_target(get_main_window());
// 3. Init Graphics (DX11 or OpenGL3)
// #TODO: #Graphics#Main - `Main_Entry_Point`
// 4. [ ] Setup Mouse and Keyboard Inputs
// 5. [ ] Launch second thread; thread groups
*/
#endif
}