aboutsummaryrefslogtreecommitdiff
path: root/code/handmade.h
diff options
context:
space:
mode:
Diffstat (limited to 'code/handmade.h')
-rw-r--r--code/handmade.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/code/handmade.h b/code/handmade.h
new file mode 100644
index 0000000..b807644
--- /dev/null
+++ b/code/handmade.h
@@ -0,0 +1,57 @@
+#if !defined(HANDMADE_H)
+/* ========================================================================
+ $File: $
+ $Date: $
+ $Revision: $
+ $Creator: Casey Muratori $
+ $Notice: (C) Copyright 2014 by Molly Rocket, Inc. All Rights Reserved. $
+ ======================================================================== */
+
+#include "handmade_platform.h"
+#include "handmade_math.h"
+
+struct memory_arena
+{
+ memory_index Size;
+ u8 *Base;
+ memory_index Used;
+};
+
+void
+InitializeArena(memory_arena *Arena, memory_index Size, void *Base)
+{
+ Arena->Size = Size;
+ Arena->Base = (u8 *)Base;
+ Arena->Used = 0;
+}
+
+#define PushStruct(Arena, type) ((type *)PushSize((Arena), (sizeof(type))))
+#define PushArray(Arena, Count, type) (type *)PushSize((Arena), (sizeof(type))*(Count))
+void *
+PushSize(memory_arena *Arena, memory_index Size)
+{
+ Assert((Arena->Used + Size) < Arena->Size);
+
+ void *Result = Arena->Base + Arena->Used;
+ Arena->Used += Size;
+
+ return Result;
+}
+
+#include "handmade_intrinsics.h"
+
+struct loaded_bitmap
+{
+ int Width;
+ int Height;
+ u32 *Pixels;
+};
+
+struct game_state
+{
+ r32 Slope;
+ r32 Step;
+};
+
+#define HANDMADE_H
+#endif