Commit graph

31 commits

Author SHA1 Message Date
Charlie Malmqvist
f2b81a0621 v0.01.004 - Gamepad input, text wrapping, bug fixes 2024-08-19 16:37:21 +02:00
kacpercwiklinski
f9bf7ffee4 Fix for temporary storage overflow warning
Why do we need this?
* Now the user is not warned about temp memory overflow which may introduce hard to debug bugs with memory management.
Describe at least one specific and practical problem this solves for people developing a game
* The buffer overflown and the pointers have been overwritten - undefined behavior, the pc fly into space. This fix fixes what the warning is meant to be. Warn in overflow situation to avoid potential bugs.
Does this add complexity/friction for people making games? If so, how do you justify that?
* There's no complexity in this PR.
2024-08-15 09:58:42 +02:00
Charlie Malmqvist
782d86c38a Fix Memory woopsie 2024-07-30 18:24:20 +02:00
Charlie Malmqvist
71708cfc77 More unused memory locking 2024-07-28 17:17:58 +02:00
Charlie Malmqvist
f9788b2e74 Some memory rework, concurrency improvements, cleanups 2024-07-28 15:08:36 +02:00
Charlie Malmqvist
3e015088bd Mandatory woopsie #10572 2024-07-23 23:32:50 +02:00
Charlie Malmqvist
4aa832a822 Refactor more to be able to build as dll and link a single global oogabooga instance, and made an example for a hot loaded game 2024-07-23 17:33:11 +02:00
Charlie Malmqvist
e61a294960 Conditionally compile oogabooga global state instance with OOGABOOGA_LINK_EXTERNAL_INSTANCE 2024-07-22 19:19:57 +02:00
Charlie Malmqvist
88053ab14a v0.01.001 - Spacial audio, custom shading, scissor boxing 2024-07-20 16:10:55 +02:00
Charlie Malmqvist
e4649e564d #Cleanup 2024-07-17 16:36:13 +02:00
Charlie
c39902d6b1 v0.01.000 - AUDIO! 2024-07-15 21:40:27 +02:00
Charlie
c92b6fd4b7 - Z Layers
- Sorting
- Contiguous quad buffer
2024-07-10 17:10:38 +02:00
Charlie
cc74dc68e4 ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? 2024-07-09 18:51:15 +02:00
Charlie
b37652e1ce v0.00.004 - Custom logging, more concurrency & bugfixing
Concurrency:
	- Refactored spinlock out of OS api (deprecated old procs)
	- Concurrency utilites:
		void spinlock_init(Spinlock *l);
		void spinlock_acquire_or_wait(Spinlock* l);
		bool spinlock_acquire_or_wait_timeout(Spinlock* l, f64 timeout_seconds);
		void spinlock_release(Spinlock* l);
		void mutex_init(Mutex *m);
		void mutex_destroy(Mutex *m);
		void mutex_acquire_or_wait(Mutex *m);
		void mutex_release(Mutex *m);
		void binary_semaphore_init(Binary_Semaphore *sem, bool initial_state);
		void binary_semaphore_destroy(Binary_Semaphore *sem);
		void binary_semaphore_wait(Binary_Semaphore *sem);
		void binary_semaphore_signal(Binary_Semaphore *sem);
		Macro MEMORY_BARRIER
	- Concurrency tests

Docs:
	- custom_logger.c example to show how one can make a custom logger and have logs displayed in-game

Utility:
	- draw_text_and_measure() which is just an overload of draw_text but it also does a measure and returns it

Misc:
	- Added u64 thread_id to global context. This is set in main() for main thread and in thread startup when you dispatch a Thread
	- Fixed a bug where plain rects would be drawn with the incorrect color
	- Fixed a bug where quads from earlier frames would be drawn
