From bfaa86f438370927b8d282f1be27cf54a12e8aa3 Mon Sep 17 00:00:00 2001 From: randy Date: Wed, 17 Jul 2024 13:24:19 +0700 Subject: [PATCH 1/4] Update README.md --- README.md | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index be16076..d268408 100644 --- a/README.md +++ b/README.md @@ -58,11 +58,6 @@ By default, the repository has an educational license that makes the engine free [Educational license terms](https://github.com/alpinestudios/oogabooga/blob/master/LICENSE.md) -When you're ready to take the next step and work on a commercial game, you can upgrade to the full commercial license. +You can obtain the full commercial license by being an active member of the community and making your first game. -Here are the benefits of obtaining the full license: -- Permanent Ownership: You completely own the source code for life. -- No Recurring Fees or Royalties: Just an affordable one-time payment. -- It qualifies you to enter the private Skool community, where there's daily calls with Randy & Charlie, to help speedrun your game's development - -You can [contact us](https://randy.gg/contact) to find out more. \ No newline at end of file +[Learn more here](https://www.skool.com/game-dev) From 28898b026e3aa0c8d79087e8941e76aa0f3ab601 Mon Sep 17 00:00:00 2001 From: Charlie Malmqvist Date: Sat, 20 Jul 2024 16:14:26 +0200 Subject: [PATCH 2/4] Fix mandatory woopsie --- oogabooga/examples/minimal_game_loop.c | 1 - 1 file changed, 1 deletion(-) diff --git a/oogabooga/examples/minimal_game_loop.c b/oogabooga/examples/minimal_game_loop.c index 220e8da..848e04e 100644 --- a/oogabooga/examples/minimal_game_loop.c +++ b/oogabooga/examples/minimal_game_loop.c @@ -16,7 +16,6 @@ int entry(int argc, char **argv) { reset_temporary_storage(); - float64 now = os_get_current_time_in_seconds(); Matrix4 rect_xform = m4_scalar(1.0); rect_xform = m4_rotate_z(rect_xform, (f32)now); rect_xform = m4_translate(rect_xform, v3(-.25f, -.25f, 0)); From 5509c7166ed4da0ad77d66e73a4cb0093b723c4c Mon Sep 17 00:00:00 2001 From: Francesco Cozzuto Date: Mon, 22 Jul 2024 01:06:21 +0200 Subject: [PATCH 3/4] Add OOGABOOGA_HEADLESS option --- oogabooga/gfx_impl_d3d11.c | 29 --------------------- oogabooga/oogabooga.c | 41 +++++++++++++++++------------ oogabooga/os_impl_windows.c | 51 +++++++++++++++++++++++++++++++++---- oogabooga/os_interface.c | 7 +++++ oogabooga/tests.c | 7 ++++- 5 files changed, 84 insertions(+), 51 deletions(-) diff --git a/oogabooga/gfx_impl_d3d11.c b/oogabooga/gfx_impl_d3d11.c index 4cf702a..2e08937 100644 --- a/oogabooga/gfx_impl_d3d11.c +++ b/oogabooga/gfx_impl_d3d11.c @@ -123,35 +123,6 @@ void CALLBACK d3d11_debug_callback(D3D11_MESSAGE_CATEGORY category, D3D11_MESSAG } } -#define win32_check_hr(hr) win32_check_hr_impl(hr, __LINE__, __FILE__); -void win32_check_hr_impl(HRESULT hr, u32 line, const char* file_name) { - if (hr != S_OK) { - - LPVOID errorMsg; - DWORD dwFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS; - - DWORD messageLength = FormatMessageW( - dwFlags, - NULL, - hr, - MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), - (LPWSTR) &errorMsg, - 0, - NULL ); - - if (messageLength > 0) { - MessageBoxW(NULL, (LPWSTR)errorMsg, L"Error", MB_OK | MB_ICONERROR); - } else { - MessageBoxW(NULL, L"Failed to retrieve error message.", L"Error", MB_OK | MB_ICONERROR); - } - - - panic("win32 hr failed in file %cs on line %d, hr was %d", file_name, line, hr); - } -} - void d3d11_update_swapchain() { HRESULT hr; diff --git a/oogabooga/oogabooga.c b/oogabooga/oogabooga.c index 566d7f5..13daddb 100644 --- a/oogabooga/oogabooga.c +++ b/oogabooga/oogabooga.c @@ -281,10 +281,6 @@ typedef u8 bool; ///// #include "concurrency.c" -#include "gfx_interface.c" - - -#include "font.c" #include "profiling.c" #include "random.c" @@ -292,31 +288,40 @@ typedef u8 bool; #include "memory.c" #include "input.c" -#include "drawing.c" +#ifndef OOGABOOGA_HEADLESS -#include "audio.c" + #include "gfx_interface.c" -// #Portability -#if GFX_RENDERER == GFX_RENDERER_D3D11 - #include "gfx_impl_d3d11.c" -#elif GFX_RENDERER == GFX_RENDERER_VULKAN - #error "We only have a D3D11 renderer at the moment" -#elif GFX_RENDERER == GFX_RENDERER_METAL - #error "We only have a D3D11 renderer at the moment" -#else - #error "Unknown renderer GFX_RENDERER defined" + #include "font.c" + + #include "drawing.c" + + #include "audio.c" #endif #if TARGET_OS == WINDOWS #include "os_impl_windows.c" #elif TARGET_OS == LINUX - #error "Linux is not supported yet" + #include "os_impl_linux.c" #elif TARGET_OS == MACOS #error "Macos is not supported yet" #else #error "Current OS is not supported" #endif +#ifndef OOGABOOGA_HEADLESS + // #Portability + #if GFX_RENDERER == GFX_RENDERER_D3D11 + #include "gfx_impl_d3d11.c" + #elif GFX_RENDERER == GFX_RENDERER_VULKAN + #error "We only have a D3D11 renderer at the moment" + #elif GFX_RENDERER == GFX_RENDERER_METAL + #error "We only have a D3D11 renderer at the moment" + #else + #error "Unknown renderer GFX_RENDERER defined" + #endif +#endif + #include "tests.c" #define malloc please_use_alloc_for_memory_allocations_instead_of_malloc @@ -350,7 +355,11 @@ void oogabooga_init(u64 program_memory_size) { heap_init(); temporary_storage_init(); log_info("Ooga booga version is %d.%02d.%03d", OGB_VERSION_MAJOR, OGB_VERSION_MINOR, OGB_VERSION_PATCH); +#ifndef OOGABOOGA_HEADLESS gfx_init(); +#else + log_info("Headless mode on"); +#endif log_verbose("CPU has sse1: %cs", features.sse1 ? "true" : "false"); log_verbose("CPU has sse2: %cs", features.sse2 ? "true" : "false"); log_verbose("CPU has sse3: %cs", features.sse3 ? "true" : "false"); diff --git a/oogabooga/os_impl_windows.c b/oogabooga/os_impl_windows.c index b975655..3cedea4 100644 --- a/oogabooga/os_impl_windows.c +++ b/oogabooga/os_impl_windows.c @@ -12,6 +12,37 @@ void* heap_alloc(u64); void heap_dealloc(void*); +#define win32_check_hr(hr) win32_check_hr_impl(hr, __LINE__, __FILE__); +void win32_check_hr_impl(HRESULT hr, u32 line, const char* file_name) { + if (hr != S_OK) { + + LPVOID errorMsg; + DWORD dwFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS; + + DWORD messageLength = FormatMessageW( + dwFlags, + NULL, + hr, + MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), + (LPWSTR) &errorMsg, + 0, + NULL ); + + if (messageLength > 0) { + MessageBoxW(NULL, (LPWSTR)errorMsg, L"Error", MB_OK | MB_ICONERROR); + } else { + MessageBoxW(NULL, L"Failed to retrieve error message.", L"Error", MB_OK | MB_ICONERROR); + } + + + panic("win32 hr failed in file %cs on line %d, hr was %d", file_name, line, hr); + } +} + +#ifndef OOGABOOGA_HEADLESS + // Persistent Input_State_Flags win32_key_states[INPUT_KEY_CODE_COUNT]; @@ -202,6 +233,7 @@ void win32_audio_poll_default_device_thread(Thread *t); bool win32_has_audio_thread_started = false; +#endif /* OOGABOOGA_HEADLESS */ void os_init(u64 program_memory_size) { @@ -214,9 +246,9 @@ void os_init(u64 program_memory_size) { win32_check_hr(hr); context.thread_id = GetCurrentThreadId(); - - - + + + #if CONFIGURATION == RELEASE SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS); #endif @@ -256,9 +288,9 @@ void os_init(u64 program_memory_size) { os.crt_vsnprintf = (Crt_Vsnprintf_Proc)os_dynamic_library_load_symbol(os.crt, STR("vsnprintf")); assert(os.crt_vsnprintf, "Missing vsnprintf in crt"); +#ifndef OOGABOOGA_HEADLESS win32_init_window(); - local_persist Thread audio_thread, audio_poll_default_device_thread; os_thread_init(&audio_thread, win32_audio_thread); @@ -268,6 +300,7 @@ void os_init(u64 program_memory_size) { os_thread_start(&audio_poll_default_device_thread); while (!win32_has_audio_thread_started) { os_yield_thread(); } +#endif /* NOT OOGABOOGA_HEADLESS */ } void s64_to_null_terminated_string_reverse(char str[], int length) @@ -1103,6 +1136,9 @@ os_get_stack_trace(u64 *trace_count, Allocator allocator) { #endif // NOT DEBUG } + +#ifndef OOGABOOGA_HEADLESS + // Actually fuck you bill gates const GUID CLSID_MMDeviceEnumerator = {0xbcde0395, 0xe52f, 0x467c, {0x8e,0x3d, 0xc4,0x57,0x92,0x91,0x69,0x2e}}; const GUID IID_IMMDeviceEnumerator = {0xa95664d2, 0x9614, 0x4f35, {0xa7,0x46, 0xde,0x8d,0xb6,0x36,0x17,0xe6}}; @@ -1395,9 +1431,11 @@ win32_audio_thread(Thread *t) { } } +#endif /* OOGABOOGA_HEADLESS */ void os_update() { +#ifndef OOGABOOGA_HEADLESS UINT dpi = GetDpiForWindow(window._os_handle); float dpi_scale_factor = dpi / 96.0f; @@ -1512,8 +1550,10 @@ void os_update() { if (window.should_close) { win32_window_proc(window._os_handle, WM_CLOSE, 0, 0); } +#endif /* OOGABOOGA_HEADLESS */ } +#ifndef OOGABOOGA_HEADLESS Input_Key_Code os_key_to_key_code(void* os_key) { UINT win32_key = (UINT)(u64)os_key; @@ -1624,4 +1664,5 @@ void* key_code_to_os_key(Input_Key_Code key_code) { panic("Invalid key code %d", key_code); return 0; -} \ No newline at end of file +} +#endif /* OOGABOOGA_HEADLESS */ \ No newline at end of file diff --git a/oogabooga/os_interface.c b/oogabooga/os_interface.c index 38c475f..e88f9cd 100644 --- a/oogabooga/os_interface.c +++ b/oogabooga/os_interface.c @@ -8,6 +8,9 @@ typedef HANDLE File; #elif defined(__linux__) + #ifndef OOGABOOGA_HEADLESS + #define "Linux is only supported for headless builds" + #endif typedef SOMETHING Mutex_Handle; typedef SOMETHING Thread_Handle; typedef SOMETHING Dynamic_Library_Handle; @@ -282,6 +285,8 @@ void dump_stack_trace() { } } +#ifndef OOGABOOGA_HEADLESS + /// /// // Window management @@ -308,4 +313,6 @@ typedef struct Os_Window { } Os_Window; Os_Window window; +#endif + void os_update(); \ No newline at end of file diff --git a/oogabooga/tests.c b/oogabooga/tests.c index 024e4d6..d6a08b5 100644 --- a/oogabooga/tests.c +++ b/oogabooga/tests.c @@ -1151,6 +1151,7 @@ void test_mutex() { mutex_destroy(&data.mutex); } +#ifndef OOGABOOGA_HEADLESS int compare_draw_quads(const void *a, const void *b) { return ((Draw_Quad*)a)->z-((Draw_Quad*)b)->z; } @@ -1220,6 +1221,8 @@ void test_sort() { print("Merge sort took on average %llu cycles and %.2f ms\n", cycles / num_samples, (seconds * 1000.0) / (float64)num_samples); } +#endif /* OOGABOOGA_HEADLESS */ + void oogabooga_run_tests() { @@ -1258,10 +1261,12 @@ void oogabooga_run_tests() { print("Testing mutex... "); test_mutex(); print("OK!\n"); - + +#ifndef OOGABOOGA_HEADLESS print("Testing radix sort... "); test_sort(); print("OK!\n"); +#endif print("All tests ok!\n"); } \ No newline at end of file From 6f7f5cb1e6254acca9e37554d4ca7cca09411fad Mon Sep 17 00:00:00 2001 From: Francesco Cozzuto Date: Mon, 22 Jul 2024 01:12:36 +0200 Subject: [PATCH 4/4] Fix outdated comment --- oogabooga/input.c | 1 - 1 file changed, 1 deletion(-) diff --git a/oogabooga/input.c b/oogabooga/input.c index 36ff98e..ebf7b56 100644 --- a/oogabooga/input.c +++ b/oogabooga/input.c @@ -19,7 +19,6 @@ case INPUT_EVENT_KEY: ...; break; case INPUT_EVENT_SCROLL: ...; break; case INPUT_EVENT_TEXT: ...; break; - case INPUT_EVENT_CLOSE: ...; break; } } */