diff options
author | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-07-21 16:17:26 +1000 |
---|---|---|
committer | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-07-21 16:17:26 +1000 |
commit | 1f9b47d925a0a21111e458a573a991ef26a35528 (patch) | |
tree | 7d7fc43b24d096b4c7998e6f09684619c670ffd3 /scripts | |
parent | 47465948f2a5a85d0882ff116fce095f401d69c1 (diff) |
start adding rust bindgen
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/amalgamation/celeritas.h | 54 | ||||
-rw-r--r-- | scripts/amalgamation/gen_amalgamation.py | 55 |
2 files changed, 99 insertions, 10 deletions
diff --git a/scripts/amalgamation/celeritas.h b/scripts/amalgamation/celeritas.h new file mode 100644 index 0000000..b432915 --- /dev/null +++ b/scripts/amalgamation/celeritas.h @@ -0,0 +1,54 @@ +void GPU_Renderpass_Destroy(GPU_Renderpass* pass); +void GraphicsPipeline_Destroy(GPU_Pipeline* pipeline); +GPU_CmdEncoder GPU_CmdEncoder_Create(); +void GPU_CmdEncoder_Destroy(GPU_CmdEncoder* encoder); +void GPU_CmdEncoder_Begin(GPU_CmdEncoder* encoder); +void GPU_CmdEncoder_Finish(GPU_CmdEncoder* encoder); +void GPU_CmdEncoder_BeginRender(GPU_CmdEncoder* encoder, GPU_Renderpass* renderpass); +void GPU_CmdEncoder_EndRender(GPU_CmdEncoder* encoder); +void GPU_QueueSubmit(GPU_CmdBuffer* cmd_buffer); +void GPU_BufferDestroy(BufferHandle handle); +void GPU_BufferUpload(BufferHandle buffer, size_t n_bytes, const void* data); +TextureHandle GPU_TextureCreate(TextureDesc desc, bool create_view, const void* data); +void GPU_TextureDestroy(TextureHandle handle); +void GPU_TextureUpload(TextureHandle handle, size_t n_bytes, const void* data); +void GPU_EncodeBindPipeline(GPU_CmdEncoder* encoder, GPU_Pipeline* pipeline); +void GPU_EncodeBindShaderData(GPU_CmdEncoder* encoder, u32 group, ShaderData data); +void GPU_EncodeSetVertexBuffer(GPU_CmdEncoder* encoder, BufferHandle buf); +void GPU_EncodeSetIndexBuffer(GPU_CmdEncoder* encoder, BufferHandle buf); +void GPU_EncodeDraw(GPU_CmdEncoder* encoder, u64 count); +void GPU_EncodeDrawIndexed(GPU_CmdEncoder* encoder, u64 index_count); +bool GPU_Backend_BeginFrame(); +void GPU_Backend_EndFrame(); +Skybox Skybox_Create(const char** face_paths, int n); +void Skybox_Draw(Skybox* skybox, Camera camera); +void SetCamera(Camera camera); +void SetMainLight(DirectionalLight light); +void PBR_Init(PBR_Storage* storage); +void Shadow_Init(Shadow_Storage* storage, u32 shadowmap_width, u32 shadowmap_height); +void Shadow_Run(RenderEnt* entities, size_t entity_count); +void Shadow_DrawDebugQuad(); +TextureHandle Shadow_GetShadowMapTexture(Shadow_Storage* storage); +void Immdraw_Init(Immdraw_Storage* storage); +void Immdraw_Shutdown(Immdraw_Storage* storage); +void Immdraw_Plane(Transform tf, Vec4 colour, bool wireframe); +void Immdraw_Cuboid(Transform tf, Vec4 colour, bool wireframe); +void Immdraw_Sphere(Transform tf, f32 size, Vec4 colour, bool wireframe); +void Immdraw_TransformGizmo(Transform tf, f32 size); +void EncodeDrawModel(Handle model, Mat4 transform); +void EncodeDrawMesh(Mesh* mesh, Material* material, Mat4 affine); +bool Renderer_Init(RendererConfig config, Renderer* renderer, GLFWwindow** out_window); +void Renderer_Shutdown(Renderer* renderer); +size_t Renderer_GetMemReqs(); +void Render_FrameBegin(Renderer* renderer); +void Render_FrameEnd(Renderer* renderer); +void Render_RenderEntities(RenderEnt* entities, size_t entity_count); +TextureData TextureDataLoad(const char* path, bool invert_y); +void TextureUpload(TextureHandle handle, size_t n_bytes, const void* data); +TextureHandle TextureLoadFromFile(const char* path); +ModelHandle ModelLoad(const char* debug_name, const char* filepath); +Mesh Mesh_Create(Geometry* geometry, bool free_on_upload); +void Mesh_Delete(Mesh* mesh); +void DrawMesh(Mesh* mesh, Material* material, Mat4 model); +void Render_DrawTerrain(); +static inline Vec3 vec3_create(f32 x, f32 y, f32 z); diff --git a/scripts/amalgamation/gen_amalgamation.py b/scripts/amalgamation/gen_amalgamation.py index 45a1c21..4a4d946 100644 --- a/scripts/amalgamation/gen_amalgamation.py +++ b/scripts/amalgamation/gen_amalgamation.py @@ -2,23 +2,58 @@ # # This makes including and linking Celeritas very easy. import re -import sys +import os +from pathlib import Path -def find_pub_functions(filepath): +categories = { + "RAL": "src/ral", + "Render": "src/new_render", + "Maths": "src/maths" +} + +def find_pub_functions_in_folder(folder_path): + functions = [] + for filename in os.listdir(folder_path): + filepath = os.path.join(folder_path, filename) + if os.path.isfile(filepath): + file_funcs = find_pub_functions_in_file(filepath) + functions.extend(file_funcs) + + return functions + +def find_pub_functions_in_file(file_path): pattern = r'PUB\s+(\w+\s+)*(\w+)\s+(\w+)\s*\((.*?)\)' - with open(filepath, 'r') as file: + with open(file_path, 'r') as file: content = file.read() matches = re.finditer(pattern, content, re.MULTILINE) + # Collect all the functions into an array + functions = [] for match in matches: - print(match.group(0)) + signature = match.group(0) + if signature.startswith("PUB "): + signature = signature[4:] -if __name__ == "__main__": - if len(sys.argv) != 2: - print("Usage: python script.py <path_to_c_file>") - sys.exit(1) + print(signature) + functions.append(signature) + + return functions - file_path = sys.argv[1] - find_pub_functions(file_path) +def generate_header(): + header_path = "celeritas.h" + + script_dir = Path(__file__).resolve().parent + grandparent_dir = script_dir.parents[1] + + with open(header_path, 'w') as export_file: + for category in categories.keys(): + folder = os.path.join(grandparent_dir, categories[category]) + category_funcs = find_pub_functions_in_folder(folder) + for func in category_funcs: + export_file.write(func) + export_file.write(';\n') + +if __name__ == "__main__": + generate_header() |