2024-07-09 18:38:06 +02:00
Charlie
e54897432b Fixed memory bug & window placement
- Improved assert messages to be more clear about what might be happening if they fail
- Added more checks in debug to detect heap corruption and what not
- Fixed a bug where the program would crash because a heap block was perfectly full
- Fixed Y placement of window when changing the window rect
- Fixed window sizing when setting scaled_width or scaled_height
- Updated readme
2024-07-09 09:15:35 +02:00
Charlie
05fd88472b Fix merge conflicts 2024-07-09 09:13:44 +02:00
Charlie
a805557a76 Fixed memory bug & window placement
- Improved assert messages to be more clear about what might be happening if they fail
- Added more checks in debug to detect heap corruption and what not
- Fixed a bug where the program would crash because a heap block was perfectly full
- Fixed Y placement of window when changing the window rect
- Fixed window sizing when setting scaled_width or scaled_height
- Updated readme
2024-07-08 17:57:23 +02:00
Charlie
aee3f78bd5 Add minimal libraries for decoding audio 2024-07-08 15:33:01 +02:00
Charlie
ebaa52c326 Naive hash table & tests 2024-07-06 15:50:16 +02:00
Charlie
05919248eb - Replace lodepng with stb_image (& add stb_truetype for fonts)
- Fix d3d11 Input assembler not being created correctly bug
- Fix framerate being locked by swap chain present
- Move enable_vsync to window
- sqrt & rsqrt simd
- Add release build & run in vscode tasks & launch
- Cleanup
2024-07-04 20:56:27 +02:00
Charlie
546f8af3d4 - Fixed bug in ALLOCATOR_REALLOC corrupting memory/returning invalid address
- Added asserts to make sure we detect similar bugs faster
- Made simd shippable & configurable
- Some documentation in oogabooga.c on configuration
- Very optimized release build script
- Cleaned some stuff up
2024-07-03 17:55:25 +02:00
Charlie
1f2809d23e Ooga'd some boogas 2024-07-02 19:12:31 +02:00
Charlie
b15c7c6e41 - Fixed D3D11 eating 40000000 cycles for no reason (Thank you Bill Gates)
- Refactor drawing to keep blocks persistent in memory
- Make string usage easier & more consisten (macros for string vs const char*)
- rdtsc intrinsic (get cycle count)
- Profiling macros (generates a google trace json)
- Write D3D11 debug messages to stdout
- String_Builder & thorough tests for it
2024-07-02 15:27:33 +02:00
Charlie
ea37ceb3bd Explicit allocators 2024-07-01 13:10:06 +02:00
Charlie
b9503d8d19 - D3D11, Image drawing & Matrix4 xform drawing
- I didn't get rotation going quite right with the xform, but it's 2am goodnight
	- Smashed my head and had bad thoughts about microsoft many times

- stuff
- lotsa example code in entry.c
2024-07-01 02:14:08 +02:00
Charlie
6879130bb0 - File IO
- os_file_open(string path, Os_Io_Open_Flags flags)
	- os_file_close(File f)
	- os_file_delete(string path)
	- os_file_write_string(File f, string s)
	- os_file_write_bytes(File f, void *buffer, u64 size_in_bytes)
	- os_file_read(File f, void* buffer, u64 bytes_to_read, u64 *actual_read_bytes)
	- os_write_entire_file_handle(File f, string data)
	- os_write_entire_file(string path, string data)
	- os_read_entire_file_handle(File f, string *result)
	- os_read_entire_file(string path, string *result)
	- fprint(File, string/char*, ...)
	- Buncha tests

- os_high_precision_sleep
- talloc_string
- Program memory is touched on VirtualAlloc so it actually allocates physical memory (and we can tell when an address is untouched)
2024-06-29 20:55:43 +02:00
Charlie
c61f216d37 - Simple rectangle drawing
- We just add to a frame of quads which the renderer deals with in gfx_update
	- draw_quad, draw_rect, draw_rect_rotated
	- Currently just implemented with legacy opengl, so we can't do custom shading
- Added third party code from lodepng so we can load pngs without any other dependencies (no C includes)
- ALLOCATOR_REALLOCATE
- Basic Vector2, Vector3, Vector4 stuff, and some math utilities
- Added <math.h> dependency for now.
- Graphics renderer frontend layer
- Naive get_random() implementation
2024-06-29 13:27:37 +02:00
Charlie
41795425d0 Build with clang (& fix stuff so it compiles with clang 2024-06-28 19:10:29 +02:00
Charlie
db73d0bd2e - Basic fixed-length string with replacement for C standard printing & fmt stuff
- Jai-like print procedures
	- %s formats 'string' and to format a char* you do %cs
	- It detects if %cs pointer is outside of program memory or stack and asserts
	- AND same for if a char* is passed to %s
	- Print directly writes to stdout without any allocations
	- Basic utlity procedures
	- Buncha string tests
- Beef up assert to display file & line as well
- Don't define memcpy procedures if compiler has intrinsics for them
- Init memory arena for allocations in initialization time before heap is ready (stack memory)
- os_compare_and_swap
- Spinlock "primitive" (wrapper around a bool using compare_and_swap)
- Switched to using spinlock instead of os mutex in heap for synchronization.
- is_pointer_valid() which checks if address is in program_memory or thread stack
2024-06-28 18:50:30 +02:00
Charlie
68d1efb759 - Start work on string library
- Dyamically load minimum crt symbols in os backend so we don't need to #include c headers
- Some more os calls:
	- write to stdout (with our string type)
	- macros for variadic argument lists
	- Dynamic library loading
2024-06-28 12:07:02 +02:00
Charlie
98feda0cbb - build.c which includes everything to be built and configures build with #defines
- Some compile options that make sense for build.bat, and a build_release.bat
- oogabooga:
	- Big buffer program_memory that always has same base address (goodbye serialisation problems)
		- Big buffer grows as needed, crash when out of memory
	- Very sexy platform abstraction & basic os call procedures
	- Heap allocator around the program memory.
    - Jaiyfication (context, context.allocator, push_allocator, temp allocator)
	- Some tests to make sure we ooga the right boogas
2024-06-28 03:28:23 +02:00