├── .gitattributes ├── .gitignore ├── .gitlab-ci.yml ├── .gitmodules ├── .travis.yml ├── AUTHORS.md ├── CMakeLists.txt ├── HISTORY.md ├── LICENSE.md ├── README.md ├── build.py ├── core ├── bgfxshaders │ ├── bgfx_compute.sh │ ├── bgfx_shader.sh │ ├── common.sh │ └── shaderlib.sh ├── core │ └── default.dock_layout └── gamecontrollerdb.txt ├── docker-compose.yml ├── docs ├── architecture.md.html ├── gen │ ├── array.md.html │ ├── hash.md.html │ └── os.md.html ├── img │ ├── old_prototype012019.png │ ├── old_prototype112017.png │ ├── old_prototype201511.png │ ├── old_prototype42016.png │ └── prototyp.png ├── index.md.html └── markdeep.min.js ├── examples └── develop │ ├── .gitignore │ ├── README.md │ └── src │ ├── components │ ├── c_ball.inl │ ├── c_gamepad_controler.inl │ ├── c_pad.inl │ ├── c_player_input.inl │ └── c_rectangle.inl │ ├── content │ ├── box2.entity │ ├── camera.entity │ ├── ceong │ │ ├── ball.entity │ │ ├── ceong.entity │ │ ├── fs_pad.sc │ │ ├── pad.entity │ │ ├── pad.material │ │ ├── pad.shader │ │ ├── varying.def.sc │ │ ├── vs_pad.sc │ │ └── wall.entity │ ├── copy.material │ ├── copy.shader │ ├── duck.entity │ ├── empty.entity │ ├── fs_copy.sc │ ├── fs_shader1.sc │ ├── fs_shader2.sc │ ├── helmet.entity │ ├── level2.entity │ ├── level3.entity │ ├── m4.entity │ ├── m4.material │ ├── material1.material │ ├── material1222.material │ ├── material177777.material │ ├── material2.material │ ├── scene │ │ ├── Box.gltf │ │ ├── Duck.gltf │ │ ├── SciFiHelmet.bin │ │ ├── SciFiHelmet.gltf │ │ ├── SciFiHelmet_BaseColor.png │ │ ├── box.scene │ │ ├── duck.scene │ │ ├── duck │ │ │ ├── duck.texture │ │ │ └── duckCM.bmp │ │ ├── m4a1 │ │ │ ├── m4_diff.tga │ │ │ └── m4a1.texture │ │ ├── scifihelmet.scene │ │ ├── scifihelmet.texture │ │ └── solider │ │ │ ├── body01.png │ │ │ ├── body01.tga │ │ │ ├── head.texture │ │ │ ├── head01.png │ │ │ ├── head01.tga │ │ │ ├── m4.texture │ │ │ ├── m4tex.png │ │ │ └── m4tex.tga │ ├── shader1.shader │ ├── shader2.shader │ ├── texture1.texture │ ├── texture1.tga │ ├── texture2.png │ ├── texture2.texture │ ├── texture2.tga │ ├── uv_checker.png │ ├── uv_checker.texture │ ├── uv_checker.tga │ ├── varying.def.sc │ ├── vs_copy.sc │ ├── vs_shader1.sc │ └── vs_shader2.sc │ ├── core │ ├── fs_texture_preview.sc │ ├── texture_preview.material │ ├── texture_preview.shader │ ├── varying.def.sc │ └── vs_texture_preview.sc │ ├── game_example.c │ ├── global.yml │ └── systems │ ├── rectangle_renderer.inl │ └── s_player_input.inl ├── requirements.txt ├── scripts ├── celib.lua ├── cetech.lua ├── genie.lua ├── tool_doc.lua ├── tool_hash.lua └── toolchain.lua ├── src ├── celib │ ├── api.h │ ├── cdb.h │ ├── celib_types.h │ ├── config.h │ ├── containers │ │ ├── array.h │ │ ├── bagraph.h │ │ ├── bitset.h │ │ ├── buffer.h │ │ ├── hash.h │ │ ├── mpmc.h │ │ └── spsc.h │ ├── core.h │ ├── fs.h │ ├── handler.h │ ├── id.h │ ├── log.h │ ├── macros.h │ ├── math │ │ ├── bounds.h │ │ └── math.h │ ├── memory │ │ ├── allocator.h │ │ ├── memory.h │ │ ├── memory_tracer.h │ │ └── private │ │ │ ├── memory.c │ │ │ ├── memory_tracer.c │ │ │ ├── system_alloc.inl │ │ │ └── virt_alloc.inl │ ├── module.h │ ├── murmur.h │ ├── os │ │ ├── cpu.h │ │ ├── error.h │ │ ├── input.h │ │ ├── object.h │ │ ├── path.h │ │ ├── private │ │ │ ├── os.c │ │ │ ├── os_cpu.c │ │ │ ├── os_error.c │ │ │ ├── os_input_sdl.c │ │ │ ├── os_object.c │ │ │ ├── os_path.c │ │ │ ├── os_process.c │ │ │ ├── os_thread.c │ │ │ ├── os_time.c │ │ │ ├── os_vio.c │ │ │ └── os_window_sdl2.c │ │ ├── process.h │ │ ├── thread.h │ │ ├── time.h │ │ ├── vio.h │ │ └── window.h │ ├── platform.h │ ├── private │ │ ├── api.c │ │ ├── api_private.inl │ │ ├── cdb.c │ │ ├── celib_module.c │ │ ├── config.c │ │ ├── core.c │ │ ├── fs.c │ │ ├── id.c │ │ ├── log.c │ │ ├── log_stdout.c │ │ ├── queue_mpmc.inl │ │ ├── task.c │ │ └── ydb.c │ ├── task.h │ └── ydb.h ├── cetech │ ├── camera │ │ ├── camera.h │ │ └── private │ │ │ └── camera.c │ ├── controlers │ │ ├── controlers.h │ │ ├── gamepad.h │ │ ├── keyboard.h │ │ ├── mouse.h │ │ └── private │ │ │ ├── controlers.c │ │ │ ├── gamepad.c │ │ │ ├── gamepadstr.h │ │ │ ├── keyboard.c │ │ │ ├── keystr.h │ │ │ ├── mouse.c │ │ │ └── mousebtnstr.h │ ├── debugdraw │ │ ├── dd.h │ │ └── private │ │ │ ├── bgfx_debugdraw │ │ │ ├── bounds.cpp │ │ │ ├── bounds.h │ │ │ ├── debugdraw.cpp │ │ │ ├── debugdraw.h │ │ │ ├── fs_debugdraw_fill.bin.h │ │ │ ├── fs_debugdraw_fill.sc │ │ │ ├── fs_debugdraw_fill_lit.bin.h │ │ │ ├── fs_debugdraw_fill_lit.sc │ │ │ ├── fs_debugdraw_fill_texture.bin.h │ │ │ ├── fs_debugdraw_fill_texture.sc │ │ │ ├── fs_debugdraw_lines.bin.h │ │ │ ├── fs_debugdraw_lines.sc │ │ │ ├── fs_debugdraw_lines_stipple.bin.h │ │ │ ├── fs_debugdraw_lines_stipple.sc │ │ │ ├── varying.def.sc │ │ │ ├── vs_debugdraw_fill.bin.h │ │ │ ├── vs_debugdraw_fill.sc │ │ │ ├── vs_debugdraw_fill_lit.bin.h │ │ │ ├── vs_debugdraw_fill_lit.sc │ │ │ ├── vs_debugdraw_fill_lit_mesh.bin.h │ │ │ ├── vs_debugdraw_fill_lit_mesh.sc │ │ │ ├── vs_debugdraw_fill_mesh.bin.h │ │ │ ├── vs_debugdraw_fill_mesh.sc │ │ │ ├── vs_debugdraw_fill_texture.bin.h │ │ │ ├── vs_debugdraw_fill_texture.sc │ │ │ ├── vs_debugdraw_lines.bin.h │ │ │ ├── vs_debugdraw_lines.sc │ │ │ ├── vs_debugdraw_lines_stipple.bin.h │ │ │ └── vs_debugdraw_lines_stipple.sc │ │ │ └── dd.cpp │ ├── debugui │ │ ├── debugui.h │ │ ├── icons_font_awesome.h │ │ └── private │ │ │ ├── bgfx_imgui │ │ │ ├── droidsans.ttf.h │ │ │ ├── fs_imgui_color.bin.h │ │ │ ├── fs_imgui_color.sc │ │ │ ├── fs_imgui_cubemap.bin.h │ │ │ ├── fs_imgui_cubemap.sc │ │ │ ├── fs_imgui_image.bin.h │ │ │ ├── fs_imgui_image.sc │ │ │ ├── fs_imgui_image_swizz.bin.h │ │ │ ├── fs_imgui_image_swizz.sc │ │ │ ├── fs_imgui_latlong.bin.h │ │ │ ├── fs_imgui_latlong.sc │ │ │ ├── fs_imgui_texture.bin.h │ │ │ ├── fs_imgui_texture.sc │ │ │ ├── fs_ocornut_imgui.bin.h │ │ │ ├── fs_ocornut_imgui.sc │ │ │ ├── icons_font_awesome.ttf.h │ │ │ ├── icons_kenney.ttf.h │ │ │ ├── imgui.cpp │ │ │ ├── imgui.h │ │ │ ├── makefile │ │ │ ├── roboto_regular.ttf.h │ │ │ ├── robotomono_regular.ttf.h │ │ │ ├── scintilla.cpp │ │ │ ├── scintilla.h │ │ │ ├── varying.def.sc │ │ │ ├── vs_imgui_color.bin.h │ │ │ ├── vs_imgui_color.sc │ │ │ ├── vs_imgui_cubemap.bin.h │ │ │ ├── vs_imgui_cubemap.sc │ │ │ ├── vs_imgui_image.bin.h │ │ │ ├── vs_imgui_image.sc │ │ │ ├── vs_imgui_latlong.bin.h │ │ │ ├── vs_imgui_latlong.sc │ │ │ ├── vs_imgui_texture.bin.h │ │ │ ├── vs_imgui_texture.sc │ │ │ ├── vs_ocornut_imgui.bin.h │ │ │ └── vs_ocornut_imgui.sc │ │ │ ├── debugui.cpp │ │ │ ├── iconfontheaders │ │ │ ├── .gitignore │ │ │ ├── GenerateIconFontCppHeaders.py │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── icons_kenney.h │ │ │ └── icons_material_design.h │ │ │ ├── imgui_wrap.inl │ │ │ └── ocornut-imgui │ │ │ ├── imconfig.h │ │ │ ├── imgui.cpp │ │ │ ├── imgui.h │ │ │ ├── imgui_draw.cpp │ │ │ ├── imgui_internal.h │ │ │ ├── imgui_user.h │ │ │ ├── imgui_user.inl │ │ │ ├── stb_rect_pack.h │ │ │ ├── stb_textedit.h │ │ │ ├── stb_truetype.h │ │ │ └── widgets │ │ │ ├── color_picker.h │ │ │ ├── color_picker.inl │ │ │ ├── color_wheel.h │ │ │ ├── color_wheel.inl │ │ │ ├── dock.h │ │ │ ├── dock.inl │ │ │ ├── file_list.h │ │ │ ├── file_list.inl │ │ │ ├── gizmo.h │ │ │ ├── gizmo.inl │ │ │ ├── memory_editor.h │ │ │ ├── memory_editor.inl │ │ │ ├── range_slider.h │ │ │ └── range_slider.inl │ ├── default_rg │ │ ├── default_rg.h │ │ └── private │ │ │ └── default_rg.c │ ├── ecs │ │ ├── ecs.h │ │ └── private │ │ │ └── ecs.c │ ├── editor │ │ ├── action_manager.h │ │ ├── dock.h │ │ ├── editor.h │ │ ├── editor_ui.h │ │ ├── private │ │ │ ├── action_manager.c │ │ │ ├── dock.c │ │ │ ├── editor.c │ │ │ ├── editor_ui.c │ │ │ └── selected_object.c │ │ └── selcted_object.h │ ├── entity │ │ └── private │ │ │ ├── entity_editor.c │ │ │ ├── entity_explorer.c │ │ │ └── entity_property.c │ ├── explorer │ │ ├── explorer.h │ │ └── private │ │ │ └── explorer.c │ ├── game │ │ ├── game_system.h │ │ ├── game_view.h │ │ └── private │ │ │ ├── game_system.c │ │ │ └── game_view.c │ ├── kernel │ │ ├── kernel.h │ │ └── private │ │ │ └── kernel.c │ ├── log_view │ │ ├── log_view.h │ │ └── private │ │ │ └── log_view.cpp │ ├── machine │ │ ├── machine.h │ │ └── private │ │ │ └── machine_sdl2.c │ ├── material │ │ ├── material.h │ │ └── private │ │ │ └── material.c │ ├── mesh │ │ ├── primitive_mesh.h │ │ ├── private │ │ │ ├── primitive_mesh.c │ │ │ └── static_mesh.c │ │ └── static_mesh.h │ ├── metrics │ │ ├── metrics.h │ │ └── private │ │ │ └── metrics.c │ ├── node_graph │ │ ├── node_graph.h │ │ └── private │ │ │ ├── node_graph.c │ │ │ └── node_test.c │ ├── node_graph_editor │ │ ├── node_graph_editor.h │ │ └── private │ │ │ └── node_graph_editor.cpp │ ├── parent │ │ ├── parent.h │ │ └── private │ │ │ └── parent.c │ ├── physics2d │ │ ├── physics2d.h │ │ └── private │ │ │ └── physics2d.c │ ├── physics2d_box2d │ │ └── private │ │ │ └── physics2d_box2d.cpp │ ├── physics3d │ │ ├── physics3d.h │ │ └── private │ │ │ └── physics3d.c │ ├── physics3d_bullet │ │ └── private │ │ │ └── physics3d_bullet.cpp │ ├── profiler │ │ └── private │ │ │ └── profiler_dock.c │ ├── property_editor │ │ ├── private │ │ │ └── property_editor.c │ │ └── property_editor.h │ ├── render_graph │ │ ├── private │ │ │ ├── celib_module.inl │ │ │ ├── render_builder.inl │ │ │ └── render_graph.c │ │ └── render_graph.h │ ├── renderer │ │ ├── gfx.h │ │ ├── private │ │ │ ├── bgfx_utils.h │ │ │ ├── c_viewport.inl │ │ │ ├── gfx.inl │ │ │ ├── packrect.h │ │ │ └── renderer.c │ │ └── renderer.h │ ├── resource │ │ ├── private │ │ │ ├── resource.c │ │ │ ├── resource_compiler.c │ │ │ └── resourcedb.c │ │ ├── resource.h │ │ ├── resource_compiler.h │ │ └── resourcedb.h │ ├── resource_browser │ │ ├── private │ │ │ └── resource_browser.cpp │ │ └── resource_browser.h │ ├── resource_editor │ │ ├── private │ │ │ └── resource_editor.c │ │ └── resource_editor.h │ ├── resource_preview │ │ ├── private │ │ │ └── resource_preview.c │ │ └── resource_preview.h │ ├── scene │ │ ├── private │ │ │ ├── gltf_compiler.inl │ │ │ ├── scene.c │ │ │ └── scene_compiler.cpp │ │ └── scene.h │ ├── shader │ │ ├── private │ │ │ └── shader.c │ │ └── shader.h │ ├── static_module.h │ ├── texture │ │ ├── private │ │ │ └── texture.c │ │ └── texture.h │ └── transform │ │ ├── private │ │ └── transform.c │ │ └── transform.h ├── sqlite │ └── private │ │ └── sqlite3.c └── tools │ ├── doc │ └── doc.c │ └── hash │ └── hash.c ├── toolchain ├── Dockerfile └── requirements.txt └── tools ├── darwin64 └── genie └── linux64 └── genie /.gitattributes: -------------------------------------------------------------------------------- 1 | externals/build/** linguist-vendored=true 2 | src/cetech/debugui/private/bgfx_imgui/** linguist-vendored=true 3 | src/cetech/debugui/private/iconfontheaders/** linguist-vendored=true 4 | src/cetech/debugui/private/ocornut-imgui/** linguist-vendored=true 5 | src/cetech/debugui/private/ocornut-imgui/bgfx_utils.h linguist-vendored=true 6 | src/cetech/debugdraw/private/debugdraw/bgfx_debugdraw/** linguist-vendored=true 7 | 8 | *.material linguist-language=YAML 9 | *.texture linguist-language=YAML 10 | *.shader linguist-language=YAML 11 | *.entity linguist-language=YAML 12 | *.scene linguist-language=YAML 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .gtm 3 | .vagrant 4 | .cache 5 | .vscode 6 | 7 | /bin/ 8 | /build*/ 9 | /*.build/ 10 | /*.xcodeproj/ 11 | /cmake-build-debug/ 12 | /cmake-build-release/ 13 | /CMakeFiles/ 14 | /CMakeScripts/ 15 | /site/ 16 | 17 | __pycache__ 18 | 19 | *.kdev4 20 | *~ 21 | *.orig 22 | *.o 23 | *.sln 24 | *.csproj 25 | *.speccache 26 | *.DS_Store 27 | 28 | perf.data* 29 | logsystem.db 30 | /TODO.md 31 | 32 | *.srctrl* 33 | 34 | *.cmake 35 | CMakeCache.txt -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | ########## 2 | # Stages # 3 | ############################################################################### 4 | stages: 5 | - docker_image 6 | - build 7 | - test 8 | - documentation 9 | 10 | ################ 11 | # Docker image # 12 | ############################################################################### 13 | docker_image: 14 | stage: docker_image 15 | image: docker:latest 16 | 17 | only: 18 | - toolchain 19 | 20 | except: 21 | - branches 22 | 23 | services: 24 | - docker:dind 25 | 26 | script: 27 | - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY 28 | - docker build -t $CI_REGISTRY_IMAGE/toolchain:master toolchain/ 29 | - docker push $CI_REGISTRY_IMAGE/toolchain:master 30 | 31 | ######### 32 | # Build # 33 | ############################################################################### 34 | build: 35 | image: $CI_REGISTRY/cyberegoorg/cetech/toolchain:master 36 | stage: build 37 | allow_failure: true 38 | variables: 39 | GIT_SUBMODULE_STRATEGY: normal 40 | 41 | artifacts: 42 | paths: 43 | - bin 44 | 45 | script: 46 | - tools/linux64/genie --gcc=linux-clang gmake 47 | - make -C .build/projects/gmake-linux-clang/ config=debug64 48 | - make -C .build/projects/gmake-linux-clang/ config=release64 49 | 50 | ######## 51 | # Test # 52 | ############################################################################### 53 | test_release: 54 | image: $CI_REGISTRY/cyberegoorg/cetech/toolchain:master 55 | stage: test 56 | allow_failure: true 57 | variables: 58 | SDL_VIDEODRIVER: dummy 59 | 60 | dependencies: 61 | - build 62 | 63 | script: 64 | - bin/linux64/cetech_develop -compile -src ./examples/develop/src -build ./examples/develop/build -renderer.type noop 65 | 66 | test_debug: 67 | image: $CI_REGISTRY/cyberegoorg/cetech/toolchain:master 68 | stage: test 69 | allow_failure: true 70 | variables: 71 | SDL_VIDEODRIVER: dummy 72 | 73 | dependencies: 74 | - build 75 | 76 | script: 77 | - bin/linux64/cetech_develop_debug -compile -src ./examples/develop/src -build ./examples/develop/build -renderer.type noop 78 | 79 | ################ 80 | # Gitlab pages # 81 | ############################################################################### 82 | pages: 83 | image: $CI_REGISTRY/cyberegoorg/cetech/toolchain:master 84 | stage: documentation 85 | script: 86 | - tools/linux64/genie doc 87 | - cp -R docs public 88 | - cp docs/index.md.html public/index.html 89 | 90 | dependencies: 91 | - build 92 | 93 | only: 94 | - master 95 | 96 | artifacts: 97 | paths: 98 | - public 99 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "externals"] 2 | path = externals 3 | url = https://gitlab.com/cyberegoorg/CETech-externals.git 4 | [submodule "playground/icons/breeze"] 5 | path = playground/icons/breeze 6 | url = https://gitlab.com/cyberegoorg/CETech-icons-breeze.git 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | git: 2 | depth: 1 3 | language: c 4 | os: 5 | - osx 6 | # - linux 7 | # - windows 8 | 9 | env: 10 | global: 11 | - SDL_VIDEODRIVER=dummy 12 | 13 | addons: 14 | apt: 15 | sources: 16 | - ubuntu-toolchain-r-test 17 | packages: 18 | - clang 19 | - cmake 20 | - cmake-data 21 | 22 | before_install: 23 | - if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get -qq update; fi 24 | 25 | script: 26 | - echo $TRAVIS_OS_NAME 27 | - cmake --version 28 | - if [[ "$TRAVIS_OS_NAME" != "windows" ]]; then clang --version; fi 29 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo pip3 install -r requirements.txt; fi 30 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then pip3 install -r requirements.txt; fi 31 | - python3 build.py 32 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then bin/darwin64/cetech_develop -compile -src ./examples/develop/src -build ./examples/develop/build -renderer.type noop; fi 33 | 34 | -------------------------------------------------------------------------------- /AUTHORS.md: -------------------------------------------------------------------------------- 1 | # Authors 2 | 3 | * Ondra Voves [ondra.voves@cyberego.org] 4 | -------------------------------------------------------------------------------- /HISTORY.md: -------------------------------------------------------------------------------- 1 | # History 2 | 3 | # 0.1.0 (WIP) 4 | -------------------------------------------------------------------------------- /core/bgfxshaders/common.sh: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2019 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 4 | */ 5 | 6 | #include "bgfx_shader.sh" 7 | #include "shaderlib.sh" 8 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | toolchain: 4 | build: 5 | context: ./toolchain/ 6 | 7 | working_dir: /cetech/ 8 | 9 | volumes: 10 | - ./:/cetech/ 11 | 12 | build: 13 | build: 14 | context: ./toolchain/ 15 | 16 | working_dir: /cetech/ 17 | 18 | volumes: 19 | - ./:/cetech/ 20 | 21 | command: bash -c 'tools/linux64/genie --gcc=linux-clang gmake && make -C .build/projects/gmake-linux-clang/ config=debug64' 22 | 23 | build-externals: 24 | build: 25 | context: ./toolchain/ 26 | 27 | working_dir: /cetech/ 28 | 29 | volumes: 30 | - ./:/cetech/ 31 | 32 | command: python3 externals/externals.py -v 33 | -------------------------------------------------------------------------------- /docs/architecture.md.html: -------------------------------------------------------------------------------- 1 | 2 | **CETech architecture** 3 | 4 | # ECS 5 | 6 | ## Chunk 7 | 8 | ************************************************************************************************ 9 | * +---+ 10 | * | | +----------+ +----------+ +------------+ 11 | * | | |Next chunk| |Prev chunk| | ... | 12 | * | | +----------+ +----------+ +------------+ 13 | * | | 14 | * | | 15 | * | | +------------+------------+---+------------+ 16 | * | | | Idx 0 | Idx 1 |...| Idx N | 17 | * | | +------------+------------+---+------------+ 18 | * | | 19 | * | | +----------------+ +------------+------------+---+------------+ 20 | * | | | Enity ID |---->| Entity ID | Entity ID |...| Entity ID |--+ 21 | * | | +----------------+ +------------+------------+---+------------+ | 22 | * | | +-----------------------------------------------------------+ 23 | * | C | | 24 | * | h | v 25 | * | u | +---+ +----------------+ +------------+------------+---+------------+ 26 | * | n | | | |Component type 0|---->|Component 0 |Component 1 |...|Component N |--+ 27 | * | k | | | +----------------+ +------------+------------+---+------------+ | 28 | * | | | A | | 29 | * | | | r | +-----------------------------------------------------------+ 30 | * | | | c | | 31 | * | | | h | v 32 | * | | | e | +----------------+ +------------+------------+---+------------+ 33 | * | | | m | |Component type 1|---->|Component 0 |Component 1 |...|Component N |--+ 34 | * | | | a | +----------------+ +------------+------------+---+------------+ | 35 | * | | | s | +-----------------------------------------------------------+ 36 | * | | | k | | 37 | * | | | | v 38 | * | | | | +----------------+ +------------+------------+---+------------+ 39 | * | | | | |Component type N|---->|Component 0 |Component 1 |...|Component N | 40 | * | | +---+ +----------------+ +------------+------------+---+------------+ 41 | * +---+ 42 | ************************************************************************************************ 43 | 44 | 45 | -------------------------------------------------------------------------------- /docs/img/old_prototype012019.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyberegoorg/cetech/09857e278ba1596fc1b0e790164bd4dbf843bc5d/docs/img/old_prototype012019.png -------------------------------------------------------------------------------- /docs/img/old_prototype112017.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyberegoorg/cetech/09857e278ba1596fc1b0e790164bd4dbf843bc5d/docs/img/old_prototype112017.png -------------------------------------------------------------------------------- /docs/img/old_prototype201511.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyberegoorg/cetech/09857e278ba1596fc1b0e790164bd4dbf843bc5d/docs/img/old_prototype201511.png -------------------------------------------------------------------------------- /docs/img/old_prototype42016.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyberegoorg/cetech/09857e278ba1596fc1b0e790164bd4dbf843bc5d/docs/img/old_prototype42016.png -------------------------------------------------------------------------------- /docs/img/prototyp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyberegoorg/cetech/09857e278ba1596fc1b0e790164bd4dbf843bc5d/docs/img/prototyp.png -------------------------------------------------------------------------------- /examples/develop/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | 3 | *.imported -------------------------------------------------------------------------------- /examples/develop/README.md: -------------------------------------------------------------------------------- 1 | # Develop project 2 | 3 | # Run 4 | 5 | Linux: 6 | 7 | ```bash 8 | ./bin/linux64/cetech_develop -src ./examples/develop/src -build ./examples/develop/build 9 | ``` 10 | -------------------------------------------------------------------------------- /examples/develop/src/components/c_ball.inl: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | // component 8 | #define BALL_COMPONENT \ 9 | CE_ID64_0("ball", 0xc57998c0dbf5ddd2ULL) 10 | 11 | static const char *ball_display_name() { 12 | return "Ball"; 13 | } 14 | 15 | static struct ct_ecs_component_i0 ball_component_i = { 16 | .display_name = ball_display_name, 17 | .cdb_type = BALL_COMPONENT, 18 | }; 19 | -------------------------------------------------------------------------------- /examples/develop/src/components/c_gamepad_controler.inl: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | // component 8 | 9 | typedef struct gamepad_controler_component { 10 | float gamepad_id; 11 | } gamepad_controler_component; 12 | 13 | #define GAMEPAD_COMPONENT \ 14 | CE_ID64_0("gamepad_controller", 0x49293316c5688da9ULL) 15 | 16 | static const char *gamepad_controler_display_name() { 17 | return "Gamepad controler"; 18 | } 19 | 20 | #define GAMEPAD_ID \ 21 | CE_ID64_0("gamepad_id", 0xc5ea6dc1179d6f0aULL) 22 | 23 | static const ce_cdb_prop_def_t0 gamepad_controler_compo_prop[] = { 24 | { 25 | .name = "gamepad_id", 26 | .type = CE_CDB_TYPE_FLOAT, 27 | }, 28 | }; 29 | 30 | static void _gamepad_controler_on_spawn(ct_world_t0 world, 31 | ce_cdb_t0 db, 32 | uint64_t obj, 33 | void *data) { 34 | gamepad_controler_component *c = data; 35 | 36 | const ce_cdb_obj_o0 *r = ce_cdb_a0->read(db, obj); 37 | (*c) = (gamepad_controler_component) {.gamepad_id = ce_cdb_a0->read_uint64(r, GAMEPAD_ID, 0)}; 38 | 39 | } 40 | 41 | static struct ct_ecs_component_i0 gamepad_controler_component_i = { 42 | .display_name = gamepad_controler_display_name, 43 | .cdb_type = GAMEPAD_COMPONENT, 44 | .size = sizeof(gamepad_controler_component), 45 | .from_cdb_obj = _gamepad_controler_on_spawn, 46 | }; 47 | -------------------------------------------------------------------------------- /examples/develop/src/components/c_pad.inl: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | // component 8 | #define PAD_COMPONENT \ 9 | CE_ID64_0("pad", 0x4d967a4a49a1ee61ULL) 10 | 11 | static const char *pad_display_name() { 12 | return "Pad"; 13 | } 14 | 15 | static struct ct_ecs_component_i0 pad_component_i = { 16 | .display_name = pad_display_name, 17 | .cdb_type = PAD_COMPONENT, 18 | }; 19 | -------------------------------------------------------------------------------- /examples/develop/src/components/c_player_input.inl: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | // component 8 | #define PLAYER_INPUT_COMPONENT \ 9 | CE_ID64_0("player_input", 0xd89eea239dbc4d7aULL) 10 | 11 | #define PLAYER_INPUT_MOVE \ 12 | CE_ID64_0("move", 0x33603ac62788b5c5ULL) 13 | 14 | #define PLAYER_INPUT_MOVE_SPEED \ 15 | CE_ID64_0("move_speed", 0x992619d01515f950ULL) 16 | 17 | #define PLAYER_INPUT_SHOOT_DIR \ 18 | CE_ID64_0("shoot_dir", 0x2cd9f4c7b4921bb0ULL) 19 | 20 | 21 | typedef struct player_input_component { 22 | float move; 23 | float move_speed; 24 | ce_vec2_t shoot_dir; 25 | } player_input_component; 26 | 27 | static const char *player_input_display_name() { 28 | return "Player input"; 29 | } 30 | 31 | static void _player_input_on_spawn(ct_world_t0 world, 32 | ce_cdb_t0 db, 33 | uint64_t obj, 34 | void *data) { 35 | player_input_component *c = data; 36 | 37 | const ce_cdb_obj_o0 *r = ce_cdb_a0->read(db, obj); 38 | 39 | uint64_t dir = ce_cdb_a0->read_subobject(r, PLAYER_INPUT_SHOOT_DIR, 0); 40 | const ce_cdb_obj_o0 *dir_r = ce_cdb_a0->read(db, dir); 41 | 42 | (*c) = (player_input_component) { 43 | .move = ce_cdb_a0->read_float(r, PLAYER_INPUT_MOVE, 0.0f), 44 | .move_speed = ce_cdb_a0->read_float(r, PLAYER_INPUT_MOVE_SPEED, 0.0f), 45 | .shoot_dir = (ce_vec2_t) { 46 | .x = ce_cdb_a0->read_float(dir_r, PROP_VEC_X, 0.0f), 47 | .y = ce_cdb_a0->read_float(dir_r, PROP_VEC_Y, 0.0f), 48 | } 49 | 50 | }; 51 | } 52 | 53 | static struct ct_ecs_component_i0 player_input_component_i = { 54 | .display_name = player_input_display_name, 55 | .cdb_type = PLAYER_INPUT_COMPONENT, 56 | .size = sizeof(player_input_component), 57 | .from_cdb_obj = _player_input_on_spawn, 58 | }; 59 | 60 | 61 | static const ce_cdb_prop_def_t0 player_input_component_prop[] = { 62 | { 63 | .name = "move", 64 | .type = CE_CDB_TYPE_FLOAT, 65 | }, 66 | { 67 | .name = "move_speed", 68 | .type = CE_CDB_TYPE_FLOAT, 69 | }, 70 | { 71 | .name = "shoot_dir", 72 | .type = CE_CDB_TYPE_SUBOBJECT, 73 | .obj_type = VEC2_CDB_TYPE, 74 | .flags = CE_CDB_PROP_FLAG_UNPACK, 75 | }, 76 | }; -------------------------------------------------------------------------------- /examples/develop/src/components/c_rectangle.inl: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | // component 8 | 9 | typedef struct rectangle_component { 10 | ce_vec2_t half_size; 11 | } rectangle_component; 12 | 13 | #define RECTANGLE_COMPONENT \ 14 | CE_ID64_0("rectangle", 0xc2352da254c3b48aULL) 15 | 16 | #define RECTANGLE_HALF_SIZE_PROP \ 17 | CE_ID64_0("half_size", 0xfae83ca4619fb60aULL) 18 | 19 | static const char *rectangle_display_name() { 20 | return "Rectangle"; 21 | } 22 | 23 | static void _rectangle_on_spawn(ct_world_t0 world, 24 | ce_cdb_t0 db, 25 | uint64_t obj, 26 | void *data) { 27 | rectangle_component *c = data; 28 | 29 | const ce_cdb_obj_o0 *r = ce_cdb_a0->read(db, obj); 30 | 31 | uint64_t vec = ce_cdb_a0->read_subobject(r, RECTANGLE_HALF_SIZE_PROP, 0); 32 | const ce_cdb_obj_o0 *vec_r = ce_cdb_a0->read(db, vec); 33 | 34 | *c = (rectangle_component){ 35 | .half_size = (ce_vec2_t) { 36 | .x = ce_cdb_a0->read_float(vec_r, PROP_VEC_X, 0.0f), 37 | .y = ce_cdb_a0->read_float(vec_r, PROP_VEC_Y, 0.0f), 38 | } 39 | }; 40 | } 41 | 42 | static const ce_cdb_prop_def_t0 rectangle_component_prop[] = { 43 | { 44 | .name = "half_size", 45 | .type = CE_CDB_TYPE_SUBOBJECT, 46 | .obj_type = VEC2_CDB_TYPE, 47 | .flags = CE_CDB_PROP_FLAG_UNPACK, 48 | }, 49 | }; 50 | 51 | static struct ct_ecs_component_i0 rectangle_component_i = { 52 | .display_name = rectangle_display_name, 53 | .cdb_type = RECTANGLE_COMPONENT, 54 | .size = sizeof(rectangle_component), 55 | .from_cdb_obj = _rectangle_on_spawn, 56 | }; 57 | -------------------------------------------------------------------------------- /examples/develop/src/content/box2.entity: -------------------------------------------------------------------------------- 1 | cdb_uid: 0xf7f5289f75e5f044 2 | cdb_type: entity 3 | name: (null) 4 | components: 5 | cdb_type: cdb_objset 6 | 0xe92a6c7185d73f6c: 7 | cdb_uid: 0xe92a6c7185d73f6c 8 | cdb_type: local_to_world 9 | 0x503ef52859bc3e3b: 10 | cdb_uid: 0x503ef52859bc3e3b 11 | cdb_type: static_mesh 12 | material: 0x24c9413e88ebaaa8 13 | scene: 0x3d4a26bc5ef4b90d 14 | node: (null) 15 | mesh: Mesh 16 | 0x1840da989e81141d: 17 | cdb_uid: 0x1840da989e81141d 18 | cdb_type: position 19 | position: 20 | cdb_uid: 0xb67854521dcb9072 21 | cdb_type: 0x6112fca24c71dad 22 | x: -10.000000 23 | y: 5.000000 24 | z: 40.000000 25 | children: 26 | cdb_type: cdb_objset 27 | 0xa6a54889e160cc7: 28 | cdb_uid: 0xa6a54889e160cc7 29 | cdb_type: entity 30 | name: (null) 31 | components: 32 | cdb_type: cdb_objset 33 | 0xd61f046bc560891c: 34 | cdb_uid: 0xd61f046bc560891c 35 | cdb_type: local_to_world 36 | 0x4a326290ac160cc7: 37 | cdb_uid: 0x4a326290ac160cc7 38 | cdb_type: local_to_parent 39 | 0xa8b2a1932060891c: 40 | cdb_uid: 0xa8b2a1932060891c 41 | cdb_type: position 42 | position: 43 | cdb_uid: 0x46ea1b4c9fab0571 44 | cdb_type: 0x6112fca24c71dad 45 | x: 14.000001 46 | y: 2.000000 47 | z: 0.000000 48 | 0x5a880c5cf0f581c6: 49 | cdb_uid: 0x5a880c5cf0f581c6 50 | cdb_type: static_mesh 51 | material: 0x15f21001d1 52 | scene: 0x97c41c8996520208 53 | node: (null) 54 | mesh: SciFiHelmet 55 | children: 56 | cdb_type: cdb_objset 57 | 0x658bbd5fee819: 58 | cdb_uid: 0x658bbd5fee819 59 | cdb_type: entity 60 | cdb_instance: 0x899cfb7b8c84a36c 61 | components: 62 | cdb_type: cdb_objset 63 | 0x9e3dd2755549646e: 64 | cdb_uid: 0x9e3dd2755549646e 65 | cdb_type: local_to_world 66 | cdb_instance: 0xa07874d664cf1fc1 67 | 0x3c754c2ed493e0c3: 68 | cdb_uid: 0x3c754c2ed493e0c3 69 | cdb_type: static_mesh 70 | cdb_instance: 0x8f3fd7c530f91115 71 | 0xee95525127de5d18: 72 | cdb_uid: 0xee95525127de5d18 73 | cdb_type: local_to_parent 74 | children: 75 | cdb_type: cdb_objset 76 | -------------------------------------------------------------------------------- /examples/develop/src/content/camera.entity: -------------------------------------------------------------------------------- 1 | cdb_uid: 0x57899875c4457313 2 | cdb_type: entity 3 | name: (null) 4 | components: 5 | cdb_type: cdb_objset 6 | 0x1ea4d40ad3a179e1: 7 | cdb_uid: 0x1ea4d40ad3a179e1 8 | cdb_type: local_to_world 9 | 0xd72994c74e847f5b: 10 | cdb_uid: 0xd72994c74e847f5b 11 | cdb_type: camera 12 | camera_type: perspective 13 | near: 0.100000 14 | far: 1000.000000 15 | fov: 60.000000 16 | 0x33a940d4bee3e3c: 17 | cdb_uid: 0x33a940d4bee3e3c 18 | cdb_type: viewport 19 | children: 20 | cdb_type: cdb_objset 21 | -------------------------------------------------------------------------------- /examples/develop/src/content/ceong/ball.entity: -------------------------------------------------------------------------------- 1 | cdb_uid: 0xa395900c2bc44ce8 2 | cdb_type: entity 3 | name: ball 4 | components: 5 | cdb_type: cdb_objset 6 | 0x67f9896de60ec93d: 7 | cdb_uid: 0x67f9896de60ec93d 8 | cdb_type: local_to_world 9 | 0x2fef2a3fb338ba91: 10 | cdb_uid: 0x2fef2a3fb338ba91 11 | cdb_type: ball 12 | 0x50c5dbcdff5e53dd: 13 | cdb_uid: 0x50c5dbcdff5e53dd 14 | cdb_type: rectangle 15 | half_size: 16 | cdb_uid: 0x3e54243cc5e58e2c 17 | cdb_type: vec2_t 18 | x: 8.000000 19 | y: 8.000000 20 | 0x491391859e06cf70: 21 | cdb_uid: 0x491391859e06cf70 22 | cdb_type: rectangle_renderer 23 | material: 0xbfb6c2d7354678ec 24 | 0x77cce97732314df: 25 | cdb_uid: 0x77cce97732314df 26 | cdb_type: collider2d 27 | shape: 28 | cdb_uid: 0xa5b44850f26d9134 29 | cdb_type: collider2d_shape_rectangle 30 | half_size: 31 | cdb_uid: 0x43ebc20a71b80d89 32 | cdb_type: vec2_t 33 | x: 8.000000 34 | y: 8.000000 35 | 0xe6034d6b95e1fedd: 36 | cdb_uid: 0xe6034d6b95e1fedd 37 | cdb_type: velocity2d 38 | linear: 39 | cdb_uid: 0x3dba11a16a2c7b32 40 | cdb_type: vec2_t 41 | x: 0.000000 42 | y: 0.000000 43 | angular: 0.000000 44 | 0x44578d189fcada2f: 45 | cdb_uid: 0x44578d189fcada2f 46 | cdb_type: mass2d 47 | mass: 1.000000 48 | 0xda344e1adb89c42d: 49 | cdb_uid: 0xda344e1adb89c42d 50 | cdb_type: position 51 | position: 52 | cdb_uid: 0x786bc7d45ad44082 53 | cdb_type: 0x6112fca24c71dad 54 | x: 0.000000 55 | y: 0.000000 56 | z: 0.000000 57 | 0x6d6a27f667b3b581: 58 | cdb_uid: 0x6d6a27f667b3b581 59 | cdb_type: rotation 60 | rotation: 61 | cdb_uid: 0xba1a1afe6fe31d6 62 | cdb_type: 0x6112fca24c71dad 63 | x: 0.000000 64 | y: 0.000000 65 | z: 0.000000 66 | children: 67 | cdb_type: cdb_objset 68 | -------------------------------------------------------------------------------- /examples/develop/src/content/ceong/fs_pad.sc: -------------------------------------------------------------------------------- 1 | $input v_view, v_normal 2 | 3 | #include "common.sh" 4 | 5 | uniform vec4 color; 6 | 7 | void main() { 8 | gl_FragData[0] = color; 9 | } 10 | -------------------------------------------------------------------------------- /examples/develop/src/content/ceong/pad.entity: -------------------------------------------------------------------------------- 1 | cdb_uid: 0x564c98159cba3052 2 | cdb_type: entity 3 | name: pad 4 | components: 5 | cdb_type: cdb_objset 6 | 0x23bdfb43b317794d: 7 | cdb_uid: 0x23bdfb43b317794d 8 | cdb_type: local_to_world 9 | 0xab4d4f3310f34c87: 10 | cdb_uid: 0xab4d4f3310f34c87 11 | cdb_type: rectangle 12 | half_size: 13 | cdb_uid: 0x5f7fadfbe2d7cfd1 14 | cdb_type: vec2_t 15 | x: 8.000000 16 | y: 32.000000 17 | 0xfab273448e38044e: 18 | cdb_uid: 0xfab273448e38044e 19 | cdb_type: player_input 20 | move: 0.000000 21 | move_speed: 15000.000000 22 | shoot_dir: 23 | cdb_uid: 0x719961fd4c6882e9 24 | cdb_type: vec2_t 25 | x: 0.000000 26 | y: 0.000000 27 | 0x505912ebe0a8d032: 28 | cdb_uid: 0x505912ebe0a8d032 29 | cdb_type: pad 30 | 0xe51bd0700c2bb279: 31 | cdb_uid: 0xe51bd0700c2bb279 32 | cdb_type: rectangle_renderer 33 | material: 0xbfb6c2d7354678ec 34 | 0xb74649a9c69bc81a: 35 | cdb_uid: 0xb74649a9c69bc81a 36 | cdb_type: gamepad_controller 37 | gamepad_id: 0.000000 38 | 0x7263f2ec38dda6d5: 39 | cdb_uid: 0x7263f2ec38dda6d5 40 | cdb_type: position 41 | position: 42 | cdb_uid: 0x109b6ca5b828232a 43 | cdb_type: 0x6112fca24c71dad 44 | x: 0.000000 45 | y: 0.000000 46 | z: 0.000000 47 | 0x3047d1ad599c90d3: 48 | cdb_uid: 0x3047d1ad599c90d3 49 | cdb_type: rotation 50 | rotation: 51 | cdb_uid: 0xce7f4b66d8e70d28 52 | cdb_type: 0x6112fca24c71dad 53 | x: 0.000000 54 | y: 0.000000 55 | z: 0.000000 56 | children: 57 | cdb_type: cdb_objset 58 | -------------------------------------------------------------------------------- /examples/develop/src/content/ceong/pad.material: -------------------------------------------------------------------------------- 1 | cdb_uid: 0xbfb6c2d7354678ec 2 | cdb_type: material 3 | layers: 4 | cdb_type: cdb_objset 5 | 0x9b2e443e0dddcda9: 6 | cdb_uid: 0x9b2e443e0dddcda9 7 | cdb_type: material_layer 8 | name: gbuffer 9 | shader: 0x340f387f64db7196 10 | render_state: 11 | cdb_uid: 0x78ccc53d72122492 12 | cdb_type: render_state 13 | rgb_write: true 14 | alpha_write: true 15 | depth_write: true 16 | depth_test_less: true 17 | cull_ccw: true 18 | msaa: true 19 | variables: 20 | cdb_type: cdb_objset 21 | 0x3e8302bae4fce294: 22 | cdb_uid: 0x3e8302bae4fce294 23 | cdb_type: material_variable_color 24 | name: color 25 | x: 1.000000 26 | y: 0.999990 27 | z: 0.999990 28 | w: 1.000000 29 | -------------------------------------------------------------------------------- /examples/develop/src/content/ceong/pad.shader: -------------------------------------------------------------------------------- 1 | cdb_uid: 0x340f387f64db7196 2 | cdb_type: shader 3 | vs_input: 'content/ceong/vs_pad.sc' 4 | fs_input: 'content/ceong/fs_pad.sc' 5 | -------------------------------------------------------------------------------- /examples/develop/src/content/ceong/varying.def.sc: -------------------------------------------------------------------------------- 1 | vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0); 2 | vec4 v_view : TEXCOORD1 = vec4(0.0, 0.0, 0.0, 0.0); 3 | vec3 v_normal : NORMAL = vec3(0.0, 0.0, 1.0); 4 | 5 | vec3 a_position : POSITION; 6 | vec3 a_normal : NORMAL; 7 | vec2 a_texcoord0 : TEXCOORD0; 8 | -------------------------------------------------------------------------------- /examples/develop/src/content/ceong/vs_pad.sc: -------------------------------------------------------------------------------- 1 | $input a_position, a_normal 2 | $output v_view, v_normal 3 | 4 | #include "common.sh" 5 | 6 | void main() { 7 | gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0)); 8 | v_view = mul(u_modelView, vec4(a_position, 1.0)); 9 | v_normal = normalize(mul(u_modelView, vec4(a_normal, 0.0)).xyz); 10 | } 11 | -------------------------------------------------------------------------------- /examples/develop/src/content/ceong/wall.entity: -------------------------------------------------------------------------------- 1 | cdb_uid: 0x78ea792503e07fe1 2 | cdb_type: entity 3 | name: wall 4 | components: 5 | cdb_type: cdb_objset 6 | 0xba9d9aceb9b23685: 7 | cdb_uid: 0xba9d9aceb9b23685 8 | cdb_type: local_to_world 9 | 0x234ccf9915dc27d9: 10 | cdb_uid: 0x234ccf9915dc27d9 11 | cdb_type: rectangle 12 | half_size: 13 | cdb_uid: 0xdc8736e7511d3ddb 14 | cdb_type: vec2_t 15 | x: 0.000000 16 | y: 0.000000 17 | 0x4d94b1607106cf70: 18 | cdb_uid: 0x4d94b1607106cf70 19 | cdb_type: rectangle_renderer 20 | material: 0xbfb6c2d7354678ec 21 | 0xe07151026e6882e9: 22 | cdb_uid: 0xe07151026e6882e9 23 | cdb_type: collider2d 24 | shape: 25 | cdb_uid: 0x7ea8cabbedb2ff3e 26 | cdb_type: collider2d_shape_rectangle 27 | half_size: 28 | cdb_uid: 0x1ce044756cfd7b93 29 | cdb_type: vec2_t 30 | x: 0.000000 31 | y: 0.000000 32 | 0xa4cbbde2fd5b7ad1: 33 | cdb_uid: 0xa4cbbde2fd5b7ad1 34 | cdb_type: position 35 | position: 36 | cdb_uid: 0x4303379c7ca5f726 37 | cdb_type: 0x6112fca24c71dad 38 | x: 0.000000 39 | y: 0.000000 40 | z: 0.000000 41 | 0xd570be37c2445623: 42 | cdb_uid: 0xd570be37c2445623 43 | cdb_type: rotation 44 | rotation: 45 | cdb_uid: 0x73a837f1418ed278 46 | cdb_type: 0x6112fca24c71dad 47 | x: 0.000000 48 | y: 0.000000 49 | z: 0.000000 50 | children: 51 | cdb_type: cdb_objset 52 | -------------------------------------------------------------------------------- /examples/develop/src/content/copy.material: -------------------------------------------------------------------------------- 1 | cdb_uid: 0xe27880f9fbb28b8d 2 | cdb_type: "material" 3 | layers: 4 | cdb_type: cdb_objset 5 | 0x2b41c78abb6dbba9: 6 | cdb_uid: "0x2b41c78abb6dbba9" 7 | cdb_type: material_layer 8 | 9 | name: default 10 | shader: "0xd693a02d1669a559" 11 | 12 | render_state: 13 | cdb_uid: "0x1280ea4b02aee59a" 14 | cdb_type: render_state 15 | 16 | rgb_write: true 17 | alpha_write: true 18 | depth_write: true 19 | depth_test_less: true 20 | cull_ccw: true 21 | msaa: true 22 | 23 | variables: 24 | cdb_type: cdb_objset 25 | 0x945f5b924d402d13: 26 | cdb_uid: "0x945f5b924d402d13" 27 | cdb_type: material_variable_texture_handler 28 | name: s_input_texture 29 | -------------------------------------------------------------------------------- /examples/develop/src/content/copy.shader: -------------------------------------------------------------------------------- 1 | cdb_type: "shader" 2 | cdb_uid: 0xd693a02d1669a559 3 | vs_input: 'content/vs_copy.sc' 4 | fs_input: 'content/fs_copy.sc' 5 | -------------------------------------------------------------------------------- /examples/develop/src/content/duck.entity: -------------------------------------------------------------------------------- 1 | cdb_uid: 0x899cfb7b8c84a36c 2 | cdb_type: entity 3 | name: (null) 4 | components: 5 | cdb_type: cdb_objset 6 | 0xa07874d664cf1fc1: 7 | cdb_uid: 0xa07874d664cf1fc1 8 | cdb_type: local_to_world 9 | 0x8f3fd7c530f91115: 10 | cdb_uid: 0x8f3fd7c530f91115 11 | cdb_type: static_mesh 12 | material: 0x15f21001d1 13 | scene: 0xcd111fa2efb3a30b 14 | node: (null) 15 | mesh: LOD3spShape 16 | children: 17 | cdb_type: cdb_objset 18 | -------------------------------------------------------------------------------- /examples/develop/src/content/empty.entity: -------------------------------------------------------------------------------- 1 | cdb_uid: 0xb0458fd869e7c36b 2 | cdb_type: entity 3 | name: (null) 4 | components: 5 | cdb_type: cdb_objset 6 | children: 7 | cdb_type: cdb_objset 8 | -------------------------------------------------------------------------------- /examples/develop/src/content/fs_copy.sc: -------------------------------------------------------------------------------- 1 | $input v_texcoord0 2 | 3 | #include "common.sh" 4 | 5 | SAMPLER2D(s_input_texture, 6 | 0); 7 | 8 | void main() { 9 | float gray = dot(texture2D(s_input_texture, v_texcoord0), 10 | vec4(0.299, 0.587, 0.114, 1.0)); 11 | 12 | gl_FragData[0] = texture2D(s_input_texture, v_texcoord0); 13 | // gl_FragData[0] = vec4(1.0f, 0.0f, 0.0f, 1.0f); 14 | // gl_FragData[0] = vec4(gray, gray, gray, 1.0f); 15 | //gl_FragData[0] = texture2D(s_input_texture, v_texcoord0) * vec4(0.0, 1.0, 0.0, 1.0); 16 | // gl_FragData[0] = texture2D(s_input_texture, v_texcoord0) * vec4(0.0, 1.0, 0.0, 1.0); 17 | // gl_FragData[0] = vec4(v_texcoord0, 0.0f, 1.0f); 18 | } 19 | -------------------------------------------------------------------------------- /examples/develop/src/content/fs_shader1.sc: -------------------------------------------------------------------------------- 1 | $input v_texcoord0, v_view, v_normal 2 | 3 | #include "common.sh" 4 | 5 | SAMPLER2D(u_texColor,0); 6 | 7 | uniform vec4 u_vec4; 8 | uniform vec4 u_vec42; 9 | 10 | void main() { 11 | float gray = dot(texture2D(u_texColor, v_texcoord0), 12 | vec4(0.299, 0.587, 0.114, 1.0)); 13 | 14 | gl_FragData[0] = vec4(texture2D(u_texColor, v_texcoord0).xyz, 1.0f) * u_vec4; 15 | //gl_FragData[0] = vec4(0.0f, 0.0f, 1.0f, 1.0f); 16 | // gl_FragData[0] = vec4(gray, gray, gray, 1.0f); 17 | // gl_FragData[0] = u_vec4; 18 | } 19 | -------------------------------------------------------------------------------- /examples/develop/src/content/fs_shader2.sc: -------------------------------------------------------------------------------- 1 | $input v_texcoord0, v_view, v_normal 2 | 3 | #include "common.sh" 4 | 5 | SAMPLER2D(u_texColor, 0); 6 | 7 | uniform vec4 u_vec4; 8 | uniform vec4 u_vec42; 9 | 10 | void main() { 11 | gl_FragData[0] = texture2D(u_texColor, v_texcoord0) * u_vec4; 12 | //gl_FragData[0] = vec4(0.0f, 0.0f, 1.0f, 1.0f); 13 | gl_FragData[0] = u_vec4; 14 | } 15 | -------------------------------------------------------------------------------- /examples/develop/src/content/helmet.entity: -------------------------------------------------------------------------------- 1 | cdb_uid: 0x9664d09f438e09bf 2 | cdb_type: entity 3 | name: (null) 4 | components: 5 | cdb_type: cdb_objset 6 | 0x7223792ec3d88614: 7 | cdb_uid: 0x7223792ec3d88614 8 | cdb_type: local_to_world 9 | 0x25e1bb3c6a4cf3bd: 10 | cdb_uid: 0x25e1bb3c6a4cf3bd 11 | cdb_type: static_mesh 12 | material: 0x15f21001d1 13 | scene: 0x97c41c8996520208 14 | node: (null) 15 | mesh: SciFiHelmet 16 | children: 17 | cdb_type: cdb_objset 18 | -------------------------------------------------------------------------------- /examples/develop/src/content/level2.entity: -------------------------------------------------------------------------------- 1 | cdb_uid: 0x588f56dc4e82f7b2 2 | cdb_type: entity 3 | name: Level 2 4 | components: 5 | cdb_type: cdb_objset 6 | 0x38a1e9c2481e8f31: 7 | cdb_uid: 0x38a1e9c2481e8f31 8 | cdb_type: local_to_world 9 | children: 10 | cdb_type: cdb_objset 11 | 0x168c410f48a0016a: 12 | cdb_uid: 0x168c410f48a0016a 13 | cdb_type: entity 14 | cdb_instance: 0x1680afa75da0014d 15 | components: 16 | cdb_type: cdb_objset 17 | 0x168c410f48a0016b: 18 | cdb_uid: 0x168c410f48a0016b 19 | cdb_type: local_to_world 20 | cdb_instance: 0x1680b5652a000164 21 | 0x168c410f48a0016f: 22 | cdb_uid: 0x168c410f48a0016f 23 | cdb_type: static_mesh 24 | cdb_instance: 0x1680b5662820015d 25 | children: 26 | cdb_type: cdb_objset 27 | 0x168c410f48a00170: 28 | cdb_uid: 0x168c410f48a00170 29 | cdb_type: entity 30 | cdb_instance: 0x1680ea049d5001aa 31 | components: 32 | cdb_type: cdb_objset 33 | 0x168c410f48a00175: 34 | cdb_uid: 0x168c410f48a00175 35 | cdb_type: static_mesh 36 | cdb_instance: 0x1680ea0700e00121 37 | children: 38 | cdb_type: cdb_objset 39 | -------------------------------------------------------------------------------- /examples/develop/src/content/m4.entity: -------------------------------------------------------------------------------- 1 | cdb_uid: 0x1680afa75da0014d 2 | cdb_type: entity 3 | name: (null) 4 | components: 5 | cdb_type: cdb_objset 6 | 0x1680b5652a000164: 7 | cdb_uid: 0x1680b5652a000164 8 | cdb_type: local_to_world 9 | 0x1680b5662820015d: 10 | cdb_uid: 0x1680b5662820015d 11 | cdb_type: static_mesh 12 | material: 0x1680b59ec410011b 13 | scene: 0xcd111fa2efb3a30b 14 | node: (null) 15 | mesh: LOD3spShape 16 | children: 17 | cdb_type: cdb_objset 18 | 0x1680ea049d5001aa: 19 | cdb_uid: 0x1680ea049d5001aa 20 | cdb_type: entity 21 | name: (null) 22 | components: 23 | cdb_type: cdb_objset 24 | 0x1680ea0606e0011b: 25 | cdb_uid: 0x1680ea0606e0011b 26 | cdb_type: local_to_world 27 | 0x1680ea0700e00121: 28 | cdb_uid: 0x1680ea0700e00121 29 | cdb_type: static_mesh 30 | material: 0x1680b59ec410011b 31 | scene: 0x97c41c8996520208 32 | node: (null) 33 | mesh: SciFiHelmet 34 | children: 35 | cdb_type: cdb_objset 36 | -------------------------------------------------------------------------------- /examples/develop/src/content/m4.material: -------------------------------------------------------------------------------- 1 | cdb_uid: 0x1680b59ec410011b 2 | cdb_type: material 3 | cdb_instance: 0x24c9413e88ebaaa8 4 | layers: 5 | cdb_type: cdb_objset 6 | 0x1680b59ec410011d: 7 | cdb_uid: 0x1680b59ec410011d 8 | cdb_instance: 0x9b2e443e0dddcdd9 9 | render_state: 10 | cdb_uid: 0x1680b59ec410011e 11 | cdb_type: render_state 12 | cdb_instance: 0x78ccc53d72122491 13 | variables: 14 | cdb_type: cdb_objset 15 | 0x1680b59ec4100120: 16 | cdb_uid: 0x1680b59ec4100120 17 | cdb_instance: 0xf81a1ce60b9ba9e8 18 | value: 0x1c80b5de261dcdce 19 | 0x1680b59ec4100121: 20 | cdb_uid: 0x1680b59ec4100121 21 | cdb_instance: 0x3e8302bae4fce293 22 | 0x1680b59ec4200122: 23 | cdb_uid: 0x1680b59ec4200122 24 | cdb_instance: 0xe66d5daf1a451dbf 25 | -------------------------------------------------------------------------------- /examples/develop/src/content/material1.material: -------------------------------------------------------------------------------- 1 | cdb_uid: "0x24c9413e88ebaaa8" 2 | cdb_type: material 3 | 4 | layers: 5 | cdb_type: cdb_objset 6 | 0x9b2e443e0dddcdd9: 7 | cdb_uid: "0x9b2e443e0dddcdd9" 8 | cdb_type: material_layer 9 | name: gbuffer 10 | shader: "0x7ecb3362fa2b019c" 11 | 12 | render_state: 13 | cdb_uid: "0x78ccc53d72122491" 14 | cdb_type: render_state 15 | rgb_write: true 16 | alpha_write: true 17 | depth_write: true 18 | depth_test_less: true 19 | cull_ccw: true 20 | msaa: true 21 | 22 | variables: 23 | cdb_type: cdb_objset 24 | 25 | 0xf81a1ce60b9ba9e8: 26 | cdb_uid: "0xf81a1ce60b9ba9e8" 27 | name: u_texColor 28 | cdb_type: material_variable_texture 29 | value: "0xe918b8b9d6e08e45" 30 | 31 | 0x3e8302bae4fce293: 32 | cdb_uid: "0x3e8302bae4fce293" 33 | name: u_vec4 34 | cdb_type: material_variable_color 35 | x: 1.000000 36 | y: 1.000000 37 | z: 1.000000 38 | w: 1.000000 39 | 40 | 0xe66d5daf1a451dbf: 41 | cdb_uid: "0xe66d5daf1a451dbf" 42 | name: u_vec42 43 | cdb_type: material_variable_vec4 44 | x: 1.000000 45 | y: 1.000000 46 | z: 1.000000 47 | w: 1.000000 48 | -------------------------------------------------------------------------------- /examples/develop/src/content/material1222.material: -------------------------------------------------------------------------------- 1 | cdb_uid: 0x15f21001d1 2 | cdb_type: material 3 | cdb_instance: 0x24c9413e88ebaaa8 4 | layers: 5 | cdb_type: cdb_objset 6 | 0x15f21001d3: 7 | cdb_uid: 0x15f21001d3 8 | cdb_instance: 0x9b2e443e0dddcdd9 9 | render_state: 10 | cdb_uid: 0x15f21001d4 11 | cdb_type: render_state 12 | cdb_instance: 0x78ccc53d72122491 13 | variables: 14 | cdb_type: cdb_objset 15 | 0x15f21001d6: 16 | cdb_uid: 0x15f21001d6 17 | cdb_instance: 0xf81a1ce60b9ba9e8 18 | value: 0xa4053ffff8ffc601 19 | 0x15f21001d7: 20 | cdb_uid: 0x15f21001d7 21 | cdb_instance: 0x3e8302bae4fce293 22 | 0x15f21001d8: 23 | cdb_uid: 0x15f21001d8 24 | cdb_instance: 0xe66d5daf1a451dbf 25 | -------------------------------------------------------------------------------- /examples/develop/src/content/material177777.material: -------------------------------------------------------------------------------- 1 | cdb_uid: 0x14e51001f7 2 | cdb_type: material 3 | cdb_instance: 0x24c9413e88ebaaa8 4 | layers: 5 | cdb_type: cdb_objset 6 | 0x152d20013d: 7 | cdb_uid: 0x152d20013d 8 | cdb_instance: 0x9b2e443e0dddcdd9 9 | render_state: 10 | cdb_uid: 0x152d20013e 11 | cdb_type: render_state 12 | cdb_instance: 0x78ccc53d72122491 13 | variables: 14 | cdb_type: cdb_objset 15 | 0x152d200140: 16 | cdb_uid: 0x152d200140 17 | cdb_instance: 0xf81a1ce60b9ba9e8 18 | value: 0x8027fcdfa6ddd00b 19 | 0x152d200141: 20 | cdb_uid: 0x152d200141 21 | cdb_instance: 0x3e8302bae4fce293 22 | 0x152d200142: 23 | cdb_uid: 0x152d200142 24 | cdb_instance: 0xe66d5daf1a451dbf 25 | -------------------------------------------------------------------------------- /examples/develop/src/content/material2.material: -------------------------------------------------------------------------------- 1 | cdb_uid: 0x1680e3de7a10018f 2 | cdb_type: material 3 | cdb_instance: 0x24c9413e88ebaaa8 4 | layers: 5 | cdb_type: cdb_objset 6 | 0x1680e3de7a100191: 7 | cdb_uid: 0x1680e3de7a100191 8 | cdb_instance: 0x9b2e443e0dddcdd9 9 | shader: 0xa6ad6fe0a13cd90e 10 | render_state: 11 | cdb_uid: 0x1680e3de7a100192 12 | cdb_type: render_state 13 | cdb_instance: 0x78ccc53d72122491 14 | variables: 15 | cdb_type: cdb_objset 16 | 0x1680e3de7a100194: 17 | cdb_uid: 0x1680e3de7a100194 18 | cdb_instance: 0xf81a1ce60b9ba9e8 19 | 0x1680e3de7a100195: 20 | cdb_uid: 0x1680e3de7a100195 21 | cdb_instance: 0x3e8302bae4fce293 22 | 0x1680e3de7a100196: 23 | cdb_uid: 0x1680e3de7a100196 24 | cdb_instance: 0xe66d5daf1a451dbf 25 | -------------------------------------------------------------------------------- /examples/develop/src/content/scene/SciFiHelmet.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyberegoorg/cetech/09857e278ba1596fc1b0e790164bd4dbf843bc5d/examples/develop/src/content/scene/SciFiHelmet.bin -------------------------------------------------------------------------------- /examples/develop/src/content/scene/SciFiHelmet_BaseColor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyberegoorg/cetech/09857e278ba1596fc1b0e790164bd4dbf843bc5d/examples/develop/src/content/scene/SciFiHelmet_BaseColor.png -------------------------------------------------------------------------------- /examples/develop/src/content/scene/box.scene: -------------------------------------------------------------------------------- 1 | cdb_uid: 0x3d4a26bc5ef4b90d 2 | cdb_type: scene 3 | import: 4 | cdb_uid: 0xdb81a075de3f3562 5 | cdb_type: scene_import 6 | input: content/scene/Box.gltf 7 | -------------------------------------------------------------------------------- /examples/develop/src/content/scene/duck.scene: -------------------------------------------------------------------------------- 1 | cdb_uid: 0xcd111fa2efb3a30b 2 | cdb_type: scene 3 | import: 4 | cdb_uid: 0x6b48995c6efe1f60 5 | cdb_type: scene_import 6 | input: content/scene/Duck.gltf 7 | -------------------------------------------------------------------------------- /examples/develop/src/content/scene/duck/duck.texture: -------------------------------------------------------------------------------- 1 | cdb_uid: 0xa4053ffff8ffc601 2 | cdb_type: "texture" 3 | input: content/scene/duck/duckCM.bmp 4 | -------------------------------------------------------------------------------- /examples/develop/src/content/scene/duck/duckCM.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyberegoorg/cetech/09857e278ba1596fc1b0e790164bd4dbf843bc5d/examples/develop/src/content/scene/duck/duckCM.bmp -------------------------------------------------------------------------------- /examples/develop/src/content/scene/m4a1/m4_diff.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyberegoorg/cetech/09857e278ba1596fc1b0e790164bd4dbf843bc5d/examples/develop/src/content/scene/m4a1/m4_diff.tga -------------------------------------------------------------------------------- /examples/develop/src/content/scene/m4a1/m4a1.texture: -------------------------------------------------------------------------------- 1 | cdb_uid: 0x1c80b5de261dcdce 2 | cdb_type: "texture" 3 | input: content/scene/m4a1/m4_diff.tga 4 | gen_mipmaps: yes 5 | -------------------------------------------------------------------------------- /examples/develop/src/content/scene/scifihelmet.scene: -------------------------------------------------------------------------------- 1 | cdb_uid: 0x97c41c8996520208 2 | cdb_type: scene 3 | import: 4 | cdb_uid: 0x35fb9643159c7e5d 5 | cdb_type: scene_import 6 | input: content/scene/SciFiHelmet.gltf 7 | -------------------------------------------------------------------------------- /examples/develop/src/content/scene/scifihelmet.texture: -------------------------------------------------------------------------------- 1 | cdb_uid: 0xb0da5103fe804b64 2 | cdb_type: texture 3 | input: content/scene/SciFiHelmet_BaseColor.png 4 | gen_mipmaps: true 5 | is_normalmap: false 6 | texture_handler: 0 7 | -------------------------------------------------------------------------------- /examples/develop/src/content/scene/solider/body01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyberegoorg/cetech/09857e278ba1596fc1b0e790164bd4dbf843bc5d/examples/develop/src/content/scene/solider/body01.png -------------------------------------------------------------------------------- /examples/develop/src/content/scene/solider/body01.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyberegoorg/cetech/09857e278ba1596fc1b0e790164bd4dbf843bc5d/examples/develop/src/content/scene/solider/body01.tga -------------------------------------------------------------------------------- /examples/develop/src/content/scene/solider/head.texture: -------------------------------------------------------------------------------- 1 | cdb_type: "texture" 2 | cdb_uid: 0x8beb8d2b20191aba 3 | input: content/scene/solider/head01.tga 4 | -------------------------------------------------------------------------------- /examples/develop/src/content/scene/solider/head01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyberegoorg/cetech/09857e278ba1596fc1b0e790164bd4dbf843bc5d/examples/develop/src/content/scene/solider/head01.png -------------------------------------------------------------------------------- /examples/develop/src/content/scene/solider/head01.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyberegoorg/cetech/09857e278ba1596fc1b0e790164bd4dbf843bc5d/examples/develop/src/content/scene/solider/head01.tga -------------------------------------------------------------------------------- /examples/develop/src/content/scene/solider/m4.texture: -------------------------------------------------------------------------------- 1 | cdb_type: "texture" 2 | cdb_uid: "0xe918b8b9d6e08e45" 3 | input: content/scene/solider/m4tex.tga 4 | -------------------------------------------------------------------------------- /examples/develop/src/content/scene/solider/m4tex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyberegoorg/cetech/09857e278ba1596fc1b0e790164bd4dbf843bc5d/examples/develop/src/content/scene/solider/m4tex.png -------------------------------------------------------------------------------- /examples/develop/src/content/scene/solider/m4tex.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyberegoorg/cetech/09857e278ba1596fc1b0e790164bd4dbf843bc5d/examples/develop/src/content/scene/solider/m4tex.tga -------------------------------------------------------------------------------- /examples/develop/src/content/shader1.shader: -------------------------------------------------------------------------------- 1 | cdb_type: "shader" 2 | cdb_uid: 0x7ecb3362fa2b019c 3 | vs_input: 'content/vs_shader1.sc' 4 | fs_input: 'content/fs_shader1.sc' 5 | -------------------------------------------------------------------------------- /examples/develop/src/content/shader2.shader: -------------------------------------------------------------------------------- 1 | cdb_type: "shader" 2 | cdb_uid: 0xa6ad6fe0a13cd90e 3 | vs_input: 'content/vs_shader1.sc' 4 | fs_input: 'content/fs_shader2.sc' 5 | -------------------------------------------------------------------------------- /examples/develop/src/content/texture1.texture: -------------------------------------------------------------------------------- 1 | cdb_uid: "0x2d523a81d1791140" 2 | cdb_type: "texture" 3 | input: content/texture2.png 4 | gen_mipmaps: yes 5 | is_normalmap: no 6 | -------------------------------------------------------------------------------- /examples/develop/src/content/texture1.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyberegoorg/cetech/09857e278ba1596fc1b0e790164bd4dbf843bc5d/examples/develop/src/content/texture1.tga -------------------------------------------------------------------------------- /examples/develop/src/content/texture2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyberegoorg/cetech/09857e278ba1596fc1b0e790164bd4dbf843bc5d/examples/develop/src/content/texture2.png -------------------------------------------------------------------------------- /examples/develop/src/content/texture2.texture: -------------------------------------------------------------------------------- 1 | cdb_type: "texture" 2 | cdb_uid: 0xe1ab713dde582de1 3 | input: content/texture2.png 4 | gen_mipmaps: yes 5 | is_normalmap: no 6 | -------------------------------------------------------------------------------- /examples/develop/src/content/texture2.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyberegoorg/cetech/09857e278ba1596fc1b0e790164bd4dbf843bc5d/examples/develop/src/content/texture2.tga -------------------------------------------------------------------------------- /examples/develop/src/content/uv_checker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyberegoorg/cetech/09857e278ba1596fc1b0e790164bd4dbf843bc5d/examples/develop/src/content/uv_checker.png -------------------------------------------------------------------------------- /examples/develop/src/content/uv_checker.texture: -------------------------------------------------------------------------------- 1 | cdb_uid: 0x8027fcdfa6ddd00b 2 | cdb_type: "texture" 3 | input: content/uv_checker.png 4 | gen_mipmaps: true 5 | -------------------------------------------------------------------------------- /examples/develop/src/content/uv_checker.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyberegoorg/cetech/09857e278ba1596fc1b0e790164bd4dbf843bc5d/examples/develop/src/content/uv_checker.tga -------------------------------------------------------------------------------- /examples/develop/src/content/varying.def.sc: -------------------------------------------------------------------------------- 1 | vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0); 2 | vec4 v_view : TEXCOORD1 = vec4(0.0, 0.0, 0.0, 0.0); 3 | vec3 v_normal : NORMAL = vec3(0.0, 0.0, 1.0); 4 | 5 | vec3 a_position : POSITION; 6 | vec3 a_normal : NORMAL; 7 | vec2 a_texcoord0 : TEXCOORD0; 8 | -------------------------------------------------------------------------------- /examples/develop/src/content/vs_copy.sc: -------------------------------------------------------------------------------- 1 | $input a_position, a_texcoord0 2 | $output v_texcoord0 3 | 4 | #include "common.sh" 5 | 6 | void main() { 7 | gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0)); 8 | v_texcoord0 = a_texcoord0; 9 | } 10 | -------------------------------------------------------------------------------- /examples/develop/src/content/vs_shader1.sc: -------------------------------------------------------------------------------- 1 | $input a_position, a_normal, a_texcoord0 2 | $output v_texcoord0, v_view, v_normal 3 | 4 | #include "common.sh" 5 | 6 | void main() { 7 | gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0)); 8 | v_view = mul(u_modelView, vec4(a_position, 1.0)); 9 | v_normal = normalize(mul(u_modelView, vec4(a_normal, 0.0)).xyz); 10 | 11 | v_texcoord0 = a_texcoord0; 12 | } 13 | -------------------------------------------------------------------------------- /examples/develop/src/content/vs_shader2.sc: -------------------------------------------------------------------------------- 1 | $input a_position, a_normal, a_texcoord0 2 | $output v_texcoord0, v_view, v_normal 3 | 4 | #include "common.sh" 5 | 6 | void main() { 7 | gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0)); 8 | v_view = mul(u_modelView, vec4(a_position, 1.0)); 9 | v_normal = normalize(mul(u_modelView, vec4(a_normal, 0.0)).xyz); 10 | 11 | v_texcoord0 = a_texcoord0; 12 | } 13 | -------------------------------------------------------------------------------- /examples/develop/src/core/fs_texture_preview.sc: -------------------------------------------------------------------------------- 1 | $input v_texcoord0, v_view, v_normal 2 | 3 | #include "common.sh" 4 | 5 | SAMPLER2D(u_texColor,0); 6 | 7 | void main() { 8 | gl_FragData[0] = vec4(texture2D(u_texColor, v_texcoord0).xyz, 1.0f); 9 | } 10 | -------------------------------------------------------------------------------- /examples/develop/src/core/texture_preview.material: -------------------------------------------------------------------------------- 1 | cdb_uid: 0x16810eb6a8b0019d 2 | cdb_type: material 3 | cdb_instance: 0x24c9413e88ebaaa8 4 | layers: 5 | cdb_type: cdb_objset 6 | 0x16810eb6a8b0019f: 7 | cdb_uid: 0x16810eb6a8b0019f 8 | cdb_instance: 0x9b2e443e0dddcdd9 9 | shader: 0x4ecb3362fa2b018c 10 | render_state: 11 | cdb_type: render_state 12 | cdb_uid: 0x16810eb6a8b001a0 13 | cdb_instance: 0x78ccc53d72122491 14 | variables: 15 | cdb_type: cdb_objset 16 | 0x16810eb6a8b001a2: 17 | cdb_uid: 0x16810eb6a8b001a2 18 | cdb_instance: 0xf81a1ce60b9ba9e8 19 | 0x16810eb6a8b001a3: 20 | cdb_uid: 0x16810eb6a8b001a3 21 | cdb_instance: 0x3e8302bae4fce293 22 | 0x16810eb6a8b001a4: 23 | cdb_uid: 0x16810eb6a8b001a4 24 | cdb_instance: 0xe66d5daf1a451dbf 25 | -------------------------------------------------------------------------------- /examples/develop/src/core/texture_preview.shader: -------------------------------------------------------------------------------- 1 | cdb_type: "shader" 2 | cdb_uid: 0x4ecb3362fa2b018c 3 | vs_input: 'core/vs_texture_preview.sc' 4 | fs_input: 'core/fs_texture_preview.sc' 5 | -------------------------------------------------------------------------------- /examples/develop/src/core/varying.def.sc: -------------------------------------------------------------------------------- 1 | vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0); 2 | vec4 v_view : TEXCOORD1 = vec4(0.0, 0.0, 0.0, 0.0); 3 | vec3 v_normal : NORMAL = vec3(0.0, 0.0, 1.0); 4 | 5 | vec3 a_position : POSITION; 6 | vec3 a_normal : NORMAL; 7 | vec2 a_texcoord0 : TEXCOORD0; 8 | -------------------------------------------------------------------------------- /examples/develop/src/core/vs_texture_preview.sc: -------------------------------------------------------------------------------- 1 | $input a_position, a_normal, a_texcoord0 2 | $output v_texcoord0, v_view, v_normal 3 | 4 | #include "common.sh" 5 | 6 | void main() { 7 | gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0)); 8 | v_view = mul(u_modelView, vec4(a_position, 1.0)); 9 | v_normal = normalize(mul(u_modelView, vec4(a_normal, 0.0)).xyz); 10 | 11 | v_texcoord0 = a_texcoord0; 12 | } 13 | -------------------------------------------------------------------------------- /examples/develop/src/global.yml: -------------------------------------------------------------------------------- 1 | cdb_type: config 2 | variables: 3 | cdb_type: cdb_objset 4 | 5 | 0xd15063a21b3e7f1f: 6 | cdb_type: config_variable_ref 7 | name: core.boot_ent 8 | value: 0xf44b05ff3bdfc99e 9 | 10 | 0xd25063a21b3e7f1f: 11 | cdb_type: config_variable_int 12 | name: screen.x 13 | value: 1024 14 | 15 | 0xd35063a21b3e7f2f: 16 | cdb_type: config_variable_int 17 | name: screen.y 18 | value: 768 19 | 20 | 0xd45364a21b3e7f2f: 21 | cdb_type: config_variable_str 22 | name: load_module.0 23 | value: game_example_develop 24 | 25 | 0xd45364a21b3e7f33: 26 | cdb_type: config_variable_str 27 | name: load_module.1 28 | value: module_profiler 29 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pyyaml 2 | jinja2 -------------------------------------------------------------------------------- /scripts/celib.lua: -------------------------------------------------------------------------------- 1 | function use_celib() 2 | links { 3 | "celib", 4 | "pthread", 5 | "z", 6 | 7 | path.join(EXTERNALS_DIR, "lib", "libyaml_static.a"), 8 | path.join(EXTERNALS_DIR, "lib", "libSDL2.a"), 9 | } 10 | 11 | configuration { "osx" } 12 | links { 13 | "iconv", 14 | "objc", 15 | } 16 | 17 | linkoptions { 18 | "-framework Cocoa", 19 | "-framework CoreAudio", 20 | "-framework AudioToolbox", 21 | "-framework ForceFeedback", 22 | "-framework CoreVideo", 23 | "-framework Carbon", 24 | "-framework IOKit", 25 | "-framework QuartzCore", 26 | 27 | "-framework OpenGL", 28 | "-weak_framework Metal", 29 | } 30 | 31 | configuration {} 32 | 33 | 34 | end 35 | 36 | project "celib" 37 | kind "StaticLib" 38 | 39 | files { 40 | path.join(CETECH_DIR, "src/celib/**.h"), 41 | path.join(CETECH_DIR, "src/celib/**.inl"), 42 | path.join(CETECH_DIR, "src/celib/**.c"), 43 | path.join(CETECH_DIR, "src/celib/**.cpp"), 44 | } 45 | 46 | configuration { "linux-*" } 47 | buildoptions { 48 | "-fPIC", 49 | } 50 | 51 | configuration {} 52 | -------------------------------------------------------------------------------- /scripts/cetech.lua: -------------------------------------------------------------------------------- 1 | project "cetech_develop" 2 | kind "ConsoleApp" 3 | 4 | use_celib() 5 | 6 | defines { 7 | "CETECH_DEVELOP=1" 8 | } 9 | 10 | files { 11 | path.join(CETECH_DIR, "src/cetech/**.c"), 12 | path.join(CETECH_DIR, "src/cetech/**.h"), 13 | path.join(CETECH_DIR, "src/cetech/**.inl"), 14 | path.join(CETECH_DIR, "src/cetech/**.cpp"), 15 | } 16 | 17 | excludes { 18 | path.join(CETECH_DIR, "src/cetech/mono/**.*"), 19 | } 20 | 21 | links { 22 | path.join(EXTERNALS_DIR, "lib", "libbgfxRelease.a"), 23 | path.join(EXTERNALS_DIR, "lib", "libbimgRelease.a"), 24 | path.join(EXTERNALS_DIR, "lib", "libbxRelease.a"), 25 | path.join(EXTERNALS_DIR, "lib", "libsqlite3.a"), 26 | path.join(EXTERNALS_DIR, "lib", "libbox2d.a"), 27 | path.join(EXTERNALS_DIR, "lib", "libnfd.a"), 28 | } 29 | 30 | copy_to_bin() 31 | 32 | configuration { "osx" } 33 | links { 34 | "iconv", 35 | "objc", 36 | } 37 | 38 | linkoptions { 39 | } 40 | 41 | configuration { "linux" } 42 | links { 43 | "GL", 44 | "X11", 45 | "z" 46 | } 47 | 48 | 49 | configuration {} 50 | -------------------------------------------------------------------------------- /scripts/genie.lua: -------------------------------------------------------------------------------- 1 | ARCH = os.is64bit() and '64' or '32' 2 | 3 | OS = _OS 4 | if OS == "macosx" then 5 | OS = "darwin" 6 | end 7 | 8 | OS_ARCH = OS .. ARCH 9 | 10 | CETECH_DIR = path.getabsolute("..") 11 | BUILD_DIR = path.join(CETECH_DIR, ".build") 12 | SOURCE_DIR = path.join(CETECH_DIR, "src") 13 | EXAMPLES_DIR = path.join(CETECH_DIR, "examples") 14 | 15 | TOOLS_DIR = path.join(CETECH_DIR, "tools", OS_ARCH) 16 | EXTERNALS_DIR = path.join(CETECH_DIR, "externals", "build", OS_ARCH, "release") 17 | BIN_DIR = path.join(CETECH_DIR, "bin", OS_ARCH) 18 | 19 | newaction { 20 | trigger = "doc", 21 | description = "Generate documentation", 22 | execute = function() 23 | local args = "" .. 24 | " --source " .. SOURCE_DIR .. 25 | " --build " .. path.join(CETECH_DIR, "docs", "gen") 26 | 27 | return os.execute(path.join(BIN_DIR, "doc") .. args) 28 | end 29 | } 30 | 31 | newaction { 32 | trigger = "hash", 33 | description = "Generate static hash", 34 | execute = function() 35 | local args = "" .. 36 | " --source " .. SOURCE_DIR 37 | 38 | os.execute(path.join(BIN_DIR, "hash") .. args) 39 | 40 | args = "" .. 41 | " --source " .. EXAMPLES_DIR 42 | os.execute(path.join(BIN_DIR, "hash") .. args) 43 | end 44 | } 45 | 46 | 47 | function copy_to_bin() 48 | postbuildcommands { 49 | "mkdir -p " .. BIN_DIR, 50 | "cp -f $(TARGET) " .. BIN_DIR, 51 | } 52 | end 53 | 54 | solution "cetech" 55 | configurations { 56 | "Debug", 57 | "Release", 58 | } 59 | 60 | platforms { 61 | -- "x32", 62 | "x64", 63 | "Native", -- for targets where bitness is not specified 64 | } 65 | 66 | language "C++" 67 | 68 | dofile "toolchain.lua" 69 | toolchain(BUILD_DIR, "") 70 | 71 | function copyLib() 72 | end 73 | 74 | includedirs { 75 | path.join(CETECH_DIR, "src"), 76 | path.join(EXTERNALS_DIR), 77 | path.join(EXTERNALS_DIR, "include"), 78 | } 79 | 80 | libdirs { 81 | path.join(EXTERNALS_DIR, "lib"), 82 | } 83 | 84 | configuration { "Debug" } 85 | targetsuffix "_debug" 86 | 87 | configuration { "Release" } 88 | targetsuffix "" 89 | 90 | configuration { "Debug" } 91 | defines { 92 | "CETECH_DEBUG=1", 93 | } 94 | 95 | configuration { } 96 | 97 | 98 | 99 | dofile "celib.lua" 100 | 101 | dofile "tool_hash.lua" 102 | dofile "tool_doc.lua" 103 | 104 | dofile "cetech.lua" 105 | -------------------------------------------------------------------------------- /scripts/tool_doc.lua: -------------------------------------------------------------------------------- 1 | project "doc" 2 | kind "ConsoleApp" 3 | 4 | use_celib() 5 | 6 | 7 | files { 8 | path.join(CETECH_DIR, "src/tools/doc/**.c"), 9 | } 10 | 11 | copy_to_bin() 12 | 13 | configuration {} 14 | -------------------------------------------------------------------------------- /scripts/tool_hash.lua: -------------------------------------------------------------------------------- 1 | project "hash" 2 | kind "ConsoleApp" 3 | 4 | use_celib() 5 | 6 | files { 7 | path.join(CETECH_DIR, "src/tools/hash/**.c"), 8 | } 9 | 10 | copy_to_bin() 11 | 12 | configuration {} 13 | -------------------------------------------------------------------------------- /src/celib/api.h: -------------------------------------------------------------------------------- 1 | // # API 2 | 3 | #ifndef CE_API_H 4 | #define CE_API_H 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #include "celib_types.h" 11 | 12 | #include "murmur.h" 13 | 14 | #define CE_API_API \ 15 | CE_ID64_0("ce_api_a0", 0x95b23cc231103112ULL) 16 | 17 | // Init api 18 | #define CE_INIT_API(_api, name) \ 19 | name = (struct name*) (_api)->get(ce_hash_murmur2_64(#name, strlen(#name), 0)) 20 | 21 | 22 | // Api entry 23 | // 24 | // - *api* - Api pointer 25 | // - *idx* - private. 26 | // - *entry* - private. 27 | typedef struct ce_api_entry_t0 { 28 | uint32_t idx; 29 | void *entry; 30 | void *api; 31 | } ce_api_entry_t0; 32 | 33 | 34 | typedef void (ce_api_on_add_t0)(uint64_t name, 35 | void *api); 36 | 37 | typedef void (ce_api_on_remove_t0)(uint64_t name, 38 | void *api); 39 | 40 | struct ce_api_a0 { 41 | void (*add_api)(uint64_t name_id, 42 | void *api, 43 | uint32_t size); 44 | 45 | void (*add_impl)(uint64_t name_id, 46 | void *api, 47 | uint32_t size); 48 | 49 | void (*remove_api)(uint64_t name_id, 50 | void *api); 51 | 52 | void (*remove_impl)(uint64_t name_id, 53 | void *api); 54 | 55 | int (*exist)(const char *name); 56 | 57 | void *(*get)(uint64_t name); 58 | 59 | ce_api_entry_t0 (*first)(uint64_t name); 60 | 61 | ce_api_entry_t0 (*next)(ce_api_entry_t0 entry); 62 | 63 | void (*register_on_add)(ce_api_on_add_t0 *on_add); 64 | }; 65 | 66 | 67 | CE_MODULE(ce_api_a0); 68 | 69 | #ifdef __cplusplus 70 | }; 71 | #endif 72 | 73 | #endif //CE_API_H 74 | -------------------------------------------------------------------------------- /src/celib/config.h: -------------------------------------------------------------------------------- 1 | #ifndef CE_CONFIG_H 2 | #define CE_CONFIG_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "celib_types.h" 9 | 10 | #define CE_CONFIG_API \ 11 | CE_ID64_0("ce_config_a0", 0xd75a5088e70ad1bbULL) 12 | 13 | #define CE_CONFIG_TYPE \ 14 | CE_ID64_0("config", 0x82645835e6b73232ULL) 15 | 16 | #define CE_CONFIG_VARIABLE_REF \ 17 | CE_ID64_0("config_variable_ref", 0xcba63cf174888fe5ULL) 18 | 19 | #define CE_CONFIG_VARIABLE_INT \ 20 | CE_ID64_0("config_variable_int", 0x6f579c4309784aadULL) 21 | 22 | #define CE_CONFIG_VARIABLE_STR \ 23 | CE_ID64_0("config_variable_str", 0x28475786507229b9ULL) 24 | 25 | #define CE_CONFIG_VARIABLES \ 26 | CE_ID64_0("variables", 0x4fb1ab3fd540bd03ULL) 27 | 28 | #define CE_CONFIG_NAME \ 29 | CE_ID64_0("name", 0xd4c943cba60c270bULL) 30 | 31 | #define CE_CONFIG_VALUE \ 32 | CE_ID64_0("value", 0x920b430f38928dc9ULL) 33 | 34 | #define CE_CONFIG_VARIABLE_REF \ 35 | CE_ID64_0("config_variable_ref", 0xcba63cf174888fe5ULL) 36 | 37 | #define CE_CONFIG_VARIABLE_INT \ 38 | CE_ID64_0("config_variable_int", 0x6f579c4309784aadULL) 39 | 40 | #define CE_CONFIG_VARIABLE_STR \ 41 | CE_ID64_0("config_variable_str", 0x28475786507229b9ULL) 42 | 43 | typedef struct ce_alloc_t0 ce_alloc_t0; 44 | typedef struct ce_cdb_t0 ce_cdb_t0; 45 | 46 | struct ce_config_a0 { 47 | //! Parse commandline arguments. 48 | int (*parse_args)(int argc, 49 | const char **argv); 50 | 51 | //! Load config from file. 52 | int (*from_file)(ce_cdb_t0 db, 53 | const char *path, 54 | ce_alloc_t0 *alloc); 55 | 56 | bool (*exist)(uint64_t name); 57 | 58 | float (*read_float)(uint64_t name, 59 | float defaultt); 60 | 61 | uint64_t (*read_uint)(uint64_t name, 62 | uint64_t defaultt); 63 | 64 | const char *(*read_str)(uint64_t name, 65 | const char *defaultt); 66 | 67 | void (*set_float)(uint64_t name, 68 | float value); 69 | 70 | void (*set_uint)(uint64_t name, 71 | uint64_t value); 72 | 73 | void (*set_str)(uint64_t name, 74 | const char *value); 75 | 76 | //! Dump all variables to log 77 | void (*log_all)(); 78 | }; 79 | 80 | CE_MODULE(ce_config_a0); 81 | 82 | #ifdef __cplusplus 83 | }; 84 | #endif 85 | 86 | #endif //CE_CONFIG_H 87 | -------------------------------------------------------------------------------- /src/celib/containers/bitset.h: -------------------------------------------------------------------------------- 1 | // 2 | // **Bitset** 3 | // # Description 4 | 5 | 6 | #ifndef CE_BITSET_H 7 | #define CE_BITSET_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | #include "celib/celib_types.h" 14 | 15 | // # Struct 16 | typedef struct ce_bitset_t0 { 17 | uint64_t *slots; 18 | uint64_t n; 19 | } ce_bitset_t0; 20 | 21 | // # Function 22 | 23 | // Init bitset for max *n* items. 24 | static inline void ce_bitset_init(ce_bitset_t0 *bitset, 25 | uint64_t n, 26 | ce_alloc_t0 *alloc) { 27 | uint64_t slot_num = n / 64; 28 | ce_array_resize(bitset->slots, slot_num, alloc); 29 | memset(bitset->slots, 0, sizeof(uint64_t) * slot_num); 30 | bitset->n = n; 31 | } 32 | 33 | static inline void ce_bitset_clean(ce_bitset_t0 *bitset) { 34 | uint64_t slot_num = bitset->n / 64; 35 | memset(bitset->slots, 0, sizeof(uint64_t) * slot_num); 36 | } 37 | 38 | // Free bitset. 39 | static inline void ce_bitset_free(ce_bitset_t0 *bitset, 40 | ce_alloc_t0 *alloc) { 41 | ce_array_free(bitset->slots, alloc); 42 | bitset->n = 0; 43 | } 44 | 45 | // Set contain key 46 | static inline void ce_bitset_add(ce_bitset_t0 *bitset, 47 | uint64_t key) { 48 | uint64_t idx = key % bitset->n; 49 | 50 | uint64_t slot_idx = idx / 64; 51 | uint64_t bit_idx = idx % 64; 52 | 53 | uint64_t bit_mask = 1UL << bit_idx; 54 | 55 | bitset->slots[slot_idx] |= bit_mask; 56 | } 57 | 58 | // Remove key 59 | static inline void ce_bitset_remove(ce_bitset_t0 *bitset, 60 | uint64_t key) { 61 | uint64_t idx = key % bitset->n; 62 | 63 | uint64_t slot_idx = idx / 64; 64 | uint64_t bit_idx = idx % 64; 65 | 66 | uint64_t bit_mask = ~(1UL << bit_idx); 67 | 68 | bitset->slots[slot_idx] &= bit_mask; 69 | } 70 | 71 | // Contain key? 72 | static inline bool ce_bitset_is_set(ce_bitset_t0 *bitset, 73 | uint64_t key) { 74 | uint64_t idx = key % bitset->n; 75 | 76 | uint64_t slot_idx = idx / 64; 77 | uint64_t bit_idx = idx % 64; 78 | 79 | uint64_t bit_mask = 1UL << bit_idx; 80 | 81 | return (bitset->slots[slot_idx] & bit_mask) > 0; 82 | } 83 | 84 | #ifdef __cplusplus 85 | }; 86 | #endif 87 | 88 | #endif //CE_BITSET_H 89 | -------------------------------------------------------------------------------- /src/celib/containers/buffer.h: -------------------------------------------------------------------------------- 1 | // **Char buffer** 2 | // # Description 3 | // Helper function for [array](array.md.html) of type `char`. 4 | // 5 | // !!! ERROR: Buffer set to NULL before first use[.](https://www.monkeyuser.com/2018/debugging/) 6 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7 | // char* array = NULL; 8 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 9 | // 10 | // # Example 11 | // ~~~~~~~~~~ 12 | // char* buffer = NULL; 13 | // ce_buffer_printf(&buffer, ce_memory_a0–>system, "%d, %f, %s", 1, 1.5f, "foo"); 14 | // 15 | // printf("%s", buffer); // 1, 1.5f, foo 16 | // 17 | // ce_buffer_free(buffer, ce_memory_a0–>system) 18 | // ~~~~~~~~~~ 19 | // 20 | 21 | #ifndef CE_BUFFER_H 22 | #define CE_BUFFER_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #include "celib/macros.h" 29 | #include "celib/celib_types.h" 30 | #include "celib/containers/array.h" 31 | 32 | // # Macro 33 | 34 | // Buffer size 35 | #define ce_buffer_size(b) \ 36 | ce_array_size(b) 37 | 38 | // Push n chars to buffer 39 | #define ce_buffer_push_n(a, items, n, alloc) \ 40 | ce_array_push_n(a, items, n, alloc) 41 | 42 | // Push char to buffer 43 | #define ce_buffer_push_ch(a, ch, alloc) \ 44 | ce_array_push(a, ch, alloc) 45 | 46 | // Clear buffer 47 | #define ce_buffer_clear(b) \ 48 | ce_array_clean(b) 49 | 50 | // Free buffer 51 | #define ce_buffer_free(a, alloc) \ 52 | ce_array_free(a, alloc) 53 | 54 | static inline int ce_buffer_printf(char **b, 55 | ce_alloc_t0 *alloc, 56 | const char *format, 57 | ...) CE_ATTR_FORMAT(3, 4); 58 | 59 | // # Function 60 | 61 | // printf *format*, *...* msg to buffer 62 | static inline int ce_buffer_printf(char **b, 63 | ce_alloc_t0 *alloc, 64 | const char *format, 65 | ...) { 66 | va_list args; 67 | 68 | va_start(args, format); 69 | int n = vsnprintf(NULL, 0, format, args); 70 | va_end(args); 71 | 72 | uint32_t end = ce_array_size(*b); 73 | ce_array_resize(*b, end + n + 1, alloc); 74 | 75 | va_start(args, format); 76 | vsnprintf((*b) + end, n + 1, format, args); 77 | va_end(args); 78 | 79 | ce_array_resize(*b, end + n, alloc); 80 | 81 | return n; 82 | } 83 | 84 | #ifdef __cplusplus 85 | }; 86 | #endif 87 | 88 | #endif //CE_BUFFER_H 89 | -------------------------------------------------------------------------------- /src/celib/containers/spsc.h: -------------------------------------------------------------------------------- 1 | // 2 | // **SPSC queue** 3 | // 4 | // based on: https://github.com/mstump/queues/blob/master/include/spsc-bounded-queue.hpp 5 | 6 | #ifndef CE_SPSC_H 7 | #define CE_SPSC_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | #include "celib/celib_types.h" 14 | #include 15 | 16 | // # Struct 17 | typedef struct ce_spsc_queue_t0 { 18 | cache_line_pad_t _pad0; 19 | size_t size; 20 | size_t itemsize; 21 | size_t mask; 22 | uint8_t *buffer; 23 | 24 | cache_line_pad_t _pad1; 25 | atomic_size_t head; 26 | 27 | cache_line_pad_t _pad2; 28 | atomic_size_t tail; 29 | } ce_spsc_queue_t0; 30 | 31 | static inline void ce_spsc_init(ce_spsc_queue_t0 *queue, 32 | size_t size, 33 | size_t itemsize, 34 | ce_alloc_t0 *alloc) { 35 | CE_ASSERT("", (size != 0) && ((size & (~size + 1)) == size)); 36 | 37 | *queue = (ce_spsc_queue_t0) { 38 | .size = size, 39 | .itemsize = itemsize, 40 | .mask = size - 1, 41 | .buffer = CE_ALLOC(alloc, uint8_t, size * (itemsize + 1)), 42 | }; 43 | } 44 | 45 | static inline void ce_spsc_free(ce_spsc_queue_t0 *queue, 46 | ce_alloc_t0 *alloc) { 47 | CE_FREE(alloc, queue->buffer); 48 | 49 | *queue = (ce_spsc_queue_t0) {}; 50 | } 51 | 52 | static inline bool ce_spsc_enqueue(ce_spsc_queue_t0 *queue, 53 | void *item) { 54 | const size_t head = atomic_load_explicit(&queue->head, memory_order_relaxed); 55 | 56 | if (((atomic_load_explicit(&queue->tail, memory_order_acquire) - (head + 1)) & queue->mask) >= 57 | 1) { 58 | memcpy(queue->buffer + (queue->itemsize * (head & queue->mask)), item, 59 | queue->itemsize); 60 | atomic_store_explicit(&queue->head, queue->head + 1, memory_order_release); 61 | return true; 62 | } 63 | return false; 64 | } 65 | 66 | static inline bool ce_spsc_dequeue(ce_spsc_queue_t0 *queue, 67 | void *item) { 68 | const size_t tail = atomic_load_explicit(&queue->tail, memory_order_relaxed); 69 | 70 | if (((atomic_load_explicit(&queue->head, memory_order_acquire) - tail) & queue->mask) >= 1) { 71 | memcpy(item, queue->buffer + (queue->itemsize * (tail & queue->mask)), 72 | queue->itemsize); 73 | atomic_store_explicit(&queue->tail, queue->tail + 1, memory_order_release); 74 | return true; 75 | } 76 | return false; 77 | } 78 | 79 | #ifdef __cplusplus 80 | }; 81 | #endif 82 | 83 | #endif //CE_SPSC_H 84 | -------------------------------------------------------------------------------- /src/celib/core.h: -------------------------------------------------------------------------------- 1 | #ifndef CE_CECORE_H 2 | #define CE_CECORE_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "celib_types.h" 9 | 10 | bool ce_init(); 11 | 12 | bool ce_shutdown(); 13 | 14 | #ifdef __cplusplus 15 | }; 16 | #endif 17 | 18 | #endif //CE_CECORE_H 19 | -------------------------------------------------------------------------------- /src/celib/fs.h: -------------------------------------------------------------------------------- 1 | #ifndef CE_FILESYSTEM_TYPES_H 2 | #define CE_FILESYSTEM_TYPES_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "celib_types.h" 9 | 10 | #define CE_FS_API \ 11 | CE_ID64_0("ce_fs_a0", 0xb833e93306ececb0ULL) 12 | 13 | typedef struct ce_alloc_t0 ce_alloc_t0; 14 | typedef struct ce_vio_t0 ce_vio_t0; 15 | 16 | typedef enum ce_fs_open_mode_e0 { 17 | FS_OPEN_READ, 18 | FS_OPEN_WRITE, 19 | } ce_fs_open_mode_e0; 20 | 21 | //! Filesystem API V0 22 | struct ce_fs_a0 { 23 | ce_vio_t0 *(*open)(uint64_t root, 24 | const char *path, 25 | ce_fs_open_mode_e0 mode); 26 | 27 | void (*map_root_dir)(uint64_t root, 28 | const char *base_path, 29 | bool watch); 30 | 31 | void (*close)(ce_vio_t0 *file); 32 | 33 | void (*listdir)(uint64_t root, 34 | const char *path, 35 | const char *filter, 36 | bool only_dir, 37 | bool recursive, 38 | char ***files, 39 | uint32_t *count, 40 | ce_alloc_t0 *allocator); 41 | 42 | void (*listdir_iter)(uint64_t root, 43 | const char *path, 44 | const char *filter, 45 | bool only_dir, 46 | bool recursive, 47 | void (*on_item)(const char *path)); 48 | 49 | void (*listdir_free)(char **files, 50 | uint32_t count, 51 | ce_alloc_t0 *allocator); 52 | 53 | int (*create_directory)(uint64_t root, 54 | const char *path); 55 | 56 | int64_t (*file_mtime)(uint64_t root, 57 | const char *path); 58 | 59 | void (*get_full_path)(uint64_t root, 60 | const char *path, 61 | char *fullpath, 62 | uint32_t max_len); 63 | 64 | }; 65 | 66 | CE_MODULE(ce_fs_a0); 67 | 68 | #ifdef __cplusplus 69 | }; 70 | #endif 71 | 72 | #endif //CE_FILESYSTEM_TYPES_H -------------------------------------------------------------------------------- /src/celib/handler.h: -------------------------------------------------------------------------------- 1 | #ifndef CE_HANDLER_H 2 | #define CE_HANDLER_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "celib_types.h" 9 | 10 | #include "celib/containers/array.h" 11 | 12 | 13 | typedef struct ce_handler_t0 { 14 | char *generation; 15 | uint64_t *free_idx; 16 | } ce_handler_t0; 17 | 18 | #define _GENBITCOUNT 8 19 | #define _INDEXBITCOUNT 54 20 | #define _MINFREEINDEXS 1024 21 | 22 | #define handler_idx(h) ((h) >> _GENBITCOUNT) 23 | #define handler_gen(h) ((h) & ((1 << (_GENBITCOUNT - 1)))) 24 | 25 | static inline uint64_t ce_handler_create(ce_handler_t0 *handler, 26 | const ce_alloc_t0 *allocator) { 27 | uint64_t idx; 28 | 29 | if (ce_array_size(handler->free_idx) > _MINFREEINDEXS) { 30 | idx = handler->free_idx[0]; 31 | ce_array_pop_front(handler->free_idx); 32 | } else { 33 | ce_array_push(handler->generation, 0, allocator); 34 | 35 | idx = ce_array_size(handler->generation) - 1; 36 | } 37 | 38 | uint64_t hid = ((idx) << _GENBITCOUNT) | (handler->generation[idx]); 39 | 40 | return hid; 41 | } 42 | 43 | static inline void ce_handler_destroy(ce_handler_t0 *handler, 44 | uint64_t handlerid, 45 | const ce_alloc_t0 *allocator) { 46 | uint64_t id = handler_idx(handlerid); 47 | 48 | handler->generation[id] += 1; 49 | ce_array_push(handler->free_idx, id, allocator); 50 | } 51 | 52 | static inline bool ce_handler_alive(ce_handler_t0 *handler, 53 | uint64_t handlerid) { 54 | return handler->generation[handler_idx(handlerid)] == handler_gen(handlerid); 55 | } 56 | 57 | static inline void ce_handler_free(ce_handler_t0 *handler, 58 | const ce_alloc_t0 *allocator) { 59 | ce_array_free(handler->free_idx, allocator); 60 | ce_array_free(handler->generation, allocator); 61 | } 62 | 63 | #ifdef __cplusplus 64 | }; 65 | #endif 66 | 67 | #endif //CE_HANDLER_H 68 | -------------------------------------------------------------------------------- /src/celib/id.h: -------------------------------------------------------------------------------- 1 | #ifndef CE_ID_H 2 | #define CE_ID_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "celib_types.h" 9 | 10 | #define CE_ID_API \ 11 | CE_ID64_0("ce_id_a0", 0x1784034d025c1467ULL) 12 | 13 | struct ce_id_a0 { 14 | uint64_t (*id64)(const char *str); 15 | 16 | const char *(*str_from_id64)(uint64_t key); 17 | }; 18 | 19 | CE_MODULE(ce_id_a0); 20 | 21 | #ifdef __cplusplus 22 | }; 23 | #endif 24 | 25 | #endif //CE_ID_H 26 | -------------------------------------------------------------------------------- /src/celib/math/bounds.h: -------------------------------------------------------------------------------- 1 | #ifndef BOUNDS_H 2 | #define BOUNDS_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "celib/celib_types.h" 9 | 10 | typedef struct ce_aabb_t { 11 | ce_vec3_t min; 12 | ce_vec3_t max; 13 | } ce_aabb_t; 14 | 15 | typedef struct ce_cylinder_t { 16 | ce_vec3_t pos; 17 | ce_vec3_t end; 18 | float radius; 19 | } ce_cylinder_t; 20 | 21 | typedef struct ce_capsule_t { 22 | ce_vec3_t pos; 23 | ce_vec3_t end; 24 | float radius; 25 | } ce_capsule_t; 26 | 27 | typedef struct ce_cone_t { 28 | ce_vec3_t pos; 29 | ce_vec3_t end; 30 | float radius; 31 | } ce_cone_t; 32 | 33 | typedef struct ce_disk_t { 34 | ce_vec3_t center; 35 | ce_vec3_t normal; 36 | float radius; 37 | } ce_disk_t; 38 | 39 | typedef struct ce_obb_t { 40 | float mtx[16]; 41 | } ce_obb_t; 42 | 43 | typedef struct ce_plane_t { 44 | ce_vec3_t normal; 45 | ce_vec3_t dist; 46 | } ce_plane_t; 47 | 48 | typedef struct ce_ray_t { 49 | ce_vec3_t pos; 50 | ce_vec3_t dir; 51 | } ce_ray_t; 52 | 53 | typedef struct ce_sphere_t { 54 | ce_vec3_t center; 55 | float radius; 56 | } ce_sphere_t; 57 | 58 | typedef struct ce_tris_t { 59 | ce_vec3_t v0; 60 | ce_vec3_t v1; 61 | ce_vec3_t v2; 62 | } ce_tris_t; 63 | 64 | typedef struct ce_hit_t { 65 | ce_vec3_t pos; 66 | ce_vec3_t normal; 67 | float dist; 68 | } ce_hit_t; 69 | 70 | #ifdef __cplusplus 71 | }; 72 | #endif 73 | 74 | #endif // BOUNDS_H 75 | -------------------------------------------------------------------------------- /src/celib/memory/allocator.h: -------------------------------------------------------------------------------- 1 | // **Abstract memory alocator** 2 | // 3 | 4 | #ifndef CE_MEMORY_ALLOCATOR_H 5 | #define CE_MEMORY_ALLOCATOR_H 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #include "celib/celib_types.h" 12 | 13 | #define CE_ALLOC(a, T, size) \ 14 | (T*)((a)->vt->reallocate((a->inst), \ 15 | NULL, \ 16 | size, \ 17 | 0, \ 18 | CE_ALIGNOF(T), \ 19 | __FILE__, \ 20 | __LINE__)) 21 | 22 | #define CE_ALLOCATE_ALIGN(a, T, size, align) \ 23 | (T*)((a)->vt->reallocate((a->inst), \ 24 | NULL, \ 25 | size, \ 26 | 0, \ 27 | align, \ 28 | __FILE__, \ 29 | __LINE__)) 30 | 31 | #define CE_REALLOC(a, T, ptr, size, old_size) \ 32 | (T*)((a)->vt->reallocate((a->inst), \ 33 | ptr, \ 34 | size, \ 35 | old_size, \ 36 | CE_ALIGNOF(T), \ 37 | __FILE__, \ 38 | __LINE__)) 39 | 40 | #define CE_FREE(a, p) \ 41 | ((a)->vt->reallocate((a->inst),p,0,0,0, __FILE__, __LINE__)) 42 | 43 | typedef struct ce_alloc_o0 ce_alloc_o0; 44 | typedef struct ce_mem_tracer_t0 ce_mem_tracer_t0; 45 | 46 | typedef struct ce_alloc_vt0 { 47 | void *(*reallocate)(const ce_alloc_o0 *a, 48 | void *ptr, 49 | size_t size, 50 | size_t old_size, 51 | size_t align, 52 | const char *filename, 53 | uint32_t line); 54 | 55 | ce_mem_tracer_t0 *(*memory_tracer)(const ce_alloc_o0 *a); 56 | } ce_alloc_vt0; 57 | 58 | typedef struct ce_alloc_t0 { 59 | ce_alloc_o0 *inst; 60 | ce_alloc_vt0 *vt; 61 | } ce_alloc_t0; 62 | 63 | #ifdef __cplusplus 64 | #define CE_NEW(a, T) \ 65 | new ((a)->vt->reallocate((a->inst), \ 66 | NULL, \ 67 | sizeof(T), \ 68 | 0, \ 69 | CE_ALIGNOF(T), \ 70 | __FILE__, \ 71 | __LINE__)) T 72 | 73 | #define CE_DELETE(a, ptr) _ct_delete(a, ptr) 74 | #endif 75 | 76 | #ifdef __cplusplus 77 | }; 78 | #endif 79 | 80 | #ifdef __cplusplus 81 | template 82 | inline void _ct_delete(ce_alloc_t0 *a, T* ptr) 83 | { 84 | if (!ptr){return;} ptr->~T(); CE_FREE(a, ptr); 85 | } 86 | #endif 87 | 88 | #endif //CE_MEMORY_ALLOCATOR_H 89 | -------------------------------------------------------------------------------- /src/celib/memory/memory.h: -------------------------------------------------------------------------------- 1 | #ifndef CE_MEMORY_H 2 | #define CE_MEMORY_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "celib/celib_types.h" 9 | 10 | #define CE_MEMORY_API \ 11 | CE_ID64_0("ce_memory_a0", 0x5fc4626a7b1e5fdfULL) 12 | 13 | typedef struct ce_alloc_t0 ce_alloc_t0; 14 | 15 | //! Memory system API V0 16 | struct ce_memory_a0 { 17 | ce_alloc_t0 *system; 18 | ce_alloc_t0 *virt_system; 19 | 20 | char *(*str_dup)(const char *s, 21 | ce_alloc_t0 *allocator); 22 | }; 23 | 24 | CE_MODULE(ce_memory_a0); 25 | 26 | #ifdef __cplusplus 27 | }; 28 | #endif 29 | 30 | #endif //CE_MEMORY_H 31 | -------------------------------------------------------------------------------- /src/celib/memory/memory_tracer.h: -------------------------------------------------------------------------------- 1 | #ifndef CE_MEMORY_TRACER_H 2 | #define CE_MEMORY_TRACER_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "celib/celib_types.h" 9 | 10 | #define CE_MEMORY_TRACER_API \ 11 | CE_ID64_0("ce_memory_tracer_a0", 0x9aa78aa7346e8a72ULL) 12 | 13 | typedef struct ce_alloc_t0 ce_alloc_t0; 14 | 15 | typedef struct ce_memory_tracer_o0 ce_memory_tracer_o0; 16 | 17 | typedef struct ce_memory_tracer_vt0 { 18 | void (*trace_ptr)(ce_memory_tracer_o0 *inst, 19 | void *ptr, 20 | size_t size, 21 | const char *filename, 22 | uint32_t line); 23 | 24 | void (*untrace_ptr)(ce_memory_tracer_o0 *inst, 25 | void *ptr); 26 | 27 | uint64_t (*allocated_size)(ce_memory_tracer_o0 *inst); 28 | } ce_memory_tracer_vt0; 29 | 30 | typedef struct ce_mem_tracer_t0 { 31 | ce_memory_tracer_o0 *inst; 32 | ce_memory_tracer_vt0 *vt; 33 | } ce_mem_tracer_t0; 34 | 35 | struct ce_memory_tracer_a0 { 36 | ce_mem_tracer_t0 *(*create)(); 37 | 38 | void (*destroy)(ce_mem_tracer_t0 *tracer); 39 | }; 40 | 41 | CE_MODULE(ce_memory_tracer_a0); 42 | 43 | #ifdef __cplusplus 44 | }; 45 | #endif 46 | 47 | #endif //CE_MEMORY_TRACER_H 48 | -------------------------------------------------------------------------------- /src/celib/memory/private/memory.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "celib/memory/memory_tracer.h" 10 | 11 | #define LOG_WHERE "memory" 12 | #define CE_TRACE_MEMORY 0 13 | 14 | #define _G ct_memory_global 15 | 16 | #include "virt_alloc.inl" 17 | #include "system_alloc.inl" 18 | 19 | //static struct _G { 20 | //} _G = {}; 21 | 22 | //// 23 | 24 | char *str_dup(const char *s, 25 | struct ce_alloc_t0 *allocator) { 26 | const uint32_t size = strlen(s) + 1; 27 | 28 | char *d = CE_ALLOC(allocator, char, size); 29 | CE_ASSERT("string", d != NULL); 30 | 31 | memset(d, '\0', sizeof(char) * size); 32 | strcpy(d, s); 33 | 34 | return d; 35 | } 36 | 37 | static struct ce_memory_a0 _api = { 38 | .system = &_system_allocator, 39 | .virt_system = &_virt_system_allocator, 40 | .str_dup = str_dup, 41 | }; 42 | 43 | struct ce_memory_a0 *ce_memory_a0 = &_api; 44 | 45 | 46 | void memory_tracer_init(struct ce_api_a0 *api); 47 | 48 | void memory_tracer_shutdown(); 49 | 50 | void memory_register_api(struct ce_api_a0 *api) { 51 | memory_tracer_init(api); 52 | 53 | _system_allocator_inst.tracer = ce_memory_tracer_a0->create(); 54 | 55 | api->add_api(CE_MEMORY_API, &_api, sizeof(_api)); 56 | 57 | } 58 | 59 | void memory_init() { 60 | } 61 | 62 | void memsys_shutdown() { 63 | memory_tracer_shutdown(); 64 | } 65 | -------------------------------------------------------------------------------- /src/celib/memory/private/system_alloc.inl: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_SYSTEM_ALLOC_INL 2 | #define CETECH_SYSTEM_ALLOC_INL 3 | 4 | #include 5 | 6 | #include 7 | #include "../memory_tracer.h" 8 | 9 | typedef struct system_allocator_t { 10 | ce_mem_tracer_t0 *tracer; 11 | } system_allocator_t; 12 | 13 | static system_allocator_t _system_allocator_inst; 14 | 15 | static ce_mem_tracer_t0 *_memory_tracer(const ce_alloc_o0 *_a) { 16 | system_allocator_t *a = (system_allocator_t *) _a; 17 | return a->tracer; 18 | } 19 | 20 | static void *_reallocate(const ce_alloc_o0 *_a, 21 | void *ptr, 22 | size_t size, 23 | size_t old_size, 24 | size_t align, 25 | const char *filename, 26 | uint32_t line) { 27 | CE_UNUSED(align); 28 | 29 | void *new_ptr = NULL; 30 | 31 | new_ptr = realloc(ptr, size); 32 | 33 | system_allocator_t *a = (system_allocator_t *) _a; 34 | ce_mem_tracer_t0 *tracer = a->tracer; 35 | 36 | if (tracer) { 37 | tracer->vt->untrace_ptr(tracer->inst, ptr); 38 | 39 | if (size) { 40 | tracer->vt->trace_ptr(tracer->inst, new_ptr, size, filename, line); 41 | } 42 | } 43 | 44 | return new_ptr; 45 | } 46 | 47 | 48 | static struct ce_alloc_vt0 system_vt = { 49 | .reallocate = _reallocate, 50 | .memory_tracer = _memory_tracer, 51 | }; 52 | 53 | static struct ce_alloc_t0 _system_allocator = { 54 | .inst = (ce_alloc_o0 *) &_system_allocator_inst, 55 | .vt = &system_vt, 56 | }; 57 | 58 | 59 | #endif //CETECH_SYSTEM_ALLOC_INL 60 | -------------------------------------------------------------------------------- /src/celib/memory/private/virt_alloc.inl: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_VIRT_SYSTEM_INL 2 | #define CETECH_VIRT_SYSTEM_INL 3 | 4 | #include 5 | 6 | static void *_reallocate_virt(const ce_alloc_o0 *a, 7 | void *ptr, 8 | size_t size, 9 | size_t old_size, 10 | size_t align, 11 | const char *filename, 12 | uint32_t line) { 13 | 14 | if (!size) { 15 | munmap(ptr, old_size); 16 | return NULL; 17 | } 18 | 19 | return mmap(NULL, 20 | size, 21 | PROT_READ | PROT_WRITE, 22 | MAP_PRIVATE | MAP_ANONYMOUS | 23 | MAP_NORESERVE, 24 | -1, 0); 25 | } 26 | 27 | static struct ce_alloc_vt0 virt_system_vt = { 28 | .reallocate = _reallocate_virt 29 | }; 30 | 31 | 32 | static struct ce_alloc_t0 _virt_system_allocator = { 33 | .inst = NULL, 34 | .vt = &virt_system_vt, 35 | }; 36 | 37 | 38 | #endif //CETECH_VIRT_SYSTEM_INL 39 | -------------------------------------------------------------------------------- /src/celib/module.h: -------------------------------------------------------------------------------- 1 | #ifndef CE_PLUGIN_API_H 2 | #define CE_PLUGIN_API_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "celib_types.h" 9 | 10 | struct ce_api_a0; 11 | 12 | #define CE_MODULE0_API \ 13 | CE_ID64_0("ce_module_a0", 0x23a8afeb527d63dcULL) 14 | 15 | //! Add static module and load it 16 | //! \param name Module name 17 | #define CE_ADD_STATIC_MODULE(name) \ 18 | extern void name ## _load_module(struct ce_api_a0*, int reload); \ 19 | extern void name ## _unload_module(struct ce_api_a0*, int reload); \ 20 | ce_module_a0->add_static(#name, name ## _load_module, name ## _unload_module) 21 | 22 | //! Load static module 23 | //! \param name Module name 24 | #define CE_LOAD_STATIC_MODULE(api, name) \ 25 | extern void name ## _load_module(struct ce_api_a0*, int reload); \ 26 | name ## _load_module(api, 0) 27 | 28 | //! Unload static module 29 | //! \param name Module name 30 | #define CE_UNLOAD_STATIC_MODULE(api, name) \ 31 | extern void name ## _unload_module(struct ce_api_a0* api, int reload); \ 32 | name ## _unload_module(api, 0) 33 | 34 | #define CE_MODULE_LOAD(name) name##_load_module 35 | #define CE_MODULE_UNLOAD(name) name##_unload_module 36 | 37 | typedef void (ce_load_module_t0)(struct ce_api_a0 *api, 38 | int reload); 39 | 40 | typedef void (ce_unload_module_t0)(struct ce_api_a0 *api, 41 | int reload); 42 | 43 | struct ce_module_a0 { 44 | //! Add static modules 45 | //! \param fce get api module fce 46 | void (*add_static)(const char *name, 47 | ce_load_module_t0 *load, 48 | ce_unload_module_t0 *unload); 49 | 50 | //! Load module from path 51 | //! \param path Plugin path 52 | void (*load)(const char *path); 53 | 54 | //! Load module from dir 55 | //! \param path Plugin dir path 56 | void (*load_dirs)(const char *path); 57 | 58 | void (*unload_all)(void); 59 | 60 | //! Reload module by path 61 | void (*reload)(const char *path); 62 | 63 | //! Reload all loaded modules 64 | void (*reload_all)(void); 65 | 66 | void (*do_reload)(); 67 | }; 68 | 69 | CE_MODULE(ce_module_a0); 70 | 71 | #ifdef __cplusplus 72 | }; 73 | #endif 74 | 75 | #endif //CE_PLUGIN_API_H 76 | -------------------------------------------------------------------------------- /src/celib/murmur.h: -------------------------------------------------------------------------------- 1 | #ifndef CE_MURMUR_H 2 | #define CE_MURMUR_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | static inline uint64_t ce_hash_murmur2_64(const void *key, 11 | uint64_t len, 12 | uint64_t seed) { 13 | if (!key) { 14 | return 0; 15 | } 16 | 17 | 18 | static const uint64_t m = 0xc6a4a7935bd1e995ULL; 19 | static const uint32_t r = 47; 20 | 21 | uint64_t h = seed ^(len * m); 22 | 23 | const uint64_t *data = (const uint64_t *) key; 24 | const uint64_t *end = data + (len / 8); 25 | 26 | while (data != end) { 27 | 28 | #ifdef CE_BIG_ENDIAN 29 | uint64_t k = *data++; 30 | char* p = (char*)&k; 31 | char c; 32 | c = p[0]; p[0] = p[7]; p[7] = c; 33 | c = p[1]; p[1] = p[6]; p[6] = c; 34 | c = p[2]; p[2] = p[5]; p[5] = c; 35 | c = p[3]; p[3] = p[4]; p[4] = c; 36 | #else 37 | uint64_t k = *data++; 38 | #endif 39 | 40 | k *= m; 41 | k ^= k >> r; 42 | k *= m; 43 | 44 | h ^= k; 45 | h *= m; 46 | } 47 | 48 | const unsigned char *data2 = (const unsigned char *) data; 49 | 50 | switch (len & 7) { 51 | case 7: 52 | h ^= ((uint64_t) data2[6]) << 48; 53 | case 6: 54 | h ^= ((uint64_t) data2[5]) << 40; 55 | case 5: 56 | h ^= ((uint64_t) data2[4]) << 32; 57 | case 4: 58 | h ^= ((uint64_t) data2[3]) << 24; 59 | case 3: 60 | h ^= ((uint64_t) data2[2]) << 16; 61 | case 2: 62 | h ^= ((uint64_t) data2[1]) << 8; 63 | case 1: 64 | h ^= ((uint64_t) data2[0]); 65 | h *= m; 66 | }; 67 | 68 | h ^= h >> r; 69 | h *= m; 70 | h ^= h >> r; 71 | 72 | return h; 73 | } 74 | 75 | static inline uint32_t ct_hash_murmur2_32(const void *key, 76 | uint32_t len, 77 | uint32_t seed) { 78 | const unsigned int m = 0x5bd1e995; 79 | const int r = 24; 80 | 81 | unsigned int h = seed ^len; 82 | 83 | const unsigned char *data = (const unsigned char *) key; 84 | 85 | while (len >= 4) { 86 | unsigned int k = *(unsigned int *) data; 87 | 88 | k *= m; 89 | k ^= k >> r; 90 | k *= m; 91 | 92 | h *= m; 93 | h ^= k; 94 | 95 | data += 4; 96 | len -= 4; 97 | } 98 | 99 | switch (len) { 100 | case 3: 101 | h ^= data[2] << 16; 102 | case 2: 103 | h ^= data[1] << 8; 104 | case 1: 105 | h ^= data[0]; 106 | h *= m; 107 | }; 108 | 109 | h ^= h >> 13; 110 | h *= m; 111 | h ^= h >> 15; 112 | 113 | return h; 114 | } 115 | 116 | #ifdef __cplusplus 117 | }; 118 | #endif 119 | 120 | #endif //CE_MURMUR_H 121 | -------------------------------------------------------------------------------- /src/celib/os/cpu.h: -------------------------------------------------------------------------------- 1 | // **OS cpu** 2 | // 3 | 4 | #ifndef CE_OS_CPU_H 5 | #define CE_OS_CPU_H 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #include "celib/celib_types.h" 12 | 13 | #define CE_OS_CPU_API \ 14 | CE_ID64_0("ce_os_cpu_a0", 0x41ff4437e99cbff7ULL) 15 | 16 | struct ce_os_cpu_a0 { 17 | // Get cpu core count 18 | int (*count)(void); 19 | }; 20 | 21 | 22 | CE_MODULE(ce_os_cpu_a0); 23 | 24 | #ifdef __cplusplus 25 | }; 26 | #endif 27 | 28 | #endif //CE_OS_CPU_H 29 | -------------------------------------------------------------------------------- /src/celib/os/error.h: -------------------------------------------------------------------------------- 1 | // **OS error** 2 | // 3 | 4 | #ifndef CE_OS_ERROR_H 5 | #define CE_OS_ERROR_H 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #include "celib/celib_types.h" 12 | 13 | #define CE_OS_ERROR_API \ 14 | CE_ID64_0("ce_os_error_a0", 0x67f389a4cfbbeb51ULL) 15 | 16 | 17 | struct ce_os_error_a0 { 18 | // Assert 19 | void (*assert)(const char *where, 20 | const char *condition, 21 | const char *filename, 22 | int line); 23 | 24 | char *(*stacktrace)(int skip); 25 | 26 | void (*stacktrace_free)(char *st); 27 | }; 28 | 29 | 30 | CE_MODULE(ce_os_error_a0); 31 | 32 | #ifdef __cplusplus 33 | }; 34 | #endif 35 | 36 | #endif //CE_OS_ERROR_H 37 | -------------------------------------------------------------------------------- /src/celib/os/input.h: -------------------------------------------------------------------------------- 1 | // **OS input** 2 | // 3 | 4 | #ifndef CE_OS_INPUT_H 5 | #define CE_OS_INPUT_H 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #include "celib/celib_types.h" 12 | 13 | #define CE_OS_INPUT_API \ 14 | CE_ID64_0("ce_os_input_a0", 0x5b789087d6f8fcd7ULL) 15 | 16 | struct ce_os_input_a0 { 17 | const char *(*get_clipboard_text)(); 18 | 19 | void (*set_clipboard_text)(const char *text); 20 | }; 21 | 22 | 23 | CE_MODULE(ce_os_input_a0); 24 | 25 | #ifdef __cplusplus 26 | }; 27 | #endif 28 | 29 | #endif //CE_OS_INPUT_H 30 | -------------------------------------------------------------------------------- /src/celib/os/object.h: -------------------------------------------------------------------------------- 1 | // **OS object** 2 | // 3 | 4 | #ifndef CE_OS_OBJECT_H 5 | #define CE_OS_OBJECT_H 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #include "celib/celib_types.h" 12 | 13 | #define CE_OS_OBJECT_API \ 14 | CE_ID64_0("ce_os_object_a0", 0x39f93df9f2df7e0fULL) 15 | 16 | 17 | struct ce_os_object_a0 { 18 | // Load shared lib 19 | void *(*load)(const char *path); 20 | 21 | // Unload shared lib 22 | void (*unload)(void *so); 23 | 24 | // Load function from shared lib 25 | void *(*load_function)(void *so, 26 | const char *name); 27 | }; 28 | 29 | 30 | CE_MODULE(ce_os_object_a0); 31 | 32 | #ifdef __cplusplus 33 | }; 34 | #endif 35 | 36 | #endif //CE_OS_OBJECT_H 37 | -------------------------------------------------------------------------------- /src/celib/os/path.h: -------------------------------------------------------------------------------- 1 | // **OS path** 2 | // 3 | 4 | #ifndef CE_OS_PATH_H 5 | #define CE_OS_PATH_H 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #include "celib/celib_types.h" 12 | 13 | #define CE_OS_PATH_API \ 14 | CE_ID64_0("ce_os_path_a0", 0xb1f6bb5e13c8aca1ULL) 15 | 16 | typedef struct ce_alloc_t0 ce_alloc_t0; 17 | 18 | struct ce_os_path_a0 { 19 | // Get file modified time 20 | uint32_t (*file_mtime)(const char *path); 21 | 22 | // List dir 23 | // - path Dir path 24 | // - recursive Resucrsive list? 25 | // - files Result files 26 | // - allocator Allocator 27 | void (*list)(const char *path, 28 | const char **patern, 29 | uint32_t patern_n, 30 | int recursive, 31 | int only_dir, 32 | char ***files, 33 | uint32_t *count, 34 | struct ce_alloc_t0 *allocator); 35 | 36 | // Free list dir array 37 | // - files Files array 38 | // - allocator Allocator 39 | void (*list_free)(char **files, 40 | uint32_t count, 41 | struct ce_alloc_t0 *allocator); 42 | 43 | // Create dir path 44 | // - path Path 45 | int (*make_path)(const char *path); 46 | 47 | // Get filename from path 48 | // - path Path 49 | const char *(*filename)(const char *path); 50 | 51 | // Get file basename (filename without extension) 52 | // - path Path 53 | // - out Out basename 54 | // - size 55 | void (*basename)(const char *path, 56 | char *out); 57 | 58 | void (*dir)(char *out, 59 | const char *path); 60 | 61 | void (*dirname)(char *out, 62 | const char *path); 63 | 64 | // Get file extension 65 | // - path Path 66 | const char *(*extension)(const char *path); 67 | 68 | // Join paths and return path len. 69 | // - allocator Allocator 70 | // - count Path count. 71 | void (*join)(char **buffer, 72 | struct ce_alloc_t0 *allocator, 73 | uint32_t count, 74 | ...); 75 | 76 | void (*copy_file)(ce_alloc_t0 *allocator, 77 | const char *from, 78 | const char *to); 79 | 80 | bool (*is_dir)(const char *path); 81 | }; 82 | 83 | CE_MODULE(ce_os_path_a0); 84 | 85 | #ifdef __cplusplus 86 | }; 87 | #endif 88 | 89 | #endif //CE_OS_PATH_H 90 | -------------------------------------------------------------------------------- /src/celib/os/private/os.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | #include 5 | #include "celib/macros.h" 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | extern struct ce_os_cpu_a0 cpu_api; 19 | extern struct ce_os_error_a0 error_api; 20 | extern struct ce_os_object_a0 object_api; 21 | extern struct ce_os_path_a0 path_api; 22 | extern struct ce_os_process_a0 process_api; 23 | extern struct ce_os_thread_a0 thread_api; 24 | extern struct ce_os_time_a0 time_api; 25 | extern struct ce_os_vio_a0 vio_api; 26 | extern struct ce_os_window_a0 window_api; 27 | extern struct ce_os_input_a0 input_api; 28 | 29 | 30 | void CE_MODULE_LOAD(os)(struct ce_api_a0 *api, 31 | int reload) { 32 | CE_UNUSED(reload); 33 | 34 | api->add_api(CE_OS_PATH_API, &path_api, sizeof(path_api)); 35 | api->add_api(CE_OS_CPU_API, &cpu_api, sizeof(cpu_api)); 36 | api->add_api(CE_OS_ERROR_API, &error_api, sizeof(error_api)); 37 | api->add_api(CE_OS_OBJECT_API, &object_api, sizeof(object_api)); 38 | api->add_api(CE_OS_PROCESS_API, &process_api, sizeof(process_api)); 39 | api->add_api(CE_OS_TIME_API, &time_api, sizeof(time_api)); 40 | api->add_api(CE_OS_VIO_API, &vio_api, sizeof(vio_api)); 41 | api->add_api(CE_OS_WINDOW_API, &window_api, sizeof(window_api)); 42 | api->add_api(CE_OS_INPUT_API, &input_api, sizeof(input_api)); 43 | api->add_api(CE_OS_THREAD_API, &thread_api, sizeof(thread_api)); 44 | 45 | } 46 | 47 | void CE_MODULE_UNLOAD(os)(struct ce_api_a0 *api, 48 | int reload) { 49 | 50 | CE_UNUSED(reload); 51 | CE_UNUSED(api); 52 | } 53 | -------------------------------------------------------------------------------- /src/celib/os/private/os_cpu.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | int cpu_count() { 6 | return SDL_GetCPUCount(); 7 | } 8 | 9 | struct ce_os_cpu_a0 cpu_api = { 10 | .count = cpu_count 11 | }; 12 | 13 | struct ce_os_cpu_a0 *ce_os_cpu_a0 = &cpu_api; 14 | -------------------------------------------------------------------------------- /src/celib/os/private/os_error.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | 10 | #include 11 | 12 | #if CE_PLATFORM_LINUX || CE_PLATFORM_OSX 13 | 14 | #include 15 | 16 | #endif 17 | 18 | #include 19 | 20 | char *stacktrace(int skip) { 21 | #if CE_PLATFORM_LINUX || CE_PLATFORM_OSX 22 | ce_alloc_t0 *a = ce_memory_a0->system; 23 | 24 | char *return_str = CE_ALLOC(a, char, 4096); 25 | return_str[0] = '\0'; 26 | 27 | void *array[32]; 28 | int size = backtrace(array, 32); 29 | 30 | char **messages = backtrace_symbols(array, size); 31 | 32 | char buffer[256]; 33 | for (int i = skip; i < size && messages != NULL; ++i) { 34 | buffer[0] = '\0'; 35 | char *mangled_name = 0, *offset_begin = 0, *offset_end = 0; 36 | 37 | for (char *p = messages[i]; *p; ++p) { 38 | if (*p == '(') { 39 | mangled_name = p; 40 | } else if (*p == '+') { 41 | offset_begin = p; 42 | } else if (*p == ')') { 43 | offset_end = p; 44 | break; 45 | } 46 | } 47 | 48 | if (mangled_name && offset_begin && offset_end && 49 | mangled_name < offset_begin) { 50 | *mangled_name++ = '\0'; 51 | *offset_begin++ = '\0'; 52 | *offset_end++ = '\0'; 53 | 54 | sprintf(buffer, 55 | " - %s: %s() +%s %s\n", 56 | messages[i], 57 | mangled_name, 58 | offset_begin, 59 | offset_end); 60 | 61 | strcat(return_str, buffer); 62 | 63 | } else { 64 | sprintf(buffer, " - %s\n", messages[i]); 65 | strcat(return_str, buffer); 66 | } 67 | } 68 | 69 | CE_FREE(a, messages); 70 | return return_str; 71 | #endif 72 | 73 | return NULL; 74 | } 75 | 76 | void stacktrace_free(char *st) { 77 | ce_alloc_t0 *a = ce_memory_a0->system; 78 | 79 | CE_FREE(a, st); 80 | } 81 | 82 | 83 | void ct_error_assert(const char *where, 84 | const char *condition, 85 | const char *filename, 86 | int line) { 87 | 88 | ce_log_a0->error(where, 89 | "assert: %s %s:%d", 90 | condition, 91 | filename, 92 | line); 93 | abort(); 94 | } 95 | 96 | struct ce_os_error_a0 error_api = { 97 | .assert = ct_error_assert, 98 | .stacktrace = stacktrace, 99 | .stacktrace_free = stacktrace_free, 100 | 101 | }; 102 | 103 | struct ce_os_error_a0 *ce_os_error_a0 = &error_api; 104 | -------------------------------------------------------------------------------- /src/celib/os/private/os_input_sdl.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | static char *global_sdl_clipboard = NULL; 6 | 7 | const char *get_clipboard_text() { 8 | if (global_sdl_clipboard) { 9 | SDL_free(global_sdl_clipboard); 10 | } 11 | 12 | global_sdl_clipboard = SDL_GetClipboardText(); 13 | return global_sdl_clipboard; 14 | } 15 | 16 | void set_clipboard_text(const char *text) { 17 | SDL_SetClipboardText(text); 18 | } 19 | 20 | struct ce_os_input_a0 input_api = { 21 | .get_clipboard_text=get_clipboard_text, 22 | .set_clipboard_text=set_clipboard_text, 23 | }; 24 | 25 | struct ce_os_input_a0 *ce_os_input_a0 = &input_api; -------------------------------------------------------------------------------- /src/celib/os/private/os_object.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #if CE_PLATFORM_LINUX 5 | #define _GNU_SOURCE 0 6 | #include 7 | #endif 8 | 9 | #if CE_PLATFORM_OSX 10 | 11 | #include 12 | 13 | #endif 14 | 15 | 16 | 17 | #include 18 | 19 | #include "celib/log.h" 20 | 21 | 22 | 23 | #define LOG_WHERE "object" 24 | 25 | void *load_object(const char *path) { 26 | char buffer[128]; 27 | uint32_t it = sprintf(buffer, "%s", path); 28 | 29 | #if CE_PLATFORM_LINUX 30 | it += sprintf(buffer+it, ".so"); 31 | void *obj = dlmopen(LM_ID_NEWLM, buffer, RTLD_GLOBAL | RTLD_NOW); 32 | #endif 33 | 34 | #if CE_PLATFORM_OSX 35 | it += sprintf(buffer + it, ".dylib"); 36 | void *obj = dlopen(buffer, RTLD_GLOBAL | RTLD_NOW); 37 | #endif 38 | 39 | if (obj == NULL) { 40 | ce_log_a0->error(LOG_WHERE, "Could not load object file %s", dlerror()); 41 | return NULL; 42 | } 43 | 44 | return obj; 45 | } 46 | 47 | void unload_object(void *so) { 48 | CE_ASSERT(LOG_WHERE, so != NULL); 49 | 50 | dlclose(so); 51 | } 52 | 53 | void *load_function(void *so, 54 | const char *name) { 55 | if (!so) { 56 | return NULL; 57 | } 58 | 59 | void *fce = dlsym(so, name); 60 | 61 | if (fce == NULL) { 62 | ce_log_a0->error(LOG_WHERE, "%s", dlerror()); 63 | return NULL; 64 | } 65 | 66 | return fce; 67 | } 68 | 69 | 70 | struct ce_os_object_a0 object_api = { 71 | .load = load_object, 72 | .unload = unload_object, 73 | .load_function = load_function 74 | }; 75 | 76 | struct ce_os_object_a0 *ce_os_object_a0 = &object_api; 77 | -------------------------------------------------------------------------------- /src/celib/os/private/os_process.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "celib/macros.h" 4 | 5 | 6 | #include "celib/log.h" 7 | #include 8 | 9 | int exec(const char *argv) { 10 | #if CE_PLATFORM_LINUX || CE_PLATFORM_OSX 11 | char output[4096]; 12 | 13 | ce_log_a0->debug("os_sdl", "exec %s", argv); 14 | 15 | FILE *fp = popen(argv, "r"); 16 | if (fp == NULL) 17 | return -1; 18 | 19 | while (fgets(output, CE_ARRAY_LEN(output), fp) != NULL) { 20 | printf("%s", output); 21 | } 22 | 23 | int status = pclose(fp); 24 | 25 | if (status == -1) { 26 | ce_log_a0->error("os_sdl", "output %s", output); 27 | } 28 | 29 | return status; 30 | #else 31 | #error "Implement this" 32 | #endif 33 | } 34 | 35 | struct ce_os_process_a0 process_api = { 36 | .exec = exec 37 | }; 38 | 39 | struct ce_os_process_a0 *ce_os_process_a0 = &process_api; 40 | -------------------------------------------------------------------------------- /src/celib/os/private/os_thread.c: -------------------------------------------------------------------------------- 1 | #include "include/SDL2/SDL.h" 2 | #include 3 | 4 | #if CE_PLATFORM_LINUX 5 | #include 6 | #endif 7 | 8 | #if CE_PLATFORM_OSX 9 | 10 | #include 11 | 12 | #endif 13 | 14 | 15 | #include 16 | #include 17 | 18 | 19 | //! Create new thread 20 | //! \param fce Thread fce 21 | //! \param name Thread name 22 | //! \param data Thread data 23 | //! \return new thread 24 | ce_thread_t0 thread_create(ce_thread_fce_t0 fce, 25 | const char *name, 26 | void *data) { 27 | return (ce_thread_t0) {.o=(uint64_t) SDL_CreateThread(fce, name, data)}; 28 | } 29 | 30 | //! Kill thread 31 | //! \param thread thread 32 | void thread_kill(ce_thread_t0 thread) { 33 | SDL_DetachThread((SDL_Thread *) thread.o); 34 | } 35 | 36 | //! Wait for thread 37 | //! \param thread Thread 38 | //! \param status Thread exit status 39 | void thread_wait(ce_thread_t0 thread, 40 | int *status) { 41 | SDL_WaitThread((SDL_Thread *) thread.o, status); 42 | } 43 | 44 | //! Get id for thread 45 | //! \param thread Thread 46 | //! \return ID 47 | uint64_t thread_get_id(ce_thread_t0 thread) { 48 | return SDL_GetThreadID((SDL_Thread *) thread.o); 49 | } 50 | 51 | //! Get actual thread id 52 | //! \return Thread id 53 | uint64_t thread_actual_id() { 54 | return SDL_ThreadID(); 55 | } 56 | 57 | #include 58 | void thread_yield() { 59 | #if CE_PLATFORM_OSX || CE_PLATFORM_LINUX 60 | usleep(0);// sched_yield(); 61 | #else 62 | #error "Implement this" 63 | #endif 64 | } 65 | 66 | void thread_spin_lock(ce_spinlock_t0 *lock) { 67 | SDL_AtomicLock((SDL_SpinLock *) lock); 68 | } 69 | 70 | void thread_spin_unlock(ce_spinlock_t0 *lock) { 71 | SDL_AtomicUnlock((SDL_SpinLock *) lock); 72 | } 73 | 74 | struct ce_os_thread_a0 thread_api = { 75 | .create = thread_create, 76 | .kill = thread_kill, 77 | .wait = thread_wait, 78 | .get_id = thread_get_id, 79 | .actual_id = thread_actual_id, 80 | .yield = thread_yield, 81 | .spin_lock = thread_spin_lock, 82 | .spin_unlock = thread_spin_unlock 83 | }; 84 | 85 | struct ce_os_thread_a0 *ce_os_thread_a0 = &thread_api; 86 | -------------------------------------------------------------------------------- /src/celib/os/private/os_time.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "include/SDL2/SDL.h" 5 | 6 | //============================================================================== 7 | // Time 8 | // ============================================================================== 9 | 10 | uint32_t get_ticks() { 11 | return SDL_GetTicks(); 12 | } 13 | 14 | uint64_t get_perf_counter() { 15 | return SDL_GetPerformanceCounter(); 16 | } 17 | 18 | uint64_t get_perf_freq() { 19 | return SDL_GetPerformanceFrequency(); 20 | } 21 | 22 | uint64_t timestamp_ms() { 23 | struct timespec spec; 24 | clock_gettime(CLOCK_REALTIME, &spec); 25 | 26 | time_t s = spec.tv_sec; 27 | uint64_t ms = round(spec.tv_nsec / 1.0e6); 28 | if (ms > 999) { 29 | s++; 30 | ms = 0; 31 | } 32 | 33 | ms += s * 1000; 34 | 35 | return ms; 36 | } 37 | 38 | struct ce_os_time_a0 time_api = { 39 | .ticks =get_ticks, 40 | .perf_counter = get_perf_counter, 41 | .perf_freq = get_perf_freq, 42 | .timestamp_ms = timestamp_ms, 43 | }; 44 | 45 | struct ce_os_time_a0 *ce_os_time_a0 = &time_api; 46 | 47 | -------------------------------------------------------------------------------- /src/celib/os/private/os_vio.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #include "include/SDL2/SDL.h" 6 | #include "celib/memory/allocator.h" 7 | #include 8 | 9 | #define LOG_WHERE_OS "vio_sdl" 10 | 11 | int64_t vio_sdl_seek(ce_vio_o0 *file, 12 | int64_t offset, 13 | enum ce_vio_seek whence) { 14 | CE_ASSERT(LOG_WHERE_OS, file != NULL); 15 | 16 | static int _whence[] = { 17 | [VIO_SEEK_SET] = RW_SEEK_SET, 18 | [VIO_SEEK_CUR] = RW_SEEK_CUR, 19 | [VIO_SEEK_END] = RW_SEEK_END 20 | }; 21 | 22 | return SDL_RWseek((SDL_RWops *) file, offset, _whence[whence]); 23 | } 24 | 25 | size_t vio_sdl_read(ce_vio_o0 *file, 26 | void *buffer, 27 | size_t size, 28 | size_t maxnum) { 29 | CE_ASSERT(LOG_WHERE_OS, file != NULL); 30 | 31 | return SDL_RWread((SDL_RWops *) file, buffer, size, maxnum); 32 | }; 33 | 34 | size_t vio_sdl_write(ce_vio_o0 *file, 35 | const void *buffer, 36 | size_t size, 37 | size_t maxnum) { 38 | CE_ASSERT(LOG_WHERE_OS, file != NULL); 39 | 40 | return SDL_RWwrite((SDL_RWops *) file, buffer, size, maxnum); 41 | }; 42 | 43 | int64_t vio_sdl_size(ce_vio_o0 *file) { 44 | CE_ASSERT(LOG_WHERE_OS, file != NULL); 45 | 46 | return SDL_RWsize((SDL_RWops *) file); 47 | }; 48 | 49 | int vio_sdl_close(ce_vio_o0 *file) { 50 | CE_ASSERT(LOG_WHERE_OS, file != NULL); 51 | 52 | SDL_RWclose((SDL_RWops *) file); 53 | return 1; 54 | } 55 | 56 | 57 | static ce_vio_vt0 vio_vt = { 58 | .write = vio_sdl_write, 59 | .read = vio_sdl_read, 60 | .seek = vio_sdl_seek, 61 | .size = vio_sdl_size, 62 | .close = vio_sdl_close, 63 | }; 64 | 65 | struct ce_vio_t0 *vio_from_file(const char *path, 66 | enum ce_vio_open_mode mode) { 67 | 68 | ce_alloc_t0 *alloc = ce_memory_a0->system; 69 | 70 | ce_vio_t0 *vio = CE_ALLOC(alloc, struct ce_vio_t0, sizeof(ce_vio_t0)); 71 | 72 | CE_ASSERT(LOG_WHERE_OS, vio != NULL); 73 | 74 | if (!vio) { 75 | return NULL; 76 | } 77 | 78 | SDL_RWops *rwops = SDL_RWFromFile(path, mode == VIO_OPEN_WRITE ? "w" : "r"); 79 | 80 | if (!rwops) { 81 | return NULL; 82 | } 83 | 84 | 85 | vio->inst = (ce_vio_o0 *) rwops; 86 | vio->vt = &vio_vt; 87 | 88 | return vio; 89 | } 90 | 91 | void vio_close(struct ce_vio_t0 *vio) { 92 | vio->vt->close(vio->inst); 93 | 94 | ce_alloc_t0 *alloc = ce_memory_a0->system; 95 | CE_FREE(alloc, vio); 96 | } 97 | 98 | struct ce_os_vio_a0 vio_api = { 99 | .from_file = vio_from_file, 100 | .close = vio_close, 101 | }; 102 | 103 | struct ce_os_vio_a0 *ce_os_vio_a0 = &vio_api; 104 | 105 | -------------------------------------------------------------------------------- /src/celib/os/process.h: -------------------------------------------------------------------------------- 1 | // **OS process** 2 | // 3 | 4 | #ifndef CE_OS_PROCESS_H 5 | #define CE_OS_PROCESS_H 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #include "celib/celib_types.h" 12 | 13 | #define CE_OS_PROCESS_API \ 14 | CE_ID64_0("ce_os_process_a0", 0xde6406a21bedc619ULL) 15 | 16 | struct ce_os_process_a0 { 17 | int (*exec)(const char *argv); 18 | }; 19 | 20 | 21 | CE_MODULE(ce_os_process_a0); 22 | 23 | #ifdef __cplusplus 24 | }; 25 | #endif 26 | 27 | #endif //CE_OS_PROCESS_H 28 | -------------------------------------------------------------------------------- /src/celib/os/thread.h: -------------------------------------------------------------------------------- 1 | // **OS thread** 2 | // 3 | 4 | #ifndef CE_OS_THREAD_H 5 | #define CE_OS_THREAD_H 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #include "celib/celib_types.h" 12 | 13 | #define CE_OS_THREAD_API \ 14 | CE_ID64_0("ce_os_thread_a0", 0x487c28f7f512ba0dULL) 15 | 16 | typedef struct ce_thread_t0 { 17 | uint64_t o; 18 | } ce_thread_t0; 19 | 20 | typedef int (ce_thread_fce_t0)(void *data); 21 | 22 | typedef struct ce_spinlock_t0 { 23 | uint64_t o; 24 | } ce_spinlock_t0; 25 | 26 | struct ce_os_thread_a0 { 27 | // Create new thread 28 | // - fce Thread fce 29 | // - name Thread name 30 | // - data Thread data 31 | ce_thread_t0 (*create)(ce_thread_fce_t0 fce, 32 | const char *name, 33 | void *data); 34 | 35 | // Kill thread 36 | // - thread thread 37 | void (*kill)(ce_thread_t0 thread); 38 | 39 | // Wait for thread 40 | // - thread Thread 41 | // - status Thread exit status 42 | void (*wait)(ce_thread_t0 thread, 43 | int *status); 44 | 45 | // Get id for thread 46 | // - thread Thread 47 | uint64_t (*get_id)(ce_thread_t0 thread); 48 | 49 | // Get actual thread id 50 | uint64_t (*actual_id)(); 51 | 52 | void (*yield)(); 53 | 54 | void (*spin_lock)(ce_spinlock_t0 *lock); 55 | 56 | void (*spin_unlock)(ce_spinlock_t0 *lock); 57 | }; 58 | 59 | 60 | CE_MODULE(ce_os_thread_a0); 61 | 62 | #ifdef __cplusplus 63 | }; 64 | #endif 65 | 66 | #endif //CE_OS_THREAD_H 67 | -------------------------------------------------------------------------------- /src/celib/os/time.h: -------------------------------------------------------------------------------- 1 | // **OS time** 2 | // 3 | 4 | #ifndef CE_OS_TIME_H 5 | #define CE_OS_TIME_H 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #include "celib/celib_types.h" 12 | 13 | #define CE_OS_TIME_API \ 14 | CE_ID64_0("ce_os_time_a0", 0x909d08abc10715f8ULL) 15 | 16 | 17 | struct ce_os_time_a0 { 18 | uint32_t (*ticks)(); 19 | 20 | uint64_t (*perf_counter)(); 21 | 22 | uint64_t (*perf_freq)(); 23 | 24 | uint64_t (*timestamp_ms)(); 25 | }; 26 | 27 | CE_MODULE(ce_os_time_a0); 28 | 29 | #ifdef __cplusplus 30 | }; 31 | #endif 32 | 33 | #endif //CE_OS_TIME_H 34 | -------------------------------------------------------------------------------- /src/celib/os/vio.h: -------------------------------------------------------------------------------- 1 | // **OS vio** 2 | // 3 | 4 | #ifndef CE_OS_VIO_H 5 | #define CE_OS_VIO_H 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #include "celib/celib_types.h" 12 | 13 | #define CE_OS_VIO_API \ 14 | CE_ID64_0("ce_os_vio_a0", 0x989fe40200d61012ULL) 15 | 16 | enum ce_vio_open_mode { 17 | VIO_OPEN_READ, 18 | VIO_OPEN_WRITE, 19 | }; 20 | 21 | enum ce_vio_seek { 22 | VIO_SEEK_SET = 1, 23 | VIO_SEEK_CUR, 24 | VIO_SEEK_END 25 | }; 26 | 27 | typedef struct ce_vio_o0 ce_vio_o0; 28 | 29 | typedef struct ce_vio_vt0 { 30 | int64_t (*size)(ce_vio_o0 *inst); 31 | 32 | int64_t (*seek)(ce_vio_o0 *inst, 33 | int64_t offset, 34 | enum ce_vio_seek whence); 35 | 36 | size_t (*read)(ce_vio_o0 *inst, 37 | void *ptr, 38 | size_t size, 39 | size_t maxnum); 40 | 41 | size_t (*write)(ce_vio_o0 *inst, 42 | const void *ptr, 43 | size_t size, 44 | size_t num); 45 | 46 | int (*close)(ce_vio_o0 *inst); 47 | } ce_vio_vt0; 48 | 49 | typedef struct ce_vio_t0 { 50 | ce_vio_o0 *inst; 51 | ce_vio_vt0 *vt; 52 | } ce_vio_t0; 53 | 54 | struct ce_os_vio_a0 { 55 | ce_vio_t0 *(*from_file)(const char *path, 56 | enum ce_vio_open_mode mode); 57 | 58 | void (*close)(struct ce_vio_t0 *vio); 59 | }; 60 | 61 | 62 | CE_MODULE(ce_os_vio_a0); 63 | 64 | #ifdef __cplusplus 65 | }; 66 | #endif 67 | 68 | #endif //CE_OS_VIO_H 69 | -------------------------------------------------------------------------------- /src/celib/os/window.h: -------------------------------------------------------------------------------- 1 | // **OS window** 2 | // 3 | 4 | #ifndef CE_OS_WINDOW_H 5 | #define CE_OS_WINDOW_H 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #include "celib/celib_types.h" 12 | 13 | #define CE_OS_WINDOW_API \ 14 | CE_ID64_0("ce_os_window_a0", 0xe0214a9e3b01137bULL) 15 | 16 | 17 | enum { 18 | EVENT_WINDOW_INVALID = 0, //< Invalid type 19 | 20 | EVENT_WINDOW_RESIZED = 13, //< Window resized 21 | }; 22 | 23 | struct ce_window_resized_event { 24 | uint32_t window_id; 25 | int32_t width; 26 | int32_t height; 27 | }; 28 | 29 | enum ce_window_flags { 30 | WINDOW_NOFLAG = (1 << 0), 31 | WINDOW_FULLSCREEN = (1 << 1), 32 | WINDOW_SHOWN = (1 << 2), 33 | WINDOW_HIDDEN = (1 << 3), 34 | WINDOW_BORDERLESS = (1 << 4), 35 | WINDOW_RESIZABLE = (1 << 5), 36 | WINDOW_MINIMIZED = (1 << 6), 37 | WINDOW_MAXIMIZED = (1 << 7), 38 | WINDOW_INPUT_GRABBED = (1 << 8), 39 | WINDOW_INPUT_FOCUS = (1 << 9), 40 | WINDOW_MOUSE_FOCUS = (1 << 10), 41 | WINDOW_FULLSCREEN_DESKTOP = (1 << 11), 42 | WINDOW_ALLOW_HIGHDPI = (1 << 12), 43 | WINDOW_MOUSE_CAPTURE = (1 << 13), 44 | WINDOW_ALWAYS_ON_TOP = (1 << 14), 45 | WINDOW_SKIP_TASKBAR = (1 << 15), 46 | WINDOW_UTILITY = (1 << 16), 47 | WINDOW_TOOLTIP = (1 << 17), 48 | WINDOW_POPUP_MENU = (1 << 18), 49 | }; 50 | 51 | enum ce_window_pos { 52 | WINDOWPOS_NOFLAG = (1 << 0), 53 | WINDOWPOS_CENTERED = (1 << 1), 54 | WINDOWPOS_UNDEFINED = (1 << 2), 55 | }; 56 | 57 | typedef void ce_window_o0; 58 | 59 | typedef struct ce_window_t0 { 60 | ce_window_o0 *inst; 61 | 62 | void (*set_title)(ce_window_o0 *inst, 63 | const char *title); 64 | 65 | const char *(*get_title)(ce_window_o0 *inst); 66 | 67 | void (*resize)(ce_window_o0 *inst, 68 | uint32_t width, 69 | uint32_t height); 70 | 71 | void (*size)(ce_window_o0 *inst, 72 | uint32_t *width, 73 | uint32_t *height); 74 | 75 | void *(*native_window_ptr)(ce_window_o0 *inst); 76 | 77 | void *(*native_display_ptr)(ce_window_o0 *inst); 78 | 79 | void (*warp_mouse)(ce_window_o0 *inst, 80 | int x, 81 | int y); 82 | } ce_window_t0; 83 | 84 | 85 | struct ce_os_window_a0 { 86 | ce_window_t0 *(*create)(const char *title, 87 | enum ce_window_pos x, 88 | enum ce_window_pos y, 89 | const int32_t width, 90 | const int32_t height, 91 | uint32_t flags, 92 | ce_alloc_t0 *alloc); 93 | 94 | ce_window_t0 *(*create_from)(void *hndl, 95 | ce_alloc_t0 *alloc); 96 | 97 | void (*destroy)(ce_window_t0 *w, 98 | ce_alloc_t0 *alloc); 99 | }; 100 | 101 | CE_MODULE(ce_os_window_a0); 102 | 103 | #ifdef __cplusplus 104 | }; 105 | #endif 106 | 107 | #endif //CE_OS_WINDOW_H 108 | -------------------------------------------------------------------------------- /src/celib/private/api_private.inl: -------------------------------------------------------------------------------- 1 | #ifndef CE__API_H 2 | #define CE__API_H 3 | 4 | struct ce_alloc_t0; 5 | struct ce_api_a0; 6 | 7 | void api_init(ce_alloc_t0 *allocator); 8 | 9 | void api_shutdown(); 10 | 11 | #endif //CE__API_H 12 | -------------------------------------------------------------------------------- /src/celib/private/core.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include "celib/private/api_private.inl" 9 | 10 | void memory_register_api(struct ce_api_a0 *api); 11 | 12 | struct sigaction sigact; 13 | 14 | static void signal_handler(int sig) { 15 | if (sig == SIGSEGV) { 16 | ce_log_a0->error("hell", ""); 17 | exit(-1); 18 | } 19 | } 20 | 21 | void init_signals(void) { 22 | sigact.sa_handler = signal_handler; 23 | sigemptyset(&sigact.sa_mask); 24 | sigact.sa_flags = 0; 25 | 26 | sigaddset(&sigact.sa_mask, SIGSEGV); 27 | sigaction(SIGSEGV, &sigact, (struct sigaction *) NULL); 28 | } 29 | 30 | bool ce_init() { 31 | ce_alloc_t0 *core_alloc = ce_memory_a0->system; 32 | 33 | api_init(core_alloc); 34 | 35 | CE_LOAD_STATIC_MODULE(ce_api_a0, log); 36 | 37 | memory_register_api(ce_api_a0); 38 | 39 | CE_LOAD_STATIC_MODULE(ce_api_a0, hashlib); 40 | CE_LOAD_STATIC_MODULE(ce_api_a0, os); 41 | 42 | init_signals(); 43 | 44 | CE_LOAD_STATIC_MODULE(ce_api_a0, task); 45 | CE_LOAD_STATIC_MODULE(ce_api_a0, cdb); 46 | CE_LOAD_STATIC_MODULE(ce_api_a0, config); 47 | CE_LOAD_STATIC_MODULE(ce_api_a0, filesystem); 48 | CE_LOAD_STATIC_MODULE(ce_api_a0, module); 49 | CE_LOAD_STATIC_MODULE(ce_api_a0, ydb); 50 | 51 | return true; 52 | } 53 | 54 | void memsys_shutdown(); 55 | 56 | bool ce_shutdown() { 57 | 58 | CE_UNLOAD_STATIC_MODULE(ce_api_a0, os); 59 | CE_UNLOAD_STATIC_MODULE(ce_api_a0, task); 60 | CE_UNLOAD_STATIC_MODULE(ce_api_a0, config); 61 | 62 | CE_UNLOAD_STATIC_MODULE(ce_api_a0, filesystem); 63 | CE_UNLOAD_STATIC_MODULE(ce_api_a0, cdb); 64 | CE_UNLOAD_STATIC_MODULE(ce_api_a0, module); 65 | CE_UNLOAD_STATIC_MODULE(ce_api_a0, hashlib); 66 | // CE_UNLOAD_STATIC_MODULE(ce_api_a0, ydb); 67 | 68 | api_shutdown(); 69 | memsys_shutdown(); 70 | 71 | return true; 72 | } 73 | -------------------------------------------------------------------------------- /src/celib/task.h: -------------------------------------------------------------------------------- 1 | #ifndef CE_TASKMANAGER_H 2 | #define CE_TASKMANAGER_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define CE_TASK_API \ 9 | CE_ID64_0("ce_task_a0", 0x4dbd12f32a50782eULL) 10 | 11 | //! Worker enum 12 | typedef enum ce_workers_e0 { 13 | TASK_WORKER_MAIN = 0, //!< Main worker 14 | TASK_MAX_WORKERS = 32, //!< Max workers 15 | } ce_workers_e0; 16 | 17 | //! Task item struct 18 | typedef struct ce_task_item_t0 { 19 | const char *name; //!< Task name 20 | void (*work)(void *data); //!< Task work 21 | void *data; //!< Worker data 22 | } ce_task_item_t0; 23 | 24 | typedef struct ce_task_counter_t0 ce_task_counter_t0; 25 | 26 | //! Task API V0 27 | struct ce_task_a0 { 28 | //! Workers count 29 | //! \return Workers count 30 | int (*worker_count)(); 31 | 32 | //! Curent worker id 33 | //! \return Worker id 34 | char (*worker_id)(); 35 | 36 | //! Add new task 37 | //! \param items Task item array 38 | //! \param count Task item count 39 | void (*add)(ce_task_item_t0 *items, 40 | uint32_t count, 41 | ce_task_counter_t0 **counter); 42 | 43 | void (*add_specific)(uint32_t worker_id, 44 | ce_task_item_t0 *items, 45 | uint32_t count, 46 | ce_task_counter_t0 **counter); 47 | 48 | void (*wait_for_counter)(ce_task_counter_t0 *signal, 49 | int32_t value); 50 | 51 | void (*wait_for_counter_no_work)(ce_task_counter_t0 *signal, 52 | int32_t value); 53 | }; 54 | 55 | CE_MODULE(ce_task_a0); 56 | 57 | #ifdef __cplusplus 58 | }; 59 | #endif 60 | 61 | #endif //CE_TASKMANAGER_H 62 | -------------------------------------------------------------------------------- /src/celib/ydb.h: -------------------------------------------------------------------------------- 1 | #ifndef CE_YDB_H 2 | #define CE_YDB_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #define CE_YDB_API \ 13 | CE_ID64_0("ce_ydb_a0", 0xf5be4873d4ac8920ULL) 14 | 15 | typedef struct ce_vio_t0 ce_vio_t0; 16 | typedef struct ce_alloc_t0 ce_alloc_t0; 17 | typedef struct ce_cdb_t0 ce_cdb_t0; 18 | typedef struct cnode_t cnode_t; 19 | 20 | 21 | struct ce_ydb_a0 { 22 | uint64_t (*get_obj)(const char *path); 23 | 24 | void (*read_cnodes)(const char *path, 25 | cnode_t **cnodes); 26 | 27 | 28 | void (*create_root_obj)(cnode_t *cnodes, 29 | ce_cdb_t0 tmp_db); 30 | 31 | void (*dump_cnodes)(ce_cdb_t0 db, 32 | cnode_t *cnodes, 33 | char **outputs); 34 | 35 | uint64_t (*cnodes_from_vio)(ce_vio_t0 *vio, 36 | cnode_t **nodes, 37 | ce_alloc_t0 *alloc); 38 | }; 39 | 40 | CE_MODULE(ce_ydb_a0); 41 | 42 | #ifdef __cplusplus 43 | }; 44 | #endif 45 | 46 | #endif //CE_YDB_H 47 | -------------------------------------------------------------------------------- /src/cetech/camera/camera.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_CAMERA_H 2 | #define CETECH_CAMERA_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | 11 | #define CT_CAMERA_API \ 12 | CE_ID64_0("ct_camera_a0", 0x66ecb4e7c5973115ULL) 13 | 14 | #define CT_CAMERA_COMPONENT \ 15 | CE_ID64_0("camera", 0x60ed8c3931822dc7ULL) 16 | 17 | #define CT_ACTIVE_CAMERA_COMPONENT \ 18 | CE_ID64_0("active_camera", 0xa0430cee11242caULL) 19 | 20 | #define PROP_CAMERA_TYPE \ 21 | CE_ID64_0("camera_type", 0xaf56273bba8c279bULL) 22 | 23 | #define CAMERA_TYPE_ORTHO \ 24 | CE_ID64_0("ortho", 0x747f66809b7ad519ULL) 25 | 26 | #define CAMERA_TYPE_PERSPECTIVE \ 27 | CE_ID64_0("perspective", 0x281d823258cc7c6eULL) 28 | 29 | #define PROP_FOV \ 30 | CE_ID64_0("fov", 0x805726a3c8974fbdULL) 31 | 32 | #define PROP_NEAR \ 33 | CE_ID64_0("near", 0xa1840af4acd01e77ULL) 34 | 35 | #define PROP_FAR \ 36 | CE_ID64_0("far", 0xe8d4ceded45dd6acULL) 37 | 38 | 39 | #define PROP_CAMERA_ENT \ 40 | CE_ID64_0("camera_ent", 0x83b9039ed72a162fULL) 41 | 42 | typedef struct ct_world_t0 ct_world_t0; 43 | typedef struct ct_entity_t0 ct_entity_t0; 44 | 45 | typedef struct ct_camera_component { 46 | float near; 47 | float far; 48 | float fov; 49 | uint64_t camera_type; 50 | } ct_camera_component; 51 | 52 | typedef struct ct_camera_data_t0 { 53 | ct_camera_component camera; 54 | ce_mat4_t world; 55 | } ct_camera_data_t0; 56 | 57 | typedef struct ct_active_camera { 58 | ct_entity_t0 camera_ent; 59 | } ct_active_camera; 60 | 61 | //! Camera API V0 62 | struct ct_camera_a0 { 63 | //! Get camera project and view matrix 64 | void (*get_project_view)(ce_mat4_t world, 65 | ct_camera_component camera, 66 | float *proj, 67 | float *view, 68 | int width, 69 | int height); 70 | }; 71 | 72 | 73 | CE_MODULE(ct_camera_a0); 74 | 75 | #ifdef __cplusplus 76 | }; 77 | #endif 78 | 79 | #endif //CETECH_CAMERA_H 80 | -------------------------------------------------------------------------------- /src/cetech/controlers/controlers.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_CONTROLERS_H 2 | #define CETECH_CONTROLERS_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | 11 | #define CT_CONTROLERS_API \ 12 | CE_ID64_0("ct_controlers_a0", 0x81e928c4fbba526dULL) 13 | 14 | #define CT_CONTROLERS_I \ 15 | CE_ID64_0("ct_controler_i0", 0xa5442c265384697cULL) 16 | 17 | #define CONTROLER_BUTTON \ 18 | CE_ID64_0("button", 0x1e232360426fac96ULL) 19 | 20 | #define CONTROLER_AXIS \ 21 | CE_ID64_0("axis", 0xeb6778864cd804e1ULL) 22 | 23 | #define CONTROLER_POSITION_X \ 24 | CE_ID64_0("position.x", 0x46b9c080961061caULL) 25 | 26 | #define CONTROLER_POSITION_Y \ 27 | CE_ID64_0("position.y", 0xca45b3734c0b3e81ULL) 28 | 29 | #define CONTROLER_POSITION_Z \ 30 | CE_ID64_0("position.z", 0x1c9cfdf1ce5b0b7aULL) 31 | 32 | #define CONTROLER_KEYCODE \ 33 | CE_ID64_0("keycode", 0xe8153a02000cbab3ULL) 34 | 35 | #define CONTROLER_TEXT \ 36 | CE_ID64_0("text", 0x887e193c80929e7ULL) 37 | 38 | typedef struct ct_controler_i0 { 39 | uint64_t (*name)(); 40 | 41 | //! Is gamepad active? 42 | int (*is_active)(uint32_t idx); 43 | 44 | //! Return button index 45 | uint32_t (*button_index)(const char *button_name); 46 | 47 | //! Return button name 48 | const char *(*button_name)(const uint32_t button_index); 49 | 50 | //! Return button state 51 | int (*button_state)(uint32_t idx, 52 | const uint32_t button_index); 53 | 54 | //! Is button pressed? 55 | int (*button_pressed)(uint32_t idx, 56 | const uint32_t button_index); 57 | 58 | //! Is button released? 59 | int (*button_released)(uint32_t idx, 60 | const uint32_t button_index); 61 | 62 | //! Return axis index 63 | uint32_t (*axis_index)(const char *axis_name); 64 | 65 | //! Return axis name 66 | const char *(*axis_name)(const uint32_t axis_index); 67 | 68 | //! Return axis value 69 | void (*axis)(uint32_t idx, 70 | const uint32_t axis_index, 71 | float *value); 72 | 73 | //! Play rumble 74 | void (*play_rumble)(uint32_t idx, 75 | float strength, 76 | uint32_t length); 77 | 78 | char *(*text)(uint32_t idx); 79 | } ct_controler_i0; 80 | 81 | 82 | #define CONTROLER_ID \ 83 | CE_ID64_0("id", 0xb0d09cc783d6a0ecULL) 84 | 85 | struct ct_controlers_a0 { 86 | ct_controler_i0 *(*get)(uint64_t name); 87 | }; 88 | 89 | CE_MODULE(ct_controlers_a0); 90 | 91 | #ifdef __cplusplus 92 | }; 93 | #endif 94 | 95 | #endif //CETECH_CONTROLERS_H 96 | -------------------------------------------------------------------------------- /src/cetech/controlers/gamepad.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_GAMEPAD_H 2 | #define CETECH_GAMEPAD_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | #define CONTROLER_GAMEPAD \ 11 | CE_ID64_0("gamepad", 0x6aa699de487f71eeULL) 12 | 13 | #define CT_GAMEPAD_TASK \ 14 | CE_ID64_0("gamepad_task", 0x120510962813be6fULL) 15 | 16 | 17 | #ifdef __cplusplus 18 | }; 19 | #endif 20 | 21 | #endif //CETECH_GAMEPAD_H 22 | //! \} -------------------------------------------------------------------------------- /src/cetech/controlers/keyboard.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_KEYBOARD_H 2 | #define CETECH_KEYBOARD_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | #define CONTROLER_KEYBOARD \ 11 | CE_ID64_0("keyboard", 0x413d83f1d027f82eULL) 12 | 13 | #define CT_KEYBOARD_TASK \ 14 | CE_ID64_0("keyboard_task", 0x905ae7202b55aafcULL) 15 | 16 | #ifdef __cplusplus 17 | }; 18 | #endif 19 | 20 | #endif //CETECH_KEYBOARD_H 21 | //! \} -------------------------------------------------------------------------------- /src/cetech/controlers/mouse.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_MOUSE_H 2 | #define CETECH_MOUSE_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | 11 | #define CONTROLER_MOUSE \ 12 | CE_ID64_0("mouse", 0x7c351278fe937928ULL) 13 | 14 | #define CT_MOUSE_TASK \ 15 | CE_ID64_0("mouse_task", 0x143aa2eadb0ac19eULL) 16 | 17 | #ifdef __cplusplus 18 | }; 19 | #endif 20 | 21 | #endif //CETECH_MOUSE_H 22 | -------------------------------------------------------------------------------- /src/cetech/controlers/private/controlers.c: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Includes 3 | //============================================================================== 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | #include "celib/memory/allocator.h" 15 | #include 16 | #include 17 | 18 | #import 19 | 20 | 21 | //============================================================================== 22 | // Defines 23 | //============================================================================== 24 | 25 | #define LOG_WHERE "controlers" 26 | 27 | //============================================================================== 28 | // Globals 29 | //============================================================================== 30 | 31 | #define _G controlers_global 32 | static struct _G { 33 | ce_hash_t interface_map; 34 | } _G = {}; 35 | 36 | 37 | //============================================================================== 38 | // Interface 39 | //============================================================================== 40 | 41 | static void _on_api_add(uint64_t name, 42 | void *api) { 43 | 44 | if (name == CT_CONTROLERS_I) { 45 | ct_controler_i0 *controlers_i = api; 46 | 47 | ce_hash_add(&_G.interface_map, controlers_i->name(), 48 | (uint64_t) controlers_i, ce_memory_a0->system); 49 | } 50 | } 51 | 52 | struct ct_controler_i0 *get_by_name(uint64_t name) { 53 | ct_controler_i0 *controlers_i; 54 | controlers_i = (ct_controler_i0 *) ce_hash_lookup(&_G.interface_map, name, 0); 55 | return controlers_i; 56 | }; 57 | 58 | static struct ct_controlers_a0 ct_controlers_api = { 59 | .get = get_by_name, 60 | }; 61 | 62 | struct ct_controlers_a0 *ct_controlers_a0 = &ct_controlers_api; 63 | 64 | void CE_MODULE_LOAD(controlers)(struct ce_api_a0 *api, 65 | int reload) { 66 | CE_UNUSED(reload); 67 | CE_INIT_API(api, ce_log_a0); 68 | CE_INIT_API(api, ce_id_a0); 69 | CE_INIT_API(api, ce_cdb_a0); 70 | 71 | _G = (struct _G) {}; 72 | 73 | api->add_api(CT_CONTROLERS_API, 74 | ct_controlers_a0, sizeof(ct_controlers_api)); 75 | 76 | api->register_on_add(_on_api_add); 77 | } 78 | 79 | void CE_MODULE_UNLOAD(controlers)(struct ce_api_a0 *api, 80 | int reload) { 81 | 82 | CE_UNUSED(reload); 83 | CE_UNUSED(api); 84 | 85 | _G = (struct _G) {}; 86 | } -------------------------------------------------------------------------------- /src/cetech/controlers/private/gamepadstr.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Includes 3 | //============================================================================== 4 | 5 | static const char *_btn_to_str[GAMEPAD_BTN_MAX] = { 6 | [GAMEPAD_BTN_INVALID] = "invalid", 7 | [GAMEPAD_BTN_A] = "a", 8 | [GAMEPAD_BTN_B] = "b", 9 | [GAMEPAD_BTN_X] = "x", 10 | [GAMEPAD_BTN_Y] = "y", 11 | [GAMEPAD_BTN_BACK] = "back", 12 | [GAMEPAD_BTN_GUIDE] = "guide", 13 | [GAMEPAD_BTN_START] = "start", 14 | [GAMEPAD_BTN_LEFTSTICK] = "left_stick", 15 | [GAMEPAD_BTN_RIGHTSTICK] = "right_stick", 16 | [GAMEPAD_BTN_LEFTSHOULDER] = "left_shoulder", 17 | [GAMEPAD_BTN_RIGHTSHOULDER] = "right_shoulder", 18 | [GAMEPAD_BTN_DPADUP] = "dpad_up", 19 | [GAMEPAD_BTN_DPADDOWN] = "dpad_down", 20 | [GAMEPAD_BTN_DPADLEFT] = "dpad_left", 21 | [GAMEPAD_BTN_DPADRIGHT] = "dpad_right" 22 | }; 23 | 24 | static const char *_axis_to_str[GAMEPAD_AXIX_MAX] = { 25 | [GAMEPAD_AXIS_INVALID] = "invalid", 26 | [GAMEPAD_AXIS_LEFT] = "left", 27 | [GAMEPAD_AXIS_RIGHT] = "right", 28 | [GAMEPAD_AXIS_TRIGER] = "triger" 29 | }; 30 | -------------------------------------------------------------------------------- /src/cetech/controlers/private/mousebtnstr.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // Includes 3 | //============================================================================== 4 | 5 | static const char *_btn_to_str[MOUSE_BTN_MAX] = { 6 | [MOUSE_BTN_UNKNOWN] = "", 7 | [MOUSE_BTN_LEFT] = "left", 8 | [MOUSE_BTN_MIDLE] = "midle", 9 | [MOUSE_BTN_RIGHT] = "right", 10 | }; 11 | 12 | static const char *_axis_to_str[MOUSE_AXIS_MAX] = { 13 | [MOUSE_AXIS_UNKNOWN] = "", 14 | [MOUSE_AXIS_ABSOULTE] = "absolute", 15 | [MOUSE_AXIS_RELATIVE] = "relative", 16 | [MOUSE_AXIS_WHEEL] = "wheel", 17 | }; -------------------------------------------------------------------------------- /src/cetech/debugdraw/dd.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_DEBUGDRAW_H 2 | #define CETECH_DEBUGDRAW_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | #define CT_DD_A0 \ 11 | CE_ID64_0("ct_dd_a0", 0xfdd19bc6b2e51af8ULL) 12 | 13 | typedef enum { 14 | CT_DD_AXIS_NONE, 15 | CT_DD_AXIS_X, 16 | CT_DD_AXIS_Y, 17 | CT_DD_AXIS_Z, 18 | } ct_dd_axis_e0; 19 | 20 | struct ct_dd_a0 { 21 | void (*begin)(uint8_t view); 22 | 23 | void (*end)(); 24 | 25 | void (*push)(); 26 | 27 | void (*pop)(); 28 | 29 | void (*set_transform_mtx)(float *mtx); 30 | 31 | void (*set_color)(float r, 32 | float g, 33 | float b, 34 | float a); 35 | 36 | void (*draw_axis)(float x, 37 | float y, 38 | float z, 39 | float len, 40 | ct_dd_axis_e0 highlight, 41 | float thickness); 42 | 43 | void (*move_to)(float x, 44 | float y, 45 | float z); 46 | 47 | void (*line_to)(float x, 48 | float y, 49 | float z); 50 | 51 | void (*close)(); 52 | }; 53 | 54 | CE_MODULE(ct_dd_a0); 55 | 56 | #ifdef __cplusplus 57 | }; 58 | #endif 59 | 60 | #endif //CETECH_DEBUGDRAW_H 61 | -------------------------------------------------------------------------------- /src/cetech/debugdraw/private/bgfx_debugdraw/fs_debugdraw_fill.sc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2019 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 4 | */ 5 | 6 | #include 7 | 8 | uniform vec4 u_params[4]; 9 | 10 | #define u_lightDir u_params[0].xyz 11 | #define u_shininess u_params[0].w 12 | #define u_skyColor u_params[1].xyz 13 | #define u_groundColor u_params[2].xyz 14 | #define u_matColor u_params[3] 15 | 16 | void main() 17 | { 18 | gl_FragColor = u_matColor; 19 | } 20 | -------------------------------------------------------------------------------- /src/cetech/debugdraw/private/bgfx_debugdraw/fs_debugdraw_fill_lit.sc: -------------------------------------------------------------------------------- 1 | $input v_view, v_world 2 | 3 | /* 4 | * Copyright 2011-2019 Branimir Karadzic. All rights reserved. 5 | * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 6 | */ 7 | 8 | #include 9 | 10 | uniform vec4 u_params[4]; 11 | 12 | #define u_lightDir u_params[0].xyz 13 | #define u_shininess u_params[0].w 14 | #define u_skyColor u_params[1].xyz 15 | #define u_groundColor u_params[2].xyz 16 | #define u_matColor u_params[3] 17 | 18 | void main() 19 | { 20 | vec3 normal = normalize(cross(dFdx(v_world), dFdy(v_world) ) ); 21 | vec3 viewDir = -normalize(v_view); 22 | 23 | float ndotl = dot(normal, u_lightDir); 24 | vec3 diffuse = mix(u_groundColor, u_skyColor, ndotl*0.5 + 0.5) * u_matColor.xyz; 25 | 26 | #if 0 27 | vec3 reflected = 2.0*ndotl*normal - u_lightDir; 28 | float rdotv = dot(reflected, viewDir); 29 | float spec = step(0.0, ndotl) * pow(max(0.0, rdotv), u_shininess); 30 | #else 31 | float spec = 0.0; 32 | #endif 33 | 34 | gl_FragColor = vec4(diffuse + vec3_splat(spec), u_matColor.w); 35 | } 36 | -------------------------------------------------------------------------------- /src/cetech/debugdraw/private/bgfx_debugdraw/fs_debugdraw_fill_texture.sc: -------------------------------------------------------------------------------- 1 | $input v_texcoord0, v_color0 2 | 3 | /* 4 | * Copyright 2011-2019 Branimir Karadzic. All rights reserved. 5 | * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 6 | */ 7 | 8 | #include 9 | 10 | SAMPLER2D(s_texColor, 0); 11 | 12 | void main() 13 | { 14 | gl_FragColor = texture2D(s_texColor, v_texcoord0) * v_color0; 15 | } 16 | -------------------------------------------------------------------------------- /src/cetech/debugdraw/private/bgfx_debugdraw/fs_debugdraw_lines.sc: -------------------------------------------------------------------------------- 1 | $input v_color0 2 | 3 | /* 4 | * Copyright 2011-2019 Branimir Karadzic. All rights reserved. 5 | * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 6 | */ 7 | 8 | #include 9 | 10 | void main() 11 | { 12 | gl_FragColor = v_color0; 13 | } 14 | -------------------------------------------------------------------------------- /src/cetech/debugdraw/private/bgfx_debugdraw/fs_debugdraw_lines_stipple.sc: -------------------------------------------------------------------------------- 1 | $input v_color0, v_stipple 2 | 3 | /* 4 | * Copyright 2011-2019 Branimir Karadzic. All rights reserved. 5 | * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 6 | */ 7 | 8 | #include 9 | 10 | void main() 11 | { 12 | if (0.125 < mod(v_stipple, 0.25) ) 13 | { 14 | discard; 15 | } 16 | 17 | gl_FragColor = v_color0; 18 | } 19 | -------------------------------------------------------------------------------- /src/cetech/debugdraw/private/bgfx_debugdraw/varying.def.sc: -------------------------------------------------------------------------------- 1 | vec3 a_position : POSITION; 2 | uvec4 a_indices : BLENDINDICES; 3 | vec4 a_color0 : COLOR0; 4 | vec2 a_texcoord0 : TEXCOORD0; 5 | 6 | vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0); 7 | vec4 v_color0 : COLOR = vec4(1.0, 0.0, 0.0, 1.0); 8 | float v_stipple : TEXCOORD0 = 0.0; 9 | vec3 v_view : TEXCOORD0 = vec3(0.0, 0.0, 0.0); 10 | vec3 v_world : TEXCOORD1 = vec3(0.0, 0.0, 0.0); 11 | -------------------------------------------------------------------------------- /src/cetech/debugdraw/private/bgfx_debugdraw/vs_debugdraw_fill.sc: -------------------------------------------------------------------------------- 1 | $input a_position, a_indices 2 | 3 | /* 4 | * Copyright 2011-2019 Branimir Karadzic. All rights reserved. 5 | * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 6 | */ 7 | 8 | #include 9 | 10 | void main() 11 | { 12 | vec4 model = mul(u_model[int(a_indices.x)], vec4(a_position, 1.0) ); 13 | gl_Position = mul(u_viewProj, model); 14 | } 15 | -------------------------------------------------------------------------------- /src/cetech/debugdraw/private/bgfx_debugdraw/vs_debugdraw_fill_lit.sc: -------------------------------------------------------------------------------- 1 | $input a_position, a_indices 2 | $output v_view, v_world 3 | 4 | /* 5 | * Copyright 2011-2019 Branimir Karadzic. All rights reserved. 6 | * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 7 | */ 8 | 9 | #include 10 | 11 | void main() 12 | { 13 | vec4 world = mul(u_model[int(a_indices.x)], vec4(a_position, 1.0) ); 14 | gl_Position = mul(u_viewProj, world); 15 | v_view = mul(u_view, world).xyz; 16 | v_world = world.xyz; 17 | } 18 | -------------------------------------------------------------------------------- /src/cetech/debugdraw/private/bgfx_debugdraw/vs_debugdraw_fill_lit_mesh.sc: -------------------------------------------------------------------------------- 1 | $input a_position, a_indices 2 | $output v_view, v_world 3 | 4 | /* 5 | * Copyright 2011-2019 Branimir Karadzic. All rights reserved. 6 | * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 7 | */ 8 | 9 | #include 10 | 11 | void main() 12 | { 13 | vec4 world = mul(u_model[0], vec4(a_position, 1.0) ); 14 | gl_Position = mul(u_viewProj, world); 15 | v_view = mul(u_view, world).xyz; 16 | v_world = world.xyz; 17 | } 18 | -------------------------------------------------------------------------------- /src/cetech/debugdraw/private/bgfx_debugdraw/vs_debugdraw_fill_mesh.sc: -------------------------------------------------------------------------------- 1 | $input a_position, a_indices 2 | 3 | /* 4 | * Copyright 2011-2019 Branimir Karadzic. All rights reserved. 5 | * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 6 | */ 7 | 8 | #include 9 | 10 | void main() 11 | { 12 | vec4 model = mul(u_model[0], vec4(a_position, 1.0) ); 13 | gl_Position = mul(u_viewProj, model); 14 | } 15 | -------------------------------------------------------------------------------- /src/cetech/debugdraw/private/bgfx_debugdraw/vs_debugdraw_fill_texture.sc: -------------------------------------------------------------------------------- 1 | $input a_position, a_texcoord0, a_color0 2 | $output v_texcoord0, v_color0 3 | 4 | /* 5 | * Copyright 2011-2019 Branimir Karadzic. All rights reserved. 6 | * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 7 | */ 8 | 9 | #include 10 | 11 | void main() 12 | { 13 | gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) ); 14 | v_texcoord0 = a_texcoord0; 15 | v_color0 = a_color0; 16 | } 17 | -------------------------------------------------------------------------------- /src/cetech/debugdraw/private/bgfx_debugdraw/vs_debugdraw_lines.sc: -------------------------------------------------------------------------------- 1 | $input a_position, a_color0 2 | $output v_color0 3 | 4 | /* 5 | * Copyright 2011-2019 Branimir Karadzic. All rights reserved. 6 | * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 7 | */ 8 | 9 | #include 10 | 11 | void main() 12 | { 13 | gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) ); 14 | v_color0 = a_color0; 15 | } 16 | -------------------------------------------------------------------------------- /src/cetech/debugdraw/private/bgfx_debugdraw/vs_debugdraw_lines_stipple.sc: -------------------------------------------------------------------------------- 1 | $input a_position, a_color0, a_texcoord0 2 | $output v_color0, v_stipple 3 | 4 | /* 5 | * Copyright 2011-2019 Branimir Karadzic. All rights reserved. 6 | * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 7 | */ 8 | 9 | #include 10 | 11 | void main() 12 | { 13 | gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) ); 14 | v_color0 = a_color0; 15 | v_stipple = a_texcoord0.x; 16 | } 17 | -------------------------------------------------------------------------------- /src/cetech/debugdraw/private/dd.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | 6 | #include "../dd.h" 7 | 8 | #include "bgfx_debugdraw/debugdraw.h" 9 | 10 | #define _G dd_global 11 | 12 | static struct _G { 13 | DebugDrawEncoder enc; 14 | } _G; 15 | 16 | 17 | static void begin(uint8_t viewid) { 18 | _G.enc = DebugDrawEncoder(); 19 | _G.enc.begin(viewid, true); 20 | } 21 | 22 | static void end() { 23 | _G.enc.end(); 24 | } 25 | 26 | static Axis::Enum _to_axis_enum(ct_dd_axis_e0 axis) { 27 | static Axis::Enum _tbl[] = { 28 | [CT_DD_AXIS_NONE] = Axis::Count, 29 | [CT_DD_AXIS_X] = Axis::X, 30 | [CT_DD_AXIS_Y] = Axis::Y, 31 | [CT_DD_AXIS_Z] = Axis::Z, 32 | }; 33 | 34 | return _tbl[axis]; 35 | } 36 | 37 | static void draw_axis(float x, 38 | float y, 39 | float z, 40 | float len, 41 | ct_dd_axis_e0 highlight, 42 | float thickness) { 43 | _G.enc.drawAxis(x, y, z, len, _to_axis_enum(highlight), thickness); 44 | } 45 | 46 | static void set_transform_mtx(float *mtx) { 47 | _G.enc.setTransform(mtx); 48 | } 49 | 50 | void move_to(float x, 51 | float y, 52 | float z) { 53 | _G.enc.moveTo(x, y, z); 54 | } 55 | 56 | void line_to(float x, 57 | float y, 58 | float z) { 59 | _G.enc.lineTo(x, y, z); 60 | } 61 | 62 | void close() { 63 | _G.enc.close(); 64 | } 65 | 66 | void push() { 67 | _G.enc.push(); 68 | } 69 | 70 | void pop() { 71 | _G.enc.pop(); 72 | } 73 | 74 | void set_color(float r, 75 | float g, 76 | float b, 77 | float a) { 78 | 79 | union { 80 | struct { 81 | uint8_t r, g, b, a; 82 | }; 83 | uint32_t argba; 84 | } argba = { 85 | .r = static_cast(r * 255), 86 | .g = static_cast(g * 255), 87 | .b = static_cast(b * 255), 88 | .a = static_cast(a * 255), 89 | }; 90 | 91 | _G.enc.setColor(argba.argba); 92 | } 93 | 94 | 95 | static struct ct_dd_a0 api = { 96 | .begin = begin, 97 | .end = end, 98 | .push = push, 99 | .pop = pop, 100 | .set_transform_mtx = set_transform_mtx, 101 | .draw_axis = draw_axis, 102 | .move_to = move_to, 103 | .line_to = line_to, 104 | .close = close, 105 | .set_color = set_color, 106 | }; 107 | 108 | struct ct_dd_a0 *ct_dd_a0 = &api; 109 | 110 | extern "C" { 111 | void CE_MODULE_LOAD(dd)(struct ce_api_a0 *api, 112 | int reload) { 113 | _G = (struct _G) {}; 114 | 115 | api->add_api(CT_DD_A0, ct_dd_a0, sizeof(struct ct_dd_a0)); 116 | 117 | ddInit(); 118 | } 119 | 120 | void CE_MODULE_UNLOAD(dd)(struct ce_api_a0 *api, 121 | int reload) { 122 | ddShutdown(); 123 | _G = (struct _G) {}; 124 | } 125 | } -------------------------------------------------------------------------------- /src/cetech/debugui/private/bgfx_imgui/fs_imgui_color.sc: -------------------------------------------------------------------------------- 1 | $input v_color0 2 | 3 | /* 4 | * Copyright 2011-2018 Branimir Karadzic. All rights reserved. 5 | * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 6 | */ 7 | 8 | #include 9 | 10 | void main() 11 | { 12 | gl_FragColor = v_color0; 13 | } 14 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/bgfx_imgui/fs_imgui_cubemap.sc: -------------------------------------------------------------------------------- 1 | $input v_normal 2 | 3 | /* 4 | * Copyright 2011-2018 Branimir Karadzic. All rights reserved. 5 | * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 6 | */ 7 | 8 | #include 9 | 10 | uniform vec4 u_imageLodEnabled; 11 | SAMPLERCUBE(s_texColor, 0); 12 | 13 | #define u_imageLod u_imageLodEnabled.x 14 | #define u_imageEnabled u_imageLodEnabled.y 15 | 16 | void main() 17 | { 18 | vec3 color = textureCubeLod(s_texColor, v_normal, u_imageLod).xyz; 19 | float alpha = 0.2 + 0.8*u_imageEnabled; 20 | gl_FragColor = vec4(color, alpha); 21 | } 22 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/bgfx_imgui/fs_imgui_image.sc: -------------------------------------------------------------------------------- 1 | $input v_texcoord0 2 | 3 | /* 4 | * Copyright 2014 Dario Manesku. All rights reserved. 5 | * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 6 | */ 7 | 8 | #include 9 | 10 | uniform vec4 u_imageLodEnabled; 11 | SAMPLER2D(s_texColor, 0); 12 | 13 | #define u_imageLod u_imageLodEnabled.x 14 | #define u_imageEnabled u_imageLodEnabled.y 15 | 16 | void main() 17 | { 18 | vec3 color = texture2DLod(s_texColor, v_texcoord0, u_imageLod).xyz; 19 | float alpha = 0.2 + 0.8*u_imageEnabled; 20 | gl_FragColor = vec4(color, alpha); 21 | } 22 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/bgfx_imgui/fs_imgui_image_swizz.sc: -------------------------------------------------------------------------------- 1 | $input v_texcoord0 2 | 3 | /* 4 | * Copyright 2014 Dario Manesku. All rights reserved. 5 | * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 6 | */ 7 | 8 | #include 9 | 10 | uniform vec4 u_imageLodEnabled; 11 | uniform vec4 u_swizzle; 12 | SAMPLER2D(s_texColor, 0); 13 | 14 | #define u_imageLod u_imageLodEnabled.x 15 | #define u_imageEnabled u_imageLodEnabled.y 16 | 17 | void main() 18 | { 19 | float color = dot(texture2DLod(s_texColor, v_texcoord0, u_imageLod), u_swizzle); 20 | float alpha = 0.2 + 0.8*u_imageEnabled; 21 | gl_FragColor = vec4(vec3_splat(color), alpha); 22 | } 23 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/bgfx_imgui/fs_imgui_latlong.sc: -------------------------------------------------------------------------------- 1 | $input v_texcoord0 2 | 3 | /* 4 | * Copyright 2014-2015 Dario Manesku. All rights reserved. 5 | * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 6 | */ 7 | 8 | #include 9 | 10 | uniform vec4 u_imageLodEnabled; 11 | SAMPLERCUBE(s_texColor, 0); 12 | 13 | #define u_imageLod u_imageLodEnabled.x 14 | #define u_imageEnabled u_imageLodEnabled.y 15 | 16 | vec3 vecFromLatLong(vec2 _uv) 17 | { 18 | float pi = 3.14159265; 19 | float twoPi = 2.0*pi; 20 | float phi = _uv.x * twoPi; 21 | float theta = _uv.y * pi; 22 | 23 | vec3 result; 24 | result.x = -sin(theta)*sin(phi); 25 | result.y = cos(theta); 26 | result.z = -sin(theta)*cos(phi); 27 | 28 | return result; 29 | } 30 | 31 | void main() 32 | { 33 | vec3 dir = vecFromLatLong(v_texcoord0); 34 | vec3 color = textureCubeLod(s_texColor, dir, u_imageLod).xyz; 35 | float alpha = 0.2 + 0.8*u_imageEnabled; 36 | 37 | gl_FragColor = vec4(color, alpha); 38 | } 39 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/bgfx_imgui/fs_imgui_texture.sc: -------------------------------------------------------------------------------- 1 | $input v_texcoord0, v_color0 2 | 3 | /* 4 | * Copyright 2011-2018 Branimir Karadzic. All rights reserved. 5 | * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 6 | */ 7 | 8 | #include 9 | 10 | SAMPLER2D(s_texColor, 0); 11 | 12 | void main() 13 | { 14 | float alpha = texture2D(s_texColor, v_texcoord0).x; 15 | gl_FragColor = vec4(v_color0.xyz, v_color0.w * alpha); 16 | } 17 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/bgfx_imgui/fs_ocornut_imgui.sc: -------------------------------------------------------------------------------- 1 | $input v_color0, v_texcoord0 2 | 3 | #include "../common.sh" 4 | 5 | SAMPLER2D(s_tex, 0); 6 | 7 | void main() 8 | { 9 | vec4 texel = texture2D(s_tex, v_texcoord0); 10 | gl_FragColor = texel * v_color0; 11 | } 12 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/bgfx_imgui/makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011-2018 Branimir Karadzic. All rights reserved. 3 | # License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 4 | # 5 | 6 | include ../../../scripts/shader-embeded.mk 7 | 8 | droidsans.ttf.h: ../../runtime/font/droidsans.ttf 9 | @bin2c -f $(<) -o $(@) -n s_droidSansTtf 10 | 11 | roboto_regular.ttf.h: ../../runtime/font/roboto-regular.ttf 12 | @bin2c -f $(<) -o $(@) -n s_robotoRegularTtf 13 | 14 | robotomono_regular.ttf.h: ../../runtime/font/robotomono-regular.ttf 15 | @bin2c -f $(<) -o $(@) -n s_robotoMonoRegularTtf 16 | 17 | icons_font_awesome.ttf.h: ../../runtime/font/fontawesome-webfont.ttf 18 | @bin2c -f $(<) -o $(@) -n s_iconsFontAwesomeTtf 19 | 20 | icons_kenney.ttf.h: ../../runtime/font/kenney-icon-font.ttf 21 | @bin2c -f $(<) -o $(@) -n s_iconsKenneyTtf 22 | 23 | fonts: droidsans.ttf.h \ 24 | roboto_regular.ttf.h \ 25 | robotomono_regular.ttf.h \ 26 | icons_font_awesome.ttf.h \ 27 | icons_kenney.ttf.h 28 | 29 | rebuild: fonts 30 | @make -s --no-print-directory clean all 31 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/bgfx_imgui/scintilla.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2018 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE 4 | */ 5 | 6 | #ifndef SCINTILLA_H_HEADER_GUARD 7 | #define SCINTILLA_H_HEADER_GUARD 8 | 9 | #if defined(SCI_NAMESPACE) 10 | 11 | #include 12 | 13 | struct ScintillaEditor 14 | { 15 | static ScintillaEditor* create(int _width, int _height); 16 | static void destroy(ScintillaEditor* _scintilla); 17 | 18 | intptr_t command(unsigned int _message, uintptr_t _p0 = 0, intptr_t _p1 = 0); 19 | void draw(); 20 | }; 21 | 22 | ScintillaEditor* ImGuiScintilla(const char* _name, bool* _opened, const ImVec2& _size); 23 | 24 | #endif // defined(SCI_NAMESPACE) 25 | 26 | #endif // SCINTILLA_H_HEADER_GUARD 27 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/bgfx_imgui/varying.def.sc: -------------------------------------------------------------------------------- 1 | vec4 v_color0 : COLOR0 = vec4(1.0, 0.0, 0.0, 1.0); 2 | vec3 v_normal : NORMAL = vec3(0.0, 0.0, 1.0); 3 | vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0); 4 | 5 | vec3 a_position : POSITION; 6 | vec4 a_normal : NORMAL; 7 | vec4 a_color0 : COLOR0; 8 | vec2 a_texcoord0 : TEXCOORD0; 9 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/bgfx_imgui/vs_imgui_color.sc: -------------------------------------------------------------------------------- 1 | $input a_position, a_color0 2 | $output v_color0 3 | 4 | /* 5 | * Copyright 2011-2018 Branimir Karadzic. All rights reserved. 6 | * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 7 | */ 8 | 9 | #include 10 | 11 | void main() 12 | { 13 | gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0) ); 14 | v_color0 = a_color0; 15 | } 16 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/bgfx_imgui/vs_imgui_cubemap.sc: -------------------------------------------------------------------------------- 1 | $input a_position, a_normal 2 | $output v_normal 3 | 4 | /* 5 | * Copyright 2011-2018 Branimir Karadzic. All rights reserved. 6 | * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 7 | */ 8 | 9 | #include 10 | 11 | void main() 12 | { 13 | gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) ); 14 | v_normal = a_normal.xyz; 15 | } 16 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/bgfx_imgui/vs_imgui_image.sc: -------------------------------------------------------------------------------- 1 | $input a_position, a_texcoord0 2 | $output v_texcoord0 3 | 4 | /* 5 | * Copyright 2014 Dario Manesku. All rights reserved. 6 | * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 7 | */ 8 | 9 | #include 10 | 11 | void main() 12 | { 13 | gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0) ); 14 | v_texcoord0 = a_texcoord0; 15 | } 16 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/bgfx_imgui/vs_imgui_latlong.sc: -------------------------------------------------------------------------------- 1 | $input a_position, a_texcoord0 2 | $output v_texcoord0 3 | 4 | /* 5 | * Copyright 2015 Dario Manesku. All rights reserved. 6 | * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 7 | */ 8 | 9 | #include 10 | 11 | void main() 12 | { 13 | gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) ); 14 | v_texcoord0 = a_texcoord0; 15 | } 16 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/bgfx_imgui/vs_imgui_texture.sc: -------------------------------------------------------------------------------- 1 | $input a_position, a_texcoord0, a_color0 2 | $output v_texcoord0, v_color0 3 | 4 | /* 5 | * Copyright 2011-2018 Branimir Karadzic. All rights reserved. 6 | * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause 7 | */ 8 | 9 | #include 10 | 11 | void main() 12 | { 13 | gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0) ); 14 | v_texcoord0 = a_texcoord0; 15 | v_color0 = a_color0; 16 | } 17 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/bgfx_imgui/vs_ocornut_imgui.sc: -------------------------------------------------------------------------------- 1 | $input a_position, a_texcoord0, a_color0 2 | $output v_color0, v_texcoord0 3 | 4 | #include "../common.sh" 5 | 6 | void main() 7 | { 8 | vec2 pos = 2.0*a_position.xy*u_viewTexel.xy; 9 | gl_Position = vec4(pos.x - 1.0, 1.0 - pos.y, 0.0, 1.0); 10 | v_texcoord0 = a_texcoord0; 11 | v_color0 = a_color0; 12 | } 13 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/iconfontheaders/.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | 5 | # C extensions 6 | *.so 7 | 8 | # Distribution / packaging 9 | .Python 10 | env/ 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | *.egg-info/ 23 | .installed.cfg 24 | *.egg 25 | 26 | # PyInstaller 27 | # Usually these files are written by a python script from a template 28 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 29 | *.manifest 30 | *.spec 31 | 32 | # Installer logs 33 | pip-log.txt 34 | pip-delete-this-directory.txt 35 | 36 | # Unit test / coverage reports 37 | htmlcov/ 38 | .tox/ 39 | .coverage 40 | .coverage.* 41 | .cache 42 | nosetests.xml 43 | coverage.xml 44 | *,cover 45 | 46 | # Translations 47 | *.mo 48 | *.pot 49 | 50 | # Django stuff: 51 | *.log 52 | 53 | # Sphinx documentation 54 | docs/_build/ 55 | 56 | # PyBuilder 57 | target/ 58 | .idea/ 59 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/iconfontheaders/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Juliette Foucaut 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/ocornut-imgui/imgui_user.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace ImGui 5 | { 6 | struct Font 7 | { 8 | enum Enum 9 | { 10 | Regular, 11 | Mono, 12 | 13 | Count 14 | }; 15 | }; 16 | 17 | void PushFont(Font::Enum _font); 18 | 19 | // BK - simple string class for convenience. 20 | class ImString 21 | { 22 | public: 23 | ImString(); 24 | ImString(const ImString& rhs); 25 | ImString(const char* rhs); 26 | ~ImString(); 27 | 28 | ImString& operator=(const ImString& rhs); 29 | ImString& operator=(const char* rhs); 30 | 31 | void Clear(); 32 | bool IsEmpty() const; 33 | 34 | const char* CStr() const 35 | { 36 | return NULL == Ptr ? "" : Ptr; 37 | } 38 | 39 | private: 40 | char* Ptr; 41 | }; 42 | 43 | } // namespace ImGui 44 | 45 | #include "cetech/debugui/private/ocornut-imgui/widgets/color_picker.h" 46 | #include "cetech/debugui/private/ocornut-imgui/widgets/color_wheel.h" 47 | #include "cetech/debugui/private/ocornut-imgui/widgets/dock.h" 48 | #include "cetech/debugui/private/ocornut-imgui/widgets/file_list.h" 49 | #include "cetech/debugui/private/ocornut-imgui/widgets/gizmo.h" 50 | #include "cetech/debugui/private/ocornut-imgui/widgets/memory_editor.h" 51 | #include "cetech/debugui/private/ocornut-imgui/widgets/range_slider.h" 52 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/ocornut-imgui/imgui_user.inl: -------------------------------------------------------------------------------- 1 | namespace ImGui 2 | { 3 | ImString::ImString() 4 | : Ptr(NULL) 5 | { 6 | } 7 | 8 | ImString::ImString(const ImString& rhs) 9 | : Ptr(NULL) 10 | { 11 | if (NULL != rhs.Ptr 12 | && 0 != strcmp(rhs.Ptr, "")) 13 | { 14 | Ptr = ImStrdup(rhs.Ptr); 15 | } 16 | } 17 | 18 | ImString::ImString(const char* rhs) 19 | : Ptr(NULL) 20 | { 21 | if (NULL != rhs 22 | && 0 != strcmp(rhs, "")) 23 | { 24 | Ptr = ImStrdup(rhs); 25 | } 26 | } 27 | 28 | ImString::~ImString() 29 | { 30 | Clear(); 31 | } 32 | 33 | ImString& ImString::operator=(const ImString& rhs) 34 | { 35 | if (this != &rhs) 36 | { 37 | *this = rhs.Ptr; 38 | } 39 | 40 | return *this; 41 | } 42 | 43 | ImString& ImString::operator=(const char* rhs) 44 | { 45 | if (Ptr != rhs) 46 | { 47 | Clear(); 48 | 49 | if (NULL != rhs 50 | && 0 != strcmp(rhs, "")) 51 | { 52 | Ptr = ImStrdup(rhs); 53 | } 54 | } 55 | 56 | return *this; 57 | } 58 | 59 | void ImString::Clear() 60 | { 61 | if (NULL != Ptr) 62 | { 63 | MemFree(Ptr); 64 | Ptr = NULL; 65 | } 66 | } 67 | 68 | bool ImString::IsEmpty() const 69 | { 70 | return NULL == Ptr; 71 | } 72 | } // namespace 73 | 74 | #include "cetech/debugui/private/ocornut-imgui/widgets/color_picker.inl" 75 | #include "cetech/debugui/private/ocornut-imgui/widgets/color_wheel.inl" 76 | #include "cetech/debugui/private/ocornut-imgui/widgets/dock.inl" 77 | #include "cetech/debugui/private/ocornut-imgui/widgets/file_list.inl" 78 | #include "cetech/debugui/private/ocornut-imgui/widgets/gizmo.inl" 79 | #include "cetech/debugui/private/ocornut-imgui/widgets/memory_editor.inl" 80 | #include "cetech/debugui/private/ocornut-imgui/widgets/range_slider.inl" 81 | 82 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/ocornut-imgui/stb_rect_pack.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/ocornut-imgui/stb_textedit.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/ocornut-imgui/stb_truetype.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/ocornut-imgui/widgets/color_picker.h: -------------------------------------------------------------------------------- 1 | namespace ImGui 2 | { 3 | bool ColorPicker4(float* col, bool show_alpha); 4 | bool ColorPicker3(float col[3]); 5 | 6 | inline bool ColorEdit4(const char* label, uint32_t* _rgba, bool show_alpha = true) 7 | { 8 | uint8_t* rgba = (uint8_t*)_rgba; 9 | float col[4] = 10 | { 11 | rgba[0]/255.0f, 12 | rgba[1]/255.0f, 13 | rgba[2]/255.0f, 14 | rgba[3]/255.0f, 15 | }; 16 | bool result = ColorEdit4(label, col, show_alpha); 17 | rgba[0] = uint8_t(col[0]*255.0f); 18 | rgba[1] = uint8_t(col[1]*255.0f); 19 | rgba[2] = uint8_t(col[2]*255.0f); 20 | rgba[3] = uint8_t(col[3]*255.0f); 21 | return result; 22 | } 23 | 24 | } // namespace ImGui 25 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/ocornut-imgui/widgets/color_wheel.h: -------------------------------------------------------------------------------- 1 | namespace ImGui 2 | { 3 | void ColorWheel(const char* _text, float* _rgba, float _size); 4 | 5 | void ColorWheel(const char* _text, uint32_t* _rgba, float _size); 6 | 7 | } // namespace ImGui 8 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/ocornut-imgui/widgets/color_wheel.inl: -------------------------------------------------------------------------------- 1 | namespace ImGui 2 | { 3 | void ColorWheel(const char* _text, float* _rgba, float _size) 4 | { 5 | (void)_size; 6 | ColorEdit4(_text 7 | , _rgba, 0 8 | | ImGuiColorEditFlags_PickerHueWheel 9 | | ImGuiColorEditFlags_Float 10 | ); 11 | } 12 | 13 | inline void decodeRgba(float* _dst, const uint32_t* _src) 14 | { 15 | uint8_t* src = (uint8_t*)_src; 16 | _dst[0] = float(src[0] / 255.0f); 17 | _dst[1] = float(src[1] / 255.0f); 18 | _dst[2] = float(src[2] / 255.0f); 19 | _dst[3] = float(src[3] / 255.0f); 20 | } 21 | 22 | inline void encodeRgba(uint32_t* _dst, const float* _src) 23 | { 24 | uint8_t* dst = (uint8_t*)_dst; 25 | dst[0] = uint8_t(_src[0] * 255.0); 26 | dst[1] = uint8_t(_src[1] * 255.0); 27 | dst[2] = uint8_t(_src[2] * 255.0); 28 | dst[3] = uint8_t(_src[3] * 255.0); 29 | } 30 | 31 | void ColorWheel(const char* _text, uint32_t* _rgba, float _size) 32 | { 33 | float rgba[4]; 34 | decodeRgba(rgba, _rgba); 35 | ColorWheel(_text, rgba, _size); 36 | encodeRgba(_rgba, rgba); 37 | } 38 | 39 | } // namespace ImGui 40 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/ocornut-imgui/widgets/dock.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace ImGui { 9 | /// 10 | IMGUI_API void InitDockContext(); 11 | 12 | /// 13 | IMGUI_API void ShutdownDockContext(); 14 | 15 | /// 16 | IMGUI_API void RootDock(const ImVec2 &pos, 17 | const ImVec2 &size); 18 | 19 | /// 20 | IMGUI_API bool BeginDock(const char *label, 21 | bool *opened = NULL, 22 | ImGuiWindowFlags extra_flags = 0); 23 | 24 | /// 25 | IMGUI_API void EndDock(); 26 | 27 | /// 28 | IMGUI_API void SetDockActive(); 29 | 30 | /// 31 | IMGUI_API void saveToYaml(char** buffer, ce_alloc_t0* alloc); 32 | 33 | IMGUI_API void loadFromYaml(const char *file, 34 | struct ce_ydb_a0 *ydb, 35 | struct ce_ydb_a0 *yng, struct ce_cdb_a0* cdb); 36 | 37 | } // namespace ImGui 38 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/ocornut-imgui/widgets/file_list.h: -------------------------------------------------------------------------------- 1 | namespace ImGui 2 | { 3 | struct ImFileInfo 4 | { 5 | ImFileInfo(const char* name, int64_t size); 6 | ~ImFileInfo(); 7 | 8 | ImString Name; 9 | int64_t Size; 10 | }; 11 | 12 | struct ImFileList 13 | { 14 | typedef ImVector FileInfoArray; 15 | FileInfoArray FileList; 16 | int Pos; 17 | 18 | ImFileList(const char* path = ".") 19 | : Pos(0) 20 | { 21 | ChDir(path); 22 | } 23 | 24 | void ChDir(const char* path); 25 | void Draw(); 26 | }; 27 | 28 | } // namespace ImGui 29 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/ocornut-imgui/widgets/file_list.inl: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | namespace ImGui 6 | { 7 | ImFileInfo::ImFileInfo(const char* name, int64_t size) 8 | : Name(name) 9 | , Size(size) 10 | { 11 | } 12 | 13 | ImFileInfo::~ImFileInfo() 14 | { 15 | } 16 | 17 | void ImFileList::ChDir(const char* path) 18 | { 19 | #if BX_PLATFORM_PS4 20 | BX_UNUSED(path); 21 | #else 22 | DIR* dir = opendir(path); 23 | if (NULL != dir) 24 | { 25 | FileList.clear(); 26 | 27 | for (dirent* item = readdir(dir); NULL != item; item = readdir(dir) ) 28 | { 29 | if (0 == ImStricmp(item->d_name, "..") ) 30 | { 31 | FileList.push_back(ImFileInfo(item->d_name, -1) ); 32 | } 33 | else if (0 != ImStricmp(item->d_name, ".") ) 34 | { 35 | if (item->d_type & DT_DIR) 36 | { 37 | FileList.push_back(ImFileInfo(item->d_name, -1) ); 38 | } 39 | else 40 | { 41 | struct stat statbuf; 42 | stat(item->d_name, &statbuf); 43 | FileList.push_back(ImFileInfo(item->d_name, statbuf.st_size) ); 44 | } 45 | } 46 | } 47 | 48 | closedir(dir); 49 | } 50 | #endif // BX_PLATFORM_PS4 51 | } 52 | 53 | void ImFileList::Draw() 54 | { 55 | BeginChild("##file_list", ImVec2(0.0f, 0.0f) ); 56 | PushFont(Font::Mono); 57 | 58 | PushItemWidth(-1); 59 | if (ListBoxHeader("##empty", ImVec2(0.0f, 0.0f) ) ) 60 | { 61 | const float lineHeight = GetTextLineHeightWithSpacing(); 62 | 63 | ImString chdir; 64 | 65 | int pos = 0; 66 | ImGuiListClipper clipper(FileList.size(), lineHeight); 67 | for (FileInfoArray::const_iterator it = FileList.begin(), itEnd = FileList.end() 68 | ; it != itEnd 69 | ; ++it 70 | ) 71 | { 72 | if (pos >= clipper.DisplayStart 73 | && pos < clipper.DisplayEnd) 74 | { 75 | PushID(pos); 76 | 77 | const bool isDir = -1 == it->Size; 78 | bool isSelected = Pos == pos; 79 | 80 | bool clicked = Selectable(it->Name.CStr(), &isSelected); 81 | SameLine(150); 82 | if (isDir) 83 | { 84 | Text("%10s", ""); 85 | } 86 | else 87 | { 88 | Text("%10" PRId64, it->Size); 89 | } 90 | 91 | if (clicked) 92 | { 93 | if (0 == strcmp(it->Name.CStr(), "..") ) 94 | { 95 | chdir = it->Name; 96 | } 97 | 98 | Pos = pos; 99 | 100 | if (isDir) 101 | { 102 | chdir = it->Name; 103 | } 104 | } 105 | 106 | PopID(); 107 | } 108 | ++pos; 109 | } 110 | clipper.End(); 111 | 112 | ListBoxFooter(); 113 | 114 | if (!chdir.IsEmpty() ) 115 | { 116 | ChDir(chdir.CStr() ); 117 | } 118 | } 119 | 120 | PopFont(); 121 | EndChild(); 122 | } 123 | 124 | } // namespace ImGui 125 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/ocornut-imgui/widgets/memory_editor.h: -------------------------------------------------------------------------------- 1 | namespace ImGui 2 | { 3 | struct MemoryEditor 4 | { 5 | bool AllowEdits; 6 | bool HexII; 7 | int Rows; 8 | int DataEditingAddr; 9 | bool DataEditingTakeFocus; 10 | char DataInput[32]; 11 | char AddrInput[32]; 12 | 13 | MemoryEditor() 14 | { 15 | AllowEdits = true; 16 | HexII = true; 17 | Rows = 16; 18 | DataEditingAddr = -1; 19 | DataEditingTakeFocus = false; 20 | strcpy(DataInput, ""); 21 | strcpy(AddrInput, ""); 22 | } 23 | 24 | void Draw(void* mem_data, int mem_size, int base_display_addr = 0); 25 | void Draw(const void* mem_data, int mem_size, int base_display_addr = 0); 26 | }; 27 | } // namespace ImGui 28 | -------------------------------------------------------------------------------- /src/cetech/debugui/private/ocornut-imgui/widgets/range_slider.h: -------------------------------------------------------------------------------- 1 | namespace ImGui 2 | { 3 | IMGUI_API bool RangeSliderFloat(const char* label, float* v1, float* v2, float v_min, float v_max, const char* display_format = "(%.3f, %.3f)", float power = 1.0f); 4 | 5 | } // namespace ImGui 6 | -------------------------------------------------------------------------------- /src/cetech/default_rg/default_rg.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_DEFAULT_RENDER_GRAPH_H 2 | #define CETECH_DEFAULT_RENDER_GRAPH_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | #define CT_DEFAULT_RG_API \ 11 | CE_ID64_0("ct_default_rg_a0", 0xe909f984404895b4ULL) 12 | 13 | typedef struct ct_rg_module_t0 ct_rg_module; 14 | typedef struct ct_world_t0 ct_world_t0; 15 | 16 | #define _GBUFFER \ 17 | CE_ID64_0("gbuffer", 0xc0d9fff4f568ebfdULL) 18 | 19 | #define _DEFAULT \ 20 | CE_ID64_0("default", 0xf27605035974b5ecULL) 21 | 22 | #define _COLOR \ 23 | CE_ID64_0("color", 0x6776ddaf0290228ULL) 24 | 25 | #define _DEPTH \ 26 | CE_ID64_0("depth", 0x911ffdcbfa56fec1ULL) 27 | 28 | 29 | struct ct_default_rg_a0 { 30 | void (*feed_module)(ct_rg_module_t0 *m); 31 | }; 32 | 33 | #ifdef __cplusplus 34 | }; 35 | #endif 36 | 37 | CE_MODULE(ct_default_rg_a0); 38 | 39 | #endif //CETECH_DEFAULT_RENDER_GRAPH_H 40 | -------------------------------------------------------------------------------- /src/cetech/editor/action_manager.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_ACTION_MANAGER_H 2 | #define CETECH_ACTION_MANAGER_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | #define CT_ACTION_MANAGER_API \ 12 | CE_ID64_0("ct_action_manager_a0", 0xcdad2ddf745f6c55ULL) 13 | 14 | struct ct_action_manager_a0 { 15 | void (*register_action)(uint64_t name, 16 | const char *shortcut, 17 | void (*fce)()); 18 | 19 | void (*unregister_action)(uint64_t name); 20 | 21 | const char *(*shortcut_str)(uint64_t name); 22 | 23 | void (*execute)(uint64_t name); 24 | 25 | void (*check)(); 26 | }; 27 | 28 | CE_MODULE(ct_action_manager_a0); 29 | 30 | #ifdef __cplusplus 31 | }; 32 | #endif 33 | 34 | #endif //CETECH_ACTION_MANAGER_H 35 | -------------------------------------------------------------------------------- /src/cetech/editor/dock.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_DOCK_H 2 | #define CETECH_DOCK_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | #define CT_DOCK_API \ 12 | CE_ID64_0("ct_dock_a0", 0x90cc2a5b4273931aULL) 13 | 14 | #define CT_DOCK_I \ 15 | CE_ID64_0("ct_dock_i0", 0x3a3181c12a9e109fULL) 16 | 17 | #define PROP_DOCK_DATA \ 18 | CE_ID64_0("dock_data", 0x944132def1f8c765ULL) 19 | 20 | #define DOCKS_LAYOUT_TYPE \ 21 | CE_ID64_0("docks_layout", 0x7336aa61594d9ff9ULL) 22 | 23 | #define DOCK_LAYOUT_TYPE \ 24 | CE_ID64_0("dock_layout", 0x4e4af47b58821c36ULL) 25 | 26 | #define DOCK_DOCKS \ 27 | CE_ID64_0("docks", 0xf9937f250674149ULL) 28 | 29 | #define DOCK_INDEX \ 30 | CE_ID64_0("index", 0xb03b8bced9422c44ULL) 31 | 32 | #define DOCK_LABEL \ 33 | CE_ID64_0("label", 0x29f0c34fda4b3acfULL) 34 | 35 | #define DOCK_LOCATION \ 36 | CE_ID64_0("location", 0x104249e36e86d778ULL) 37 | 38 | #define DOCK_X \ 39 | CE_ID64_0("x", 0x8295151af8224269ULL) 40 | 41 | #define DOCK_Y \ 42 | CE_ID64_0("y", 0x9a5db2cd2c1fd6ceULL) 43 | 44 | #define DOCK_SIZE_X \ 45 | CE_ID64_0("size_x", 0xacc8adbd22d2416bULL) 46 | 47 | #define DOCK_SIZE_Y \ 48 | CE_ID64_0("size_y", 0x1211758e2a991897ULL) 49 | 50 | #define DOCK_STATUS \ 51 | CE_ID64_0("status", 0xcdb5c90212e5367fULL) 52 | 53 | #define DOCK_ACTIVE \ 54 | CE_ID64_0("active", 0xb19ad128fab64ca4ULL) 55 | 56 | #define DOCK_OPENED \ 57 | CE_ID64_0("opened", 0xa33c08a6d3dc9422ULL) 58 | 59 | #define DOCK_PREV \ 60 | CE_ID64_0("prev", 0x29ec8f894c44aa64ULL) 61 | 62 | #define DOCK_NEXT \ 63 | CE_ID64_0("next", 0x278440c8fcb56970ULL) 64 | 65 | #define DOCK_CHILD0 \ 66 | CE_ID64_0("child0", 0x689ee2e497b819b4ULL) 67 | 68 | #define DOCK_CHILD1 \ 69 | CE_ID64_0("child1", 0xdec55fcd7f7396daULL) 70 | 71 | #define DOCK_PARENT \ 72 | CE_ID64_0("parent", 0xc46a4b4368e0f801ULL) 73 | 74 | typedef struct ct_dock_i0 { 75 | uint64_t type; 76 | 77 | uint64_t (*ui_flags)(); 78 | 79 | uint64_t (*open)(); 80 | 81 | void (*close)(uint64_t content, 82 | uint64_t context); 83 | 84 | const char *(*name)(); 85 | 86 | const char *(*display_title)(uint64_t content, 87 | uint64_t selected_object); 88 | 89 | void (*draw_ui)(uint64_t content, 90 | uint64_t context, 91 | uint64_t selected_object); 92 | 93 | void (*draw_menu)(uint64_t content, 94 | uint64_t context, 95 | uint64_t selected_object); 96 | 97 | void (*draw_main_menu)(uint64_t content); 98 | } ct_dock_i0; 99 | 100 | 101 | struct ct_dock_a0 { 102 | void (*create_dock)(uint64_t type, 103 | bool visible); 104 | 105 | void (*draw_all)(); 106 | 107 | void (*draw_menu)(); 108 | }; 109 | 110 | CE_MODULE(ct_dock_a0); 111 | 112 | #ifdef __cplusplus 113 | }; 114 | #endif 115 | 116 | #endif //CETECH_DOCK_H 117 | -------------------------------------------------------------------------------- /src/cetech/editor/editor.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_PLAYGROUND_H 2 | #define CETECH_PLAYGROUND_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | #define CT_EDITOR_MODULE_I \ 12 | CE_ID64_0("ct_editor_module_i0", 0x761dbf8cf91061a1ULL) 13 | 14 | #define CT_EDITOR_TASK \ 15 | CE_ID64_0("editor_task", 0x5eb9f56061f23532ULL) 16 | 17 | typedef struct ct_editor_module_i0 { 18 | bool (*init)(); 19 | 20 | bool (*shutdown)(); 21 | 22 | void (*draw_menu)(); 23 | 24 | void (*update)(float dt); 25 | 26 | } ct_editor_module_i0; 27 | 28 | #ifdef __cplusplus 29 | }; 30 | #endif 31 | 32 | #endif //CETECH_PLAYGROUND_H 33 | -------------------------------------------------------------------------------- /src/cetech/editor/selcted_object.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_SELECTED_OBJECT_H 2 | #define CETECH_SELECTED_OBJECT_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | #define CT_SELECTED_OBJECT_API \ 11 | CE_ID64_0("ct_selected_object_a0", 0x9ea58b4cfb24327cULL) 12 | 13 | 14 | struct ct_selected_object_a0 { 15 | void (*set_selected_object)(uint64_t context, 16 | uint64_t obj); 17 | 18 | uint64_t (*selected_object)(uint64_t context); 19 | 20 | void (*set_previous)(uint64_t context); 21 | 22 | void (*set_next)(uint64_t context); 23 | 24 | bool (*has_previous)(uint64_t context); 25 | 26 | bool (*has_next)(uint64_t context); 27 | }; 28 | 29 | CE_MODULE(ct_selected_object_a0); 30 | 31 | #ifdef __cplusplus 32 | }; 33 | #endif 34 | 35 | #endif //CETECH_SELECTED_OBJECT_H 36 | -------------------------------------------------------------------------------- /src/cetech/explorer/explorer.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_EXPLORER_H 2 | #define CETECH_EXPLORER_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | #define CT_EXPLORER_I \ 11 | CE_ID64_0("ct_explorer_i0", 0xdaa9b6ac2664c06dULL) 12 | 13 | typedef struct ct_explorer_i0 { 14 | uint64_t (*cdb_type)(); 15 | 16 | uint64_t (*draw_ui)(uint64_t top_level_obj, 17 | uint64_t selected_obj, 18 | uint64_t context); 19 | 20 | void (*draw_menu)(uint64_t selected_obj, 21 | uint64_t context); 22 | } ct_explorer_i0; 23 | 24 | #ifdef __cplusplus 25 | }; 26 | #endif 27 | 28 | #endif //CETECH_EXPLORER_H 29 | -------------------------------------------------------------------------------- /src/cetech/game/game_system.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_GAME_H 2 | #define CETECH_GAME_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | #define CT_GAME_SYSTEM_API \ 11 | CE_ID64_0("ct_game_system_a0", 0x1a5b2ed4808612b9ULL) 12 | 13 | #define CT_GAME_I \ 14 | CE_ID64_0("ct_game_i0", 0x22500b95a05f8b37ULL) 15 | 16 | #define CT_GAME_TASK \ 17 | CE_ID64_0("game_task", 0x56c73acaa12b1278ULL) 18 | 19 | typedef struct ct_rg_builder_t0 ct_rg_builder_t0; 20 | typedef struct ct_viewport_t0 ct_viewport_t0; 21 | 22 | typedef struct ct_game_i0 { 23 | uint64_t (*name)(); 24 | 25 | void (*init)(ct_world_t0 world); 26 | 27 | void (*shutdown)(ct_world_t0 world); 28 | 29 | void (*update)(ct_world_t0 world, 30 | float dt); 31 | } ct_game_i0; 32 | 33 | struct ct_game_system_a0 { 34 | ct_world_t0 (*world)(); 35 | 36 | void (*pause)(); 37 | 38 | bool (*is_paused)(); 39 | 40 | void (*play)(); 41 | 42 | void (*step)(float dt); 43 | }; 44 | 45 | CE_MODULE(ct_game_system_a0); 46 | 47 | #ifdef __cplusplus 48 | }; 49 | #endif 50 | 51 | #endif //CETECH_GAME_H 52 | -------------------------------------------------------------------------------- /src/cetech/game/game_view.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_GAME_VIEW_H 2 | #define CETECH_GAME_VIEW_H 3 | 4 | #include 5 | #include 6 | 7 | #endif //CETECH_GAME_VIEW_H 8 | -------------------------------------------------------------------------------- /src/cetech/kernel/kernel.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_KERNEL_H 2 | #define CETECH_KERNEL_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define CT_KERNEL_API \ 9 | CE_ID64_0("ct_kernel_a0", 0xdb873264c27eedf3ULL) 10 | 11 | #define CONFIG_PLATFORM \ 12 | CE_ID64_0("kernel.platform", 0xa2e788cf39b7339bULL) 13 | 14 | #define CONFIG_NATIVE_PLATFORM \ 15 | CE_ID64_0("kernel.native_platform", 0xede1e0cf393fc17eULL) 16 | 17 | #define CONFIG_BOOT_ENT \ 18 | CE_ID64_0("core.boot_ent", 0x111eabf289640feeULL) 19 | 20 | #define CONFIG_GAME \ 21 | CE_ID64_0("game", 0x8a426cdbe2604989ULL) 22 | 23 | #define SOURCE_ROOT \ 24 | CE_ID64_0("source", 0x921f1370045bad6eULL) 25 | 26 | #define BUILD_ROOT \ 27 | CE_ID64_0("build", 0x4429661936ece1eaULL) 28 | 29 | #define CT_INPUT_TASK \ 30 | CE_ID64_0("input_task", 0xba6140c0d9e00706ULL) 31 | 32 | #define CT_KERNEL_TASK_I \ 33 | CE_ID64_0("ct_kernel_task_i0", 0xc47eec37e164c0a7ULL) 34 | 35 | #define _KERNEL_LIST(...) (uint64_t[]){__VA_ARGS__} 36 | #define _KERNEL_LIST_SIZE(list) (sizeof(list) / sizeof(list[0])) 37 | 38 | #define CT_KERNEL_BEFORE(...) \ 39 | ((ce_ptr_pair_t0){.ptr=&_KERNEL_LIST(__VA_ARGS__),.len=_KERNEL_LIST_SIZE(_KERNEL_LIST(__VA_ARGS__))}) 40 | 41 | #define CT_KERNEL_AFTER(...) \ 42 | ((ce_ptr_pair_t0){.ptr=&_KERNEL_LIST(__VA_ARGS__),.len=_KERNEL_LIST_SIZE(_KERNEL_LIST(__VA_ARGS__))}) 43 | 44 | typedef void (*ce_kernel_taks_update_t)(float dt); 45 | 46 | typedef void (*ce_kernel_taks_init_t)(); 47 | 48 | typedef void (*ce_kernel_taks_shutdown_t)(); 49 | 50 | typedef struct ct_kernel_task_i0 { 51 | uint64_t name; 52 | 53 | ce_ptr_pair_t0 update_before; 54 | ce_ptr_pair_t0 update_after; 55 | 56 | ce_ptr_pair_t0 init_before; 57 | ce_ptr_pair_t0 init_after; 58 | 59 | void (*update)(float dt); 60 | 61 | void (*init)(); 62 | 63 | void (*shutdown)(); 64 | } ct_kernel_task_i0; 65 | 66 | struct ct_kernel_a0 { 67 | void (*quit)(); 68 | }; 69 | 70 | 71 | CE_MODULE(ct_kernel_a0); 72 | 73 | #ifdef __cplusplus 74 | }; 75 | #endif 76 | 77 | #endif //CETECH_KERNEL_H 78 | -------------------------------------------------------------------------------- /src/cetech/log_view/log_view.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_LOG_VIEW_H 2 | #define CETECH_LOG_VIEW_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "../../celib/celib_types.h" 9 | 10 | #define LOG_VIEW \ 11 | CE_ID64_0("log_view", 0x6cb70528dcc6bdebULL) 12 | 13 | #ifdef __cplusplus 14 | }; 15 | #endif 16 | 17 | #endif //CETECH_LOG_VIEW_H 18 | -------------------------------------------------------------------------------- /src/cetech/mesh/primitive_mesh.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_PRIMITIVE_MESH_H 2 | #define CETECH_PRIMITIVE_MESH_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | typedef struct ct_primitive_mesh { 11 | uint64_t material; 12 | } ct_primitive_mesh_c; 13 | 14 | 15 | #define PRIMITIVE_MESH_COMPONENT \ 16 | CE_ID64_0("primitive_mesh", 0x41994de0b780f885ULL) 17 | 18 | #define PRIMITIVE_MESH_MATERIAL_PROP \ 19 | CE_ID64_0("material", 0xeac0b497876adedfULL) 20 | 21 | #ifdef __cplusplus 22 | }; 23 | #endif 24 | 25 | #endif //CETECH_PRIMITIVE_MESH_H -------------------------------------------------------------------------------- /src/cetech/mesh/static_mesh.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_MESH_RENDERER_H 2 | #define CETECH_MESH_RENDERER_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | typedef struct ct_mesh_component { 11 | uint64_t material; 12 | uint64_t scene; 13 | uint64_t node; 14 | uint64_t mesh; 15 | } ct_mesh_component; 16 | 17 | #define STATIC_MESH_COMPONENT \ 18 | CE_ID64_0("static_mesh", 0x7445bff74058f566ULL) 19 | 20 | #define PROP_SCENE_ID \ 21 | CE_ID64_0("scene", 0x9d0a795bfe818d19ULL) 22 | 23 | #define PROP_MATERIAL \ 24 | CE_ID64_0("material", 0xeac0b497876adedfULL) 25 | 26 | #define PROP_NODE \ 27 | CE_ID64_0("node", 0x5ae0930b5138a928ULL) 28 | 29 | #define PROP_MESH \ 30 | CE_ID64_0("mesh", 0x48ff313713a997a1ULL) 31 | 32 | #ifdef __cplusplus 33 | }; 34 | #endif 35 | 36 | #endif //CETECH_MESH_RENDERER_H -------------------------------------------------------------------------------- /src/cetech/metrics/metrics.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_METRICS_H 2 | #define CETECH_METRICS_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | #define CT_METRICS_API \ 11 | CE_ID64_0("ct_metrics_a0", 0xcb85cc37c965043ULL) 12 | 13 | struct ct_metrics_a0 { 14 | void (*begin)(); 15 | 16 | void (*end)(); 17 | 18 | void (*reg_float_metric)(const char *name); 19 | 20 | void (*clear_record)(); 21 | void (*start_record)(); 22 | void (*stop_record)(); 23 | bool (*is_recording)(); 24 | 25 | uint32_t (*recorded_frames_num)(); 26 | 27 | void (*set_float)(uint64_t name, 28 | float value); 29 | 30 | float (*get_float)(uint64_t name); 31 | 32 | const float *(*get_recorded_floats)(uint64_t name); 33 | }; 34 | 35 | CE_MODULE(ct_metrics_a0); 36 | 37 | #ifdef __cplusplus 38 | }; 39 | #endif 40 | 41 | #endif //CETECH_METRICS_H -------------------------------------------------------------------------------- /src/cetech/node_graph/node_graph.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_NODE_GRAPH_H 2 | #define CETECH_NODE_GRAPH_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | 11 | #define CT_NODE_GRAPH_API \ 12 | CE_ID64_0("ct_node_graph_a0", 0x83f8b5f2c9f24145ULL) 13 | 14 | #define CT_NODE_I \ 15 | CE_ID64_0("ct_node_i0", 0x31747424097dbbefULL) 16 | 17 | #define CT_NODE_GRAPH_RESOURCE \ 18 | CE_ID64_0("node_graph", 0xfdc584c720df8500ULL) 19 | 20 | #define CT_NODE_GRAPH_NODE \ 21 | CE_ID64_0("node_graph_node", 0xaad1c761f478e53aULL) 22 | 23 | #define CT_NODE_GRAPH_NODE_POS_X \ 24 | CE_ID64_0("position_x", 0xc8e333b60b9cb460ULL) 25 | 26 | #define CT_NODE_GRAPH_NODE_POS_Y \ 27 | CE_ID64_0("position_y", 0xe1984f910d0f8b91ULL) 28 | 29 | #define CT_NODE_GRAPH_NODE_SIZE_X \ 30 | CE_ID64_0("size_x", 0xacc8adbd22d2416bULL) 31 | 32 | #define CT_NODE_GRAPH_NODE_SIZE_Y \ 33 | CE_ID64_0("size_y", 0x1211758e2a991897ULL) 34 | 35 | 36 | #define CT_NODE_TYPE \ 37 | CE_ID64_0("type", 0xa21bd0e01ac8f01fULL) 38 | 39 | #define CT_NODE_GRAPH_NODES\ 40 | CE_ID64_0("nodes", 0x6ea600aa4b4a3195ULL) 41 | 42 | #define CT_NODE_GRAPH_CONNECTIONS\ 43 | CE_ID64_0("connections", 0x4970db49097daf8dULL) 44 | 45 | #define CT_NODE_GRAPH_NODE_INPUTS\ 46 | CE_ID64_0("inputs", 0x827c802bac814485ULL) 47 | 48 | #define CT_NODE_GRAPH_NODE_OUTPUTS\ 49 | CE_ID64_0("outputs", 0x8ac15af4f96392a6ULL) 50 | 51 | #define CT_NODE_GRAPH_CONN_FROM\ 52 | CE_ID64_0("from", 0x5b149b8e28f66e68ULL) 53 | 54 | #define CT_NODE_GRAPH_CONN_FROM_PIN\ 55 | CE_ID64_0("from_pin", 0xfaa1f325909fb075ULL) 56 | 57 | #define CT_NODE_GRAPH_CONN_TO\ 58 | CE_ID64_0("to", 0x9558f59f36417bc6ULL) 59 | 60 | #define CT_NODE_GRAPH_CONN_TO_PIN\ 61 | CE_ID64_0("to_pin", 0x56c235c40d1418d5ULL) 62 | 63 | typedef enum ct_node_pin_type_e0 { 64 | CT_NODE_PIN_NONE = 0, 65 | CT_NODE_PIN_FLOAT, 66 | CT_NODE_PIN_STRING, 67 | CT_NODE_PIN_BOOL, 68 | } ct_node_pin_type_e0; 69 | 70 | typedef struct ct_node_pin_def { 71 | enum ct_node_pin_type_e0 type; 72 | const char *name; 73 | uint64_t prop; 74 | } ct_node_pin_def; 75 | 76 | typedef struct ct_node_i0 { 77 | uint64_t (*type)(); 78 | 79 | void *(*get_interface)(uint64_t name_hash); 80 | 81 | const ct_node_pin_def *(*input_defs)(uint32_t *n); 82 | 83 | const ct_node_pin_def *(*output_defs)(uint32_t *n); 84 | 85 | } ct_node_i0; 86 | 87 | struct ct_node_graph_a0 { 88 | ct_node_i0 *(*get_interface)(uint64_t type); 89 | }; 90 | 91 | CE_MODULE(ct_node_graph_a0); 92 | 93 | #ifdef __cplusplus 94 | }; 95 | #endif 96 | 97 | #endif //CETECH_NODE_GRAPH_H 98 | -------------------------------------------------------------------------------- /src/cetech/node_graph/private/node_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "../node_graph.h" 10 | 11 | #define _G node_test_globals 12 | static struct _G { 13 | ce_alloc_t0 *allocator; 14 | } _G; 15 | 16 | 17 | static const char *display_name() { 18 | return "Test node"; 19 | } 20 | 21 | 22 | struct ct_editor_node_i0 editor_node_i0 = { 23 | .display_name = display_name, 24 | }; 25 | 26 | 27 | static uint64_t cdb_type() { 28 | return ce_id_a0->id64("node_test"); 29 | } 30 | 31 | static void *get_interface(uint64_t name_hash) { 32 | if (name_hash == CT_EDITOR_NODE_I) { 33 | return &editor_node_i0; 34 | } 35 | return NULL; 36 | } 37 | 38 | #define _PROP_IN1\ 39 | CE_ID64_0("in_1", 0xd357f354a0ff6e1dULL) 40 | 41 | #define _PROP_IN2\ 42 | CE_ID64_0("in_2", 0x9ff9657cbc3c26abULL) 43 | 44 | #define _PROP_IN3\ 45 | CE_ID64_0("in_3", 0xc32c0532c5479e19ULL) 46 | 47 | #define _PROP_IN4\ 48 | CE_ID64_0("in_4", 0x8782c563666f2d2cULL) 49 | 50 | const struct ct_node_pin_def *input_defs(uint32_t *n) { 51 | static struct ct_node_pin_def def[] = { 52 | {.name= "IN 1", .type = CT_NODE_PIN_FLOAT, .prop = _PROP_IN1}, 53 | {.name= "IN 2", .type = CT_NODE_PIN_STRING, .prop = _PROP_IN2}, 54 | {.name= "IN 3", .type = CT_NODE_PIN_BOOL, .prop = _PROP_IN3}, 55 | }; 56 | 57 | *n = CE_ARRAY_LEN(def); 58 | return def; 59 | } 60 | 61 | const struct ct_node_pin_def *output_defs(uint32_t *n) { 62 | static struct ct_node_pin_def def[] = { 63 | {.name= "OUT 1", .type = CT_NODE_PIN_FLOAT}, 64 | {.name= "OUT 2", .type = CT_NODE_PIN_FLOAT}, 65 | {.name= "OUT 3", .type = CT_NODE_PIN_STRING}, 66 | }; 67 | 68 | *n = CE_ARRAY_LEN(def); 69 | return def; 70 | } 71 | 72 | struct ct_node_i0 node_i0 = { 73 | .type = cdb_type, 74 | .get_interface = get_interface, 75 | .input_defs = input_defs, 76 | .output_defs = output_defs, 77 | }; 78 | 79 | 80 | void CE_MODULE_LOAD (node_test)(struct ce_api_a0 *api, 81 | int reload) { 82 | CE_UNUSED(reload); 83 | 84 | _G = (struct _G) { 85 | .allocator = ce_memory_a0->system, 86 | }; 87 | 88 | api->add_impl(CT_NODE_I, &node_i0, sizeof(node_i0)); 89 | 90 | } 91 | 92 | void CE_MODULE_UNLOAD (node_test)(struct ce_api_a0 *api, 93 | int reload) { 94 | 95 | CE_UNUSED(api); 96 | } -------------------------------------------------------------------------------- /src/cetech/node_graph_editor/node_graph_editor.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_NODE_GRAPH_EDITOR_H 2 | #define CETECH_NODE_GRAPH_EDITOR_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | #define CT_NODE_GRAPH_EDITOR_API \ 11 | CE_ID64_0("ct_node_graph_editor_a0", 0xc13af81eb433e221ULL) 12 | 13 | 14 | #define CT_EDITOR_NODE_I \ 15 | CE_ID64_0("ct_editor_node_i0", 0x3cb5090f34945e9bULL) 16 | 17 | 18 | typedef struct ct_editor_node_i0 { 19 | const char *(*display_name)(); 20 | } ct_editor_node_i0; 21 | 22 | 23 | struct ct_node_graph_editor_a0 { 24 | void (*add_node_modal)(const char *modal_id, 25 | uint64_t obj); 26 | 27 | void (*draw_ng_editor)(uint64_t graph, 28 | uint64_t context); 29 | }; 30 | 31 | CE_MODULE(ct_node_graph_editor_a0); 32 | 33 | #ifdef __cplusplus 34 | }; 35 | #endif 36 | 37 | #endif //CETECH_NODE_GRAPH_EDITOR_H 38 | -------------------------------------------------------------------------------- /src/cetech/parent/parent.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_PARENT_H 2 | #define CETECH_PARENT_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | typedef struct ct_entity_t0 ct_entity_t0; 9 | 10 | #define CT_PARENT_SYSTEM \ 11 | CE_ID64_0("parent_system", 0xee0a3c196a1183d0ULL) 12 | 13 | #define CT_PARENT_COMPONENT \ 14 | CE_ID64_0("parent", 0xc46a4b4368e0f801ULL) 15 | 16 | #define CT_PREVIOUS_PARENT_COMPONENT \ 17 | CE_ID64_0("previous_parent", 0xa8164f5a3848444bULL) 18 | 19 | #define CT_CHILD_COMPONENT \ 20 | CE_ID64_0("child", 0x88d0eb1725682035ULL) 21 | 22 | typedef struct ct_parent_c { 23 | ct_entity_t0 parent; 24 | } ct_parent_c; 25 | 26 | typedef struct ct_previous_parent_c { 27 | ct_entity_t0 parent; 28 | } ct_previous_parent_c; 29 | 30 | typedef struct ct_child_c { 31 | ct_entity_t0 *child; 32 | } ct_child_c; 33 | 34 | #ifdef __cplusplus 35 | }; 36 | #endif 37 | 38 | #endif //CETECH_PARENT_H -------------------------------------------------------------------------------- /src/cetech/physics2d/physics2d.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_PHYSICS2D_H 2 | #define CETECH_PHYSICS2D_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | #define PHYSICS2D_GROUP \ 11 | CE_ID64_0("physics2d_group", 0x9ab6f3cfdc87fe30ULL) 12 | 13 | #define PHYSICS2D_SYSTEM \ 14 | CE_ID64_0("physics2d", 0x4fdc4a291d00e7f5ULL) 15 | 16 | #define CT_PHYSICS_A0 \ 17 | CE_ID64_0("ct_physics_a0", 0x3ef93fecf67b99b8ULL) 18 | 19 | // World 20 | #define PHYSICS_WORLD2D_COMPONENT \ 21 | CE_ID64_0("physics_world2d", 0xcaa7b937d52834fcULL) 22 | 23 | #define PHYSICS_WORLD2D_GRAVITY_PROP\ 24 | CE_ID64_0("gravity", 0xccf0648c76b2a8c2ULL) 25 | 26 | // Velocity 27 | #define VELOCITY2D_COMPONENT \ 28 | CE_ID64_0("velocity2d", 0x223ef3bf4e53ae66ULL) 29 | 30 | #define VELOCITY2D_LINEAR_PROP \ 31 | CE_ID64_0("linear", 0x4edd18565871c654ULL) 32 | 33 | #define VELOCITY2D_ANGULAR_PROP \ 34 | CE_ID64_0("angular", 0x73e2903632f8a84ULL) 35 | 36 | // MASS 37 | #define MASS2D_COMPONENT \ 38 | CE_ID64_0("mass2d", 0x8cb74b2aa7143c7bULL) 39 | 40 | #define MASS2D_PROP \ 41 | CE_ID64_0("mass", 0xa06fab7c958a7771ULL) 42 | 43 | // Collider 44 | #define COLLIDER2D_COMPONENT \ 45 | CE_ID64_0("collider2d", 0x412adb7f43ed22b8ULL) 46 | 47 | #define BODY2D_FRICTION_PROP \ 48 | CE_ID64_0("friction", 0xa99da7441f8b5e66ULL) 49 | 50 | #define BODY2D_RESTITUTION_PROP \ 51 | CE_ID64_0("restitution", 0x2f06ac1f350e7dbeULL) 52 | 53 | #define BODY2D_DENSITY_PROP \ 54 | CE_ID64_0("density", 0xca98f4e6f68d2c8dULL) 55 | 56 | #define BODY2D_IS_SENSOR_PROP \ 57 | CE_ID64_0("is_sensor", 0x1d97e62c01dac9c4ULL) 58 | 59 | #define PHYSICS_COLLIDER2D_SHAPE_PROP \ 60 | CE_ID64_0("shape", 0x3ef87fb905f6d51bULL) 61 | 62 | #define COLLIDER2D_RECTANGLE \ 63 | CE_ID64_0("collider2d_shape_rectangle", 0x5b61668f7f402343ULL) 64 | 65 | #define PHYSICS_COLLIDER2D_RECTANGLE_HALF_SIZE \ 66 | CE_ID64_0("half_size", 0xfae83ca4619fb60aULL) 67 | 68 | typedef struct ct_physics_world2d_c { 69 | ce_vec2_t gravity; 70 | } ct_physics_world2d_c; 71 | 72 | typedef struct ct_velocity2d_c { 73 | ce_vec2_t linear; 74 | float angular; 75 | } ct_velocity2d_c; 76 | 77 | typedef struct ct_mass2d_c { 78 | float mass; 79 | } ct_mass2d_c; 80 | 81 | typedef struct ct_collider2d_c { 82 | uint64_t type; 83 | union { 84 | struct { 85 | ce_vec2_t half_size; 86 | } rectangle; 87 | }; 88 | } ct_collider2d_c; 89 | 90 | struct ct_physics2d_a0 { 91 | void (*_)(); 92 | }; 93 | 94 | CE_MODULE(ct_physics2d_a0); 95 | 96 | #ifdef __cplusplus 97 | }; 98 | #endif 99 | 100 | #endif //CETECH_PHYSICS2D_H 101 | -------------------------------------------------------------------------------- /src/cetech/physics3d/physics3d.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_PHYSICS3D_H 2 | #define CETECH_PHYSICS3D_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | #define PHYSICS3D_GROUP \ 11 | CE_ID64_0("physics3d_group", 0xcd34852a751a8e82ULL) 12 | 13 | #define PHYSICS3D_SYSTEM \ 14 | CE_ID64_0("physics3d_system", 0x1a502fdb5130e3e7ULL) 15 | 16 | #define CT_PHYSICS3D_A0 \ 17 | CE_ID64_0("ct_physics3d_a0", 0x5f3b66dce0aa7c35ULL) 18 | 19 | // World 20 | #define PHYSICS3D_WORLD_COMPONENT \ 21 | CE_ID64_0("physics_world3d", 0x95011a75ee1287baULL) 22 | 23 | #define PHYSICS_WORLD3D_GRAVITY_PROP\ 24 | CE_ID64_0("gravity", 0xccf0648c76b2a8c2ULL) 25 | 26 | // Velocity 27 | #define VELOCITY3D_COMPONENT \ 28 | CE_ID64_0("velocity3d", 0x5bbcb4f3ec532828ULL) 29 | 30 | #define VELOCITY3D_LINEAR_PROP \ 31 | CE_ID64_0("linear", 0x4edd18565871c654ULL) 32 | 33 | #define VELOCITY3D_ANGULAR_PROP \ 34 | CE_ID64_0("angular", 0x73e2903632f8a84ULL) 35 | 36 | // MASS 37 | #define MASS3D_COMPONENT \ 38 | CE_ID64_0("mass3d", 0x723906ab6ba4af64ULL) 39 | 40 | #define MASS3D_PROP \ 41 | CE_ID64_0("mass", 0xa06fab7c958a7771ULL) 42 | 43 | // Collider 44 | #define COLLIDER3D_COMPONENT \ 45 | CE_ID64_0("collider3d", 0x33787862cf3e5b8aULL) 46 | 47 | #define BODY3D_FRICTION_PROP \ 48 | CE_ID64_0("friction", 0xa99da7441f8b5e66ULL) 49 | 50 | #define BODY3D_RESTITUTION_PROP \ 51 | CE_ID64_0("restitution", 0x2f06ac1f350e7dbeULL) 52 | 53 | #define BODY3D_DENSITY_PROP \ 54 | CE_ID64_0("density", 0xca98f4e6f68d2c8dULL) 55 | 56 | #define BODY3D_IS_SENSOR_PROP \ 57 | CE_ID64_0("is_sensor", 0x1d97e62c01dac9c4ULL) 58 | 59 | #define COLLIDER3D_SHAPE_PROP \ 60 | CE_ID64_0("shape", 0x3ef87fb905f6d51bULL) 61 | 62 | #define COLLIDER3D_BOX \ 63 | CE_ID64_0("collider3d_box", 0xb00dd4c60678fceaULL) 64 | 65 | #define COLLIDER3D_BOX_HALF \ 66 | CE_ID64_0("half_size", 0xfae83ca4619fb60aULL) 67 | 68 | #define COLLIDER3D_SPHERE \ 69 | CE_ID64_0("collider3d_sphere", 0xff9d5808485c6ffaULL) 70 | 71 | #define COLLIDER3D_SPHERE_RADIUS \ 72 | CE_ID64_0("radius", 0x197aa554763f64b0ULL) 73 | 74 | typedef struct ct_physics_world3d_c { 75 | ce_vec3_t gravity; 76 | } ct_physics_world3d_c; 77 | 78 | typedef struct ct_velocity3d_c { 79 | ce_vec3_t linear; 80 | ce_vec3_t angular; 81 | } ct_velocity3d_c; 82 | 83 | typedef struct ct_mass3d_c { 84 | float mass; 85 | } ct_mass3d_c; 86 | 87 | typedef union ct_collider3d_shape_t{ 88 | struct { 89 | ce_vec3_t half_size; 90 | } box; 91 | 92 | struct { 93 | float radius; 94 | } sphere; 95 | } ct_collider3d_shape_t; 96 | 97 | typedef struct ct_collider3d_c { 98 | uint64_t type; 99 | ct_collider3d_shape_t shape; 100 | } ct_collider3d_c; 101 | 102 | struct ct_physics3d_a0 { 103 | void (*_)(); 104 | }; 105 | 106 | CE_MODULE(ct_physics_a0); 107 | 108 | #ifdef __cplusplus 109 | }; 110 | #endif 111 | 112 | #endif //CETECH_PHYSICS3D_H 113 | -------------------------------------------------------------------------------- /src/cetech/property_editor/property_editor.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_PROPERTY_INSPECTOR_H 2 | #define CETECH_PROPERTY_INSPECTOR_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | #define CT_PROP_EDITOR_API \ 12 | CE_ID64_0("ct_property_editor_a0", 0x10996d5471937b8aULL) 13 | 14 | 15 | #define CT_PROPERTY_EDITOR_I \ 16 | CE_ID64_0("ct_property_editor_i0", 0x50566f03b5eacb95ULL) 17 | 18 | typedef struct ct_resource_id_t0 ct_resource_id_t0; 19 | 20 | typedef struct ct_property_editor_i0 { 21 | uint64_t (*cdb_type)(); 22 | 23 | void (*draw_ui)(ce_cdb_t0 db, 24 | uint64_t obj, 25 | uint64_t context, 26 | const char *filter); 27 | 28 | void (*draw_menu)(uint64_t obj); 29 | } ct_property_editor_i0; 30 | 31 | 32 | struct ct_property_editor_a0 { 33 | void (*draw)(ce_cdb_t0 db, 34 | uint64_t obj, 35 | uint64_t context); 36 | 37 | ct_property_editor_i0 *(*get_interface)(uint64_t obj); 38 | }; 39 | 40 | CE_MODULE(ct_property_editor_a0); 41 | 42 | #ifdef __cplusplus 43 | }; 44 | #endif 45 | 46 | #endif //CETECH_PROPERTY_INSPECTOR_H 47 | -------------------------------------------------------------------------------- /src/cetech/renderer/private/c_viewport.inl: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | // component 8 | 9 | static const char *viewport_display_name() { 10 | return "Viewport"; 11 | } 12 | 13 | 14 | static void _viewport_on_spawn(ct_world_t0 world, 15 | ce_cdb_t0 db, 16 | uint64_t obj, 17 | void *data) { 18 | viewport_component *c = data; 19 | c->viewport = create_viewport(); 20 | } 21 | 22 | static struct ct_ecs_component_i0 viewport_component_i = { 23 | .display_name = viewport_display_name, 24 | .cdb_type = VIEWPORT_COMPONENT, 25 | .size = sizeof(viewport_component), 26 | .from_cdb_obj = _viewport_on_spawn, 27 | }; 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/cetech/resource/resource.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_RESOURCE_H 2 | #define CETECH_RESOURCE_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #define CT_RESOURCE_API \ 13 | CE_ID64_0("ct_resource_a0", 0x60a25ca5a83c2ac2ULL) 14 | 15 | #define CDB_UID_PROP \ 16 | CE_ID64_0("cdb_uid", 0x644d24512264abb2ULL) 17 | 18 | #define CDB_OBJSET \ 19 | CE_ID64_0("cdb_objset", 0x2b66a0c3813b3490ULL) 20 | 21 | #define CDB_TYPE_PROP \ 22 | CE_ID64_0("cdb_type", 0xfe5986c682be99e0ULL) 23 | 24 | #define CONFIG_BUILD \ 25 | CE_ID64_0("build", 0x4429661936ece1eaULL) 26 | 27 | #define CONFIG_COMPILE \ 28 | CE_ID64_0("compile", 0x3c797c340e1e5467ULL) 29 | 30 | #define CT_RESOURCE_I \ 31 | CE_ID64_0("ct_resource_i0", 0x3e0127963a0db5b9ULL) 32 | 33 | typedef struct ce_vio_t0 ce_vio_t0; 34 | typedef struct ce_alloc_t0 ce_alloc_t0; 35 | typedef struct ce_cdb_t0 ce_cdb_t0; 36 | 37 | typedef struct ct_resource_id_t0 { 38 | uint64_t uid; 39 | } ct_resource_id_t0; 40 | 41 | typedef bool (*ct_resource_compilator_t)(ce_cdb_t0 db, 42 | uint64_t obj); 43 | 44 | //! Resource interface 45 | typedef struct ct_resource_i0 { 46 | const char *(*name)(); 47 | 48 | uint64_t (*cdb_type)(); 49 | 50 | const char *(*display_icon)(); 51 | 52 | void *(*get_interface)(uint64_t name_hash); 53 | 54 | void (*online)(ce_cdb_t0 db, 55 | uint64_t obj); 56 | 57 | void (*offline)(ce_cdb_t0 db, 58 | uint64_t obj); 59 | 60 | void (*create_new)(uint64_t obj); 61 | 62 | ct_resource_compilator_t compilator; 63 | } ct_resource_i0; 64 | 65 | 66 | struct ct_resource_a0 { 67 | ct_resource_i0 *(*get_interface)(uint64_t type); 68 | 69 | bool (*cdb_loader)(ce_cdb_t0 db, 70 | uint64_t uid); 71 | 72 | bool (*save)(uint64_t uid); 73 | 74 | bool (*save_to_db)(uint64_t uid); 75 | }; 76 | 77 | CE_MODULE(ct_resource_a0); 78 | 79 | #ifdef __cplusplus 80 | }; 81 | #endif 82 | 83 | #endif //CETECH_RESOURCE_H 84 | -------------------------------------------------------------------------------- /src/cetech/resource/resource_compiler.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_RESOURCE_COMPILER_H 2 | #define CETECH_RESOURCE_COMPILER_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #define CT_RESOURCE_COMPILER_API \ 13 | CE_ID64_0("ct_resource_compiler_a0", 0xc084f9ae737212dcULL) 14 | 15 | #define CONFIG_SRC \ 16 | CE_ID64_0("src", 0x1cdb3620898c588eULL) 17 | 18 | #define CONFIG_CORE \ 19 | CE_ID64_0("core", 0x6da99857e9315560ULL) 20 | 21 | #define CONFIG_MODULE_DIR \ 22 | CE_ID64_0("module_dir", 0xa96daa49986032f4ULL) 23 | 24 | #define CONFIG_EXTERNAL \ 25 | CE_ID64_0("external", 0x9fb8bb487a62dc4fULL) 26 | 27 | 28 | typedef struct ce_vio_t0 ce_vio_t0; 29 | typedef struct ce_alloc_t0 ce_alloc_t0; 30 | typedef struct ct_resource_id_t0 ct_resource_id_t0; 31 | 32 | struct ct_resource_compiler_a0 { 33 | void (*compile_all)(); 34 | 35 | void (*gen_tmp_file)(char *output, 36 | uint64_t max_size, 37 | const char *platform, 38 | const char *filename, 39 | const char *ext); 40 | 41 | char *(*external_join)(ce_alloc_t0 *a, 42 | const char *name); 43 | }; 44 | 45 | CE_MODULE(ct_resource_compiler_a0); 46 | 47 | #ifdef __cplusplus 48 | }; 49 | #endif 50 | 51 | #endif //CETECH_RESOURCE_COMPILER_H 52 | -------------------------------------------------------------------------------- /src/cetech/resource/resourcedb.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_BUILDDB_H 2 | #define CETECH_BUILDDB_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | #define CT_BUILDDB_API \ 12 | CE_ID64_0("ct_resourcedb_a0", 0xc81a8d961ebf878ULL) 13 | 14 | typedef struct ct_resource_id_t0 ct_resource_id_t0; 15 | typedef struct ce_alloc_t0 ce_alloc_t0; 16 | 17 | struct ct_resourcedb_a0 { 18 | void (*put_file)(const char *filename, 19 | time_t mtime); 20 | 21 | void (*put_resource)(ct_resource_id_t0 rid, 22 | const char *type, 23 | const char *filename, 24 | bool file_resource); 25 | 26 | void (*put_resource_blob)(ct_resource_id_t0 rid, 27 | const char *data, 28 | uint64_t size); 29 | 30 | bool (*load_cdb_file)(ce_cdb_t0 db, 31 | ct_resource_id_t0 resource, 32 | uint64_t object, 33 | ce_alloc_t0 *allocator); 34 | 35 | bool (*obj_exist)(ct_resource_id_t0 resource); 36 | 37 | uint64_t (*get_resource_type)(ct_resource_id_t0 resource); 38 | 39 | bool (*get_resource_filename)(ct_resource_id_t0 resource, 40 | char *filename, 41 | size_t max_len); 42 | 43 | ct_resource_id_t0 (*get_file_resource)(const char *filename); 44 | 45 | int (*list_resource_from_dirs)(const char *dir, 46 | char ***filename, 47 | ce_alloc_t0 *alloc); 48 | 49 | int (*list_resource_by_type)(const char *name, 50 | const char *type, 51 | char ***filename, 52 | ce_alloc_t0 *alloc); 53 | 54 | void (*clean_resource_list)(char **filename, 55 | ce_alloc_t0 *alloc); 56 | }; 57 | 58 | #ifdef __cplusplus 59 | }; 60 | #endif 61 | 62 | #endif //CETECH_BUILDDB_H 63 | -------------------------------------------------------------------------------- /src/cetech/resource_browser/resource_browser.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_ASSET_BROWSER_H 2 | #define CETECH_ASSET_BROWSER_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define RESOURCE_BROWSER_SOURCE \ 9 | CE_ID64_0("source", 0x921f1370045bad6eULL) 10 | 11 | #define RESOURCE_DCLICK_EVENT \ 12 | CE_ID64_0("asset_dclic", 0xcb3f723dbc17db73ULL) 13 | 14 | #define RESOURCE_BROWSER \ 15 | CE_ID64_0("asset_browser", 0x41bbc9e4707d4c8dULL) 16 | 17 | struct ct_resource_browser_a0 { 18 | uint64_t (*edited)(); 19 | }; 20 | 21 | CE_MODULE(ct_resource_browser_a0); 22 | 23 | #ifdef __cplusplus 24 | }; 25 | #endif 26 | 27 | #endif //CETECH_ASSET_BROWSER_H 28 | -------------------------------------------------------------------------------- /src/cetech/resource_editor/resource_editor.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_EDITOR_H 2 | #define CETECH_EDITOR_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | #define CT_RESOURCE_EDITOR_I \ 11 | CE_ID64_0("ct_resource_editor_i0", 0x1271656210cd7528ULL) 12 | 13 | #define CT_RESOURCE_EDITOR_CONTEXT \ 14 | CE_ID64_0("ct_resource_editor_context", 0x9d16b1cf38ff0c4cULL) 15 | 16 | typedef struct ct_resource_editor_i0 { 17 | uint64_t (*cdb_type)(); 18 | 19 | const char *(*display_icon)(); 20 | 21 | const char *(*display_name)(); 22 | 23 | uint64_t (*open)(uint64_t obj); 24 | 25 | void (*close)(uint64_t context_obj); 26 | 27 | void (*update)(uint64_t context_obj, 28 | float dt); 29 | 30 | void (*draw_ui)(uint64_t context_obj, 31 | uint64_t context); 32 | 33 | void (*draw_menu)(uint64_t context_obj); 34 | } ct_resource_editor_i0; 35 | 36 | #ifdef __cplusplus 37 | }; 38 | #endif 39 | 40 | #endif //CETECH_EDITOR_H 41 | -------------------------------------------------------------------------------- /src/cetech/resource_preview/resource_preview.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_ASSET_PREVIEW_H 2 | #define CETECH_ASSET_PREVIEW_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | typedef struct ct_world_t0 ct_world_t0; 12 | typedef struct ct_entity_t0 ct_entity_t0; 13 | 14 | #define CT_ASSET_PREVIEW_API \ 15 | CE_ID64_0("ct_resource_preview_a0", 0x8498c030ac811f8eULL) 16 | 17 | #define RESOURCE_PREVIEW_I \ 18 | CE_ID64_0("ct_resource_preview_i0", 0x5e8a61eef5a43b61ULL) 19 | 20 | typedef struct ct_resource_preview_i0 { 21 | void (*draw_raw)(uint64_t obj, 22 | ce_vec2_t size); 23 | 24 | ct_entity_t0 (*load)(uint64_t resource, 25 | ct_world_t0 world); 26 | 27 | void (*unload)(uint64_t resource, 28 | ct_world_t0 world, 29 | ct_entity_t0 entity); 30 | 31 | void (*tooltip)(uint64_t resource, 32 | ce_vec2_t size); 33 | } ct_resource_preview_i0; 34 | 35 | 36 | struct ct_resource_preview_a0 { 37 | void (*resource_tooltip)(ct_resource_id_t0 resourceid, 38 | const char *path, 39 | ce_vec2_t size); 40 | }; 41 | 42 | CE_MODULE(ct_resource_preview_a0); 43 | 44 | #ifdef __cplusplus 45 | }; 46 | #endif 47 | 48 | #endif //CETECH_ASSET_PREVIEW_H 49 | -------------------------------------------------------------------------------- /src/cetech/shader/shader.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_SHADER_H 2 | #define CETECH_SHADER_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | #define CT_SHADER_API \ 14 | CE_ID64_0("ct_shader_a0", 0x6a9d892dacfc7576ULL) 15 | 16 | 17 | #define SHADER_TYPE \ 18 | CE_ID64_0("shader", 0xcce8d5b5f5ae333fULL) 19 | 20 | #define SHADER_VS_INPUT \ 21 | CE_ID64_0("vs_input", 0x2d6d9196e29625fdULL) 22 | 23 | #define SHADER_FS_INPUT \ 24 | CE_ID64_0("fs_input", 0x7ed33aaa3bf6f312ULL) 25 | 26 | #define SHADER_VS_DATA \ 27 | CE_ID64_0("vs_data", 0xb2eef410e8bf776aULL) 28 | 29 | #define SHADER_FS_DATA \ 30 | CE_ID64_0("fs_data", 0xa754c8f87442bf42ULL) 31 | 32 | #define SHADER_PROP \ 33 | CE_ID64_0("shader", 0xcce8d5b5f5ae333fULL) 34 | 35 | //! Shader API V0 36 | struct ct_shader_a0 { 37 | bgfx_program_handle_t (*get)(uint64_t shader); 38 | }; 39 | 40 | CE_MODULE(ct_shader_a0); 41 | 42 | #ifdef __cplusplus 43 | }; 44 | #endif 45 | 46 | #endif //CETECH_SHADER_H -------------------------------------------------------------------------------- /src/cetech/texture/texture.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_TEXTURE_H 2 | #define CETECH_TEXTURE_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define CT_TEXTURE_API \ 9 | CE_ID64_0("ct_texture_a0", 0x642bfe2717995f2fULL) 10 | 11 | #define TEXTURE_TASK \ 12 | CE_ID64_0("texture_task", 0xcfe0d7ae816cf881ULL) 13 | 14 | #define TEXTURE_TYPE \ 15 | CE_ID64_0("texture", 0xcd4238c6a0c69e32ULL) 16 | 17 | #define TEXTURE_INPUT \ 18 | CE_ID64_0("input", 0x2bbcabe5074ade9eULL) 19 | 20 | #define TEXTURE_GEN_MIPMAPS \ 21 | CE_ID64_0("gen_mipmaps", 0x22783cd1918e8655ULL) 22 | 23 | #define TEXTURE_IS_NORMALMAP \ 24 | CE_ID64_0("is_normalmap", 0xb9378d82634094d1ULL) 25 | 26 | #define TEXTURE_DATA \ 27 | CE_ID64_0("texture_data", 0x91074c9e531b0860ULL) 28 | 29 | #define TEXTURE_HANDLER_PROP \ 30 | CE_ID64_0("texture_handler", 0x4702d2246fb28a09ULL) 31 | 32 | 33 | #include 34 | 35 | typedef struct bgfx_texture_handle_s bgfx_texture_handle_t; 36 | 37 | //! Texture API V0 38 | struct ct_texture_a0 { 39 | bgfx_texture_handle_t (*get)(uint64_t name); 40 | }; 41 | 42 | CE_MODULE(ct_texture_a0); 43 | 44 | #ifdef __cplusplus 45 | }; 46 | #endif 47 | 48 | #endif //CETECH_TEXTURE_H -------------------------------------------------------------------------------- /src/cetech/transform/transform.h: -------------------------------------------------------------------------------- 1 | #ifndef CETECH_TRANSFORM_H 2 | #define CETECH_TRANSFORM_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | #define VEC2_CDB_TYPE \ 11 | CE_ID64_0("vec2_t", 0x9363184a58efecc1ULL) 12 | 13 | #define VEC3_CDB_TYPE \ 14 | CE_ID64_0("vec3_t", 0x6112fca24c71dadULL) 15 | 16 | #define VEC4_CDB_TYPE \ 17 | CE_ID64_0("vec3_t", 0x6112fca24c71dadULL) 18 | 19 | #define PROP_VEC_X \ 20 | CE_ID64_0("x", 0x8295151af8224269ULL) 21 | #define PROP_VEC_Y \ 22 | CE_ID64_0("y", 0x9a5db2cd2c1fd6ceULL) 23 | 24 | #define PROP_VEC_Z \ 25 | CE_ID64_0("z", 0x88a824e868c7c5efULL) 26 | 27 | #define PROP_VEC_W \ 28 | CE_ID64_0("w", 0x22727cb14c3bb41dULL) 29 | 30 | #define TRANSFORM_SYSTEM \ 31 | CE_ID64_0("transform", 0x69e14b13ad9b5315ULL) 32 | 33 | #define TRANSFORM_GROUP \ 34 | CE_ID64_0("transform_group", 0xa091ac1b0c1e8522ULL) 35 | 36 | #define PROP_POSITION \ 37 | CE_ID64_0("position", 0x8bbeb160190f613aULL) 38 | 39 | #define PROP_ROTATION \ 40 | CE_ID64_0("rotation", 0x2060566242789baaULL) 41 | 42 | #define PROP_SCALE \ 43 | CE_ID64_0("scale", 0xeec8c5fba3c8bc0bULL) 44 | 45 | #define POSITION_COMPONENT \ 46 | CE_ID64_0("position", 0x8bbeb160190f613aULL) 47 | 48 | #define ROTATION_COMPONENT \ 49 | CE_ID64_0("rotation", 0x2060566242789baaULL) 50 | 51 | #define SCALE_COMPONENT \ 52 | CE_ID64_0("scale", 0xeec8c5fba3c8bc0bULL) 53 | 54 | #define LOCAL_TO_WORLD_COMPONENT \ 55 | CE_ID64_0("local_to_world", 0x7681f4b3f07eea41ULL) 56 | 57 | #define LOCAL_TO_PARENT_COMPONENT \ 58 | CE_ID64_0("local_to_parent", 0xdcaec9a80da958a0ULL) 59 | 60 | typedef struct ct_position_c { 61 | ce_vec3_t pos; 62 | } ct_position_c; 63 | 64 | typedef struct ct_rotation_c { 65 | ce_vec4_t rot; 66 | } ct_rotation_c; 67 | 68 | typedef struct ct_scale_c { 69 | ce_vec3_t scl; 70 | } ct_scale_c; 71 | 72 | typedef struct ct_local_to_world_c { 73 | ce_mat4_t world; 74 | } ct_local_to_world_c; 75 | 76 | typedef struct ct_local_to_parent_c { 77 | ce_mat4_t local; 78 | } ct_local_to_parent_c; 79 | 80 | 81 | #ifdef __cplusplus 82 | }; 83 | #endif 84 | 85 | #endif //CETECH_TRANSFORM_H -------------------------------------------------------------------------------- /toolchain/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:latest 2 | 3 | ENV DEBIAN_FRONTEND noninteractive 4 | 5 | RUN apt-get update && apt-get install -y clang \ 6 | cmake \ 7 | gcc \ 8 | g++ \ 9 | git \ 10 | pkgconf \ 11 | libbsd-dev \ 12 | tcl \ 13 | libx11-dev \ 14 | libjemalloc-dev \ 15 | libgl1-mesa-dev \ 16 | zlib1g-dev \ 17 | liblzma-dev \ 18 | python3-pip \ 19 | python-dev \ 20 | cython3 21 | 22 | ADD requirements.txt /tmp/requirements.txt 23 | 24 | RUN pip3 install -r /tmp/requirements.txt 25 | -------------------------------------------------------------------------------- /toolchain/requirements.txt: -------------------------------------------------------------------------------- 1 | pyyaml 2 | jinja2 -------------------------------------------------------------------------------- /tools/darwin64/genie: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyberegoorg/cetech/09857e278ba1596fc1b0e790164bd4dbf843bc5d/tools/darwin64/genie -------------------------------------------------------------------------------- /tools/linux64/genie: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyberegoorg/cetech/09857e278ba1596fc1b0e790164bd4dbf843bc5d/tools/linux64/genie --------------------------------------------------------------------------------