Browse Source

made file tree, added dependencies

Iver 6 days ago
commit
419362a372

+ 6 - 0
LICENSE.md

@@ -0,0 +1,6 @@
+Copyright (c) 2025 Iver Martinson
+
+This software is NOT LICENSED for use, distribution, or modification.
+Do not use, distribute, or modify this code without explicit permission from the author.
+
+The author may release a license in the future. Until then, all rights are reserved.

+ 28 - 0
Makefile

@@ -0,0 +1,28 @@
+COMPILER=gcc
+FLAGS_ALL=-g -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter
+FLAGS_EXAMPLE=-Lbuilds/ -lpomelo -lfizzix -llemonguice -lpitmap -lrasteriver -lsourparse -Wl,-rpath=builds/ -lm
+FLAGS_LIB=-fPIC -shared -lc -lm 
+
+main.bin: libfizzix.so liblemonguice.so libpitmap.so librasteriver.so libsourparse.so libpomelo.so
+	$(COMPILER) $(FLAGS_ALL) src/launch\ program/main.c -o builds/main.bin $(FLAGS_EXAMPLE) 
+
+libpomelo.so:
+	$(COMPILER) $(FLAGS_ALL) src/main/main.c -o builds/libpomelo.so $(FLAGS_LIB) 
+
+libfizzix.so:
+	cp src/dependencies/libfizzix.so builds/
+
+liblemonguice.so:
+	cp src/dependencies/liblemonguice.so builds/
+
+libpitmap.so:
+	cp src/dependencies/libpitmap.so builds/
+
+librasteriver.so:
+	cp src/dependencies/librasteriver.so builds/
+
+libsourparse.so:
+	cp src/dependencies/libsourparse.so builds/
+
+clean:
+	rm builds/*

BIN
builds/libfizzix.so


BIN
builds/liblemonguice.so


BIN
builds/libpitmap.so


BIN
builds/libpomelo.so


BIN
builds/librasteriver.so


BIN
builds/libsourparse.so


BIN
builds/main.bin


+ 3 - 0
changelog.txt

@@ -0,0 +1,3 @@
+-made file tree
+-added dependencies
+-wrote small readme

+ 1 - 0
dbg

@@ -0,0 +1 @@
+gdb -ex run builds/main.bin

+ 0 - 0
issues.txt


+ 5 - 0
readme.md

@@ -0,0 +1,5 @@
+# Pomelo, A Game Engine
+
+## Etymology
+
+A pomelo is a type of citrus

+ 1 - 0
run

@@ -0,0 +1 @@
+./builds/main.bin

BIN
src/dependencies/libfizzix.so


BIN
src/dependencies/liblemonguice.so


BIN
src/dependencies/libpitmap.so


BIN
src/dependencies/librasteriver.so


BIN
src/dependencies/libsourparse.so


+ 13 - 0
src/headers/FZ_functions.h

@@ -0,0 +1,13 @@
+#ifndef FZ_FUNCTIONS_H
+#define FZ_FUNCTIONS_H
+
+#include "FZ_structs.h"
+
+FZ_scene* FZ_new_scene();
+FZ_shape* FZ_new_shape();
+int FZ_init();
+int FZ_tick(FZ_scene* scene, double deltatime); // ticks a scene
+int FZ_render_debug(FZ_scene* scene); // renders a debug window
+FZ_context* FZ_get_context();
+
+#endif

+ 95 - 0
src/headers/FZ_math.h

@@ -0,0 +1,95 @@
+#ifndef FZ_MATH_H
+#define FZ_MATH_H
+
+#include "FZ_structs.h"
+
+double distance_2(FZ_vector_2 a, FZ_vector_2 b){
+    return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
+}
+
+FZ_vector_2 v2_mul(FZ_vector_2 vector, double value){
+    vector.x *= value;
+    vector.y *= value;
+
+    return vector;
+}
+
+// element-wise add
+FZ_vector_2 v2_ew_add(FZ_vector_2 vector_a, FZ_vector_2 vector_b){
+    vector_a.x += vector_b.x;
+    vector_a.y += vector_b.y;
+
+    return vector_a;
+}
+
+// element-wise subtract
+FZ_vector_2 v2_ew_sub(FZ_vector_2 vector_a, FZ_vector_2 vector_b){
+    vector_a.x -= vector_b.x;
+    vector_a.y -= vector_b.y;
+
+    return vector_a;
+}
+
+// element-wise multiply
+FZ_vector_2 v2_ew_mul(FZ_vector_2 vector_a, FZ_vector_2 vector_b){
+    vector_a.x *= vector_b.x;
+    vector_a.y *= vector_b.y;
+
+    return vector_a;
+}
+
+FZ_vector_2 vector_2_lerp(FZ_vector_2 vector_a, FZ_vector_2 vector_b, double w1){
+    double w0 = 1.0 - w1;
+
+    FZ_vector_2 result = (FZ_vector_2){0, 0};
+
+    vector_a = v2_mul(vector_a, w0);
+    vector_b = v2_mul(vector_b, w1);
+
+    result = v2_ew_add(result, vector_a);
+    result = v2_ew_add(result, vector_b);
+
+    return result;
+}
+
+FZ_vector_2 v2_rot(FZ_vector_2 vector, FZ_vector_2 origin, double angle){
+    FZ_vector_2 new_vec = vector;
+
+    new_vec = v2_ew_sub(new_vec, origin);
+
+    new_vec.x = vector.x * cos(angle) - vector.y * sin(angle);
+    new_vec.y = vector.x * sin(angle) + vector.y * cos(angle);
+
+    new_vec = v2_ew_add(new_vec, origin);
+
+    return new_vec;
+}
+
+double v2_dot(FZ_vector_2 vector_a, FZ_vector_2 vector_b){
+    double result = vector_a.x * vector_b.x + vector_a.y * vector_b.y;
+
+    return result;
+}
+
+FZ_vector_2 v2_normalize(FZ_vector_2 vector){
+    return v2_mul(vector, 1 / sqrt(v2_dot(vector, vector)));
+}
+
+FZ_vector_2 v2_rotate_neg_90(FZ_vector_2 vector){
+    return (FZ_vector_2){-vector.y, vector.x};
+}
+
+FZ_vector_2 v2_rotate_90(FZ_vector_2 vector){
+    return (FZ_vector_2){vector.y, -vector.x};
+}
+
+// where a and b form line a, project c onto line a, return the scalar
+double project_along_vectors_normal(FZ_vector_2 a, FZ_vector_2 b, FZ_vector_2 c){
+    b = (FZ_vector_2){b.y - a.y, -(b.x - a.x)};
+    
+    c = v2_ew_sub(c, a);
+
+    return (v2_dot(c, b) / v2_dot(b, b));
+}
+
+#endif

+ 61 - 0
src/headers/FZ_structs.h

@@ -0,0 +1,61 @@
+#ifndef FZ_STRUCTS
+#define FZ_STRUCTS
+
+#include <stdint.h>
+#include <SDL2/SDL.h>
+
+typedef struct {
+    double x, y;
+} FZ_vector_2;
+
+enum {
+    FZ_SHAPE_IS_STATIC = 1 << 0,
+    FZ_SHAPE_IS_COLLIDING = 1 << 1,
+};
+
+typedef struct {
+    FZ_vector_2* points;
+    FZ_vector_2* transformed_points;
+    uint16_t point_count;
+    FZ_vector_2 scale;
+    FZ_vector_2 position;
+    FZ_vector_2 velocity;
+    double angle;
+    double angular_veclocity;
+    double mass;
+    double moment_of_intertia;
+    void (*tick_transform_function)(FZ_vector_2 position, double angle);
+    void (*tick_points_function)(FZ_vector_2* points, uint16_t point_count);
+    uint16_t flags; 
+} FZ_shape;
+
+typedef struct {
+    double penetration;
+    FZ_vector_2 contact_point;
+    int reference_line_index;
+    int incident_line_index;
+    FZ_shape* reference_shape;
+    FZ_shape* incident_shape;
+} projected_points_data;
+
+typedef struct {
+    FZ_shape** shapes;
+    uint16_t shape_count;
+    FZ_vector_2 gravity;
+} FZ_scene; 
+
+typedef struct {
+    uint16_t width, height, half_width, half_height;
+    SDL_Window* window;
+    SDL_Renderer* renderer;
+    SDL_Texture* frame_buffer_texture;
+    uint32_t* frame_buffer;
+} FZ_SDL;
+
+typedef struct {
+    uint16_t flags;
+    FZ_SDL sdl;
+    uint8_t is_running;
+} FZ_context;
+
+#endif 

+ 26 - 0
src/headers/LG_functions.h

@@ -0,0 +1,26 @@
+#ifndef LG_FUNCTIONS_H
+#define LG_FUNCTIONS_H
+
+// functions
+
+LG_font_face* LG_new_font_face(char* filename);
+
+LG_font_style* LG_new_font_style();
+
+LG_widget* LG_new_window(char* title, uint16_t width, uint16_t height);
+
+LG_widget* LG_add_panel_widget(LG_widget* parent_widget);
+
+LG_widget* LG_add_text_widget(LG_widget* parent_widget);
+
+LG_widget* LG_add_button_widget(LG_widget* parent_widget);
+
+LG_image* LG_load_image(char* filename);
+
+int LG_render_window(LG_widget* window_widget);
+
+int LG_init();
+
+LG_context* LG_get_context();
+
+#endif

+ 118 - 0
src/headers/LG_structs.h

@@ -0,0 +1,118 @@
+#ifndef LG_STRUCTS_H
+#define LG_STRUCTS_H
+
+enum {
+    LG_WIDGET_TYPE_PANEL = 0,
+    LG_WIDGET_TYPE_TEXT = 1,
+    LG_WIDGET_TYPE_BUTTON = 2,
+    LG_WIDGET_TYPE_INPUT = 3,
+    LG_WIDGET_TYPE_IMAGE = 4,
+};
+
+enum {
+    LG_WIDGET_ALIGNMENT_LEFT = 0,
+    LG_WIDGET_ALIGNMENT_CENTER_HORIZONTAL = 1,
+    LG_WIDGET_ALIGNMENT_RIGHT = 2,
+    LG_WIDGET_ALIGNMENT_UP = 3,
+    LG_WIDGET_ALIGNMENT_CENTER_VERTICAL = 4,
+    LG_WIDGET_ALIGNMENT_DOWN = 5,
+};
+
+typedef struct {
+    SDL_Window* sdl_window;
+    SDL_Renderer* sdl_renderer;
+    SDL_Texture* sdl_window_texture;
+    uint32_t* frame_buffer;
+    uint16_t width, height;
+} LG_window_data;
+
+typedef struct {
+    uint32_t* image_data;
+    int width;
+    int height;
+} LG_image;
+
+typedef struct {
+    SP_font* font;
+} LG_font_face;
+
+typedef struct {
+    LG_font_face* font_face;
+    uint32_t font_size;
+    uint32_t font_color;
+    uint8_t flags; // e.g., use defualt kerning or custom
+    int32_t kerning;
+    uint8_t font_alignment; // left, center, right, top, bottom, et cetera
+} LG_font_style;
+
+typedef struct {
+    uint32_t background_color;
+    
+    uint32_t border_color;
+    uint16_t border_size;
+    uint16_t radius;
+    
+    int32_t width;
+    int32_t height;
+    
+    uint8_t widget_alignment_horizontal;
+    uint8_t widget_alignment_vertical;
+    
+    int32_t margin;
+    int32_t margin_left;  // specific margin directions 
+    int32_t margin_right; // should be -1 if auto
+    int32_t margin_top;
+    int32_t margin_bottom;
+    
+    int32_t padding;
+    int32_t padding_left;  // specific margin directions 
+    int32_t padding_right; // should be -1 if auto
+    int32_t padding_top;
+    int32_t padding_bottom;
+} LG_widget_style;
+
+typedef struct {
+    char* text;
+    LG_font_style* font_style;
+} LG_text_data;
+
+typedef struct {
+    LG_image* image;
+} LG_image_widget_data;
+
+typedef struct {
+    LG_text_data placeholder_text_data;
+    LG_text_data input_text_data;
+} LG_input_field_widget_data;
+
+typedef struct {
+    LG_text_data text_data;
+} LG_button_widget_data;
+
+typedef struct {
+    LG_text_data text_data;
+} LG_text_widget_data;
+
+typedef struct LG_widget {
+    uint32_t type; // 0 panel, 1 text, 2 button, 3 input, 4 image
+    uint32_t id;
+    LG_image_widget_data image_widget_data;
+    LG_input_field_widget_data input_field_widget_data;
+    LG_button_widget_data button_widget_data;
+    LG_text_widget_data text_widget_data;
+    LG_widget_style* widget_style;
+    struct LG_widget** children;
+    uint32_t child_count;
+    struct LG_widget* parent;
+    LG_window_data* window_data;
+} LG_widget;
+
+typedef struct {
+    LG_font_face* default_font_face;    
+    LG_font_style* default_font_style;
+    LG_widget* default_widget;
+    uint32_t current_id;
+    uint16_t current_window_panel_count;
+} LG_context;
+
+#endif

+ 10 - 0
src/headers/PM_functions.h

@@ -0,0 +1,10 @@
+#ifndef PM_FUNCTIONS_H
+#define PM_FUNCTIONS_H
+
+// loads an image file and returns a PM_image
+PM_image* PM_load_image(const char* filename, unsigned char debug_mode);
+
+// unallocated a PM_image*
+void PM_free_image(PM_image* image);
+
+#endif

+ 13 - 0
src/headers/PM_structs.h

@@ -0,0 +1,13 @@
+#ifndef PM_STRUCTS_H
+#define PM_STRUCTS_H
+
+typedef struct {
+    uint32_t* frame_buffer; // the array that stores the pixel data
+    int width; // width of the image
+    int height; // height of the image INCLUDING all stacked frames
+    int frame_height; // height of each FRAME
+    int frame_count; // number of frames
+    uint16_t* frame_delays; // centisecond delay for each frame
+} PM_image;
+
+#endif

+ 6 - 0
src/headers/PO_functions.h

@@ -0,0 +1,6 @@
+#ifndef PO_FUNCTIONS_H
+#define PO_FUNCTIONS_H
+
+
+
+#endif

+ 6 - 0
src/headers/PO_structs.h

@@ -0,0 +1,6 @@
+#ifndef PO_STRUCTS_H
+#define PO_STRUCTS_H
+
+
+
+#endif

+ 43 - 0
src/headers/RI_functions.h

@@ -0,0 +1,43 @@
+#ifndef RI_FUNCTIONS_H
+#define RI_FUNCTIONS_H
+
+#include "RI_types.h"
+
+// returns the RI_context
+RI_context *RI_get_context();
+
+// initilizes RasterIver
+// returns completion code (0: fine, 1: error)
+int RI_init();
+
+// ticks RasterIver (updated window, check for events, renders scene, etc)
+void RI_tick();
+
+// renders a scene to the screen
+void RI_render(RI_scene *scene);
+
+// loads an OBJ file into memory as a mesh
+RI_mesh *RI_load_mesh(char* filename);
+
+// allocates and returns a pointer to a new scene
+RI_scene *RI_new_scene();
+
+// allocates and returns a pointer to a new actor
+RI_actor *RI_new_actor();
+
+// allocates and returns a pointer to a new material
+RI_material *RI_new_material();
+
+// allocates and returns a pointer to a new texture
+RI_texture *RI_new_texture(int width, int height);
+
+// loads an image file as a texture
+RI_texture* RI_load_image(char* filename);
+
+// loads an image file as an animated texture
+RI_texture* RI_load_animation(char* filename, uint16_t frame_count);
+
+// loads a gif file as an animated texture
+RI_texture* RI_load_gif(char* filename);
+
+#endif

+ 169 - 0
src/headers/RI_math.h

@@ -0,0 +1,169 @@
+#ifndef RI_MATH_H
+#define RI_MATH_H
+
+#include "stdint.h"
+#include <math.h>
+#include <CL/cl.h>
+
+typedef struct {
+    cl_double w;
+    cl_double x;
+    cl_double y;
+    cl_double z;
+} RI_vector_4;
+
+typedef struct {
+    cl_double x;
+    cl_double y;
+    cl_double z;
+} RI_vector_3;
+    
+typedef struct {
+    cl_double x;
+    cl_double y;
+} RI_vector_2;
+
+typedef struct {
+    cl_int x;
+    cl_int y;
+} RI_vector_2i;
+
+// value-wise multiplacation.
+// multiply the whole vector by 1 value
+void vector_2_times(RI_vector_2 *vector, double value){
+    vector->x *= value;
+    vector->y *= value;
+}
+
+// value-wise multiplacation.
+// multiply the whole vector by 1 value
+void vector_3_times(RI_vector_3 *vector, double value){
+    vector->x *= value;
+    vector->y *= value;
+    vector->z *= value;
+}
+
+// "hadamard" addition.
+// add each value of one vector with the matching one on the other vector
+void vector_2_element_wise_add(RI_vector_2 *addend_a, RI_vector_2 addend_b){
+    addend_a->x += addend_b.x;
+    addend_a->y += addend_b.y;
+}
+
+// hadamard multiplacation.
+// multiply each value of one vector with the matching one on the other vector
+void vector_3_hadamard(RI_vector_3 *multiplicand, RI_vector_3 multiplicator){
+    multiplicand->x *= multiplicator.x;
+    multiplicand->y *= multiplicator.y;
+    multiplicand->z *= multiplicator.z;
+}
+
+// "hadamard" addition.
+// add each value of one vector with the matching one on the other vector
+void vector_3_element_wise_add(RI_vector_3 *addend_a, RI_vector_3 addend_b){
+    addend_a->x += addend_b.x;
+    addend_a->y += addend_b.y;
+    addend_a->z += addend_b.z;
+}
+
+// "hadamard" subtraction.
+// subtraction each value of one vector with the matching one on the other vector
+void vector_3_element_wise_subtract(RI_vector_3 *minuend, RI_vector_3 subtrahend){
+    minuend->x -= subtrahend.x;
+    minuend->y -= subtrahend.y;
+    minuend->z -= subtrahend.z;
+}
+
+// conjugate a quaterion.
+// (flip the sign of the x, y, z values)
+void quaternion_conjugate(RI_vector_4* quaternion){
+    quaternion->x *= -1.0;
+    quaternion->y *= -1.0;
+    quaternion->z *= -1.0;
+}
+
+// quaternion multiplacation
+void quaternion_multiply(RI_vector_4* a, RI_vector_4 b){
+    double w1 = a->w; double x1 = a->x; double y1 = a->y; double z1 = a->z;
+    double w2 = b.w; double x2 = b.x; double y2 = b.y; double z2 = b.z;
+
+    double w = w1*w2 - x1*x2 - y1*y2 - z1*z2;
+    double x = w1*x2 + x1*w2 + y1*z2 - z1*y2;
+    double y = w1*y2 - x1*z2 + y1*w2 + z1*x2;
+    double z = w1*z2 + x1*y2 - y1*x2 + z1*w2;
+
+    *a = (RI_vector_4){w, x, y, z};
+}
+
+// linear interpolate between 2 vectors
+void vector_2_lerp(RI_vector_2 vector_a, RI_vector_2 vector_b, RI_vector_2 *result, double w1){
+    double w0 = 1.0 - w1;
+
+    vector_2_times(result, 0);
+
+    vector_2_times(&vector_a, w0);
+    vector_2_times(&vector_b, w1);
+
+    vector_2_element_wise_add(result, vector_a);
+    vector_2_element_wise_add(result, vector_b);
+}
+
+// beziate between 2 vectors.
+// A & C: end points of the line
+// B: point that determines the curve; off the line
+void vector_2_bezier_interpolate(RI_vector_2 vector_a, RI_vector_2 vector_b, RI_vector_2 vector_c, RI_vector_2 *result, double w1){
+    double w0 = 1.0 - w1;
+
+    vector_2_lerp(vector_a, vector_b, &vector_b, w1); // this works because the first vector b is a copy and the second is a reference
+    vector_2_lerp(vector_b, vector_c, &vector_c, w1);
+
+    vector_2_lerp(vector_b, vector_c, result, w1);
+}
+
+// linear interpolate between 2 vectors
+void vector_3_lerp(RI_vector_3 vector_a, RI_vector_3 vector_b, RI_vector_3 *result, double w1){
+    double w0 = 1.0 - w1;
+
+    vector_3_times(result, 0);
+
+    vector_3_times(&vector_a, w0);
+    vector_3_times(&vector_b, w1);
+
+    vector_3_element_wise_add(result, vector_a);
+    vector_3_element_wise_add(result, vector_b);
+}
+
+// returns the distance between 2 points
+int distance_2(RI_vector_2 a, RI_vector_2 b){
+    return (int)sqrtf((double)((double)(a.x - b.x) * (double)(a.x - b.x)) + (double)((double)(a.y - b.y) * (double)(a.y - b.y)));
+}
+
+void quaternion_rotate(RI_vector_3 *position, RI_vector_4 rotation){
+    RI_vector_4 pos_quat = {0, position->x, position->y, position->z};
+
+    RI_vector_4 rotation_conjugation = rotation;
+    quaternion_conjugate(&rotation_conjugation);
+
+    quaternion_multiply(&rotation, pos_quat);
+
+    quaternion_multiply(&rotation, rotation_conjugation);
+
+
+    *position = (RI_vector_3){rotation.x, rotation.y, rotation.z};
+}
+
+void RI_euler_rotation_to_quaternion(RI_vector_4 *quaternion, RI_vector_3 euler_rotation){
+    double cx = cosf(euler_rotation.x * 0.5f);
+    double sx = sinf(euler_rotation.x * 0.5f);
+    double cy = cosf(euler_rotation.y * 0.5f);
+    double sy = sinf(euler_rotation.y * 0.5f);
+    double cz = cosf(euler_rotation.z * 0.5f);
+    double sz = sinf(euler_rotation.z * 0.5f);
+
+    quaternion->w = cx * cy * cz + sx * sy * sz;
+    quaternion->x = sx * cy * cz - cx * sy * sz;
+    quaternion->y = cx * sy * cz + sx * cy * sz;
+    quaternion->z = cx * cy * sz - sx * sy * cz;
+}
+
+#endif

+ 127 - 0
src/headers/RI_memory.h

@@ -0,0 +1,127 @@
+#include "RI_types.h"
+
+RI_context context;
+
+#define RI_realloc(__ptr, __size) written_RI_realloc(__ptr, __size, __func__, __LINE__, context)
+#define RI_malloc(__size) written_RI_malloc(__size, __func__, __LINE__, context)
+#define RI_calloc(__nmemb, __size) written_RI_calloc(__nmemb, __size, __func__, __LINE__, context)
+#define RI_free(__ptr) written_RI_free(__ptr, __func__, __LINE__, context)
+
+void* written_RI_realloc(void *__ptr, size_t __size, const char *caller, int line, RI_context context){
+    void *pointer = realloc(__ptr, __size);
+
+    if (context.memory.debug_memory) {
+        int current_allocation_index = 0;
+        int checking = 1;
+
+        while (checking){
+            if (!context.memory.allocation_table[current_allocation_index].reallocated_free && context.memory.allocation_table[current_allocation_index].pointer == __ptr){
+                context.memory.allocation_table[current_allocation_index].reallocated_free = 1;
+                
+                checking = 0;
+            }
+
+            current_allocation_index++;
+            
+            if (current_allocation_index >= context.memory.allocation_search_limit){
+                checking = 0;
+            }
+        }
+
+        if (context.memory.current_allocation_index >= context.memory.allocation_table_length){
+            context.memory.allocation_table_length += 50;
+            context.memory.allocation_search_limit += 50;
+            
+            context.memory.allocation_table = (RI_memory_allocation*)RI_realloc(context.memory.allocation_table, sizeof(RI_memory_allocation) * context.memory.allocation_table_length);
+        }
+
+        context.memory.allocation_table[context.memory.current_allocation_index].allocated = 1;
+        context.memory.allocation_table[context.memory.current_allocation_index].reallocated_alloc = 1;
+        context.memory.allocation_table[context.memory.current_allocation_index].reallocated_free = 0;
+        context.memory.allocation_table[context.memory.current_allocation_index].freed = 0;
+        context.memory.allocation_table[context.memory.current_allocation_index].line = line;
+        context.memory.allocation_table[context.memory.current_allocation_index].pointer = pointer;        
+        context.memory.allocation_table[context.memory.current_allocation_index].size = __size;
+
+        context.memory.current_allocation_index++;
+    }
+
+    return pointer;
+}
+
+void* written_RI_malloc(size_t __size, const char *caller, int line, RI_context context){
+    void *pointer = malloc(__size);
+    
+    if (context.memory.debug_memory) {
+        if (context.memory.current_allocation_index >= context.memory.allocation_table_length){
+            context.memory.allocation_table_length += 50;
+            context.memory.allocation_search_limit += 50;
+            
+            context.memory.allocation_table = (RI_memory_allocation*)RI_realloc(context.memory.allocation_table, sizeof(RI_memory_allocation) * context.memory.allocation_table_length);
+        }
+
+        context.memory.allocation_table[context.memory.current_allocation_index].allocated = 1;
+        context.memory.allocation_table[context.memory.current_allocation_index].reallocated_free = 0;
+        context.memory.allocation_table[context.memory.current_allocation_index].reallocated_alloc = 0;
+        context.memory.allocation_table[context.memory.current_allocation_index].freed = 0;
+        context.memory.allocation_table[context.memory.current_allocation_index].line = line;
+        context.memory.allocation_table[context.memory.current_allocation_index].pointer = pointer;        
+        context.memory.allocation_table[context.memory.current_allocation_index].size = __size;
+
+        context.memory.current_allocation_index++;
+    }
+
+    return pointer;
+}
+
+void* written_RI_calloc(size_t __nmemb, size_t __size, const char *caller, int line, RI_context context){
+    void *pointer = calloc(__nmemb, __size);
+    
+    if (context.memory.debug_memory) {
+        if (context.memory.current_allocation_index >= context.memory.allocation_table_length){
+            context.memory.allocation_table_length += 50;
+            context.memory.allocation_search_limit += 50;
+            
+            context.memory.allocation_table = (RI_memory_allocation*)RI_realloc(context.memory.allocation_table, sizeof(RI_memory_allocation) * context.memory.allocation_table_length);
+        }
+
+        context.memory.allocation_table[context.memory.current_allocation_index].allocated = 1;
+        context.memory.allocation_table[context.memory.current_allocation_index].reallocated_free = 0;
+        context.memory.allocation_table[context.memory.current_allocation_index].reallocated_alloc = 0;
+        context.memory.allocation_table[context.memory.current_allocation_index].freed = 0;
+        context.memory.allocation_table[context.memory.current_allocation_index].line = line;
+        context.memory.allocation_table[context.memory.current_allocation_index].pointer = pointer;        
+        context.memory.allocation_table[context.memory.current_allocation_index].size = __size * __nmemb;
+            
+        context.memory.current_allocation_index++;
+    }
+
+    return pointer;
+}
+
+void written_RI_free(void *__ptr, const char *caller, int line){
+    if (context.memory.debug_memory) {
+        // size_t size = 0;
+        
+        int current_allocation_index = 0;
+        int checking = 1;
+        
+        while (checking){
+            if (!context.memory.allocation_table[current_allocation_index].reallocated_free && context.memory.allocation_table[current_allocation_index].pointer == __ptr){
+                // i dont know what this does?
+                // size = context.memory.allocation_table[current_allocation_index].size;
+                context.memory.allocation_table[current_allocation_index].freed = 1;
+                
+                checking = 0;
+            }
+            
+            current_allocation_index++;
+            
+            if (current_allocation_index >= context.memory.allocation_search_limit){
+                checking = 0;
+            }
+        }
+    }
+ 
+    free(__ptr);
+}

+ 294 - 0
src/headers/RI_types.h

@@ -0,0 +1,294 @@
+#ifndef RI_STRUCTS_H
+#define RI_STRUCTS_H
+
+#include <SDL2/SDL.h>
+#include <CL/cl.h>
+#include "RI_math.h"
+
+enum {
+    RI_ASPECT_MODE_STRETCH = 1 << 0,
+    RI_ASPECT_MODE_LETTERBOX = 1 << 1,
+};
+
+enum {
+    RI_DEBUG_NONE = 0,
+
+    // PitMap
+    RI_DEBUG_PITMAP = 1 << 29,
+
+    // frame-level
+    RI_DEBUG_FRAME_START_END_MARKERS     = 1 << 0,
+    RI_DEBUG_TICK_TIME                   = 1 << 1,
+    RI_DEBUG_KERNEL_LOADER_ERROR         = 1 << 2,
+
+    // transformer
+    RI_DEBUG_TRANSFORMER_CURRENT_ACTOR   = 1 << 3,
+    RI_DEBUG_TRANSFORMER_GLOBAL_SIZE     = 1 << 5,
+    RI_DEBUG_TRANSFORMER_LOCAL_SIZE      = 1 << 6,
+    RI_DEBUG_TRANSFORMER_EXTRA_WORK_ITEMS= 1 << 7,
+    RI_DEBUG_TRANSFORMER_TIME            = 1 << 8,
+    RI_DEBUG_TRANSFORMER_MESSAGE         = 1 << 9,
+    RI_DEBUG_TRANSFORMER_ERROR           = 1 << 11,
+    RI_DEBUG_TRANSFORMER_TEXTURE         = 1 << 29,
+
+    RI_DEBUG_TRANSFORMER_ALL = (
+        RI_DEBUG_TRANSFORMER_CURRENT_ACTOR |
+        RI_DEBUG_TRANSFORMER_GLOBAL_SIZE |
+        RI_DEBUG_TRANSFORMER_LOCAL_SIZE |
+        RI_DEBUG_TRANSFORMER_EXTRA_WORK_ITEMS |
+        RI_DEBUG_TRANSFORMER_TIME |
+        RI_DEBUG_TRANSFORMER_MESSAGE |
+        RI_DEBUG_TRANSFORMER_ERROR |
+        RI_DEBUG_TRANSFORMER_TEXTURE ),
+
+    // rasterizer
+    RI_DEBUG_RASTERIZER_TIME             = 1 << 12,
+    RI_DEBUG_RASTERIZER_GLOBAL_SIZE      = 1 << 13,
+    RI_DEBUG_RASTERIZER_LOCAL_SIZE       = 1 << 14,
+    RI_DEBUG_RASTERIZER_MESSAGE          = 1 << 15,
+    RI_DEBUG_RASTERIZER_                 = 1 << 16,
+
+    RI_DEBUG_RASTERIZER_ALL = (
+        RI_DEBUG_RASTERIZER_TIME |
+        RI_DEBUG_RASTERIZER_GLOBAL_SIZE |
+        RI_DEBUG_RASTERIZER_LOCAL_SIZE |
+        RI_DEBUG_RASTERIZER_MESSAGE |
+        RI_DEBUG_RASTERIZER_ ),
+
+    // mesh loader
+    RI_DEBUG_MESH_LOADER_ERROR           = 1 << 17,
+    RI_DEBUG_MESH_LOADER_LOADED_MESH     = 1 << 18,
+    RI_DEBUG_MESH_LOADER_REALLOCATION    = 1 << 19,
+    RI_DEBUG_MESH_LOADER_TIME            = 1 << 20,
+    RI_DEBUG_MESH_LOADER_FACE_VERT_NORM_UV_COUNT = 1 << 28,
+
+    RI_DEBUG_MESH_LOADER_ALL = (
+        RI_DEBUG_MESH_LOADER_ERROR |
+        RI_DEBUG_MESH_LOADER_LOADED_MESH |
+        RI_DEBUG_MESH_LOADER_REALLOCATION |
+        RI_DEBUG_MESH_LOADER_TIME |
+        RI_DEBUG_MESH_LOADER_FACE_VERT_NORM_UV_COUNT ),
+
+    // render function
+    RI_DEBUG_RENDER_REALLOCATION         = 1 << 21,
+    RI_DEBUG_RENDER_ERROR                = 1 << 22,
+    RI_DEBUG_RENDER_FRAME_BUFFER_READ_TIME = 1 << 23,
+    RI_DEBUG_RENDER_TIME                 = 1 << 24,
+
+    RI_DEBUG_RENDER_ALL = (
+        RI_DEBUG_RENDER_REALLOCATION |
+        RI_DEBUG_RENDER_ERROR |
+        RI_DEBUG_RENDER_FRAME_BUFFER_READ_TIME |
+        RI_DEBUG_RENDER_TIME ),
+
+    // OpenCL
+    RI_DEBUG_OPENCL_ERROR                = 1 << 25,
+
+    // init
+    RI_DEBUG_INIT_PLATFORMS              = 1 << 26,
+    RI_DEBUG_INIT_ERROR                  = (1 << 27) | RI_DEBUG_OPENCL_ERROR,
+
+    // multi-flags
+    RI_DEBUG_ETC = (
+        RI_DEBUG_FRAME_START_END_MARKERS |
+        RI_DEBUG_TICK_TIME |
+        RI_DEBUG_KERNEL_LOADER_ERROR ),
+
+    RI_DEBUG_ERRORS = (
+        RI_DEBUG_TRANSFORMER_ERROR |
+        RI_DEBUG_MESH_LOADER_ERROR |
+        RI_DEBUG_RENDER_ERROR |
+        RI_DEBUG_INIT_ERROR ),
+
+    RI_DEBUG_ALL = (
+        RI_DEBUG_ETC |
+        RI_DEBUG_TRANSFORMER_ALL |
+        RI_DEBUG_MESH_LOADER_ALL |
+        RI_DEBUG_RASTERIZER_ALL |
+        RI_DEBUG_RENDER_ALL )
+};
+
+typedef enum {
+    ri_true = 1,
+    ri_false = 0,
+} ri_bool;
+
+typedef struct {
+    uint16_t width;
+    uint16_t height; // actual height of the image INCLUDING all frames
+    uint32_t index;
+    uint32_t frame_count;
+    uint16_t current_frame;
+    uint16_t frame_height; // height of each frame
+} RI_texture;
+
+typedef struct {
+    RI_vector_3 position_0;
+    RI_vector_3 position_1;
+    RI_vector_3 position_2;
+
+    RI_vector_3 normal_0;
+    RI_vector_3 normal_1;
+    RI_vector_3 normal_2;
+
+    RI_vector_2 uv_0;
+    RI_vector_2 uv_1;
+    RI_vector_2 uv_2;
+
+    unsigned char should_render;
+} RI_face;
+
+typedef struct {
+    int position_0_index;
+    int position_1_index;
+    int position_2_index;
+
+    int normal_0_index;
+    int normal_1_index;
+    int normal_2_index;
+
+    int uv_0_index;
+    int uv_1_index;
+    int uv_2_index;
+} RI_temp_face;
+
+typedef struct {
+    int face_count;
+    int face_index;
+    int has_normals;
+    int has_uvs;
+} RI_mesh;
+
+typedef struct {
+    double r, g, b;
+} RI_color;
+
+typedef struct {
+    uint32_t albedo;
+} RI_material;
+
+typedef struct {
+    RI_vector_3 position;
+    RI_vector_4 rotation;
+    RI_vector_3 scale;
+    RI_mesh *mesh;
+    RI_texture* texture;
+    int active;
+    int material_index;
+    uint16_t texture_frame;
+} RI_actor;
+
+typedef struct {
+    RI_vector_3 position_0, position_1, position_2;
+    RI_vector_3 normal_0, normal_1, normal_2;
+    RI_vector_2 uv_0, uv_1, uv_2;
+    int16_t min_screen_x, max_screen_x, min_screen_y, max_screen_y;
+    unsigned char should_render;
+    unsigned char is_split;
+    unsigned char is_transformed;
+    unsigned char is_shrunk;
+    RI_texture texture;
+} RI_renderable_face;
+
+typedef struct {
+    RI_vector_3 position;
+    RI_vector_4 rotation;
+    float FOV, min_clip, max_clip;
+} RI_camera;
+
+typedef struct {
+    RI_actor **actors;
+    RI_camera camera;
+    int length_of_actors_array, face_count;
+} RI_scene;
+
+typedef struct {
+    size_t size;
+    void *pointer;
+    int reallocated_free;
+    int reallocated_alloc;
+    int freed;
+    int allocated;
+    int line;
+} RI_memory_allocation;
+
+typedef struct {
+    int width, height, half_width, half_height;
+    char* title;
+    unsigned char aspect_mode;
+} RI_window;
+
+typedef struct {
+    SDL_Window *window;
+    SDL_Renderer *renderer;
+    SDL_Texture *frame_buffer_texture;
+    uint32_t *frame_buffer;
+    void (*event_handler)(SDL_Event);
+    int pitch;
+} RI_SDL;
+
+typedef struct {
+    cl_platform_id platform;
+    cl_device_id device;
+    cl_context context;
+    cl_command_queue queue;
+    cl_kernel rasterization_kernel;
+    cl_kernel transformation_kernel;
+    cl_kernel tile_clear_kernel;
+    cl_mem textures_mem_buffer;
+    cl_mem renderable_faces_mem_buffer;
+    cl_mem faces_mem_buffer;
+    cl_mem frame_buffer_mem_buffer;
+    cl_mem vertecies_mem_buffer;
+    cl_mem normals_mem_buffer;
+    cl_mem uvs_mem_buffer;
+    cl_mem tiles_mem_buffer;
+    RI_renderable_face *faces_to_render;
+    RI_face *faces;
+    RI_temp_face *temp_faces;
+    RI_vector_3 *temp_vertecies;
+    RI_vector_3 *temp_normals;
+    RI_vector_2 *temp_uvs;
+    uint32_t* textures;
+    int face_count;
+    int vertex_count;
+    int normal_count;
+    int uv_count;
+    int length_of_renderable_faces_array;
+    int number_of_faces_just_rendered;
+    int length_of_textures_array;
+    int tile_width;
+    int tile_height;
+    int lagest_face_count;
+    int num_h_tiles;
+    int num_v_tiles;
+} RI_CL;
+
+typedef struct {
+    int debug_memory;
+    RI_memory_allocation *allocation_table;
+    int current_allocation_index;
+    int allocation_search_limit;
+    int allocation_table_length;
+} RI_memory;
+
+typedef struct {
+    RI_actor *default_actor;
+    RI_texture* default_texture;
+} RI_defaults;
+
+typedef struct {
+    RI_window window;
+    RI_SDL sdl;
+    RI_CL opencl;
+    RI_memory memory;
+    RI_defaults defaults;
+    int is_running;
+    char* debug_prefix;
+    int current_renderable_face_index;
+    int current_split_renderable_face_index;
+    int current_frame;
+    int debug_flags;
+} RI_context;
+
+#endif

+ 7 - 0
src/headers/SP_functions.h

@@ -0,0 +1,7 @@
+#ifndef SP_FUNCTIONS_H
+#define SP_FUNCTIONS_H
+
+SP_font* SP_load_font(char *filename);
+void SP_free_font(SP_font* font);
+
+#endif

+ 58 - 0
src/headers/SP_structs.h

@@ -0,0 +1,58 @@
+#ifndef SP_STRUCTS_H
+#define SP_STRUCTS_H
+
+typedef struct {
+    uint16_t left, right;
+    int16_t value; // kerning value for the above pair. If it's more than 0, the cahracters will be moved apart. If it's less than 0, the characters will be moved closer
+} SP_kerning_pair;
+
+typedef struct {
+    int16_t ascender;
+    int16_t descender;
+    int16_t line_gap;
+    uint16_t advance_max_width;
+    int16_t min_left_side_bearing;
+    int16_t min_right_side_bearing;
+    int16_t x_max_extent;
+    int16_t carat_slope_rise;
+    int16_t carat_slope_run;
+    int16_t carat_offset;
+    int16_t metric_data_format;
+    uint16_t number_of_h_metrics;
+} SP_hhea_table;
+
+typedef struct {
+    uint16_t advance_width;
+    int16_t left_side_bearing;
+} SP_long_hor_metric;
+
+typedef struct {
+    int scale_x, scale01, scale10, scale_y;
+    int glyph_index;
+    int16_t arg1, arg2;
+} SP_component;
+
+typedef struct {
+    int *x_coords, *y_coords, *contour_end_indicies; 
+    int number_of_points, number_of_contours, number_of_components;
+    int advance_width;
+    uint8_t *flags;
+    int16_t x_min, y_min, x_max, y_max;
+    SP_component *components;
+    int is_composite;
+} SP_glyph;
+
+typedef struct {
+    int current_byte, number_of_glyphs, number_of_kerning_pairs, *glyph_offsets; 
+    uint16_t *unicode_to_glyph_indicies;
+    float units_per_em;
+    uint8_t *buffer;
+    SP_glyph *glyphs;
+    int16_t index_to_loca_format;
+    SP_long_hor_metric *h_metrics;
+    SP_hhea_table hhea_table;
+    int16_t *left_side_bearings;
+    SP_kerning_pair *kerning_pairs; 
+} SP_font;
+
+#endif

+ 8 - 0
src/headers/fizzix.h

@@ -0,0 +1,8 @@
+#ifndef FIZZIX_H
+#define FIZZIX_H
+
+#include "FZ_functions.h"
+#include "FZ_structs.h"
+#include "FZ_math.h"
+
+#endif

+ 12 - 0
src/headers/lemonguice.h

@@ -0,0 +1,12 @@
+#ifndef LEMON_GUICE_H
+#define LEMON_GUICE_H
+
+#include <stdlib.h>
+#include <stdint.h>
+#include "../headers/sourparse.h"
+#include <SDL2/SDL.h>
+
+#include "LG_structs.h"
+#include "LG_functions.h"
+
+#endif // LEMON_GUICE_H

+ 9 - 0
src/headers/pitmap.h

@@ -0,0 +1,9 @@
+#ifndef PITMAP_H
+#define PITMAP_H
+
+#include <stdint.h>
+
+#include "PM_functions.h"
+#include "PM_structs.h"
+
+#endif

+ 7 - 0
src/headers/pomelo.h

@@ -0,0 +1,7 @@
+#ifndef POMELO_H
+#define POMELO_H
+
+#include "PO_functions.h"
+#include "PO_structs.h"
+
+#endif

+ 8 - 0
src/headers/rasteriver.h

@@ -0,0 +1,8 @@
+#ifndef RASTERIVER_H
+#define RASTERIVER_H
+
+#include "RI_types.h"
+#include "RI_functions.h"
+#include "RI_math.h"
+
+#endif

+ 9 - 0
src/headers/sourparse.h

@@ -0,0 +1,9 @@
+#ifndef SOURPARSE_H
+#define SOURPARSE_H
+
+#include "stdint.h"
+
+#include "SP_functions.h"
+#include "SP_structs.h"
+
+#endif

+ 5 - 0
src/launch program/main.c

@@ -0,0 +1,5 @@
+#include "../headers/pomelo.h"
+
+int main(){
+    return 0;
+}

+ 10 - 0
src/main/main.c

@@ -0,0 +1,10 @@
+#include "../headers/fizzix.h"
+#include "../headers/lemonguice.h"
+#include "../headers/pitmap.h"
+#include "../headers/rasteriver.h"
+#include "../headers/sourparse.h"
+#include "../headers/pomelo.h"
+
+int main(){
+    return 0;
+}

+ 1 - 0
val

@@ -0,0 +1 @@
+valgrind --leak-check=full --track-origins=yes ./builds/main.bin