├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── config.yml └── workflows │ ├── linux_opengl.yml │ ├── macos_metal.yml │ └── windows_direct3d12.yml ├── .gitignore ├── license.md ├── make ├── make.bat ├── project.js ├── readme.md ├── shaders ├── g2_colored.frag.glsl ├── g2_colored.vert.glsl ├── g2_image.frag.glsl ├── g2_image.vert.glsl ├── g2_text.frag.glsl └── g2_text.vert.glsl ├── sources ├── .clang-format ├── backends │ ├── android │ │ ├── android_native_app_glue.c │ │ ├── android_native_app_glue.h │ │ ├── java │ │ │ ├── arm │ │ │ │ └── AndroidHttpRequest.java │ │ │ └── tech │ │ │ │ └── kinc │ │ │ │ ├── KincActivity.kt │ │ │ │ ├── KincMoviePlayer.kt │ │ │ │ └── KincMovieTexture.kt │ │ └── kinc │ │ │ └── backend │ │ │ ├── Android.h │ │ │ ├── android_file_dialog.c │ │ │ ├── android_file_dialog.h │ │ │ ├── android_http_request.c │ │ │ ├── android_http_request.h │ │ │ ├── androidunit.c │ │ │ ├── audio.c.h │ │ │ ├── display.c.h │ │ │ ├── system.c.h │ │ │ ├── video.c.h │ │ │ ├── video.h │ │ │ ├── window.c.h │ │ │ └── windowdata.h │ ├── apple │ │ └── kinc │ │ │ └── backend │ │ │ ├── appleunit.m │ │ │ ├── http.m.h │ │ │ ├── system.m.h │ │ │ ├── thread.m.h │ │ │ ├── video.h │ │ │ └── video.m.h │ ├── data │ │ ├── android │ │ │ ├── app │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── build.gradle.kts │ │ │ │ └── proguard-rules.pro │ │ │ ├── build.gradle.kts │ │ │ ├── gradle.properties │ │ │ ├── gradle │ │ │ │ └── wrapper │ │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ │ └── gradle-wrapper.properties │ │ │ ├── gradlew │ │ │ ├── gradlew.bat │ │ │ ├── main │ │ │ │ ├── AndroidManifest.xml │ │ │ │ └── res │ │ │ │ │ └── values │ │ │ │ │ └── strings.xml │ │ │ └── settings.gradle.kts │ │ └── wasm │ │ │ └── JS-Sources │ │ │ ├── audio-thread.js │ │ │ ├── index.html │ │ │ ├── start.js │ │ │ └── thread_starter.js │ ├── direct3d11 │ │ └── kinc │ │ │ └── backend │ │ │ └── graphics4 │ │ │ ├── Direct3D11.c.h │ │ │ ├── Direct3D11.h │ │ │ ├── ShaderHash.c.h │ │ │ ├── ShaderHash.h │ │ │ ├── compute.c.h │ │ │ ├── compute.h │ │ │ ├── d3d11unit.c │ │ │ ├── indexbuffer.c.h │ │ │ ├── indexbuffer.h │ │ │ ├── pipeline.c.h │ │ │ ├── pipeline.h │ │ │ ├── rendertarget.c.h │ │ │ ├── rendertarget.h │ │ │ ├── shader.c.h │ │ │ ├── shader.h │ │ │ ├── texture.c.h │ │ │ ├── texture.h │ │ │ ├── vertexbuffer.c.h │ │ │ └── vertexbuffer.h │ ├── direct3d12 │ │ ├── d3dx12.h │ │ └── kinc │ │ │ └── backend │ │ │ └── graphics5 │ │ │ ├── Direct3D12.c.h │ │ │ ├── ShaderHash.c.h │ │ │ ├── ShaderHash.h │ │ │ ├── commandlist.c.h │ │ │ ├── commandlist.h │ │ │ ├── compute.c.h │ │ │ ├── compute.h │ │ │ ├── constantbuffer.c.h │ │ │ ├── constantbuffer.h │ │ │ ├── d3d12mini.h │ │ │ ├── d3d12unit.cpp │ │ │ ├── graphics.h │ │ │ ├── indexbuffer.c.h │ │ │ ├── indexbuffer.h │ │ │ ├── pipeline.c.h │ │ │ ├── pipeline.h │ │ │ ├── raytrace.c.h │ │ │ ├── raytrace.h │ │ │ ├── rendertarget.c.h │ │ │ ├── rendertarget.h │ │ │ ├── sampler.c.h │ │ │ ├── sampler.h │ │ │ ├── shader.c.h │ │ │ ├── shader.h │ │ │ ├── texture.c.h │ │ │ ├── texture.h │ │ │ ├── vertexbuffer.c.h │ │ │ └── vertexbuffer.h │ ├── g4ong5 │ │ └── kinc │ │ │ └── backend │ │ │ └── graphics4 │ │ │ ├── G4.c.h │ │ │ ├── G4.h │ │ │ ├── compute.c.h │ │ │ ├── compute.h │ │ │ ├── g4ong5unit.c │ │ │ ├── graphics.h │ │ │ ├── indexbuffer.c.h │ │ │ ├── indexbuffer.h │ │ │ ├── pipeline.c.h │ │ │ ├── pipeline.h │ │ │ ├── rendertarget.c.h │ │ │ ├── rendertarget.h │ │ │ ├── samplers.c.h │ │ │ ├── shader.c.h │ │ │ ├── shader.h │ │ │ ├── texture.c.h │ │ │ ├── texture.h │ │ │ ├── vertexbuffer.c.h │ │ │ └── vertexbuffer.h │ ├── g5ong4 │ │ └── kinc │ │ │ └── backend │ │ │ └── graphics5 │ │ │ ├── G5onG4.c.h │ │ │ ├── G5onG4.h │ │ │ ├── commandlist.c.h │ │ │ ├── commandlist.h │ │ │ ├── compute.c │ │ │ ├── compute.h │ │ │ ├── constantbuffer.c.h │ │ │ ├── constantbuffer.h │ │ │ ├── g5ong4unit.c │ │ │ ├── graphics.h │ │ │ ├── indexbuffer.c.h │ │ │ ├── indexbuffer.h │ │ │ ├── pipeline.c.h │ │ │ ├── pipeline.h │ │ │ ├── rendertarget.c.h │ │ │ ├── rendertarget.h │ │ │ ├── sampler.c.h │ │ │ ├── sampler.h │ │ │ ├── shader.c.h │ │ │ ├── shader.h │ │ │ ├── texture.c.h │ │ │ ├── texture.h │ │ │ ├── vertexbuffer.c.h │ │ │ └── vertexbuffer.h │ ├── ios │ │ └── kinc │ │ │ └── backend │ │ │ ├── GLView.h │ │ │ ├── GLView.m.h │ │ │ ├── GLViewController.h │ │ │ ├── GLViewController.m.h │ │ │ ├── KoreAppDelegate.h │ │ │ ├── KoreAppDelegate.m.h │ │ │ ├── LaunchScreen.storyboard │ │ │ ├── audio.m.h │ │ │ ├── display.h │ │ │ ├── display.m.h │ │ │ ├── displaydata.h │ │ │ ├── ios.plist │ │ │ ├── ios_file_dialog.h │ │ │ ├── ios_file_dialog.m │ │ │ ├── iosunit.m │ │ │ ├── motion.h │ │ │ ├── motion.m.h │ │ │ ├── mouse.c.h │ │ │ ├── system.m.h │ │ │ ├── window.c.h │ │ │ └── windowdata.h │ ├── license.txt │ ├── linux │ │ └── kinc │ │ │ └── backend │ │ │ ├── display.c.h │ │ │ ├── funcs.h │ │ │ ├── gamepad.c.h │ │ │ ├── gamepad.h │ │ │ ├── linuxunit.c │ │ │ ├── mouse.c.h │ │ │ ├── sound.c.h │ │ │ ├── system.c.h │ │ │ ├── video.c.h │ │ │ ├── video.h │ │ │ ├── wayland │ │ │ ├── display.c.h │ │ │ ├── system.c.h │ │ │ ├── wayland-funs.h │ │ │ ├── wayland.h │ │ │ └── window.c.h │ │ │ ├── window.c.h │ │ │ └── x11 │ │ │ ├── display.c.h │ │ │ ├── system.c.h │ │ │ ├── window.c.h │ │ │ └── x11.h │ ├── macos │ │ └── kinc │ │ │ └── backend │ │ │ ├── BasicOpenGLView.h │ │ │ ├── BasicOpenGLView.m.h │ │ │ ├── HIDGamepad.c.h │ │ │ ├── HIDGamepad.h │ │ │ ├── HIDManager.c.h │ │ │ ├── HIDManager.h │ │ │ ├── audio.c.h │ │ │ ├── display.m.h │ │ │ ├── displaydata.h │ │ │ ├── mac.plist │ │ │ ├── macosunit.m │ │ │ ├── mouse.m.h │ │ │ ├── system.c.h │ │ │ ├── system.m.h │ │ │ ├── window.c.h │ │ │ └── windowdata.h │ ├── metal │ │ └── kinc │ │ │ └── backend │ │ │ └── graphics5 │ │ │ ├── Metal.h │ │ │ ├── Metal.m.h │ │ │ ├── commandlist.h │ │ │ ├── commandlist.m.h │ │ │ ├── compute.h │ │ │ ├── compute.m.h │ │ │ ├── constantbuffer.h │ │ │ ├── constantbuffer.m.h │ │ │ ├── graphics.h │ │ │ ├── indexbuffer.h │ │ │ ├── indexbuffer.m.h │ │ │ ├── metalunit.m │ │ │ ├── pipeline.h │ │ │ ├── pipeline.m.h │ │ │ ├── raytrace.h │ │ │ ├── raytrace.m.h │ │ │ ├── rendertarget.h │ │ │ ├── rendertarget.m.h │ │ │ ├── sampler.h │ │ │ ├── sampler.m.h │ │ │ ├── shader.h │ │ │ ├── shader.m.h │ │ │ ├── texture.h │ │ │ ├── texture.m.h │ │ │ ├── vertexbuffer.h │ │ │ └── vertexbuffer.m.h │ ├── microsoft │ │ └── kinc │ │ │ └── backend │ │ │ ├── MiniWindows.h │ │ │ ├── SystemMicrosoft.c.h │ │ │ ├── SystemMicrosoft.h │ │ │ ├── atomic.h │ │ │ ├── event.c.h │ │ │ ├── event.h │ │ │ ├── fiber.c.h │ │ │ ├── fiber.h │ │ │ ├── microsoftunit.c │ │ │ ├── mutex.c.h │ │ │ ├── mutex.h │ │ │ ├── semaphore.c.h │ │ │ ├── semaphore.h │ │ │ ├── thread.c.h │ │ │ ├── thread.h │ │ │ ├── threadlocal.c.h │ │ │ └── threadlocal.h │ ├── opengl │ │ └── kinc │ │ │ └── backend │ │ │ └── graphics4 │ │ │ ├── OpenGL.c.h │ │ │ ├── OpenGL.h │ │ │ ├── OpenGLWindow.c.h │ │ │ ├── OpenGLWindow.h │ │ │ ├── compute.c.h │ │ │ ├── compute.h │ │ │ ├── graphics.h │ │ │ ├── indexbuffer.c.h │ │ │ ├── indexbuffer.h │ │ │ ├── ogl.h │ │ │ ├── openglunit.c │ │ │ ├── pipeline.c.h │ │ │ ├── pipeline.h │ │ │ ├── rendertarget.c.h │ │ │ ├── rendertarget.h │ │ │ ├── shader.c.h │ │ │ ├── shader.h │ │ │ ├── texture.c.h │ │ │ ├── texture.h │ │ │ ├── vertexbuffer.c.h │ │ │ └── vertexbuffer.h │ ├── posix │ │ └── kinc │ │ │ └── backend │ │ │ ├── atomic.h │ │ │ ├── event.c.h │ │ │ ├── event.h │ │ │ ├── mutex.c.h │ │ │ ├── mutex.h │ │ │ ├── posixunit.c │ │ │ ├── semaphore.c.h │ │ │ ├── semaphore.h │ │ │ ├── thread.c.h │ │ │ ├── thread.h │ │ │ ├── threadlocal.c.h │ │ │ └── threadlocal.h │ ├── vulkan │ │ └── kinc │ │ │ └── backend │ │ │ └── graphics5 │ │ │ ├── MiniVulkan.h │ │ │ ├── ShaderHash.c.h │ │ │ ├── ShaderHash.h │ │ │ ├── Vulkan.c.h │ │ │ ├── commandlist.c.h │ │ │ ├── commandlist.h │ │ │ ├── compute.c.h │ │ │ ├── compute.h │ │ │ ├── constantbuffer.c.h │ │ │ ├── constantbuffer.h │ │ │ ├── graphics.h │ │ │ ├── indexbuffer.c.h │ │ │ ├── indexbuffer.h │ │ │ ├── named_number.h │ │ │ ├── pipeline.c.h │ │ │ ├── pipeline.h │ │ │ ├── raytrace.c.h │ │ │ ├── raytrace.h │ │ │ ├── rendertarget.c.h │ │ │ ├── rendertarget.h │ │ │ ├── sampler.c.h │ │ │ ├── sampler.h │ │ │ ├── shader.c.h │ │ │ ├── shader.h │ │ │ ├── texture.c.h │ │ │ ├── texture.h │ │ │ ├── vertexbuffer.c.h │ │ │ ├── vertexbuffer.h │ │ │ ├── vulkan.h │ │ │ └── vulkanunit.c │ ├── wasapi │ │ └── kinc │ │ │ └── backend │ │ │ └── wasapi.c │ ├── wasm │ │ ├── GL │ │ │ └── gl.h │ │ └── kinc │ │ │ └── backend │ │ │ ├── atomic.h │ │ │ ├── audio.c.h │ │ │ ├── display.c.h │ │ │ ├── event.c.h │ │ │ ├── event.h │ │ │ ├── html5unit.c │ │ │ ├── mouse.c.h │ │ │ ├── mutex.c.h │ │ │ ├── mutex.h │ │ │ ├── semaphore.c.h │ │ │ ├── semaphore.h │ │ │ ├── system.c.h │ │ │ ├── thread.c.h │ │ │ ├── thread.h │ │ │ ├── threadlocal.c.h │ │ │ ├── threadlocal.h │ │ │ ├── video.c.h │ │ │ ├── video.h │ │ │ ├── window.c.h │ │ │ └── windowdata.h │ ├── webgpu │ │ └── kinc │ │ │ └── backend │ │ │ └── graphics5 │ │ │ ├── WebGPU.c │ │ │ ├── WebGPU.h │ │ │ ├── commandlist.c │ │ │ ├── commandlist.h │ │ │ ├── compute.c │ │ │ ├── compute.h │ │ │ ├── constantbuffer.c │ │ │ ├── constantbuffer.h │ │ │ ├── graphics.h │ │ │ ├── indexbuffer.c │ │ │ ├── indexbuffer.h │ │ │ ├── pipeline.c │ │ │ ├── pipeline.h │ │ │ ├── rendertarget.c │ │ │ ├── rendertarget.h │ │ │ ├── sampler.c │ │ │ ├── sampler.h │ │ │ ├── shader.c │ │ │ ├── shader.h │ │ │ ├── texture.c │ │ │ ├── texture.h │ │ │ ├── vertexbuffer.c │ │ │ └── vertexbuffer.h │ └── windows │ │ └── kinc │ │ └── backend │ │ ├── Windows.c.h │ │ ├── Windows.h │ │ ├── base.c.h │ │ ├── display.c.h │ │ ├── http.c.h │ │ ├── mouse.c.h │ │ ├── system.c.h │ │ ├── video.c.h │ │ ├── video.h │ │ ├── window.c.h │ │ └── windowsunit.c ├── const_data.c ├── const_data.h ├── iron.c ├── iron.h ├── iron_armpack.c ├── iron_armpack.h ├── iron_array.c ├── iron_array.h ├── iron_gc.c ├── iron_gc.h ├── iron_json.c ├── iron_json.h ├── iron_map.c ├── iron_map.h ├── iron_mat3.c ├── iron_mat3.h ├── iron_mat4.c ├── iron_mat4.h ├── iron_obj.c ├── iron_obj.h ├── iron_quat.c ├── iron_quat.h ├── iron_string.c ├── iron_string.h ├── iron_ui.c ├── iron_ui.h ├── iron_ui_ext.c ├── iron_ui_ext.h ├── iron_ui_nodes.c ├── iron_ui_nodes.h ├── iron_vec2.c ├── iron_vec2.h ├── iron_vec3.c ├── iron_vec3.h ├── iron_vec4.c ├── iron_vec4.h ├── kinc │ ├── audio1 │ │ ├── a1unit.c │ │ ├── audio.c.h │ │ ├── audio.h │ │ ├── sound.c.h │ │ ├── sound.h │ │ ├── soundstream.c.h │ │ └── soundstream.h │ ├── audio2 │ │ ├── audio.c │ │ └── audio.h │ ├── color.h │ ├── display.h │ ├── error.h │ ├── global.h │ ├── graphics2 │ │ ├── g2.c │ │ ├── g2.h │ │ ├── g2_ext.c │ │ ├── g2_ext.h │ │ ├── g2_font.h │ │ └── stb_truetype.h │ ├── graphics4 │ │ ├── compute.h │ │ ├── constantlocation.h │ │ ├── g4unit.c │ │ ├── graphics.c.h │ │ ├── graphics.h │ │ ├── indexbuffer.h │ │ ├── pipeline.c.h │ │ ├── pipeline.h │ │ ├── rendertarget.c.h │ │ ├── rendertarget.h │ │ ├── shader.h │ │ ├── texture.h │ │ ├── textureunit.h │ │ ├── usage.h │ │ ├── vertexbuffer.c.h │ │ ├── vertexbuffer.h │ │ └── vertexstructure.h │ ├── graphics5 │ │ ├── commandlist.c.h │ │ ├── commandlist.h │ │ ├── compute.h │ │ ├── constantbuffer.c.h │ │ ├── constantbuffer.h │ │ ├── constantlocation.h │ │ ├── g5unit.c │ │ ├── graphics.c.h │ │ ├── graphics.h │ │ ├── indexbuffer.h │ │ ├── pipeline.c.h │ │ ├── pipeline.h │ │ ├── raytrace.h │ │ ├── rendertarget.c.h │ │ ├── rendertarget.h │ │ ├── sampler.c.h │ │ ├── sampler.h │ │ ├── shader.h │ │ ├── texture.c.h │ │ ├── texture.h │ │ ├── textureunit.h │ │ ├── vertexbuffer.h │ │ └── vertexstructure.h │ ├── image.h │ ├── input │ │ ├── acceleration.h │ │ ├── gamepad.h │ │ ├── inputunit.c │ │ ├── keyboard.h │ │ ├── mouse.h │ │ ├── pen.h │ │ ├── rotation.h │ │ └── surface.h │ ├── io │ │ ├── filereader.h │ │ ├── filewriter.h │ │ └── iounit.c │ ├── libs │ │ ├── lz4x.h │ │ ├── neon_mathfun.h │ │ ├── sse_mathfun.h │ │ ├── stb_image.h │ │ ├── stb_sprintf.h │ │ └── stb_vorbis.c │ ├── license.txt │ ├── log.h │ ├── math │ │ ├── core.h │ │ ├── mathunit.c │ │ ├── matrix.h │ │ ├── quaternion.h │ │ ├── random.h │ │ └── vector.h │ ├── network │ │ ├── http.h │ │ ├── networkunit.c │ │ └── socket.h │ ├── readme.md │ ├── rootunit.c │ ├── simd │ │ ├── float32x4.h │ │ ├── int16x8.h │ │ ├── int32x4.h │ │ ├── int8x16.h │ │ ├── type_conversions.h │ │ ├── types.h │ │ ├── uint16x8.h │ │ ├── uint32x4.h │ │ └── uint8x16.h │ ├── system.h │ ├── threads │ │ ├── atomic.h │ │ ├── event.h │ │ ├── fiber.h │ │ ├── mutex.h │ │ ├── semaphore.h │ │ ├── thread.h │ │ └── threadlocal.h │ ├── video.h │ └── window.h ├── libs │ ├── dir.c │ ├── dir.h │ ├── gc.c │ ├── gc.h │ ├── jo_mpeg.h │ ├── jsmn.h │ ├── miniClib │ │ ├── assert.h │ │ ├── errno.h │ │ ├── license.txt │ │ ├── math.c │ │ ├── math.h │ │ ├── memory.c │ │ ├── memory.h │ │ ├── stdbool.h │ │ ├── stdio.c │ │ ├── stdio.h │ │ ├── stdlib.c │ │ ├── stdlib.h │ │ ├── string.c │ │ ├── string.h │ │ └── time.h │ ├── nfd │ │ ├── LICENSE │ │ ├── common.h │ │ ├── nfd.h │ │ ├── nfd_cocoa.m │ │ ├── nfd_common.c │ │ ├── nfd_common.h │ │ ├── nfd_gtk.c │ │ ├── nfd_win.cpp │ │ └── simple_exec.h │ ├── quickjs │ │ ├── LICENSE │ │ ├── VERSION │ │ ├── cutils.c │ │ ├── cutils.h │ │ ├── dirent_compat.h │ │ ├── libbf.c │ │ ├── libbf.h │ │ ├── libregexp-opcode.h │ │ ├── libregexp.c │ │ ├── libregexp.h │ │ ├── libunicode-table.h │ │ ├── libunicode.c │ │ ├── libunicode.h │ │ ├── list.h │ │ ├── quickjs-atom.h │ │ ├── quickjs-c-atomics.h │ │ ├── quickjs-libc.c │ │ ├── quickjs-libc.h │ │ ├── quickjs-opcode.h │ │ ├── quickjs.c │ │ └── quickjs.h │ ├── sdefl.h │ ├── sinfl.h │ └── stb_image_write.h └── ts │ ├── anim.ts │ ├── anim_bone.ts │ ├── anim_object.ts │ ├── app.ts │ ├── armature.ts │ ├── audio.ts │ ├── camera_data.ts │ ├── camera_object.ts │ ├── const_data.ts │ ├── data.ts │ ├── g2.ts │ ├── g4.ts │ ├── input.ts │ ├── iron.ts │ ├── light_data.ts │ ├── light_object.ts │ ├── lz4.ts │ ├── material_data.ts │ ├── mesh_data.ts │ ├── mesh_object.ts │ ├── object.ts │ ├── particle_data.ts │ ├── particle_sys.ts │ ├── raycast.ts │ ├── render_path.ts │ ├── scene.ts │ ├── shader_data.ts │ ├── speaker_object.ts │ ├── sys.ts │ ├── tilesheet.ts │ ├── time.ts │ ├── transform.ts │ ├── tween.ts │ ├── ui.ts │ ├── uniforms.ts │ └── world_data.ts └── tools ├── amake ├── aimage.c ├── alang.js ├── alang.md ├── alang.ts ├── ashader.c ├── iron.h ├── main.c ├── project.js └── stb_image_resize.h ├── bin ├── linux_arm64 │ └── keepme ├── linux_x64 │ └── amake ├── macos │ └── amake └── windows_x64 │ └── amake.exe ├── icon.png ├── io_export_arm.py ├── make.js ├── platform.sh ├── tcc ├── COPYING ├── VERSION ├── include │ ├── float.h │ ├── stdarg.h │ ├── stdbool.h │ ├── stddef.h │ └── varargs.h ├── libtcc1.a ├── main.c ├── make.sh ├── tcc └── tcclib.h ├── tests ├── cube │ ├── assets │ │ ├── cube.arm │ │ └── texture.png │ ├── project.js │ ├── shaders │ │ ├── mesh.frag.glsl │ │ └── mesh.vert.glsl │ ├── sources │ │ └── main.ts │ └── tsconfig.json └── triangle │ ├── main.ts │ └── project.js ├── to_spirv ├── glslang │ ├── LICENSE.txt │ ├── OGLCompilersDLL │ │ ├── InitializeDll.cpp │ │ └── InitializeDll.h │ ├── SPIRV │ │ ├── GLSL.ext.AMD.h │ │ ├── GLSL.ext.EXT.h │ │ ├── GLSL.ext.KHR.h │ │ ├── GLSL.ext.NV.h │ │ ├── GLSL.std.450.h │ │ ├── GlslangToSpv.cpp │ │ ├── GlslangToSpv.h │ │ ├── InReadableOrder.cpp │ │ ├── Logger.cpp │ │ ├── Logger.h │ │ ├── NonSemanticDebugPrintf.h │ │ ├── SPVRemapper.cpp │ │ ├── SPVRemapper.h │ │ ├── SpvBuilder.cpp │ │ ├── SpvBuilder.h │ │ ├── SpvPostProcess.cpp │ │ ├── SpvTools.cpp │ │ ├── SpvTools.h │ │ ├── bitutils.h │ │ ├── disassemble.cpp │ │ ├── disassemble.h │ │ ├── doc.cpp │ │ ├── doc.h │ │ ├── hex_float.h │ │ ├── spirv.hpp │ │ └── spvIR.h │ ├── StandAlone │ │ ├── ResourceLimits.cpp │ │ ├── ResourceLimits.h │ │ └── Worklist.h │ └── glslang │ │ ├── GenericCodeGen │ │ ├── CodeGen.cpp │ │ └── Link.cpp │ │ ├── Include │ │ ├── BaseTypes.h │ │ ├── Common.h │ │ ├── ConstantUnion.h │ │ ├── InfoSink.h │ │ ├── InitializeGlobals.h │ │ ├── PoolAlloc.h │ │ ├── ResourceLimits.h │ │ ├── ShHandle.h │ │ ├── Types.h │ │ ├── arrays.h │ │ ├── glslang_c_shader_types.h │ │ ├── intermediate.h │ │ └── revision.h │ │ ├── MachineIndependent │ │ ├── Constant.cpp │ │ ├── InfoSink.cpp │ │ ├── Initialize.cpp │ │ ├── Initialize.h │ │ ├── IntermTraverse.cpp │ │ ├── Intermediate.cpp │ │ ├── LiveTraverser.h │ │ ├── ParseContextBase.cpp │ │ ├── ParseHelper.cpp │ │ ├── ParseHelper.h │ │ ├── PoolAlloc.cpp │ │ ├── RemoveTree.cpp │ │ ├── RemoveTree.h │ │ ├── Scan.cpp │ │ ├── Scan.h │ │ ├── ScanContext.h │ │ ├── ShaderLang.cpp │ │ ├── SymbolTable.cpp │ │ ├── SymbolTable.h │ │ ├── Versions.cpp │ │ ├── Versions.h │ │ ├── attribute.cpp │ │ ├── attribute.h │ │ ├── gl_types.h │ │ ├── glslang.y │ │ ├── glslang_tab.cpp │ │ ├── glslang_tab.cpp.h │ │ ├── intermOut.cpp │ │ ├── iomapper.cpp │ │ ├── iomapper.h │ │ ├── limits.cpp │ │ ├── linkValidate.cpp │ │ ├── localintermediate.h │ │ ├── parseConst.cpp │ │ ├── parseVersions.h │ │ ├── preprocessor │ │ │ ├── Pp.cpp │ │ │ ├── PpAtom.cpp │ │ │ ├── PpContext.cpp │ │ │ ├── PpContext.h │ │ │ ├── PpScanner.cpp │ │ │ ├── PpTokens.cpp │ │ │ └── PpTokens.h │ │ ├── propagateNoContraction.cpp │ │ ├── propagateNoContraction.h │ │ ├── reflection.cpp │ │ └── reflection.h │ │ ├── OSDependent │ │ ├── Unix │ │ │ └── ossource.cpp │ │ └── osinclude.h │ │ └── Public │ │ └── ShaderLang.h ├── license.txt ├── project.js └── to_spirv.cpp └── wasm ├── README.md ├── index.html └── project.js /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a bug report 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | 13 | 14 | **Issue description:** 15 | 16 | 17 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | # Disallow blank issues to make sure people follow one of the templates. 2 | blank_issues_enabled: false 3 | -------------------------------------------------------------------------------- /.github/workflows/linux_opengl.yml: -------------------------------------------------------------------------------- 1 | name: Linux (OpenGL) 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | build: 13 | 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v2 18 | - name: Apt Update 19 | run: sudo apt-get update 20 | - name: Apt Install 21 | run: sudo apt-get install libasound2-dev libxrandr-dev libxinerama-dev libgl1-mesa-dev libxi-dev libxcursor-dev libudev-dev libgtk-3-dev --yes --quiet 22 | - name: Compile 23 | run: | 24 | cd tools/tests/cube 25 | ../../../make --graphics opengl --compile 26 | -------------------------------------------------------------------------------- /.github/workflows/macos_metal.yml: -------------------------------------------------------------------------------- 1 | name: macOS (Metal) 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | build: 13 | 14 | runs-on: macOS-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v2 18 | - name: Compile 19 | run: | 20 | cd tools/tests/cube 21 | ../../../make --graphics metal --compile --alangjs 22 | -------------------------------------------------------------------------------- /.github/workflows/windows_direct3d12.yml: -------------------------------------------------------------------------------- 1 | name: Windows (Direct3D12) 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | build: 13 | 14 | runs-on: windows-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v2 18 | - name: Get msbuild 19 | uses: microsoft/setup-msbuild@v1 20 | - name: Compile 21 | run: | 22 | cd tools/tests/cube 23 | ../../../make --graphics direct3d12 --compile 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | build/ 3 | -------------------------------------------------------------------------------- /license.md: -------------------------------------------------------------------------------- 1 | # The zlib/libpng License 2 | 3 | This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. 4 | Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 5 | The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 6 | Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 7 | This notice may not be removed or altered from any source distribution. 8 | 9 | https://github.com/armory3d/armorcore 10 | -------------------------------------------------------------------------------- /make: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . `dirname "$0"`/tools/platform.sh 4 | MAKE="`dirname "$0"`/tools/bin/$KINC_PLATFORM/amake" 5 | exec $MAKE `dirname "$0"`/tools/make.js "$@" 6 | -------------------------------------------------------------------------------- /make.bat: -------------------------------------------------------------------------------- 1 | @call "%~dp0tools\bin\windows_x64\amake.exe" "%~dp0tools\make.js" %* 2 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # armorcore 2 | 3 | 3D engine core for C with JS scripting. ArmorCore targets Direct3D12, Vulkan, Metal and WebGPU. 4 | 5 | Powered by [Kinc](https://github.com/Kode/Kinc) - low-level hardware abstraction library. 6 | 7 | ```bash 8 | git clone https://github.com/armory3d/armorcore 9 | cd armorcore 10 | ``` 11 | 12 | **Windows (x64)** 13 | ```bash 14 | ./make --graphics direct3d12 15 | # Open generated Visual Studio project at `build\Armory.sln` 16 | # Build for x64 & release 17 | ``` 18 | 19 | **Linux (x64)** 20 | ```bash 21 | ./make --graphics vulkan --compile 22 | ``` 23 | 24 | **macOS (arm64)** 25 | ```bash 26 | ./make --graphics metal 27 | # Open generated Xcode project at `build/Armory.xcodeproj` 28 | # Build 29 | ``` 30 | 31 | **Android (arm64)** 32 | ```bash 33 | ./make --graphics vulkan --target android 34 | # Open generated Android Studio project at `build/Armory` 35 | # Build 36 | ``` 37 | 38 | **iOS (arm64)** 39 | ```bash 40 | ./make --graphics metal --target ios 41 | # Open generated Xcode project at `build/Armory.xcodeproj` 42 | # Build 43 | ``` 44 | 45 | **wasm** 46 | ```bash 47 | ./make --graphics webgpu --target wasm 48 | ``` 49 | -------------------------------------------------------------------------------- /shaders/g2_colored.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | in vec4 fragment_color; 4 | out vec4 frag_color; 5 | 6 | void main() { 7 | frag_color = fragment_color; 8 | } 9 | -------------------------------------------------------------------------------- /shaders/g2_colored.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | uniform mat4 P; 4 | 5 | in vec3 pos; 6 | in vec4 col; 7 | out vec4 fragment_color; 8 | 9 | void main() { 10 | gl_Position = mul(vec4(pos, 1.0), P); 11 | fragment_color = col; 12 | } 13 | -------------------------------------------------------------------------------- /shaders/g2_image.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | uniform sampler2D tex; 4 | 5 | in vec2 tex_coord; 6 | in vec4 color; 7 | out vec4 frag_color; 8 | 9 | void main() { 10 | vec4 texcolor = texture(tex, tex_coord) * color; 11 | texcolor.rgb = texcolor.rgb * texcolor.a * color.a; 12 | frag_color = texcolor; 13 | } 14 | -------------------------------------------------------------------------------- /shaders/g2_image.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | uniform mat4 P; 4 | 5 | in vec3 pos; 6 | in vec2 tex; 7 | in vec4 col; 8 | out vec2 tex_coord; 9 | out vec4 color; 10 | 11 | void main() { 12 | gl_Position = mul(vec4(pos, 1.0), P); 13 | tex_coord = tex; 14 | color = col; 15 | } 16 | -------------------------------------------------------------------------------- /shaders/g2_text.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | uniform sampler2D tex; 4 | 5 | in vec2 tex_coord; 6 | in vec4 fragment_color; 7 | out vec4 frag_color; 8 | 9 | void main() { 10 | frag_color = vec4(fragment_color.rgb, texture(tex, tex_coord).r * fragment_color.a); 11 | } 12 | -------------------------------------------------------------------------------- /shaders/g2_text.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | uniform mat4 P; 4 | 5 | in vec3 pos; 6 | in vec2 tex; 7 | in vec4 col; 8 | out vec2 tex_coord; 9 | out vec4 fragment_color; 10 | 11 | void main() { 12 | gl_Position = mul(vec4(pos, 1.0), P); 13 | tex_coord = tex; 14 | fragment_color = col; 15 | } 16 | -------------------------------------------------------------------------------- /sources/backends/android/java/arm/AndroidHttpRequest.java: -------------------------------------------------------------------------------- 1 | package arm; 2 | 3 | // TODO: Move to Kinc 4 | 5 | import java.io.BufferedInputStream; 6 | import java.io.ByteArrayOutputStream; 7 | import java.io.InputStream; 8 | import java.net.HttpURLConnection; 9 | import java.net.URL; 10 | 11 | class AndroidHttpRequest { 12 | 13 | public static byte[] androidHttpRequest(String address) throws Exception { 14 | // https://developer.android.com/reference/java/net/HttpURLConnection.html 15 | URL url = new URL(address); 16 | HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection(); 17 | InputStream in = new BufferedInputStream(urlConnection.getInputStream()); 18 | 19 | ByteArrayOutputStream buffer = new ByteArrayOutputStream(); 20 | int i; 21 | byte[] data = new byte[4]; 22 | while ((i = in.read(data, 0, data.length)) != -1) { 23 | buffer.write(data, 0, i); 24 | } 25 | buffer.flush(); 26 | byte[] result = buffer.toByteArray(); 27 | 28 | urlConnection.disconnect(); 29 | return result; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /sources/backends/android/java/tech/kinc/KincMoviePlayer.kt: -------------------------------------------------------------------------------- 1 | package tech.kinc 2 | 3 | import java.util.ArrayList 4 | 5 | import android.view.Surface 6 | 7 | class KincMoviePlayer(var path: String) { 8 | companion object { 9 | var players = ArrayList() 10 | 11 | @JvmStatic 12 | fun updateAll() { 13 | for (player in KincMoviePlayer.players) { 14 | player!!.update() 15 | } 16 | } 17 | 18 | fun remove(id: Int) { 19 | players[id] = null 20 | } 21 | } 22 | 23 | private var movieTexture: KincMovieTexture? = null 24 | var id: Int = players.size 25 | 26 | init { 27 | players.add(this) 28 | } 29 | 30 | fun init() { 31 | movieTexture = KincMovieTexture() 32 | val surface = Surface(movieTexture!!.surfaceTexture) 33 | nativeCreate(path, surface, id) 34 | surface.release() 35 | } 36 | 37 | fun getMovieTexture(): KincMovieTexture? { 38 | return movieTexture 39 | } 40 | 41 | fun update(): Boolean { 42 | return movieTexture!!.update() 43 | } 44 | 45 | fun getTextureId(): Int { 46 | return movieTexture!!.textureId 47 | } 48 | 49 | private external fun nativeCreate(path: String, surface: Surface, id: Int) 50 | } 51 | -------------------------------------------------------------------------------- /sources/backends/android/kinc/backend/Android.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | // name in usual Java syntax (points, no slashes) 10 | jclass kinc_android_find_class(JNIEnv *env, const char *name); 11 | 12 | ANativeActivity *kinc_android_get_activity(void); 13 | 14 | AAssetManager *kinc_android_get_asset_manager(void); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /sources/backends/android/kinc/backend/android_file_dialog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | void AndroidFileDialogOpen(); 10 | wchar_t *AndroidFileDialogSave(); 11 | void android_check_permissions(); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | -------------------------------------------------------------------------------- /sources/backends/android/kinc/backend/android_http_request.c: -------------------------------------------------------------------------------- 1 | #include "android_http_request.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | ANativeActivity *kinc_android_get_activity(void); 8 | jclass kinc_android_find_class(JNIEnv *env, const char *name); 9 | 10 | void android_http_request(const char *url, const char *path, const char *data, int port, bool secure, int method, const char *header, 11 | kinc_http_callback_t callback, void *callbackdata) { 12 | ANativeActivity *activity = kinc_android_get_activity(); 13 | JNIEnv *env; 14 | JavaVM *vm = kinc_android_get_activity()->vm; 15 | (*vm)->AttachCurrentThread(vm, &env, NULL); 16 | jclass activityClass = kinc_android_find_class(env, "arm.AndroidHttpRequest"); 17 | 18 | jstring jstr = (*env)->NewStringUTF(env, url); 19 | jbyteArray bytes_array = (jbyteArray)((*env)->CallStaticObjectMethod(env, activityClass, (*env)->GetStaticMethodID(env, activityClass, "androidHttpRequest", "(Ljava/lang/String;)[B"), jstr)); 20 | jsize num_bytes = (*env)->GetArrayLength(env, bytes_array); 21 | jbyte *elements = (*env)->GetByteArrayElements(env, bytes_array, NULL); 22 | if (elements != NULL) { 23 | callback(0, 200, (char *)elements, callbackdata); 24 | // (*env)->ReleaseByteArrayElements(env, bytes_array, elements, JNI_ABORT); 25 | } 26 | 27 | (*vm)->DetachCurrentThread(vm); 28 | } 29 | -------------------------------------------------------------------------------- /sources/backends/android/kinc/backend/android_http_request.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | typedef void (*kinc_http_callback_t)(int error, int response, const char *body, void *callbackdata); 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | void android_http_request(const char *url, const char *path, const char *data, int port, bool secure, int method, const char *header, 12 | kinc_http_callback_t callback, void *callbackdata); 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /sources/backends/android/kinc/backend/androidunit.c: -------------------------------------------------------------------------------- 1 | #include "audio.c.h" 2 | #include "display.c.h" 3 | #include "system.c.h" 4 | #include "window.c.h" 5 | #include "video.c.h" -------------------------------------------------------------------------------- /sources/backends/android/kinc/backend/video.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | void *assetReader; 11 | void *videoTrackOutput; 12 | void *audioTrackOutput; 13 | double start; 14 | double next; 15 | // double audioTime; 16 | unsigned long long audioTime; 17 | bool playing; 18 | void *sound; 19 | void *androidVideo; 20 | int id; 21 | kinc_g4_texture_t image; 22 | double lastTime; 23 | int myWidth; 24 | int myHeight; 25 | } kinc_video_impl_t; 26 | 27 | typedef struct kinc_internal_video_sound_stream { 28 | void *audioTrackOutput; 29 | float *buffer; 30 | int bufferSize; 31 | int bufferWritePosition; 32 | int bufferReadPosition; 33 | uint64_t read; 34 | uint64_t written; 35 | } kinc_internal_video_sound_stream_t; 36 | 37 | void kinc_internal_video_sound_stream_init(kinc_internal_video_sound_stream_t *stream, int channel_count, int frequency); 38 | 39 | void kinc_internal_video_sound_stream_destroy(kinc_internal_video_sound_stream_t *stream); 40 | 41 | void kinc_internal_video_sound_stream_insert_data(kinc_internal_video_sound_stream_t *stream, float *data, int sample_count); 42 | 43 | float *kinc_internal_video_sound_stream_next_frame(kinc_internal_video_sound_stream_t *stream); 44 | 45 | bool kinc_internal_video_sound_stream_ended(kinc_internal_video_sound_stream_t *stream); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | -------------------------------------------------------------------------------- /sources/backends/android/kinc/backend/windowdata.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /sources/backends/apple/kinc/backend/appleunit.m: -------------------------------------------------------------------------------- 1 | #include "http.m.h" 2 | #include "system.m.h" 3 | #include "thread.m.h" 4 | #include "video.m.h" 5 | -------------------------------------------------------------------------------- /sources/backends/apple/kinc/backend/system.m.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int kinc_hardware_threads(void) { 4 | return (int)[[NSProcessInfo processInfo] processorCount]; 5 | } 6 | 7 | #ifdef KINC_APPLE_SOC 8 | 9 | int kinc_cpu_cores(void) { 10 | return kinc_hardware_threads(); 11 | } 12 | 13 | #else 14 | 15 | #include 16 | 17 | int kinc_cpu_cores(void) { 18 | uint32_t proper_cpu_count = 1; 19 | size_t count_length = sizeof(count_length); 20 | sysctlbyname("hw.physicalcpu", &proper_cpu_count, &count_length, 0, 0); 21 | return (int)proper_cpu_count; 22 | } 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /sources/backends/apple/kinc/backend/thread.m.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | static void *ThreadProc(void *arg) { 14 | @autoreleasepool { 15 | kinc_thread_t *t = (kinc_thread_t *)arg; 16 | t->impl.thread(t->impl.param); 17 | pthread_exit(NULL); 18 | return NULL; 19 | } 20 | } 21 | 22 | void kinc_thread_init(kinc_thread_t *t, void (*thread)(void *param), void *param) { 23 | t->impl.param = param; 24 | t->impl.thread = thread; 25 | pthread_attr_t attr; 26 | pthread_attr_init(&attr); 27 | // pthread_attr_setstacksize(&attr, 1024 * 64); 28 | struct sched_param sp; 29 | memset(&sp, 0, sizeof(sp)); 30 | sp.sched_priority = 0; 31 | pthread_attr_setschedparam(&attr, &sp); 32 | pthread_create(&t->impl.pthread, &attr, &ThreadProc, t); 33 | // Kt::affirmD(ret == 0); 34 | pthread_attr_destroy(&attr); 35 | } 36 | 37 | void kinc_thread_wait_and_destroy(kinc_thread_t *thread) { 38 | int ret; 39 | do { 40 | ret = pthread_join(thread->impl.pthread, NULL); 41 | } while (ret != 0); 42 | } 43 | 44 | bool kinc_thread_try_to_destroy(kinc_thread_t *thread) { 45 | return pthread_join(thread->impl.pthread, NULL) == 0; 46 | } 47 | 48 | void kinc_threads_init(void) {} 49 | 50 | void kinc_threads_quit(void) {} 51 | -------------------------------------------------------------------------------- /sources/backends/apple/kinc/backend/video.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | typedef struct { 12 | double start; 13 | double videoStart; 14 | double next; 15 | // double audioTime; 16 | unsigned long long audioTime; 17 | bool playing; 18 | bool loop; 19 | void *sound; 20 | bool image_initialized; 21 | kinc_g4_texture_t image; 22 | double lastTime; 23 | float duration; 24 | bool finished; 25 | int myWidth; 26 | int myHeight; 27 | 28 | id videoAsset; 29 | id assetReader; 30 | id videoTrackOutput; 31 | id audioTrackOutput; 32 | id url; 33 | } kinc_video_impl_t; 34 | 35 | typedef struct kinc_internal_video_sound_stream { 36 | float *buffer; 37 | int bufferSize; 38 | int bufferWritePosition; 39 | int bufferReadPosition; 40 | uint64_t read; 41 | uint64_t written; 42 | } kinc_internal_video_sound_stream_t; 43 | 44 | void kinc_internal_video_sound_stream_init(kinc_internal_video_sound_stream_t *stream, int channel_count, int frequency); 45 | 46 | void kinc_internal_video_sound_stream_destroy(kinc_internal_video_sound_stream_t *stream); 47 | 48 | void kinc_internal_video_sound_stream_insert_data(kinc_internal_video_sound_stream_t *stream, float *data, int sample_count); 49 | 50 | float *kinc_internal_video_sound_stream_next_frame(kinc_internal_video_sound_stream_t *stream); 51 | 52 | bool kinc_internal_video_sound_stream_ended(kinc_internal_video_sound_stream_t *stream); 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | -------------------------------------------------------------------------------- /sources/backends/data/android/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22.1) 2 | 3 | project("Kinc") 4 | 5 | set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}{debug_defines}") 6 | set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}{debug_defines}") 7 | set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}{release_defines}") 8 | set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}{release_defines}") 9 | 10 | include_directories( 11 | {includes}) 12 | 13 | add_library( 14 | kinc 15 | SHARED 16 | {files}) 17 | 18 | {libraries1} 19 | target_link_libraries( 20 | kinc 21 | {libraries2}) 22 | -------------------------------------------------------------------------------- /sources/backends/data/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | 23 | -keep public class tech.kinc.KincActivity { 24 | public ; 25 | } 26 | -keep public class tech.kinc.KincMoviePlayer { 27 | public ; 28 | } 29 | -keep public class tech.kinc.KincMovieTexture { 30 | public ; 31 | } 32 | -keepclasseswithmembernames,includedescriptorclasses class * { 33 | native ; 34 | } 35 | -------------------------------------------------------------------------------- /sources/backends/data/android/build.gradle.kts: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | plugins { 3 | id("com.android.application") version "8.1.0" apply false 4 | id("org.jetbrains.kotlin.android") version "1.8.0" apply false 5 | } -------------------------------------------------------------------------------- /sources/backends/data/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Kotlin code style for this project: "official" or "obsolete": 19 | kotlin.code.style=official 20 | # Enables namespacing of each library's R class so that its R class includes only the 21 | # resources declared in the library itself and none from the library's dependencies, 22 | # thereby reducing the size of the R class for that library 23 | android.nonTransitiveRClass=true -------------------------------------------------------------------------------- /sources/backends/data/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armorcore/8b04fdf059977d422e57256a496caefc6291d944/sources/backends/data/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /sources/backends/data/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Aug 04 18:00:20 CEST 2023 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /sources/backends/data/android/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | {permissions} 5 | 12 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /sources/backends/data/android/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | {name} 3 | -------------------------------------------------------------------------------- /sources/backends/data/android/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | gradlePluginPortal() 6 | } 7 | } 8 | dependencyResolutionManagement { 9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 10 | repositories { 11 | google() 12 | mavenCentral() 13 | } 14 | } 15 | 16 | rootProject.name = "{name}" 17 | include(":app") 18 | -------------------------------------------------------------------------------- /sources/backends/data/wasm/JS-Sources/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /sources/backends/data/wasm/JS-Sources/thread_starter.js: -------------------------------------------------------------------------------- 1 | function create_thread(func) { 2 | 3 | } 4 | 5 | onmessage = function(e) { 6 | console.log('onmessage'); 7 | 8 | const mod = e.data.mod; 9 | const memory = e.data.memory; 10 | const func = e.data.func; 11 | 12 | const importObject = { 13 | env: { memory }, 14 | imports: { 15 | imported_func: arg => console.log('thread: ' + arg), 16 | create_thread 17 | } 18 | }; 19 | 20 | WebAssembly.instantiate(mod, importObject).then((instance) => { 21 | console.log('Running thread'); 22 | instance.exports[func](); 23 | }); 24 | }; 25 | -------------------------------------------------------------------------------- /sources/backends/direct3d11/kinc/backend/graphics4/Direct3D11.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #define MAXIMUM_WINDOWS 16 8 | 9 | struct dx_window { 10 | HWND hwnd; 11 | IDXGISwapChain *swapChain; 12 | ID3D11Texture2D *backBuffer; 13 | ID3D11RenderTargetView *renderTargetView; 14 | ID3D11Texture2D *depthStencil; 15 | ID3D11DepthStencilView *depthStencilView; 16 | 17 | int width; 18 | int height; 19 | 20 | int new_width; 21 | int new_height; 22 | 23 | bool vsync; 24 | int depth_bits; 25 | int stencil_bits; 26 | }; 27 | 28 | struct dx_context { 29 | ID3D11Device *device; 30 | ID3D11DeviceContext *context; 31 | IDXGIDevice *dxgiDevice; 32 | IDXGIAdapter *dxgiAdapter; 33 | IDXGIFactory *dxgiFactory; 34 | 35 | int current_window; 36 | struct dx_window windows[MAXIMUM_WINDOWS]; 37 | }; 38 | 39 | extern struct dx_context dx_ctx; 40 | 41 | #include 42 | -------------------------------------------------------------------------------- /sources/backends/direct3d11/kinc/backend/graphics4/ShaderHash.c.h: -------------------------------------------------------------------------------- 1 | #include "ShaderHash.h" 2 | 3 | // djb2 4 | uint32_t kinc_internal_hash_name(unsigned char *str) { 5 | unsigned long hash = 5381; 6 | int c; 7 | while ((c = *str++)) { 8 | hash = hash * 33 ^ c; 9 | } 10 | return hash; 11 | } 12 | -------------------------------------------------------------------------------- /sources/backends/direct3d11/kinc/backend/graphics4/ShaderHash.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef struct { 11 | uint32_t hash; 12 | uint32_t index; 13 | } kinc_internal_hash_index_t; 14 | 15 | uint32_t kinc_internal_hash_name(unsigned char *str); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /sources/backends/direct3d11/kinc/backend/graphics4/compute.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | struct ID3D11Buffer; 10 | 11 | typedef struct kinc_g4_compute_constant_location_impl { 12 | uint32_t offset; 13 | uint32_t size; 14 | uint8_t columns; 15 | uint8_t rows; 16 | } kinc_g4_compute_constant_location_impl; 17 | 18 | typedef struct kinc_g4_compute_texture_unit_impl { 19 | int unit; 20 | } kinc_g4_compute_texture_unit_impl; 21 | 22 | typedef struct kinc_g4_compute_internal_shader_constant { 23 | uint32_t hash; 24 | uint32_t offset; 25 | uint32_t size; 26 | uint8_t columns; 27 | uint8_t rows; 28 | } kinc_g4_compute_internal_shader_constant; 29 | 30 | typedef struct kinc_g4_compute_shader_impl { 31 | kinc_g4_compute_internal_shader_constant constants[64]; 32 | int constantsSize; 33 | kinc_internal_hash_index_t attributes[64]; 34 | kinc_internal_hash_index_t textures[64]; 35 | struct ID3D11Buffer *constantBuffer; 36 | void *shader; 37 | uint8_t *data; 38 | int length; 39 | } kinc_g4_compute_shader_impl; 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | -------------------------------------------------------------------------------- /sources/backends/direct3d11/kinc/backend/graphics4/indexbuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct ID3D11Buffer; 4 | 5 | typedef struct { 6 | struct ID3D11Buffer *ib; 7 | void *indices; 8 | int count; 9 | int usage; 10 | bool sixteen; 11 | int last_start; 12 | int last_count; 13 | } kinc_g4_index_buffer_impl_t; 14 | -------------------------------------------------------------------------------- /sources/backends/direct3d11/kinc/backend/graphics4/pipeline.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | struct ID3D11InputLayout; 8 | struct ID3D11PixelShader; 9 | struct ID3D11VertexShader; 10 | struct ID3D11Buffer; 11 | struct ID3D11DepthStencilState; 12 | struct ID3D11RasterizerState; 13 | struct ID3D11BlendState; 14 | 15 | typedef struct { 16 | // PipelineStateImpl(); 17 | //~PipelineStateImpl(); 18 | struct ID3D11InputLayout *d3d11inputLayout; 19 | struct ID3D11Buffer *fragmentConstantBuffer; 20 | struct ID3D11Buffer *vertexConstantBuffer; 21 | struct ID3D11Buffer *geometryConstantBuffer; 22 | struct ID3D11Buffer *tessEvalConstantBuffer; 23 | struct ID3D11Buffer *tessControlConstantBuffer; 24 | struct ID3D11DepthStencilState *depthStencilState; 25 | struct ID3D11RasterizerState *rasterizerState; 26 | struct ID3D11RasterizerState *rasterizerStateScissor; 27 | struct ID3D11BlendState *blendState; 28 | // void set(Graphics4::PipelineState* pipeline, bool scissoring); 29 | // void setRasterizerState(bool scissoring); 30 | // static void setConstants(); 31 | } kinc_g4_pipeline_impl_t; 32 | 33 | void kinc_internal_set_constants(void); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | -------------------------------------------------------------------------------- /sources/backends/direct3d11/kinc/backend/graphics4/rendertarget.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | struct ID3D11Texture2D; 8 | struct ID3D11RenderTargetView; 9 | struct ID3D11DepthStencilView; 10 | struct ID3D11ShaderResourceView; 11 | 12 | typedef struct { 13 | struct ID3D11Texture2D *textureRender; 14 | struct ID3D11Texture2D *textureSample; 15 | struct ID3D11Texture2D *textureStaging; 16 | struct ID3D11RenderTargetView *renderTargetViewRender[6]; 17 | struct ID3D11RenderTargetView *renderTargetViewSample[6]; 18 | struct ID3D11Texture2D *depthStencil; 19 | struct ID3D11DepthStencilView *depthStencilView[6]; 20 | struct ID3D11ShaderResourceView *renderTargetSRV; 21 | struct ID3D11ShaderResourceView *depthStencilSRV; 22 | int format; 23 | } kinc_g4_render_target_impl_t; 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | -------------------------------------------------------------------------------- /sources/backends/direct3d11/kinc/backend/graphics4/shader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | typedef struct { 13 | uint32_t hash; 14 | uint32_t offset; 15 | uint32_t size; 16 | uint8_t columns; 17 | uint8_t rows; 18 | } kinc_internal_shader_constant_t; 19 | 20 | typedef struct { 21 | kinc_internal_shader_constant_t constants[64]; 22 | int constantsSize; 23 | kinc_internal_hash_index_t attributes[64]; 24 | kinc_internal_hash_index_t textures[64]; 25 | void *shader; 26 | uint8_t *data; 27 | int length; 28 | int type; 29 | } kinc_g4_shader_impl_t; 30 | 31 | typedef struct { 32 | uint32_t vertexOffset; 33 | uint32_t vertexSize; 34 | uint32_t fragmentOffset; 35 | uint32_t fragmentSize; 36 | uint32_t geometryOffset; 37 | uint32_t geometrySize; 38 | uint32_t tessEvalOffset; 39 | uint32_t tessEvalSize; 40 | uint32_t tessControlOffset; 41 | uint32_t tessControlSize; 42 | uint32_t computeOffset; 43 | uint32_t computeSize; 44 | uint8_t vertexColumns; 45 | uint8_t vertexRows; 46 | uint8_t fragmentColumns; 47 | uint8_t fragmentRows; 48 | uint8_t geometryColumns; 49 | uint8_t geometryRows; 50 | uint8_t tessEvalColumns; 51 | uint8_t tessEvalRows; 52 | uint8_t tessControlColumns; 53 | uint8_t tessControlRows; 54 | uint8_t computeColumns; 55 | uint8_t computeRows; 56 | } kinc_g4_constant_location_impl_t; 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | -------------------------------------------------------------------------------- /sources/backends/direct3d11/kinc/backend/graphics4/texture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct ID3D11Texture2D; 4 | struct ID3D11Texture3D; 5 | struct ID3D11ShaderResourceView; 6 | struct ID3D11UnorderedAccessView; 7 | struct ID3D11RenderTargetView; 8 | 9 | // TextureImpl(); 10 | //~TextureImpl(); 11 | // void enableMipmaps(int texWidth, int texHeight, int format); 12 | // void unmipmap(); 13 | // void unset(); 14 | 15 | typedef struct { 16 | bool hasMipmaps; 17 | int stage; 18 | struct ID3D11Texture2D *texture; 19 | struct ID3D11Texture3D *texture3D; 20 | struct ID3D11ShaderResourceView *view; 21 | struct ID3D11UnorderedAccessView *computeView; 22 | struct ID3D11RenderTargetView *renderView; 23 | int rowPitch; 24 | } kinc_g4_texture_impl_t; 25 | -------------------------------------------------------------------------------- /sources/backends/direct3d11/kinc/backend/graphics4/vertexbuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct ID3D11Buffer; 4 | 5 | typedef struct { 6 | struct ID3D11Buffer *vb; 7 | int stride; 8 | int count; 9 | int lockStart; 10 | int lockCount; 11 | float *vertices; 12 | int usage; 13 | } kinc_g4_vertex_buffer_impl_t; 14 | -------------------------------------------------------------------------------- /sources/backends/direct3d12/kinc/backend/graphics5/ShaderHash.c.h: -------------------------------------------------------------------------------- 1 | #include "ShaderHash.h" 2 | 3 | // djb2 4 | uint32_t kinc_internal_hash_name(unsigned char *str) { 5 | unsigned long hash = 5381; 6 | int c; 7 | while ((c = *str++)) { 8 | hash = hash * 33 ^ c; 9 | } 10 | return hash; 11 | } 12 | -------------------------------------------------------------------------------- /sources/backends/direct3d12/kinc/backend/graphics5/ShaderHash.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef struct { 11 | uint32_t hash; 12 | uint32_t index; 13 | } kinc_internal_hash_index_t; 14 | 15 | uint32_t kinc_internal_hash_name(unsigned char *str); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /sources/backends/direct3d12/kinc/backend/graphics5/commandlist.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "d3d12mini.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | struct kinc_g5_pipeline; 12 | struct kinc_g5_render_target; 13 | struct kinc_g5_texture; 14 | struct kinc_g5_sampler; 15 | 16 | #define KINC_INTERNAL_G5_TEXTURE_COUNT 16 17 | 18 | typedef struct { 19 | struct ID3D12CommandAllocator *_commandAllocator; 20 | struct ID3D12GraphicsCommandList *_commandList; 21 | struct kinc_g5_pipeline *_currentPipeline; 22 | int _indexCount; 23 | 24 | #ifndef NDEBUG 25 | bool open; 26 | #endif 27 | 28 | struct D3D12Rect current_full_scissor; 29 | 30 | // keep track of when a command-list is done 31 | uint64_t fence_value; 32 | struct ID3D12Fence *fence; 33 | HANDLE fence_event; 34 | 35 | struct kinc_g5_render_target *currentRenderTargets[KINC_INTERNAL_G5_TEXTURE_COUNT]; 36 | struct kinc_g5_texture *currentTextures[KINC_INTERNAL_G5_TEXTURE_COUNT]; 37 | struct kinc_g5_sampler *current_samplers[KINC_INTERNAL_G5_TEXTURE_COUNT]; 38 | 39 | int heapIndex; 40 | struct ID3D12DescriptorHeap *srvHeap; 41 | struct ID3D12DescriptorHeap *samplerHeap; 42 | } CommandList5Impl; 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | -------------------------------------------------------------------------------- /sources/backends/direct3d12/kinc/backend/graphics5/compute.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | uint32_t hash; 11 | uint32_t offset; 12 | uint32_t size; 13 | uint8_t columns; 14 | uint8_t rows; 15 | } kinc_compute_internal_shader_constant_t; 16 | 17 | typedef struct kinc_g5_compute_shader_impl { 18 | kinc_compute_internal_shader_constant_t constants[64]; 19 | int constantsSize; 20 | kinc_internal_hash_index_t attributes[64]; 21 | kinc_internal_hash_index_t textures[64]; 22 | uint8_t *data; 23 | int length; 24 | struct ID3D12Buffer *constantBuffer; 25 | struct ID3D12PipelineState *pso; 26 | } kinc_g5_compute_shader_impl; 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /sources/backends/direct3d12/kinc/backend/graphics5/constantbuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | struct ID3D12Resource; 8 | 9 | typedef struct { 10 | struct ID3D12Resource *constant_buffer; 11 | int lastStart; 12 | int lastCount; 13 | int mySize; 14 | } ConstantBuffer5Impl; 15 | 16 | extern bool kinc_g5_transposeMat3; 17 | extern bool kinc_g5_transposeMat4; 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /sources/backends/direct3d12/kinc/backend/graphics5/d3d12mini.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | struct ID3D12CommandAllocator; 10 | struct ID3D12GraphicsCommandList; 11 | struct ID3D12Fence; 12 | struct ID3D12Resource; 13 | struct ID3D12DescriptorHeap; 14 | struct IDXGISwapChain; 15 | 16 | typedef void *HANDLE; 17 | typedef unsigned __int64 UINT64; 18 | 19 | struct D3D12Viewport { 20 | float TopLeftX; 21 | float TopLeftY; 22 | float Width; 23 | float Height; 24 | float MinDepth; 25 | float MaxDepth; 26 | }; 27 | 28 | struct D3D12Rect { 29 | long left; 30 | long top; 31 | long right; 32 | long bottom; 33 | }; 34 | 35 | #define QUEUE_SLOT_COUNT 2 36 | 37 | struct dx_window { 38 | #ifndef KINC_DIRECT3D_HAS_NO_SWAPCHAIN 39 | struct IDXGISwapChain *swapChain; 40 | #endif 41 | UINT64 current_fence_value; 42 | UINT64 fence_values[QUEUE_SLOT_COUNT]; 43 | HANDLE frame_fence_events[QUEUE_SLOT_COUNT]; 44 | struct ID3D12Fence *frame_fences[QUEUE_SLOT_COUNT]; 45 | int width; 46 | int height; 47 | int new_width; 48 | int new_height; 49 | int current_backbuffer; 50 | bool vsync; 51 | int window_index; 52 | }; 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | -------------------------------------------------------------------------------- /sources/backends/direct3d12/kinc/backend/graphics5/graphics.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | -------------------------------------------------------------------------------- /sources/backends/direct3d12/kinc/backend/graphics5/indexbuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | struct ID3D12Resource; 8 | 9 | struct D3D12IindexBufferView { 10 | __int64 BufferLocation; 11 | unsigned int SizeInBytes; 12 | int Format; 13 | }; 14 | 15 | typedef struct { 16 | struct ID3D12Resource *index_buffer; 17 | struct D3D12IindexBufferView index_buffer_view; 18 | struct ID3D12Resource *upload_buffer; 19 | int count; 20 | bool gpu_memory; 21 | int format; 22 | int last_start; 23 | int last_count; 24 | } IndexBuffer5Impl; 25 | 26 | struct kinc_g5_index_buffer; 27 | 28 | void kinc_g5_internal_index_buffer_upload(struct kinc_g5_index_buffer *buffer, struct ID3D12GraphicsCommandList *commandList); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /sources/backends/direct3d12/kinc/backend/graphics5/raytrace.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | struct ID3D12StateObject; 8 | struct ID3D12Resource; 9 | 10 | typedef struct { 11 | struct ID3D12StateObject *dxr_state; 12 | struct ID3D12Resource *raygen_shader_table; 13 | struct ID3D12Resource *miss_shader_table; 14 | struct ID3D12Resource *hitgroup_shader_table; 15 | } kinc_raytrace_pipeline_impl_t; 16 | 17 | typedef struct { 18 | struct ID3D12Resource *bottom_level_accel; 19 | struct ID3D12Resource *top_level_accel; 20 | } kinc_raytrace_acceleration_structure_impl_t; 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | -------------------------------------------------------------------------------- /sources/backends/direct3d12/kinc/backend/graphics5/rendertarget.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d12mini.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | enum RenderTargetResourceState { RenderTargetResourceStateUndefined, RenderTargetResourceStateRenderTarget, RenderTargetResourceStateTexture }; 10 | 11 | typedef struct { 12 | struct ID3D12Resource *renderTarget; 13 | struct ID3D12Resource *renderTargetReadback; 14 | struct ID3D12DescriptorHeap *renderTargetDescriptorHeap; 15 | struct ID3D12DescriptorHeap *srvDescriptorHeap; 16 | struct ID3D12DescriptorHeap *depthStencilDescriptorHeap; 17 | struct ID3D12DescriptorHeap *srvDepthDescriptorHeap; 18 | struct ID3D12Resource *depthStencilTexture; 19 | struct D3D12Viewport viewport; 20 | struct D3D12Rect scissor; 21 | int stage; 22 | int stage_depth; 23 | int framebuffer_index; 24 | } RenderTarget5Impl; 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /sources/backends/direct3d12/kinc/backend/graphics5/sampler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct ID3D12DescriptorHeap; 4 | 5 | typedef struct kinc_g5_sampler_impl { 6 | struct ID3D12DescriptorHeap *sampler_heap; 7 | } kinc_g5_sampler_impl_t; 8 | -------------------------------------------------------------------------------- /sources/backends/direct3d12/kinc/backend/graphics5/shader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | typedef struct { 8 | char name[64]; 9 | uint32_t offset; 10 | uint32_t size; 11 | } ShaderConstant; 12 | 13 | typedef struct { 14 | char name[64]; 15 | int attribute; 16 | } ShaderAttribute; 17 | 18 | typedef struct { 19 | char name[64]; 20 | int texture; 21 | } ShaderTexture; 22 | 23 | typedef struct { 24 | ShaderConstant constants[32]; 25 | int constantsSize; 26 | ShaderAttribute attributes[32]; 27 | ShaderTexture textures[32]; 28 | int texturesCount; 29 | void *shader; 30 | uint8_t *data; 31 | int length; 32 | } Shader5Impl; 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | -------------------------------------------------------------------------------- /sources/backends/direct3d12/kinc/backend/graphics5/texture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | struct ID3D12Resource; 8 | struct ID3D12DescriptorHeap; 9 | struct ID3D12GraphicsCommandList; 10 | 11 | typedef struct { 12 | int unit; 13 | } TextureUnit5Impl; 14 | 15 | typedef struct { 16 | bool mipmap; 17 | int stage; 18 | int stride; 19 | struct ID3D12Resource *image; 20 | struct ID3D12Resource *uploadImage; 21 | struct ID3D12DescriptorHeap *srvDescriptorHeap; 22 | } Texture5Impl; 23 | 24 | struct kinc_g5_texture; 25 | struct kinc_g5_command_list; 26 | 27 | void kinc_g5_internal_set_textures(struct kinc_g5_command_list *commandList); 28 | void kinc_g5_internal_texture_set(struct kinc_g5_command_list *commandList, struct kinc_g5_texture *texture, int unit); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /sources/backends/direct3d12/kinc/backend/graphics5/vertexbuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | struct ID3D12Resource; 8 | 9 | struct D3D12VertexBufferView { 10 | __int64 BufferLocation; 11 | unsigned int SizeInBytes; 12 | unsigned int StrideInBytes; 13 | }; 14 | 15 | typedef struct { 16 | // ID3D12Resource* vertexBuffer; 17 | struct ID3D12Resource *uploadBuffer; 18 | struct D3D12VertexBufferView view; 19 | 20 | int myCount; 21 | int myStride; 22 | int lastStart; 23 | int lastCount; 24 | // float* vertices; 25 | // static VertexBuffer5Impl* _current; 26 | } VertexBuffer5Impl; 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /sources/backends/g4ong5/kinc/backend/graphics4/G4.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | -------------------------------------------------------------------------------- /sources/backends/g4ong5/kinc/backend/graphics4/compute.c.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | extern kinc_g5_command_list_t commandList; 13 | 14 | void kinc_g4_compute_shader_init(kinc_g4_compute_shader *shader, void *source, int length) { 15 | kinc_g5_compute_shader_init(&shader->impl.shader, source, length); 16 | } 17 | 18 | void kinc_g4_compute_shader_destroy(kinc_g4_compute_shader *shader) { 19 | kinc_g5_compute_shader_destroy(&shader->impl.shader); 20 | } 21 | 22 | kinc_g4_constant_location_t kinc_g4_compute_shader_get_constant_location(kinc_g4_compute_shader *shader, const char *name) { 23 | kinc_g4_constant_location_t location; 24 | location.impl._location = kinc_g5_compute_shader_get_constant_location(&shader->impl.shader, name); 25 | return location; 26 | } 27 | 28 | kinc_g4_texture_unit_t kinc_g4_compute_shader_get_texture_unit(kinc_g4_compute_shader *shader, const char *name) { 29 | kinc_g5_texture_unit_t g5_unit = kinc_g5_compute_shader_get_texture_unit(&shader->impl.shader, name); 30 | kinc_g4_texture_unit_t g4_unit; 31 | for (int i = 0; i < KINC_G4_SHADER_TYPE_COUNT; ++i) { 32 | g4_unit.stages[i] = g5_unit.stages[i]; 33 | } 34 | return g4_unit; 35 | } 36 | -------------------------------------------------------------------------------- /sources/backends/g4ong5/kinc/backend/graphics4/compute.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | typedef struct kinc_g4_compute_shader_impl { 6 | kinc_g5_compute_shader shader; 7 | } kinc_g4_compute_shader_impl; 8 | -------------------------------------------------------------------------------- /sources/backends/g4ong5/kinc/backend/graphics4/g4ong5unit.c: -------------------------------------------------------------------------------- 1 | #include "samplers.c.h" 2 | 3 | #include "G4.c.h" 4 | #include "compute.c.h" 5 | #include "indexbuffer.c.h" 6 | #include "pipeline.c.h" 7 | #include "rendertarget.c.h" 8 | #include "shader.c.h" 9 | #include "texture.c.h" 10 | #include "vertexbuffer.c.h" -------------------------------------------------------------------------------- /sources/backends/g4ong5/kinc/backend/graphics4/graphics.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "IndexBufferImpl.h" 4 | #include "RenderTargetImpl.h" 5 | #include "TextureImpl.h" 6 | #include "VertexBufferImpl.h" 7 | -------------------------------------------------------------------------------- /sources/backends/g4ong5/kinc/backend/graphics4/indexbuffer.c.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | extern kinc_g5_command_list_t commandList; 6 | 7 | void kinc_g4_index_buffer_init(kinc_g4_index_buffer_t *buffer, int count, kinc_g4_index_buffer_format_t format, kinc_g4_usage_t usage) { 8 | kinc_g5_index_buffer_init(&buffer->impl._buffer, count, (kinc_g5_index_buffer_format_t)format, usage == KINC_G4_USAGE_STATIC); 9 | } 10 | 11 | void kinc_g4_index_buffer_destroy(kinc_g4_index_buffer_t *buffer) { 12 | kinc_g5_index_buffer_destroy(&buffer->impl._buffer); 13 | } 14 | 15 | void *kinc_g4_index_buffer_lock_all(kinc_g4_index_buffer_t *buffer) { 16 | return kinc_g5_index_buffer_lock_all(&buffer->impl._buffer); 17 | } 18 | 19 | void *kinc_g4_index_buffer_lock(kinc_g4_index_buffer_t *buffer, int start, int count) { 20 | return kinc_g5_index_buffer_lock(&buffer->impl._buffer, start, count); 21 | } 22 | 23 | void kinc_g4_index_buffer_unlock_all(kinc_g4_index_buffer_t *buffer) { 24 | kinc_g5_index_buffer_unlock_all(&buffer->impl._buffer); 25 | kinc_g5_command_list_upload_index_buffer(&commandList, &buffer->impl._buffer); 26 | } 27 | 28 | void kinc_g4_index_buffer_unlock(kinc_g4_index_buffer_t *buffer, int count) { 29 | kinc_g5_index_buffer_unlock(&buffer->impl._buffer, count); 30 | kinc_g5_command_list_upload_index_buffer(&commandList, &buffer->impl._buffer); 31 | } 32 | 33 | int kinc_g4_index_buffer_count(kinc_g4_index_buffer_t *buffer) { 34 | return kinc_g5_index_buffer_count(&buffer->impl._buffer); 35 | } 36 | -------------------------------------------------------------------------------- /sources/backends/g4ong5/kinc/backend/graphics4/indexbuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | kinc_g5_index_buffer_t _buffer; 11 | } kinc_g4_index_buffer_impl_t; 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | -------------------------------------------------------------------------------- /sources/backends/g4ong5/kinc/backend/graphics4/pipeline.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef struct { 11 | // PipelineStateImpl(); 12 | kinc_g5_pipeline_t _pipeline; 13 | } kinc_g4_pipeline_impl_t; 14 | 15 | typedef struct { 16 | kinc_g5_constant_location_t _location; 17 | } kinc_g4_constant_location_impl_t; 18 | 19 | typedef struct { 20 | int nothing; 21 | } Kinc_G4_AttributeLocationImpl; 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | -------------------------------------------------------------------------------- /sources/backends/g4ong5/kinc/backend/graphics4/rendertarget.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | enum kinc_internal_render_target_state { KINC_INTERNAL_RENDER_TARGET_STATE_RENDER_TARGET, KINC_INTERNAL_RENDER_TARGET_STATE_TEXTURE }; 10 | 11 | typedef struct { 12 | // RenderTargetImpl(int width, int height, int depthBufferBits, bool antialiasing, Graphics5::RenderTargetFormat format, int stencilBufferBits, 13 | // int contextId); 14 | // RenderTargetImpl(int cubeMapSize, int depthBufferBits, bool antialiasing, Graphics5::RenderTargetFormat format, int stencilBufferBits, int contextId); 15 | kinc_g5_render_target_t _renderTarget; 16 | enum kinc_internal_render_target_state state; 17 | } kinc_g4_render_target_impl_t; 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /sources/backends/g4ong5/kinc/backend/graphics4/shader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | // ShaderImpl(void *data, int length, Graphics5::ShaderType type); 11 | kinc_g5_shader_t _shader; 12 | } kinc_g4_shader_impl_t; 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /sources/backends/g4ong5/kinc/backend/graphics4/texture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | typedef struct { 12 | kinc_g5_texture_unit_t _unit; 13 | } kinc_g4_texture_unit_impl_t; 14 | 15 | typedef struct { 16 | /*TextureImpl(); 17 | TextureImpl(int width, int height, Image::Format format, bool readable); 18 | TextureImpl(int width, int height, int depth, Image::Format format, bool readable); 19 | ~TextureImpl(); 20 | void unmipmap(); 21 | void unset();*/ 22 | 23 | kinc_g5_texture_t _texture; 24 | bool _uploaded; 25 | } kinc_g4_texture_impl_t; 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | -------------------------------------------------------------------------------- /sources/backends/g4ong5/kinc/backend/graphics4/vertexbuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | int myCount; 11 | // void prepareLock(); 12 | kinc_g5_vertex_buffer_t _buffer; 13 | int _currentIndex; 14 | int _multiple; 15 | uint64_t _lastFrameNumber; 16 | } kinc_g4_vertex_buffer_impl_t; 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /sources/backends/g5ong4/kinc/backend/graphics5/G5onG4.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | -------------------------------------------------------------------------------- /sources/backends/g5ong4/kinc/backend/graphics5/commandlist.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | struct kinc_g5_pipeline; 8 | 9 | #define KINC_G5ONG4_COMMANDS_SIZE 1024 10 | 11 | typedef struct { 12 | struct kinc_g5_pipeline *_currentPipeline; 13 | int _indexCount; 14 | char commands[KINC_G5ONG4_COMMANDS_SIZE]; 15 | int commandIndex; 16 | bool closed; 17 | } CommandList5Impl; 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /sources/backends/g5ong4/kinc/backend/graphics5/compute.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | void kinc_g5_compute_shader_init(kinc_g5_compute_shader *shader, void *source, int length) { 7 | kinc_g4_compute_shader_init(&shader->impl.g4, source, length); 8 | } 9 | 10 | void kinc_g5_compute_shader_destroy(kinc_g5_compute_shader *shader) { 11 | kinc_g4_compute_shader_destroy(&shader->impl.g4); 12 | } 13 | 14 | kinc_g5_constant_location_t kinc_g5_compute_shader_get_constant_location(kinc_g5_compute_shader *shader, const char *name) { 15 | kinc_g5_constant_location_t location = {0}; 16 | location.impl.location = kinc_g4_compute_shader_get_constant_location(&shader->impl.g4, name); 17 | return location; 18 | } 19 | 20 | kinc_g5_texture_unit_t kinc_g5_compute_shader_get_texture_unit(kinc_g5_compute_shader *shader, const char *name) { 21 | kinc_g5_texture_unit_t g5_unit = {0}; 22 | kinc_g4_texture_unit_t g4_unit = kinc_g4_compute_shader_get_texture_unit(&shader->impl.g4, name); 23 | assert(KINC_G4_SHADER_TYPE_COUNT == KINC_G5_SHADER_TYPE_COUNT); 24 | for (int i = 0; i < KINC_G4_SHADER_TYPE_COUNT; ++i) { 25 | g5_unit.stages[i] = g4_unit.stages[i]; 26 | } 27 | return g5_unit; 28 | } 29 | -------------------------------------------------------------------------------- /sources/backends/g5ong4/kinc/backend/graphics5/compute.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | typedef struct kinc_g5_compute_shader_impl { 6 | kinc_g4_compute_shader g4; 7 | } kinc_g5_compute_shader_impl; 8 | -------------------------------------------------------------------------------- /sources/backends/g5ong4/kinc/backend/graphics5/constantbuffer.c.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | bool kinc_g5_transposeMat3 = false; 10 | bool kinc_g5_transposeMat4 = false; 11 | 12 | void kinc_g5_constant_buffer_init(kinc_g5_constant_buffer_t *buffer, int size) { 13 | buffer->impl.mySize = size; 14 | buffer->data = malloc(size); 15 | } 16 | 17 | void kinc_g5_constant_buffer_destroy(kinc_g5_constant_buffer_t *buffer) { 18 | free(buffer->data); 19 | } 20 | 21 | void kinc_g5_constant_buffer_lock_all(kinc_g5_constant_buffer_t *buffer) {} 22 | 23 | void kinc_g5_constant_buffer_lock(kinc_g5_constant_buffer_t *buffer, int start, int count) {} 24 | 25 | void kinc_g5_constant_buffer_unlock(kinc_g5_constant_buffer_t *buffer) {} 26 | 27 | int kinc_g5_constant_buffer_size(kinc_g5_constant_buffer_t *buffer) { 28 | return buffer->impl.mySize; 29 | } 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | -------------------------------------------------------------------------------- /sources/backends/g5ong4/kinc/backend/graphics5/constantbuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | typedef struct { 8 | int lastStart; 9 | int lastCount; 10 | int mySize; 11 | } ConstantBuffer5Impl; 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | -------------------------------------------------------------------------------- /sources/backends/g5ong4/kinc/backend/graphics5/g5ong4unit.c: -------------------------------------------------------------------------------- 1 | #include "G5onG4.c.h" 2 | #include "commandlist.c.h" 3 | #include "constantbuffer.c.h" 4 | #include "indexbuffer.c.h" 5 | #include "pipeline.c.h" 6 | #include "rendertarget.c.h" 7 | #include "sampler.c.h" 8 | #include "shader.c.h" 9 | #include "texture.c.h" 10 | #include "vertexbuffer.c.h" 11 | -------------------------------------------------------------------------------- /sources/backends/g5ong4/kinc/backend/graphics5/graphics.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | -------------------------------------------------------------------------------- /sources/backends/g5ong4/kinc/backend/graphics5/indexbuffer.c.h: -------------------------------------------------------------------------------- 1 | #include "indexbuffer.h" 2 | 3 | #include 4 | 5 | #include 6 | 7 | void kinc_g5_index_buffer_init(kinc_g5_index_buffer_t *buffer, int count, kinc_g5_index_buffer_format_t format, bool gpuMemory) { 8 | buffer->impl.myCount = count; 9 | kinc_g4_index_buffer_init(&buffer->impl.buffer, count, (kinc_g4_index_buffer_format_t)format, gpuMemory ? KINC_G4_USAGE_STATIC : KINC_G4_USAGE_DYNAMIC); 10 | } 11 | 12 | void kinc_g5_index_buffer_destroy(kinc_g5_index_buffer_t *buffer) { 13 | kinc_g4_index_buffer_destroy(&buffer->impl.buffer); 14 | } 15 | 16 | void *kinc_g5_index_buffer_lock_all(kinc_g5_index_buffer_t *buffer) { 17 | return kinc_g4_index_buffer_lock_all(&buffer->impl.buffer); 18 | } 19 | 20 | void *kinc_g5_index_buffer_lock(kinc_g5_index_buffer_t *buffer, int start, int count) { 21 | return kinc_g4_index_buffer_lock(&buffer->impl.buffer, start, count); 22 | } 23 | 24 | void kinc_g5_index_buffer_unlock_all(kinc_g5_index_buffer_t *buffer) { 25 | kinc_g4_index_buffer_unlock_all(&buffer->impl.buffer); 26 | } 27 | 28 | void kinc_g5_index_buffer_unlock(kinc_g5_index_buffer_t *buffer, int count) { 29 | kinc_g4_index_buffer_unlock(&buffer->impl.buffer, count); 30 | } 31 | 32 | int kinc_g5_index_buffer_count(kinc_g5_index_buffer_t *buffer) { 33 | return buffer->impl.myCount; 34 | } 35 | -------------------------------------------------------------------------------- /sources/backends/g5ong4/kinc/backend/graphics5/indexbuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | kinc_g4_index_buffer_t buffer; 11 | int myCount; 12 | } IndexBuffer5Impl; 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /sources/backends/g5ong4/kinc/backend/graphics5/pipeline.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | kinc_g4_pipeline_t pipe; 11 | // int vertex_location_count; 12 | // int fragment_location_count; 13 | // kinc_g4_constant_location_t *vertex_locations; 14 | // kinc_g4_constant_location_t *fragment_locations; 15 | // int *vertex_sizes; 16 | // int *fragment_sizes; 17 | } PipelineState5Impl; 18 | 19 | typedef struct { 20 | int a; 21 | } ComputePipelineState5Impl; 22 | 23 | typedef struct { 24 | kinc_g4_constant_location_t location; 25 | } ConstantLocation5Impl; 26 | 27 | typedef struct { 28 | int nothing; 29 | } AttributeLocation5Impl; 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | -------------------------------------------------------------------------------- /sources/backends/g5ong4/kinc/backend/graphics5/rendertarget.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | typedef struct { 9 | kinc_g4_render_target_t target; 10 | } RenderTarget5Impl; 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | -------------------------------------------------------------------------------- /sources/backends/g5ong4/kinc/backend/graphics5/sampler.c.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void kinc_g5_sampler_init(kinc_g5_sampler_t *sampler, const kinc_g5_sampler_options_t *options) {} 4 | 5 | void kinc_g5_sampler_destroy(kinc_g5_sampler_t *sampler) {} 6 | -------------------------------------------------------------------------------- /sources/backends/g5ong4/kinc/backend/graphics5/sampler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef struct kinc_g5_sampler_impl { 4 | int a; 5 | } kinc_g5_sampler_impl_t; 6 | -------------------------------------------------------------------------------- /sources/backends/g5ong4/kinc/backend/graphics5/shader.c.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void kinc_g5_shader_init(kinc_g5_shader_t *shader, const void *source, size_t length, kinc_g5_shader_type_t type) { 5 | kinc_g4_shader_init(&shader->impl.shader, source, length, (kinc_g4_shader_type_t)type); 6 | } 7 | 8 | void kinc_g5_shader_destroy(kinc_g5_shader_t *shader) { 9 | kinc_g4_shader_destroy(&shader->impl.shader); 10 | } 11 | -------------------------------------------------------------------------------- /sources/backends/g5ong4/kinc/backend/graphics5/shader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | kinc_g4_shader_t shader; 11 | } Shader5Impl; 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | -------------------------------------------------------------------------------- /sources/backends/g5ong4/kinc/backend/graphics5/texture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef struct { 11 | kinc_g4_texture_unit_t unit; 12 | } TextureUnit5Impl; 13 | 14 | typedef struct { 15 | kinc_g4_texture_t texture; 16 | } Texture5Impl; 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /sources/backends/g5ong4/kinc/backend/graphics5/vertexbuffer.c.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | kinc_g5_vertex_buffer_t *kinc_g5_internal_current_vertex_buffer = NULL; 6 | 7 | void kinc_g5_vertex_buffer_init(kinc_g5_vertex_buffer_t *buffer, int count, kinc_g5_vertex_structure_t *structure, bool gpuMemory, int instanceDataStepRate) { 8 | buffer->impl.myCount = count; 9 | buffer->impl.myStart = 0; 10 | kinc_g4_vertex_buffer_init(&buffer->impl.buffer, count, structure, KINC_G4_USAGE_STATIC, instanceDataStepRate); 11 | } 12 | 13 | void kinc_g5_vertex_buffer_destroy(kinc_g5_vertex_buffer_t *buffer) { 14 | kinc_g4_vertex_buffer_destroy(&buffer->impl.buffer); 15 | } 16 | 17 | float *kinc_g5_vertex_buffer_lock_all(kinc_g5_vertex_buffer_t *buffer) { 18 | return kinc_g4_vertex_buffer_lock_all(&buffer->impl.buffer); 19 | } 20 | 21 | float *kinc_g5_vertex_buffer_lock(kinc_g5_vertex_buffer_t *buffer, int start, int count) { 22 | return kinc_g4_vertex_buffer_lock(&buffer->impl.buffer, start, count); 23 | } 24 | 25 | void kinc_g5_vertex_buffer_unlock_all(kinc_g5_vertex_buffer_t *buffer) { 26 | kinc_g4_vertex_buffer_unlock_all(&buffer->impl.buffer); 27 | } 28 | 29 | void kinc_g5_vertex_buffer_unlock(kinc_g5_vertex_buffer_t *buffer, int count) { 30 | kinc_g4_vertex_buffer_unlock(&buffer->impl.buffer, count); 31 | } 32 | 33 | int kinc_g5_vertex_buffer_count(kinc_g5_vertex_buffer_t *buffer) { 34 | return buffer->impl.myCount; 35 | } 36 | 37 | int kinc_g5_vertex_buffer_stride(kinc_g5_vertex_buffer_t *buffer) { 38 | return kinc_g4_vertex_buffer_stride(&buffer->impl.buffer); 39 | } 40 | -------------------------------------------------------------------------------- /sources/backends/g5ong4/kinc/backend/graphics5/vertexbuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | kinc_g4_vertex_buffer_t buffer; 11 | int myCount; 12 | int myStart; 13 | } VertexBuffer5Impl; 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /sources/backends/ios/kinc/backend/GLView.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #ifdef KINC_METAL 4 | #import 5 | #import 6 | #else 7 | #import 8 | #import 9 | #endif 10 | #ifndef KINC_TVOS 11 | #import 12 | #endif 13 | 14 | struct kinc_g5_render_target; 15 | 16 | @interface GLView : UIView { 17 | @private 18 | #ifdef KINC_METAL 19 | id device; 20 | id commandQueue; 21 | id commandBuffer; 22 | id commandEncoder; 23 | id drawable; 24 | id library; 25 | MTLRenderPassDescriptor *renderPassDescriptor; 26 | id depthTexture; 27 | #else 28 | EAGLContext *context; 29 | GLuint defaultFramebuffer, colorRenderbuffer, depthStencilRenderbuffer; 30 | #endif 31 | 32 | #ifndef KINC_TVOS 33 | CMMotionManager *motionManager; 34 | #endif 35 | bool hasAccelerometer; 36 | float lastAccelerometerX, lastAccelerometerY, lastAccelerometerZ; 37 | } 38 | 39 | - (void)begin; 40 | - (void)end; 41 | - (void)showKeyboard; 42 | - (void)hideKeyboard; 43 | #ifdef KINC_METAL 44 | - (CAMetalLayer *)metalLayer; 45 | - (id)metalDevice; 46 | - (id)metalLibrary; 47 | - (id)metalQueue; 48 | #endif 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /sources/backends/ios/kinc/backend/GLViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | #import 5 | #ifndef KINC_TVOS 6 | #import 7 | #endif 8 | 9 | @interface GLViewController : UIViewController { 10 | @private 11 | } 12 | 13 | - (void)loadView; 14 | 15 | - (void)setVisible:(BOOL)value; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /sources/backends/ios/kinc/backend/KoreAppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class GLView; 4 | 5 | @interface KoreAppDelegate : NSObject { 6 | } 7 | 8 | @end -------------------------------------------------------------------------------- /sources/backends/ios/kinc/backend/display.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Kore { 4 | namespace Display { 5 | int count(); 6 | int x(int index); 7 | int y(int index); 8 | int height(int index); 9 | int width(int index); 10 | bool isPrimary(int index); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /sources/backends/ios/kinc/backend/display.m.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #include 4 | #include 5 | 6 | void kinc_display_init(void) {} 7 | 8 | kinc_display_mode_t kinc_display_available_mode(int display, int mode) { 9 | kinc_display_mode_t dm; 10 | dm.width = kinc_window_width(0); 11 | dm.height = kinc_window_height(0); 12 | dm.frequency = 60; 13 | dm.bits_per_pixel = 32; 14 | return dm; 15 | } 16 | 17 | int kinc_display_count_available_modes(int display) { 18 | return 1; 19 | } 20 | 21 | bool kinc_display_available(int display) { 22 | return true; 23 | } 24 | 25 | const char *kinc_display_name(int display) { 26 | return "Display"; 27 | } 28 | 29 | kinc_display_mode_t kinc_display_current_mode(int display) { 30 | kinc_display_mode_t dm; 31 | dm.width = kinc_window_width(0); 32 | dm.height = kinc_window_height(0); 33 | dm.frequency = (int)[[UIScreen mainScreen] maximumFramesPerSecond]; 34 | dm.bits_per_pixel = 32; 35 | return dm; 36 | } 37 | 38 | int kinc_count_displays(void) { 39 | return 1; 40 | } 41 | 42 | int kinc_primary_display(void) { 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /sources/backends/ios/kinc/backend/displaydata.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct DisplayData { 4 | DisplayData(); 5 | }; 6 | -------------------------------------------------------------------------------- /sources/backends/ios/kinc/backend/ios_file_dialog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | void IOSFileDialogOpen(); 6 | wchar_t *IOSFileDialogSave(); 7 | void IOSDeleteFile(const char *path); 8 | -------------------------------------------------------------------------------- /sources/backends/ios/kinc/backend/ios_file_dialog.m: -------------------------------------------------------------------------------- 1 | #import "ios_file_dialog.h" 2 | 3 | #import 4 | 5 | void IOSFileDialogOpen() { 6 | UIViewController *glViewController = [UIApplication sharedApplication].keyWindow.rootViewController; 7 | UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.data"] inMode:UIDocumentPickerModeOpen]; 8 | documentPicker.delegate = glViewController; 9 | documentPicker.modalPresentationStyle = UIModalPresentationFormSheet; 10 | [glViewController presentViewController:documentPicker animated:YES completion:nil]; 11 | } 12 | 13 | wchar_t* IOSFileDialogSave() { 14 | NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 15 | NSString *documentsDirectory = [paths objectAtIndex:0]; 16 | NSString *fileName = @"/untitled"; 17 | NSString *filePath = [documentsDirectory stringByAppendingString:fileName]; 18 | return (wchar_t*)[filePath cStringUsingEncoding:NSUTF32LittleEndianStringEncoding]; 19 | } 20 | 21 | void IOSDeleteFile(const char *path) { 22 | NSError *error = nil; 23 | NSString *nspath = [NSString stringWithUTF8String:path]; 24 | [[NSFileManager defaultManager] removeItemAtPath:nspath error:&error]; 25 | } 26 | -------------------------------------------------------------------------------- /sources/backends/ios/kinc/backend/iosunit.m: -------------------------------------------------------------------------------- 1 | #include "GLView.m.h" 2 | #include "GLViewController.m.h" 3 | #include "KoreAppDelegate.m.h" 4 | #include "audio.m.h" 5 | #include "display.m.h" 6 | #include "motion.m.h" 7 | #include "mouse.c.h" 8 | #include "system.m.h" 9 | #include "window.c.h" 10 | -------------------------------------------------------------------------------- /sources/backends/ios/kinc/backend/motion.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #import 3 | // #include 4 | 5 | @interface Motion : NSObject { 6 | // Kt::GyroHandler* gyroHandler; 7 | } 8 | 9 | // + (Motion*)the; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /sources/backends/ios/kinc/backend/motion.m.h: -------------------------------------------------------------------------------- 1 | #import "motion.h" 2 | 3 | @implementation Motion 4 | /* 5 | Motion* the = [[Motion alloc]init]; 6 | + (Motion*) the {return the;}; 7 | 8 | -(void)configureAccelerometerWithGyroHandler: (Kt::GyroHandler*) gyroHandler 9 | AndUpdateInterval: (int) updateInterval 10 | { 11 | UIAccelerometer *accelerometer = [UIAccelerometer sharedAccelerometer]; 12 | accelerometer.updateInterval = 1 / updateInterval; 13 | 14 | accelerometer.delegate = self; 15 | self->gyroHandler = gyroHandler; 16 | } 17 | 18 | - (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration{ 19 | //gyroHandler->updateAccelerometerData(acceleration.x, acceleration.y, acceleration.z); 20 | } 21 | 22 | void Kt::GyroHandler::configAccelerometer(int updateInterval){ 23 | [[Motion the]configureAccelerometerWithGyroHandler:this AndUpdateInterval:updateInterval]; 24 | }; 25 | */ 26 | @end 27 | -------------------------------------------------------------------------------- /sources/backends/ios/kinc/backend/mouse.c.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void kinc_internal_mouse_lock(int window) {} 4 | 5 | void kinc_internal_mouse_unlock(void) {} 6 | 7 | bool kinc_mouse_can_lock(void) { 8 | return false; 9 | } 10 | 11 | void kinc_mouse_show(void) {} 12 | 13 | void kinc_mouse_hide(void) {} 14 | 15 | void kinc_mouse_set_position(int window, int x, int y) {} 16 | 17 | void kinc_mouse_get_position(int window, int *x, int *y) {} 18 | 19 | void kinc_mouse_set_cursor(int cursor_index) {} 20 | -------------------------------------------------------------------------------- /sources/backends/ios/kinc/backend/windowdata.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct WindowData { 4 | WindowData(); 5 | }; 6 | -------------------------------------------------------------------------------- /sources/backends/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2024 the Kinc Development Team 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 19 | 3. This notice may not be removed or altered from any source distribution. 20 | -------------------------------------------------------------------------------- /sources/backends/linux/kinc/backend/display.c.h: -------------------------------------------------------------------------------- 1 | #include "funcs.h" 2 | #include 3 | 4 | void kinc_display_init() { 5 | static bool display_initialized = false; 6 | if (display_initialized) { 7 | return; 8 | } 9 | 10 | kinc_linux_init_procs(); 11 | if (procs.display_init != NULL) { 12 | procs.display_init(); 13 | display_initialized = true; 14 | } 15 | } 16 | 17 | kinc_display_mode_t kinc_display_available_mode(int display, int mode) { 18 | return procs.display_available_mode(display, mode); 19 | } 20 | 21 | int kinc_display_count_available_modes(int display) { 22 | return procs.display_count_available_modes(display); 23 | } 24 | 25 | bool kinc_display_available(int display) { 26 | return procs.display_available(display); 27 | } 28 | 29 | const char *kinc_display_name(int display) { 30 | return procs.display_name(display); 31 | } 32 | 33 | kinc_display_mode_t kinc_display_current_mode(int display) { 34 | return procs.display_current_mode(display); 35 | } 36 | 37 | int kinc_primary_display(void) { 38 | return procs.display_primary(); 39 | } 40 | 41 | int kinc_count_displays(void) { 42 | return procs.count_displays(); 43 | } 44 | -------------------------------------------------------------------------------- /sources/backends/linux/kinc/backend/gamepad.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void kinc_linux_initHIDGamepads(); 4 | void kinc_linux_updateHIDGamepads(); 5 | void kinc_linux_closeHIDGamepads(); 6 | -------------------------------------------------------------------------------- /sources/backends/linux/kinc/backend/mouse.c.h: -------------------------------------------------------------------------------- 1 | #include "funcs.h" 2 | #include 3 | 4 | void kinc_internal_mouse_lock(int window) { 5 | procs.mouse_lock(window); 6 | } 7 | 8 | void kinc_internal_mouse_unlock() { 9 | procs.mouse_unlock(); 10 | } 11 | 12 | bool kinc_mouse_can_lock(void) { 13 | return true; 14 | } 15 | 16 | bool _mouseHidden = false; 17 | 18 | void kinc_mouse_show() { 19 | procs.mouse_show(); 20 | } 21 | 22 | void kinc_mouse_hide() { 23 | procs.mouse_hide(); 24 | } 25 | 26 | void kinc_mouse_set_cursor(int cursorIndex) { 27 | procs.mouse_set_cursor(cursorIndex); 28 | } 29 | 30 | void kinc_mouse_set_position(int window, int x, int y) { 31 | procs.mouse_set_position(window, x, y); 32 | } 33 | 34 | void kinc_mouse_get_position(int window, int *x, int *y) { 35 | procs.mouse_get_position(window, x, y); 36 | } 37 | -------------------------------------------------------------------------------- /sources/backends/linux/kinc/backend/video.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | #if defined(KINC_VIDEO_GSTREAMER) 8 | #include 9 | #else 10 | typedef struct { 11 | int nothing; 12 | } kinc_video_impl_t; 13 | 14 | typedef struct kinc_internal_video_sound_stream { 15 | int nothing; 16 | } kinc_internal_video_sound_stream_t; 17 | 18 | void kinc_internal_video_sound_stream_init(kinc_internal_video_sound_stream_t *stream, int channel_count, int frequency); 19 | 20 | void kinc_internal_video_sound_stream_destroy(kinc_internal_video_sound_stream_t *stream); 21 | 22 | void kinc_internal_video_sound_stream_insert_data(kinc_internal_video_sound_stream_t *stream, float *data, int sample_count); 23 | 24 | float *kinc_internal_video_sound_stream_next_frame(kinc_internal_video_sound_stream_t *stream); 25 | 26 | bool kinc_internal_video_sound_stream_ended(kinc_internal_video_sound_stream_t *stream); 27 | #endif 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /sources/backends/macos/kinc/backend/HIDGamepad.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | struct HIDGamepad { 8 | int padIndex; 9 | IOHIDDeviceRef hidDeviceRef; 10 | IOHIDQueueRef hidQueueRef; 11 | int hidDeviceVendorID; 12 | int hidDeviceProductID; 13 | char hidDeviceVendor[64]; 14 | char hidDeviceProduct[64]; 15 | 16 | IOHIDElementCookie axis[6]; 17 | IOHIDElementCookie buttons[15]; 18 | }; 19 | 20 | void HIDGamepad_init(struct HIDGamepad *gamepad); 21 | void HIDGamepad_destroy(struct HIDGamepad *gamepad); 22 | void HIDGamepad_bind(struct HIDGamepad *gamepad, IOHIDDeviceRef deviceRef, int padIndex); 23 | void HIDGamepad_unbind(struct HIDGamepad *gamepad); 24 | -------------------------------------------------------------------------------- /sources/backends/macos/kinc/backend/HIDManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include "HIDGamepad.h" 10 | 11 | // Maximum number of devices supported 12 | // Corresponds to size of Kore::Gamepad array 13 | static const int KINC_MAX_HID_DEVICES = 12; 14 | 15 | // Slots to hold details on connected devices 16 | struct HIDManagerDeviceRecord { 17 | bool connected; // = false; 18 | IOHIDDeviceRef device; // = NULL; 19 | struct HIDGamepad pad; 20 | }; 21 | 22 | struct HIDManager { 23 | IOHIDManagerRef managerRef; 24 | struct HIDManagerDeviceRecord devices[KINC_MAX_HID_DEVICES]; 25 | }; 26 | 27 | void HIDManager_init(struct HIDManager *manager); 28 | void HIDManager_destroy(struct HIDManager *manager); 29 | -------------------------------------------------------------------------------- /sources/backends/macos/kinc/backend/displaydata.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct DisplayData { 4 | int index; 5 | DisplayData(); 6 | }; 7 | -------------------------------------------------------------------------------- /sources/backends/macos/kinc/backend/mac.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSHumanReadableCopyright 28 | Copyright © 2018 the Kore Development Team. All rights reserved. 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /sources/backends/macos/kinc/backend/macosunit.m: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct WindowData { 4 | id handle; 5 | id view; 6 | bool fullscreen; 7 | void (*resizeCallback)(int width, int height, void *data); 8 | void *resizeCallbackData; 9 | bool (*closeCallback)(void *data); 10 | void *closeCallbackData; 11 | }; 12 | 13 | static struct WindowData windows[10] = {}; 14 | static int windowCounter = 0; 15 | 16 | #include "BasicOpenGLView.m.h" 17 | #include "HIDGamepad.c.h" 18 | #include "HIDManager.c.h" 19 | #include "audio.c.h" 20 | #include "display.m.h" 21 | #include "mouse.m.h" 22 | #include "system.c.h" 23 | #include "system.m.h" 24 | #include "window.c.h" 25 | -------------------------------------------------------------------------------- /sources/backends/macos/kinc/backend/mouse.m.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | void kinc_internal_mouse_lock(int window) { 8 | kinc_mouse_hide(); 9 | } 10 | 11 | void kinc_internal_mouse_unlock(void) { 12 | kinc_mouse_show(); 13 | } 14 | 15 | bool kinc_mouse_can_lock(void) { 16 | return true; 17 | } 18 | 19 | void kinc_mouse_show(void) { 20 | CGDisplayShowCursor(kCGDirectMainDisplay); 21 | } 22 | 23 | void kinc_mouse_hide(void) { 24 | CGDisplayHideCursor(kCGDirectMainDisplay); 25 | } 26 | 27 | void kinc_mouse_set_position(int windowId, int x, int y) { 28 | 29 | NSWindow *window = kinc_get_mac_window_handle(windowId); 30 | float scale = [window backingScaleFactor]; 31 | NSRect rect = [[NSScreen mainScreen] frame]; 32 | 33 | CGPoint point; 34 | point.x = window.frame.origin.x + (x / scale); 35 | point.y = rect.size.height - (window.frame.origin.y + (y / scale)); 36 | 37 | CGDisplayMoveCursorToPoint(windowId, point); 38 | CGAssociateMouseAndMouseCursorPosition(true); 39 | } 40 | 41 | void kinc_mouse_get_position(int windowId, int *x, int *y) { 42 | 43 | NSWindow *window = kinc_get_mac_window_handle(windowId); 44 | NSPoint point = [window mouseLocationOutsideOfEventStream]; 45 | *x = (int)point.x; 46 | *y = (int)point.y; 47 | } 48 | 49 | void kinc_mouse_set_cursor(int cursor_index) {} 50 | -------------------------------------------------------------------------------- /sources/backends/macos/kinc/backend/system.c.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | static int mouseX, mouseY; 9 | static bool keyboardShown = false; 10 | 11 | void Kinc_Mouse_GetPosition(int window, int *x, int *y) { 12 | *x = mouseX; 13 | *y = mouseY; 14 | } 15 | 16 | void kinc_keyboard_show(void) { 17 | keyboardShown = true; 18 | } 19 | 20 | void kinc_keyboard_hide(void) { 21 | keyboardShown = false; 22 | } 23 | 24 | bool kinc_keyboard_active(void) { 25 | return keyboardShown; 26 | } 27 | 28 | void kinc_vibrate(int ms) {} 29 | 30 | const char *kinc_system_id(void) { 31 | return "macOS"; 32 | } 33 | 34 | static const char *videoFormats[] = {"ogv", NULL}; 35 | 36 | const char **kinc_video_formats(void) { 37 | return videoFormats; 38 | } 39 | 40 | void kinc_set_keep_screen_on(bool on) {} 41 | 42 | #include 43 | 44 | double kinc_frequency(void) { 45 | mach_timebase_info_data_t info; 46 | mach_timebase_info(&info); 47 | return (double)info.denom / (double)info.numer / 1e-9; 48 | } 49 | 50 | kinc_ticks_t kinc_timestamp(void) { 51 | return mach_absolute_time(); 52 | } 53 | 54 | void kinc_login(void) {} 55 | 56 | void kinc_unlock_achievement(int id) {} 57 | 58 | bool kinc_gamepad_connected(int num) { 59 | return true; 60 | } 61 | 62 | void kinc_gamepad_rumble(int gamepad, float left, float right) {} 63 | -------------------------------------------------------------------------------- /sources/backends/macos/kinc/backend/windowdata.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | NSWindow *kinc_get_mac_window_handle(int window_index); 6 | -------------------------------------------------------------------------------- /sources/backends/metal/kinc/backend/graphics5/Metal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | -------------------------------------------------------------------------------- /sources/backends/metal/kinc/backend/graphics5/commandlist.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct kinc_g5_index_buffer; 4 | 5 | typedef struct { 6 | struct kinc_g5_index_buffer *current_index_buffer; 7 | } CommandList5Impl; 8 | -------------------------------------------------------------------------------- /sources/backends/metal/kinc/backend/graphics5/compute.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef struct kinc_g5_compute_shader_impl { 4 | char name[1024]; 5 | void *_function; 6 | void *_pipeline; 7 | void *_reflection; 8 | } kinc_g5_compute_shader_impl; 9 | -------------------------------------------------------------------------------- /sources/backends/metal/kinc/backend/graphics5/constantbuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef struct { 4 | void *_buffer; 5 | int lastStart; 6 | int lastCount; 7 | int mySize; 8 | } ConstantBuffer5Impl; 9 | -------------------------------------------------------------------------------- /sources/backends/metal/kinc/backend/graphics5/constantbuffer.m.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #import 4 | 5 | id getMetalDevice(void); 6 | 7 | bool kinc_g5_transposeMat3 = true; 8 | bool kinc_g5_transposeMat4 = true; 9 | 10 | void kinc_g5_constant_buffer_init(kinc_g5_constant_buffer_t *buffer, int size) { 11 | buffer->impl.mySize = size; 12 | buffer->data = NULL; 13 | buffer->impl._buffer = (__bridge_retained void *)[getMetalDevice() newBufferWithLength:size options:MTLResourceOptionCPUCacheModeDefault]; 14 | } 15 | 16 | void kinc_g5_constant_buffer_destroy(kinc_g5_constant_buffer_t *buffer) { 17 | id buf = (__bridge_transfer id)buffer->impl._buffer; 18 | buf = nil; 19 | buffer->impl._buffer = NULL; 20 | } 21 | 22 | void kinc_g5_constant_buffer_lock_all(kinc_g5_constant_buffer_t *buffer) { 23 | kinc_g5_constant_buffer_lock(buffer, 0, kinc_g5_constant_buffer_size(buffer)); 24 | } 25 | 26 | void kinc_g5_constant_buffer_lock(kinc_g5_constant_buffer_t *buffer, int start, int count) { 27 | buffer->impl.lastStart = start; 28 | buffer->impl.lastCount = count; 29 | id buf = (__bridge id)buffer->impl._buffer; 30 | uint8_t *data = (uint8_t *)[buf contents]; 31 | buffer->data = &data[start]; 32 | } 33 | 34 | void kinc_g5_constant_buffer_unlock(kinc_g5_constant_buffer_t *buffer) { 35 | buffer->data = NULL; 36 | } 37 | 38 | int kinc_g5_constant_buffer_size(kinc_g5_constant_buffer_t *buffer) { 39 | return buffer->impl.mySize; 40 | } 41 | -------------------------------------------------------------------------------- /sources/backends/metal/kinc/backend/graphics5/graphics.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | -------------------------------------------------------------------------------- /sources/backends/metal/kinc/backend/graphics5/indexbuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef struct { 4 | void *metal_buffer; 5 | int count; 6 | bool gpu_memory; 7 | int format; 8 | int last_start; 9 | int last_count; 10 | } IndexBuffer5Impl; 11 | -------------------------------------------------------------------------------- /sources/backends/metal/kinc/backend/graphics5/metalunit.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | static id command_buffer = nil; 5 | static id render_command_encoder = nil; 6 | static id compute_command_encoder = nil; 7 | 8 | static void start_render_pass(void); 9 | static void end_render_pass(void); 10 | 11 | #include "Metal.m.h" 12 | #include "commandlist.m.h" 13 | #include "compute.m.h" 14 | #include "constantbuffer.m.h" 15 | #include "indexbuffer.m.h" 16 | #include "pipeline.m.h" 17 | #include "raytrace.m.h" 18 | #include "rendertarget.m.h" 19 | #include "sampler.m.h" 20 | #include "shader.m.h" 21 | #include "texture.m.h" 22 | #include "vertexbuffer.m.h" 23 | -------------------------------------------------------------------------------- /sources/backends/metal/kinc/backend/graphics5/pipeline.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct kinc_g5_shader; 4 | 5 | typedef struct { 6 | struct kinc_g5_shader *vertexShader; 7 | struct kinc_g5_shader *fragmentShader; 8 | void *_pipeline; 9 | void *_pipelineDepth; 10 | void *_reflection; 11 | void *_depthStencil; 12 | void *_depthStencilNone; 13 | // void _set(); 14 | } PipelineState5Impl; 15 | 16 | typedef struct { 17 | int a; 18 | } ComputePipelineState5Impl; 19 | 20 | typedef struct { 21 | int vertexOffset; 22 | int fragmentOffset; 23 | int computeOffset; 24 | } ConstantLocation5Impl; 25 | -------------------------------------------------------------------------------- /sources/backends/metal/kinc/backend/graphics5/raytrace.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef struct { 4 | void *_raytracingPipeline; 5 | } kinc_raytrace_pipeline_impl_t; 6 | 7 | typedef struct { 8 | void *_accelerationStructure; 9 | } kinc_raytrace_acceleration_structure_impl_t; 10 | -------------------------------------------------------------------------------- /sources/backends/metal/kinc/backend/graphics5/rendertarget.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef struct { 4 | void *_tex; 5 | void *_texReadback; 6 | void *_depthTex; 7 | } RenderTarget5Impl; 8 | -------------------------------------------------------------------------------- /sources/backends/metal/kinc/backend/graphics5/sampler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef struct kinc_g5_sampler_impl { 4 | void *sampler; 5 | } kinc_g5_sampler_impl_t; 6 | -------------------------------------------------------------------------------- /sources/backends/metal/kinc/backend/graphics5/shader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef struct { 4 | char name[1024]; 5 | void *mtlFunction; 6 | } Shader5Impl; 7 | -------------------------------------------------------------------------------- /sources/backends/metal/kinc/backend/graphics5/texture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | typedef struct { 6 | int index; 7 | bool vertex; 8 | } TextureUnit5Impl; 9 | 10 | typedef struct { 11 | void *_tex; 12 | void *data; 13 | bool has_mipmaps; 14 | } Texture5Impl; 15 | -------------------------------------------------------------------------------- /sources/backends/metal/kinc/backend/graphics5/vertexbuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | typedef struct { 6 | // void unset(); 7 | int myCount; 8 | int myStride; 9 | void *mtlBuffer; 10 | bool gpuMemory; 11 | int lastStart; 12 | int lastCount; 13 | // static Graphics5::VertexBuffer* current; 14 | } VertexBuffer5Impl; 15 | -------------------------------------------------------------------------------- /sources/backends/microsoft/kinc/backend/SystemMicrosoft.c.h: -------------------------------------------------------------------------------- 1 | #include "SystemMicrosoft.h" 2 | 3 | #include 4 | #include 5 | 6 | #define S_OK ((HRESULT)0L) 7 | 8 | static void winerror(HRESULT result) { 9 | LPVOID buffer = NULL; 10 | DWORD dw = GetLastError(); 11 | 12 | __debugbreak(); 13 | 14 | #if defined(KINC_WINDOWS) 15 | if (dw != 0) { 16 | FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw, 17 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buffer, 0, NULL); 18 | 19 | kinc_error_message("Error: %s", buffer); 20 | } 21 | else { 22 | #endif 23 | kinc_error_message("Unknown Windows error, return value was 0x%x.", result); 24 | #if defined(KINC_WINDOWS) 25 | } 26 | #endif 27 | } 28 | 29 | void kinc_microsoft_affirm(HRESULT result) { 30 | if (result != S_OK) { 31 | winerror(result); 32 | } 33 | } 34 | 35 | void kinc_microsoft_affirm_message(HRESULT result, const char *format, ...) { 36 | va_list args; 37 | va_start(args, format); 38 | kinc_affirm_args(result == S_OK, format, args); 39 | va_end(args); 40 | } 41 | 42 | void kinc_microsoft_format(const char *format, va_list args, wchar_t *buffer) { 43 | char cbuffer[4096]; 44 | vsprintf(cbuffer, format, args); 45 | MultiByteToWideChar(CP_UTF8, 0, cbuffer, -1, buffer, 4096); 46 | } 47 | -------------------------------------------------------------------------------- /sources/backends/microsoft/kinc/backend/SystemMicrosoft.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef long HRESULT; 10 | 11 | void kinc_microsoft_affirm(HRESULT result); 12 | void kinc_microsoft_affirm_message(HRESULT result, const char *format, ...); 13 | void kinc_microsoft_format(const char *format, va_list args, wchar_t *buffer); 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /sources/backends/microsoft/kinc/backend/event.c.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void kinc_event_init(kinc_event_t *event, bool auto_clear) { 4 | event->impl.event = CreateEvent(0, auto_clear ? FALSE : TRUE, 0, 0); 5 | } 6 | 7 | void kinc_event_destroy(kinc_event_t *event) { 8 | CloseHandle(event->impl.event); 9 | } 10 | 11 | void kinc_event_signal(kinc_event_t *event) { 12 | SetEvent(event->impl.event); 13 | } 14 | 15 | void kinc_event_wait(kinc_event_t *event) { 16 | WaitForSingleObject(event->impl.event, INFINITE); 17 | } 18 | 19 | bool kinc_event_try_to_wait(kinc_event_t *event, double seconds) { 20 | return WaitForSingleObject(event->impl.event, (DWORD)(seconds * 1000.0)) != WAIT_TIMEOUT; 21 | } 22 | 23 | void kinc_event_reset(kinc_event_t *event) { 24 | ResetEvent(event->impl.event); 25 | } 26 | -------------------------------------------------------------------------------- /sources/backends/microsoft/kinc/backend/event.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | typedef struct { 8 | void *event; 9 | } kinc_event_impl_t; 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /sources/backends/microsoft/kinc/backend/fiber.c.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | VOID WINAPI fiber_func(LPVOID param) { 4 | kinc_fiber_t *fiber = (kinc_fiber_t *)param; 5 | fiber->impl.func(fiber->impl.param); 6 | } 7 | 8 | void kinc_fiber_init_current_thread(kinc_fiber_t *fiber) { 9 | fiber->impl.fiber = ConvertThreadToFiber(NULL); 10 | } 11 | 12 | void kinc_fiber_init(kinc_fiber_t *fiber, void (*func)(void *param), void *param) { 13 | fiber->impl.func = func; 14 | fiber->impl.param = param; 15 | fiber->impl.fiber = CreateFiber(0, fiber_func, fiber); 16 | } 17 | 18 | void kinc_fiber_destroy(kinc_fiber_t *fiber) { 19 | DeleteFiber(fiber->impl.fiber); 20 | fiber->impl.fiber = NULL; 21 | } 22 | 23 | void kinc_fiber_switch(kinc_fiber_t *fiber) { 24 | SwitchToFiber(fiber->impl.fiber); 25 | } 26 | -------------------------------------------------------------------------------- /sources/backends/microsoft/kinc/backend/fiber.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | typedef struct { 8 | void *fiber; 9 | void (*func)(void *param); 10 | void *param; 11 | } kinc_fiber_impl_t; 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | -------------------------------------------------------------------------------- /sources/backends/microsoft/kinc/backend/microsoftunit.c: -------------------------------------------------------------------------------- 1 | // Windows XP 2 | #define WINVER 0x0501 3 | #define _WIN32_WINNT 0x0501 4 | 5 | #define NOATOM 6 | #define NOCLIPBOARD 7 | #define NOCOLOR 8 | #define NOCOMM 9 | #define NOCTLMGR 10 | #define NODEFERWINDOWPOS 11 | #define NODRAWTEXT 12 | #define NOGDI 13 | #define NOGDICAPMASKS 14 | #define NOHELP 15 | #define NOICONS 16 | #define NOKANJI 17 | #define NOKEYSTATES 18 | #define NOMB 19 | #define NOMCX 20 | #define NOMEMMGR 21 | #define NOMENUS 22 | #define NOMETAFILE 23 | #define NOMINMAX 24 | #define NOMSG 25 | //#define NONLS 26 | #define NOOPENFILE 27 | #define NOPROFILER 28 | #define NORASTEROPS 29 | #define NOSCROLL 30 | #define NOSERVICE 31 | #define NOSHOWWINDOW 32 | #define NOSOUND 33 | #define NOSYSCOMMANDS 34 | #define NOSYSMETRICS 35 | #define NOTEXTMETRIC 36 | #define NOUSER 37 | #define NOVIRTUALKEYCODES 38 | #define NOWH 39 | #define NOWINMESSAGES 40 | #define NOWINOFFSETS 41 | #define NOWINSTYLES 42 | #define WIN32_LEAN_AND_MEAN 43 | 44 | #include 45 | 46 | #include 47 | #include 48 | #include 49 | 50 | #include "SystemMicrosoft.c.h" 51 | #include "event.c.h" 52 | #include "fiber.c.h" 53 | #include "mutex.c.h" 54 | #include "semaphore.c.h" 55 | #include "thread.c.h" 56 | #include "threadlocal.c.h" 57 | -------------------------------------------------------------------------------- /sources/backends/microsoft/kinc/backend/mutex.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | typedef struct { 8 | void *DebugInfo; 9 | long LockCount; 10 | long RecursionCount; 11 | void *OwningThread; 12 | void *LockSemaphore; 13 | unsigned long __w64 SpinCount; 14 | } kinc_microsoft_critical_section_t; 15 | 16 | typedef struct { 17 | kinc_microsoft_critical_section_t criticalSection; 18 | } kinc_mutex_impl_t; 19 | 20 | typedef struct { 21 | void *id; 22 | } kinc_uber_mutex_impl_t; 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | -------------------------------------------------------------------------------- /sources/backends/microsoft/kinc/backend/semaphore.c.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void kinc_semaphore_init(kinc_semaphore_t *semaphore, int current, int max) { 4 | semaphore->impl.handle = CreateSemaphoreA(NULL, current, max, NULL); 5 | } 6 | 7 | void kinc_semaphore_destroy(kinc_semaphore_t *semaphore) { 8 | CloseHandle(semaphore->impl.handle); 9 | semaphore->impl.handle = NULL; 10 | } 11 | 12 | void kinc_semaphore_release(kinc_semaphore_t *semaphore, int count) { 13 | ReleaseSemaphore(semaphore->impl.handle, count, NULL); 14 | } 15 | 16 | void kinc_semaphore_acquire(kinc_semaphore_t *semaphore) { 17 | WaitForSingleObject(semaphore->impl.handle, INFINITE); 18 | } 19 | 20 | bool kinc_semaphore_try_to_acquire(kinc_semaphore_t *semaphore, double seconds) { 21 | return WaitForSingleObject(semaphore->impl.handle, (DWORD)(seconds * 1000)) == WAIT_OBJECT_0; 22 | } 23 | -------------------------------------------------------------------------------- /sources/backends/microsoft/kinc/backend/semaphore.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef struct { 4 | void *handle; 5 | } kinc_semaphore_impl_t; 6 | -------------------------------------------------------------------------------- /sources/backends/microsoft/kinc/backend/thread.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | typedef struct { 8 | void *handle; 9 | void *param; 10 | void (*func)(void *param); 11 | } kinc_thread_impl_t; 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | -------------------------------------------------------------------------------- /sources/backends/microsoft/kinc/backend/threadlocal.c.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void kinc_thread_local_init(kinc_thread_local_t *local) { 4 | local->impl.slot = TlsAlloc(); 5 | TlsSetValue(local->impl.slot, 0); 6 | } 7 | 8 | void kinc_thread_local_destroy(kinc_thread_local_t *local) { 9 | TlsFree(local->impl.slot); 10 | } 11 | 12 | void *kinc_thread_local_get(kinc_thread_local_t *local) { 13 | return TlsGetValue(local->impl.slot); 14 | } 15 | 16 | void kinc_thread_local_set(kinc_thread_local_t *local, void *data) { 17 | TlsSetValue(local->impl.slot, data); 18 | } 19 | -------------------------------------------------------------------------------- /sources/backends/microsoft/kinc/backend/threadlocal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | typedef struct { 8 | int slot; 9 | } kinc_thread_local_impl_t; 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /sources/backends/opengl/kinc/backend/graphics4/OpenGL.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | int Kinc_G4_Internal_TextureAddressingU(kinc_g4_texture_unit_t unit); 12 | int Kinc_G4_Internal_TextureAddressingV(kinc_g4_texture_unit_t unit); 13 | int Kinc_G4_Internal_StencilFunc(kinc_g4_compare_mode_t mode); 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /sources/backends/opengl/kinc/backend/graphics4/OpenGLWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef KINC_WINDOWS 4 | #define WIN32_LEAN_AND_MEAN 5 | #define NOMINMAX 6 | #include 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | struct kinc_g4_render_target; 13 | 14 | typedef struct { 15 | HDC deviceContext; 16 | HGLRC glContext; 17 | 18 | int depthBufferBits; 19 | 20 | int framebuffer; 21 | unsigned vertexArray; 22 | struct kinc_g4_render_target renderTarget; 23 | } Kinc_Internal_OpenGLWindow; 24 | 25 | extern Kinc_Internal_OpenGLWindow Kinc_Internal_windows[10]; 26 | 27 | void Kinc_Internal_initWindowsGLContext(int window, int depthBufferBits, int stencilBufferBits); 28 | void Kinc_Internal_blitWindowContent(int window); 29 | void Kinc_Internal_setWindowRenderTarget(int window); 30 | void Kinc_Internal_resizeWindowRenderTarget(int window, int width, int height); 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | #endif 35 | -------------------------------------------------------------------------------- /sources/backends/opengl/kinc/backend/graphics4/compute.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef struct kinc_g4_compute_constant_location_impl { 4 | int location; 5 | unsigned int type; 6 | } kinc_g4_compute_constant_location_impl; 7 | 8 | typedef struct kinc_g4_compute_texture_unit_impl { 9 | int unit; 10 | } kinc_g4_compute_texture_unit_impl; 11 | 12 | typedef struct kinc_g4_compute_shader_impl { 13 | char **textures; 14 | int *textureValues; 15 | int textureCount; 16 | unsigned _id; 17 | unsigned _programid; 18 | char *_source; 19 | int _length; 20 | } kinc_g4_compute_shader_impl; 21 | -------------------------------------------------------------------------------- /sources/backends/opengl/kinc/backend/graphics4/graphics.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "IndexBufferImpl.h" 4 | #include "RenderTargetImpl.h" 5 | #include "TextureImpl.h" 6 | #include "VertexBufferImpl.h" 7 | -------------------------------------------------------------------------------- /sources/backends/opengl/kinc/backend/graphics4/indexbuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | uint16_t *converted_data; 11 | void *data; 12 | int count; 13 | unsigned usage; 14 | int format; 15 | unsigned buffer_id; 16 | } kinc_g4_index_buffer_impl_t; 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /sources/backends/opengl/kinc/backend/graphics4/openglunit.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static bool kinc_internal_opengl_force_16bit_index_buffer = false; 4 | static int kinc_internal_opengl_max_vertex_attribute_arrays = 0; 5 | 6 | #include "OpenGL.c.h" 7 | #include "OpenGLWindow.c.h" 8 | #include "compute.c.h" 9 | #include "indexbuffer.c.h" 10 | #include "pipeline.c.h" 11 | #include "rendertarget.c.h" 12 | #include "shader.c.h" 13 | #include "texture.c.h" 14 | #include "vertexbuffer.c.h" 15 | -------------------------------------------------------------------------------- /sources/backends/opengl/kinc/backend/graphics4/pipeline.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | typedef struct { 8 | unsigned programId; 9 | char **textures; 10 | int *textureValues; 11 | int textureCount; 12 | } kinc_g4_pipeline_impl_t; 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /sources/backends/opengl/kinc/backend/graphics4/rendertarget.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | unsigned _framebuffer; 11 | unsigned _texture; 12 | unsigned _depthTexture; 13 | bool _hasDepth; 14 | // unsigned _depthRenderbuffer; 15 | int format; 16 | } kinc_g4_render_target_impl_t; 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /sources/backends/opengl/kinc/backend/graphics4/shader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef struct { 11 | unsigned _glid; 12 | const char *source; 13 | size_t length; 14 | } kinc_g4_shader_impl_t; 15 | 16 | typedef struct { 17 | int location; 18 | unsigned type; 19 | } kinc_g4_constant_location_impl_t; 20 | 21 | typedef struct { 22 | int unit; 23 | } kinc_g4_texture_unit_impl_t; 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | -------------------------------------------------------------------------------- /sources/backends/opengl/kinc/backend/graphics4/texture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | unsigned int texture; 11 | #ifdef KINC_ANDROID 12 | bool external_oes; 13 | #endif 14 | uint8_t pixfmt; 15 | } kinc_g4_texture_impl_t; 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /sources/backends/opengl/kinc/backend/graphics4/vertexbuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | typedef struct { 12 | float *data; 13 | int myCount; 14 | int myStride; 15 | unsigned bufferId; 16 | int sectionStart; 17 | int sectionSize; 18 | // #if defined KINC_ANDROID || defined KINC_EMSCRIPTEN 19 | kinc_g4_vertex_structure_t structure; 20 | // #endif 21 | int instanceDataStepRate; 22 | #ifndef NDEBUG 23 | bool initialized; 24 | #endif 25 | } kinc_g4_vertex_buffer_impl_t; 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | -------------------------------------------------------------------------------- /sources/backends/posix/kinc/backend/event.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | pthread_cond_t event; 11 | pthread_mutex_t mutex; 12 | volatile bool set; 13 | bool auto_reset; 14 | } kinc_event_impl_t; 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /sources/backends/posix/kinc/backend/mutex.c.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | void kinc_mutex_init(kinc_mutex_t *mutex) { 6 | pthread_mutexattr_t attr; 7 | pthread_mutexattr_init(&attr); 8 | pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); 9 | pthread_mutex_init(&mutex->impl.mutex, &attr); 10 | } 11 | 12 | void kinc_mutex_destroy(kinc_mutex_t *mutex) { 13 | pthread_mutex_destroy(&mutex->impl.mutex); 14 | } 15 | 16 | bool kinc_mutex_try_to_lock(kinc_mutex_t *mutex) { 17 | return pthread_mutex_trylock(&mutex->impl.mutex) == 0; 18 | } 19 | 20 | void kinc_mutex_lock(kinc_mutex_t *mutex) { 21 | pthread_mutex_lock(&mutex->impl.mutex); 22 | } 23 | 24 | void kinc_mutex_unlock(kinc_mutex_t *mutex) { 25 | pthread_mutex_unlock(&mutex->impl.mutex); 26 | } 27 | 28 | bool kinc_uber_mutex_init(kinc_uber_mutex_t *mutex, const char *name) { 29 | return false; 30 | } 31 | 32 | void kinc_uber_mutex_destroy(kinc_uber_mutex_t *mutex) {} 33 | 34 | void kinc_uber_mutex_lock(kinc_uber_mutex_t *mutex) { 35 | assert(false); 36 | } 37 | 38 | void kinc_uber_mutex_unlock(kinc_uber_mutex_t *mutex) { 39 | assert(false); 40 | } 41 | -------------------------------------------------------------------------------- /sources/backends/posix/kinc/backend/mutex.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | pthread_mutex_t mutex; 11 | } kinc_mutex_impl_t; 12 | 13 | typedef struct { 14 | int nothing; 15 | } kinc_uber_mutex_impl_t; 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /sources/backends/posix/kinc/backend/posixunit.c: -------------------------------------------------------------------------------- 1 | #include "event.c.h" 2 | #include "mutex.c.h" 3 | #include "semaphore.c.h" 4 | #include "thread.c.h" 5 | #include "threadlocal.c.h" 6 | -------------------------------------------------------------------------------- /sources/backends/posix/kinc/backend/semaphore.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __APPLE__ 4 | #include 5 | #else 6 | #include 7 | #endif 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | typedef struct { 14 | #ifdef __APPLE__ 15 | dispatch_semaphore_t semaphore; 16 | #else 17 | sem_t semaphore; 18 | #endif 19 | } kinc_semaphore_impl_t; 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | -------------------------------------------------------------------------------- /sources/backends/posix/kinc/backend/thread.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | void *param; 11 | void (*thread)(void *param); 12 | pthread_t pthread; 13 | } kinc_thread_impl_t; 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /sources/backends/posix/kinc/backend/threadlocal.c.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void kinc_thread_local_init(kinc_thread_local_t *local) { 4 | pthread_key_create(&local->impl.key, NULL); 5 | } 6 | 7 | void kinc_thread_local_destroy(kinc_thread_local_t *local) { 8 | pthread_key_delete(local->impl.key); 9 | } 10 | 11 | void *kinc_thread_local_get(kinc_thread_local_t *local) { 12 | return pthread_getspecific(local->impl.key); 13 | } 14 | 15 | void kinc_thread_local_set(kinc_thread_local_t *local, void *data) { 16 | pthread_setspecific(local->impl.key, data); 17 | } 18 | -------------------------------------------------------------------------------- /sources/backends/posix/kinc/backend/threadlocal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | pthread_key_t key; 11 | } kinc_thread_local_impl_t; 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | -------------------------------------------------------------------------------- /sources/backends/vulkan/kinc/backend/graphics5/MiniVulkan.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /sources/backends/vulkan/kinc/backend/graphics5/ShaderHash.c.h: -------------------------------------------------------------------------------- 1 | #include "ShaderHash.h" 2 | 3 | // djb2 4 | uint32_t kinc_internal_hash_name(unsigned char *str) { 5 | unsigned long hash = 5381; 6 | int c; 7 | while (c = *str++) { 8 | hash = hash * 33 ^ c; 9 | } 10 | return hash; 11 | } 12 | -------------------------------------------------------------------------------- /sources/backends/vulkan/kinc/backend/graphics5/ShaderHash.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef struct { 11 | uint32_t hash; 12 | uint32_t index; 13 | } kinc_internal_hash_index_t; 14 | 15 | uint32_t kinc_internal_hash_name(unsigned char *str); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /sources/backends/vulkan/kinc/backend/graphics5/commandlist.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "MiniVulkan.h" 4 | 5 | typedef struct { 6 | int _indexCount; 7 | VkCommandBuffer _buffer; 8 | VkFence fence; 9 | } CommandList5Impl; 10 | -------------------------------------------------------------------------------- /sources/backends/vulkan/kinc/backend/graphics5/compute.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "MiniVulkan.h" 6 | 7 | #include "named_number.h" 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | typedef struct kinc_g5_compute_shader_impl { 14 | kinc_internal_named_number locations[KINC_INTERNAL_NAMED_NUMBER_COUNT]; 15 | kinc_internal_named_number texture_bindings[KINC_INTERNAL_NAMED_NUMBER_COUNT]; 16 | kinc_internal_named_number offsets[KINC_INTERNAL_NAMED_NUMBER_COUNT]; 17 | 18 | VkPipelineLayout pipeline_layout; 19 | VkPipeline pipeline; 20 | VkShaderModule shader_module; 21 | } kinc_g5_compute_shader_impl; 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | -------------------------------------------------------------------------------- /sources/backends/vulkan/kinc/backend/graphics5/constantbuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "MiniVulkan.h" 4 | 5 | typedef struct { 6 | VkBuffer buf; 7 | VkDescriptorBufferInfo buffer_info; 8 | VkMemoryAllocateInfo mem_alloc; 9 | VkDeviceMemory mem; 10 | int lastStart; 11 | int lastCount; 12 | int mySize; 13 | } ConstantBuffer5Impl; 14 | -------------------------------------------------------------------------------- /sources/backends/vulkan/kinc/backend/graphics5/graphics.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | -------------------------------------------------------------------------------- /sources/backends/vulkan/kinc/backend/graphics5/indexbuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "MiniVulkan.h" 4 | 5 | typedef struct { 6 | int count; 7 | int format; 8 | 9 | VkBuffer buf; 10 | VkDeviceMemory mem; 11 | VkMemoryAllocateInfo mem_alloc; 12 | } IndexBuffer5Impl; 13 | -------------------------------------------------------------------------------- /sources/backends/vulkan/kinc/backend/graphics5/named_number.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define KINC_INTERNAL_NAMED_NUMBER_COUNT 32 4 | 5 | typedef struct { 6 | char name[256]; 7 | uint32_t number; 8 | } kinc_internal_named_number; 9 | -------------------------------------------------------------------------------- /sources/backends/vulkan/kinc/backend/graphics5/pipeline.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "MiniVulkan.h" 4 | 5 | #include "named_number.h" 6 | 7 | struct kinc_g5_shader; 8 | 9 | typedef struct PipelineState5Impl_s { 10 | const char **textures; 11 | int *textureValues; 12 | int textureCount; 13 | 14 | VkPipeline framebuffer_pipeline; 15 | VkPipeline rendertarget_pipeline; 16 | VkShaderModule vert_shader_module; 17 | VkShaderModule frag_shader_module; 18 | 19 | kinc_internal_named_number vertexLocations[KINC_INTERNAL_NAMED_NUMBER_COUNT]; 20 | kinc_internal_named_number fragmentLocations[KINC_INTERNAL_NAMED_NUMBER_COUNT]; 21 | kinc_internal_named_number textureBindings[KINC_INTERNAL_NAMED_NUMBER_COUNT]; 22 | kinc_internal_named_number vertexOffsets[KINC_INTERNAL_NAMED_NUMBER_COUNT]; 23 | kinc_internal_named_number fragmentOffsets[KINC_INTERNAL_NAMED_NUMBER_COUNT]; 24 | 25 | VkPipelineLayout pipeline_layout; 26 | } PipelineState5Impl; 27 | 28 | typedef struct ComputePipelineState5Impl_t { 29 | int a; 30 | } ComputePipelineState5Impl; 31 | 32 | typedef struct { 33 | int vertexOffset; 34 | int fragmentOffset; 35 | int computeOffset; 36 | } ConstantLocation5Impl; 37 | 38 | typedef struct { 39 | int nothing; 40 | } AttributeLocation5Impl; 41 | -------------------------------------------------------------------------------- /sources/backends/vulkan/kinc/backend/graphics5/raytrace.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef KINC_ANDROID 4 | 5 | #include "MiniVulkan.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | typedef struct { 12 | VkPipeline pipeline; 13 | VkPipelineLayout pipeline_layout; 14 | VkDescriptorSet descriptor_set; 15 | VkDescriptorSetLayout descriptor_set_layout; 16 | VkBuffer raygen_shader_binding_table; 17 | VkBuffer miss_shader_binding_table; 18 | VkBuffer hit_shader_binding_table; 19 | } kinc_raytrace_pipeline_impl_t; 20 | 21 | typedef struct { 22 | VkAccelerationStructureKHR top_level_acceleration_structure; 23 | VkAccelerationStructureKHR bottom_level_acceleration_structure; 24 | uint64_t top_level_acceleration_structure_handle; 25 | uint64_t bottom_level_acceleration_structure_handle; 26 | } kinc_raytrace_acceleration_structure_impl_t; 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /sources/backends/vulkan/kinc/backend/graphics5/rendertarget.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "MiniVulkan.h" 4 | 5 | typedef struct { 6 | VkImage sourceImage; 7 | VkDeviceMemory sourceMemory; 8 | VkImageView sourceView; 9 | 10 | VkImage depthImage; 11 | VkDeviceMemory depthMemory; 12 | VkImageView depthView; 13 | int depthBufferBits; 14 | 15 | VkFramebuffer framebuffer; 16 | 17 | VkFormat format; 18 | 19 | VkBuffer readbackBuffer; 20 | VkDeviceMemory readbackMemory; 21 | bool readbackBufferCreated; 22 | 23 | int stage; 24 | int stage_depth; 25 | } RenderTarget5Impl; 26 | -------------------------------------------------------------------------------- /sources/backends/vulkan/kinc/backend/graphics5/sampler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | typedef struct kinc_g5_sampler_impl { 6 | VkSampler sampler; 7 | } kinc_g5_sampler_impl_t; 8 | -------------------------------------------------------------------------------- /sources/backends/vulkan/kinc/backend/graphics5/shader.c.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void kinc_g5_shader_init(kinc_g5_shader_t *shader, const void *source, size_t length, kinc_g5_shader_type_t type) { 4 | shader->impl.length = (int)length; 5 | shader->impl.id = 0; 6 | shader->impl.source = (char *)malloc(length + 1); 7 | for (int i = 0; i < length; ++i) { 8 | shader->impl.source[i] = ((char *)source)[i]; 9 | } 10 | shader->impl.source[length] = 0; 11 | } 12 | 13 | void kinc_g5_shader_destroy(kinc_g5_shader_t *shader) { 14 | free(shader->impl.source); 15 | shader->impl.source = NULL; 16 | } 17 | -------------------------------------------------------------------------------- /sources/backends/vulkan/kinc/backend/graphics5/shader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef struct { 4 | unsigned id; 5 | char *source; 6 | int length; 7 | } Shader5Impl; 8 | -------------------------------------------------------------------------------- /sources/backends/vulkan/kinc/backend/graphics5/texture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "MiniVulkan.h" 4 | 5 | struct texture_object { 6 | VkImage image; 7 | VkImageLayout imageLayout; 8 | 9 | VkDeviceMemory mem; 10 | VkImageView view; 11 | int32_t tex_width, tex_height; 12 | }; 13 | 14 | typedef struct { 15 | struct texture_object texture; 16 | VkDeviceSize deviceSize; 17 | 18 | uint8_t *conversionBuffer; 19 | int stride; 20 | } Texture5Impl; 21 | -------------------------------------------------------------------------------- /sources/backends/vulkan/kinc/backend/graphics5/vertexbuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "MiniVulkan.h" 6 | 7 | struct Vertices { 8 | VkBuffer buf; 9 | VkDeviceMemory mem; 10 | }; 11 | 12 | typedef struct { 13 | float *data; 14 | int myCount; 15 | int myStride; 16 | unsigned bufferId; 17 | kinc_g5_vertex_structure_t structure; 18 | VkMemoryAllocateInfo mem_alloc; 19 | int instanceDataStepRate; 20 | struct Vertices vertices; 21 | } VertexBuffer5Impl; 22 | -------------------------------------------------------------------------------- /sources/backends/wasm/kinc/backend/atomic.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define KINC_ATOMIC_COMPARE_EXCHANGE(pointer, oldValue, newValue) 4 | 5 | #define KINC_ATOMIC_COMPARE_EXCHANGE_POINTER(pointer, oldValue, newValue) 6 | 7 | #define KINC_ATOMIC_INCREMENT(pointer) 8 | 9 | #define KINC_ATOMIC_DECREMENT(pointer) 10 | 11 | #define KINC_ATOMIC_EXCHANGE_32(pointer, value) 12 | 13 | #define KINC_ATOMIC_EXCHANGE_FLOAT(pointer, value) 14 | -------------------------------------------------------------------------------- /sources/backends/wasm/kinc/backend/audio.c.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static kinc_a2_buffer_t a2_buffer; 5 | 6 | void kinc_a2_init() { 7 | kinc_a2_internal_init(); 8 | } 9 | 10 | void kinc_a2_update() {} 11 | 12 | void kinc_a2_shutdown() {} 13 | 14 | static uint32_t samples_per_second = 44100; 15 | 16 | uint32_t kinc_a2_samples_per_second(void) { 17 | return samples_per_second; 18 | } 19 | -------------------------------------------------------------------------------- /sources/backends/wasm/kinc/backend/display.c.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void kinc_display_init(void) {} 4 | 5 | int kinc_primary_display(void) { 6 | return 0; 7 | } 8 | 9 | int kinc_count_displays(void) { 10 | return 1; 11 | } 12 | 13 | bool kinc_display_available(int display_index) { 14 | return false; 15 | } 16 | 17 | const char *kinc_display_name(int display_index) { 18 | return "Browser"; 19 | } 20 | 21 | kinc_display_mode_t kinc_display_current_mode(int display_index) { 22 | kinc_display_mode_t mode; 23 | mode.x = 0; 24 | mode.y = 0; 25 | mode.width = 800; 26 | mode.height = 600; 27 | mode.pixels_per_inch = 96; 28 | mode.frequency = 60; 29 | mode.bits_per_pixel = 32; 30 | return mode; 31 | } 32 | 33 | int kinc_display_count_available_modes(int display_index) { 34 | return 1; 35 | } 36 | 37 | kinc_display_mode_t kinc_display_available_mode(int display_index, int mode_index) { 38 | kinc_display_mode_t mode; 39 | mode.x = 0; 40 | mode.y = 0; 41 | mode.width = 800; 42 | mode.height = 600; 43 | mode.pixels_per_inch = 96; 44 | mode.frequency = 60; 45 | mode.bits_per_pixel = 32; 46 | return mode; 47 | } 48 | -------------------------------------------------------------------------------- /sources/backends/wasm/kinc/backend/event.c.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void kinc_event_init(kinc_event_t *event, bool auto_reset) {} 4 | 5 | void kinc_event_destroy(kinc_event_t *event) {} 6 | 7 | void kinc_event_signal(kinc_event_t *event) {} 8 | 9 | void kinc_event_wait(kinc_event_t *event) {} 10 | 11 | bool kinc_event_try_to_wait(kinc_event_t *event, double seconds) { 12 | return false; 13 | } 14 | 15 | void kinc_event_reset(kinc_event_t *event) {} 16 | -------------------------------------------------------------------------------- /sources/backends/wasm/kinc/backend/event.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | typedef struct { 8 | int nothing; 9 | } kinc_event_impl_t; 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /sources/backends/wasm/kinc/backend/html5unit.c: -------------------------------------------------------------------------------- 1 | #include "audio.c.h" 2 | #include "display.c.h" 3 | #include "event.c.h" 4 | #include "mouse.c.h" 5 | #include "mutex.c.h" 6 | #include "semaphore.c.h" 7 | #include "system.c.h" 8 | #include "thread.c.h" 9 | #include "threadlocal.c.h" 10 | #include "video.c.h" 11 | #include "window.c.h" 12 | -------------------------------------------------------------------------------- /sources/backends/wasm/kinc/backend/mouse.c.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void kinc_internal_mouse_lock(int window) {} 4 | 5 | void kinc_internal_mouse_unlock(void) {} 6 | 7 | bool kinc_mouse_can_lock(void) { 8 | return false; 9 | } 10 | 11 | void kinc_mouse_show() {} 12 | 13 | void kinc_mouse_hide() {} 14 | 15 | void kinc_mouse_set_position(int window, int x, int y) {} 16 | 17 | void kinc_mouse_get_position(int window, int *x, int *y) {} 18 | -------------------------------------------------------------------------------- /sources/backends/wasm/kinc/backend/mutex.c.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void kinc_mutex_init(kinc_mutex_t *mutex) {} 4 | 5 | void kinc_mutex_destroy(kinc_mutex_t *mutex) {} 6 | 7 | bool kinc_mutex_try_to_lock(kinc_mutex_t *mutex) { 8 | return false; 9 | } 10 | 11 | void kinc_mutex_lock(kinc_mutex_t *mutex) {} 12 | 13 | void kinc_mutex_unlock(kinc_mutex_t *mutex) {} 14 | 15 | bool kinc_uber_mutex_init(kinc_uber_mutex_t *mutex, const char *name) { 16 | return false; 17 | } 18 | 19 | void kinc_uber_mutex_destroy(kinc_uber_mutex_t *mutex) {} 20 | 21 | void kinc_uber_mutex_lock(kinc_uber_mutex_t *mutex) {} 22 | 23 | void kinc_uber_mutex_unlock(kinc_uber_mutex_t *mutex) {} 24 | -------------------------------------------------------------------------------- /sources/backends/wasm/kinc/backend/mutex.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | typedef struct { 8 | int nothing; 9 | } kinc_mutex_impl_t; 10 | 11 | typedef struct { 12 | int nothing; 13 | } kinc_uber_mutex_impl_t; 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /sources/backends/wasm/kinc/backend/semaphore.c.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void kinc_semaphore_init(kinc_semaphore_t *semaphore, int current, int max) {} 4 | 5 | void kinc_semaphore_destroy(kinc_semaphore_t *semaphore) {} 6 | 7 | void kinc_semaphore_release(kinc_semaphore_t *semaphore, int count) {} 8 | 9 | void kinc_semaphore_acquire(kinc_semaphore_t *semaphore) {} 10 | 11 | bool kinc_semaphore_try_to_acquire(kinc_semaphore_t *semaphore, double seconds) { 12 | return false; 13 | } 14 | -------------------------------------------------------------------------------- /sources/backends/wasm/kinc/backend/semaphore.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | typedef struct { 8 | int nothing; 9 | } kinc_semaphore_impl_t; 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /sources/backends/wasm/kinc/backend/thread.c.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void kinc_thread_init(kinc_thread_t *t, void (*thread)(void *param), void *param) {} 4 | 5 | void kinc_thread_wait_and_destroy(kinc_thread_t *thread) {} 6 | 7 | bool kinc_thread_try_to_destroy(kinc_thread_t *thread) { 8 | return false; 9 | } 10 | 11 | void kinc_threads_init() {} 12 | 13 | void kinc_threads_quit() {} 14 | 15 | void kinc_thread_sleep(int milliseconds) {} 16 | -------------------------------------------------------------------------------- /sources/backends/wasm/kinc/backend/thread.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | typedef struct { 8 | int nothing; 9 | } kinc_thread_impl_t; 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /sources/backends/wasm/kinc/backend/threadlocal.c.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | void kinc_thread_local_init(kinc_thread_local_t *local) {} 6 | 7 | void kinc_thread_local_destroy(kinc_thread_local_t *local) {} 8 | 9 | void *kinc_thread_local_get(kinc_thread_local_t *local) { 10 | return NULL; 11 | } 12 | 13 | void kinc_thread_local_set(kinc_thread_local_t *local, void *data) {} 14 | -------------------------------------------------------------------------------- /sources/backends/wasm/kinc/backend/threadlocal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | typedef struct { 8 | int nothing; 9 | } kinc_thread_local_impl_t; 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /sources/backends/wasm/kinc/backend/video.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | typedef struct { 8 | int nothing; 9 | } kinc_video_impl_t; 10 | 11 | typedef struct kinc_internal_video_sound_stream { 12 | int nothing; 13 | } kinc_internal_video_sound_stream_t; 14 | 15 | void kinc_internal_video_sound_stream_init(kinc_internal_video_sound_stream_t *stream, int channel_count, int frequency); 16 | 17 | void kinc_internal_video_sound_stream_destroy(kinc_internal_video_sound_stream_t *stream); 18 | 19 | void kinc_internal_video_sound_stream_insert_data(kinc_internal_video_sound_stream_t *stream, float *data, int sample_count); 20 | 21 | float *kinc_internal_video_sound_stream_next_frame(kinc_internal_video_sound_stream_t *stream); 22 | 23 | bool kinc_internal_video_sound_stream_ended(kinc_internal_video_sound_stream_t *stream); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | -------------------------------------------------------------------------------- /sources/backends/wasm/kinc/backend/windowdata.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Kore { 4 | struct WindowData { 5 | int width, height, mode; 6 | WindowData(); 7 | }; 8 | } 9 | -------------------------------------------------------------------------------- /sources/backends/webgpu/kinc/backend/graphics5/WebGPU.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | -------------------------------------------------------------------------------- /sources/backends/webgpu/kinc/backend/graphics5/commandlist.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | WGPUCommandEncoder encoder; 11 | WGPURenderPassEncoder pass; 12 | int indexCount; 13 | } CommandList5Impl; 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /sources/backends/webgpu/kinc/backend/graphics5/compute.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void kinc_g5_compute_shader_init(kinc_g5_compute_shader *shader, void *source, int length) {} 5 | 6 | void kinc_g5_compute_shader_destroy(kinc_g5_compute_shader *shader) {} 7 | 8 | kinc_g5_constant_location_t kinc_g5_compute_shader_get_constant_location(kinc_g5_compute_shader *shader, const char *name) { 9 | kinc_g5_constant_location_t location = {0}; 10 | return location; 11 | } 12 | 13 | kinc_g5_texture_unit_t kinc_g5_compute_shader_get_texture_unit(kinc_g5_compute_shader *shader, const char *name) { 14 | kinc_g5_texture_unit_t unit = {0}; 15 | return unit; 16 | } 17 | -------------------------------------------------------------------------------- /sources/backends/webgpu/kinc/backend/graphics5/compute.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef struct kinc_g5_compute_shader_impl { 4 | int nothing; 5 | } kinc_g5_compute_shader_impl; 6 | -------------------------------------------------------------------------------- /sources/backends/webgpu/kinc/backend/graphics5/constantbuffer.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | bool kinc_g5_transposeMat3 = false; 10 | bool kinc_g5_transposeMat4 = false; 11 | 12 | void kinc_g5_constant_buffer_init(kinc_g5_constant_buffer_t *buffer, int size) { 13 | 14 | } 15 | 16 | void kinc_g5_constant_buffer_destroy(kinc_g5_constant_buffer_t *buffer) {} 17 | 18 | void kinc_g5_constant_buffer_lock_all(kinc_g5_constant_buffer_t *buffer) { 19 | kinc_g5_constant_buffer_lock(buffer, 0, kinc_g5_constant_buffer_size(buffer)); 20 | } 21 | 22 | void kinc_g5_constant_buffer_lock(kinc_g5_constant_buffer_t *buffer, int start, int count) {} 23 | 24 | void kinc_g5_constant_buffer_unlock(kinc_g5_constant_buffer_t *buffer) { 25 | 26 | } 27 | 28 | int kinc_g5_constant_buffer_size(kinc_g5_constant_buffer_t *buffer) { 29 | return 0; 30 | } 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | -------------------------------------------------------------------------------- /sources/backends/webgpu/kinc/backend/graphics5/constantbuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | WGPUBuffer buffer; 11 | } ConstantBuffer5Impl; 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | -------------------------------------------------------------------------------- /sources/backends/webgpu/kinc/backend/graphics5/graphics.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | -------------------------------------------------------------------------------- /sources/backends/webgpu/kinc/backend/graphics5/indexbuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | WGPUBuffer buffer; 11 | int count; 12 | int format; 13 | } IndexBuffer5Impl; 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /sources/backends/webgpu/kinc/backend/graphics5/pipeline.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | WGPURenderPipeline pipeline; 11 | } PipelineState5Impl; 12 | 13 | typedef struct { 14 | WGPUComputePipeline pipeline; 15 | } ComputePipelineState5Impl; 16 | 17 | typedef struct { 18 | int vertexOffset; 19 | int fragmentOffset; 20 | int computeOffset; 21 | } ConstantLocation5Impl; 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | -------------------------------------------------------------------------------- /sources/backends/webgpu/kinc/backend/graphics5/rendertarget.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void kinc_g5_render_target_init_with_multisampling(kinc_g5_render_target_t *target, int width, int height, kinc_g5_render_target_format_t format, 5 | int depthBufferBits, int stencilBufferBits, int samples_per_pixel) { 6 | 7 | } 8 | 9 | void kinc_g5_render_target_init_framebuffer_with_multisampling(kinc_g5_render_target_t *target, int width, int height, kinc_g5_render_target_format_t format, 10 | int depthBufferBits, int stencilBufferBits, int samples_per_pixel) {} 11 | 12 | void kinc_g5_render_target_init_cube_with_multisampling(kinc_g5_render_target_t *render_target, int cubeMapSize, kinc_g5_render_target_format_t format, 13 | int depthBufferBits, int stencilBufferBits, int samples_per_pixel) {} 14 | 15 | void kinc_g5_render_target_destroy(kinc_g5_render_target_t *renderTarget) {} 16 | 17 | void kinc_g5_render_target_set_depth_stencil_from(kinc_g5_render_target_t *renderTarget, kinc_g5_render_target_t *source) {} 18 | 19 | void kinc_g5_render_target_get_pixels(kinc_g5_render_target_t *renderTarget, uint8_t *data) {} 20 | 21 | void kinc_g5_render_target_generate_mipmaps(kinc_g5_render_target_t *renderTarget, int levels) {} 22 | -------------------------------------------------------------------------------- /sources/backends/webgpu/kinc/backend/graphics5/rendertarget.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | WGPUTexture texture; 11 | } RenderTarget5Impl; 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | -------------------------------------------------------------------------------- /sources/backends/webgpu/kinc/backend/graphics5/sampler.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void kinc_g5_sampler_init(kinc_g5_sampler_t *sampler, const kinc_g5_sampler_options_t *options) {} 4 | 5 | void kinc_g5_sampler_destroy(kinc_g5_sampler_t *sampler) {} 6 | -------------------------------------------------------------------------------- /sources/backends/webgpu/kinc/backend/graphics5/sampler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef struct kinc_g5_sampler_impl { 4 | int a; 5 | } kinc_g5_sampler_impl_t; 6 | -------------------------------------------------------------------------------- /sources/backends/webgpu/kinc/backend/graphics5/shader.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | extern WGPUDevice device; 6 | 7 | void kinc_g5_shader_init(kinc_g5_shader_t *shader, const void *source, size_t length, kinc_g5_shader_type_t type) { 8 | WGPUShaderModuleSPIRVDescriptor smSpirvDesc; 9 | memset(&smSpirvDesc, 0, sizeof(smSpirvDesc)); 10 | smSpirvDesc.chain.sType = WGPUSType_ShaderModuleSPIRVDescriptor; 11 | smSpirvDesc.codeSize = length / 4; 12 | smSpirvDesc.code = source; 13 | WGPUShaderModuleDescriptor smDesc; 14 | memset(&smDesc, 0, sizeof(smDesc)); 15 | smDesc.nextInChain = &smSpirvDesc; 16 | shader->impl.module = wgpuDeviceCreateShaderModule(device, &smDesc); 17 | } 18 | 19 | void kinc_g5_shader_destroy(kinc_g5_shader_t *shader) {} 20 | -------------------------------------------------------------------------------- /sources/backends/webgpu/kinc/backend/graphics5/shader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | struct WGPUShaderModuleImpl; 10 | 11 | typedef struct { 12 | WGPUShaderModule module; 13 | } Shader5Impl; 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /sources/backends/webgpu/kinc/backend/graphics5/texture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | WGPUTexture texture; 11 | } Texture5Impl; 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | -------------------------------------------------------------------------------- /sources/backends/webgpu/kinc/backend/graphics5/vertexbuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | WGPUBuffer buffer; 11 | int count; 12 | int stride; 13 | } VertexBuffer5Impl; 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /sources/backends/windows/kinc/backend/Windows.c.h: -------------------------------------------------------------------------------- 1 | #include "Windows.h" 2 | -------------------------------------------------------------------------------- /sources/backends/windows/kinc/backend/Windows.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | struct HMONITOR__; 10 | struct HWND__; 11 | 12 | int kinc_windows_get_display_for_monitor(struct HMONITOR__ *monitor); 13 | bool kinc_windows_set_display_mode(int display_index, int width, int height, int bpp, int frequency); 14 | void kinc_windows_restore_display(int display_index); 15 | void kinc_windows_restore_displays(); 16 | void kinc_windows_hide_windows(); 17 | void kinc_windows_destroy_windows(); 18 | struct HWND__ *kinc_windows_window_handle(int window_index); 19 | int kinc_windows_window_index_from_hwnd(struct HWND__ *handle); 20 | int kinc_windows_manual_width(int window); 21 | int kinc_windows_manual_height(int window); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | -------------------------------------------------------------------------------- /sources/backends/windows/kinc/backend/base.c.h: -------------------------------------------------------------------------------- 1 | #ifdef KINC_NO_CLIB 2 | 3 | #ifndef NDEBUG 4 | void _wassert(wchar_t const *message, wchar_t const *filename, unsigned line) { 5 | __debugbreak(); 6 | } 7 | 8 | void _RTC_CheckStackVars(void) {} 9 | 10 | void _RTC_InitBase(void) {} 11 | 12 | void _RTC_Shutdown(void) {} 13 | 14 | void _RTC_AllocaHelper(void) {} 15 | 16 | void _RTC_CheckStackVars2(void) {} 17 | 18 | void __GSHandlerCheck(void) {} 19 | 20 | void __fastcall __security_check_cookie(_In_ uintptr_t _StackCookie) {} 21 | 22 | uintptr_t __security_cookie; 23 | 24 | int _fltused = 1; 25 | 26 | void __report_rangecheckfailure(void) {} 27 | 28 | void __chkstk(void) {} 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /sources/backends/windows/kinc/backend/mouse.c.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | void kinc_internal_mouse_lock(int window) { 8 | kinc_mouse_hide(); 9 | HWND handle = kinc_windows_window_handle(window); 10 | SetCapture(handle); 11 | RECT rect; 12 | GetWindowRect(handle, &rect); 13 | ClipCursor(&rect); 14 | } 15 | 16 | void kinc_internal_mouse_unlock(void) { 17 | kinc_mouse_show(); 18 | ReleaseCapture(); 19 | ClipCursor(NULL); 20 | } 21 | 22 | bool kinc_mouse_can_lock(void) { 23 | return true; 24 | } 25 | 26 | void kinc_mouse_show() { 27 | // Work around the internal counter of ShowCursor 28 | while (ShowCursor(true) < 0) { 29 | } 30 | } 31 | 32 | void kinc_mouse_hide() { 33 | // Work around the internal counter of ShowCursor 34 | while (ShowCursor(false) >= 0) { 35 | } 36 | } 37 | 38 | void kinc_mouse_set_position(int window, int x, int y) { 39 | POINT point; 40 | point.x = x; 41 | point.y = y; 42 | ClientToScreen(kinc_windows_window_handle(window), &point); 43 | SetCursorPos(point.x, point.y); 44 | } 45 | 46 | void kinc_mouse_get_position(int window, int *x, int *y) { 47 | POINT point; 48 | GetCursorPos(&point); 49 | ScreenToClient(kinc_windows_window_handle(window), &point); 50 | *x = point.x; 51 | *y = point.y; 52 | } 53 | -------------------------------------------------------------------------------- /sources/backends/windows/kinc/backend/video.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | typedef struct { 8 | void *renderer; 9 | double duration; 10 | double position; 11 | bool finished; 12 | bool paused; 13 | } kinc_video_impl_t; 14 | 15 | typedef struct kinc_internal_video_sound_stream { 16 | int nothing; 17 | } kinc_internal_video_sound_stream_t; 18 | 19 | void kinc_internal_video_sound_stream_init(kinc_internal_video_sound_stream_t *stream, int channel_count, int frequency); 20 | 21 | void kinc_internal_video_sound_stream_destroy(kinc_internal_video_sound_stream_t *stream); 22 | 23 | void kinc_internal_video_sound_stream_insert_data(kinc_internal_video_sound_stream_t *stream, float *data, int sample_count); 24 | 25 | float *kinc_internal_video_sound_stream_next_frame(kinc_internal_video_sound_stream_t *stream); 26 | 27 | bool kinc_internal_video_sound_stream_ended(kinc_internal_video_sound_stream_t *stream); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /sources/const_data.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | extern const int _const_data_skydome_indices[]; 5 | extern const int _const_data_skydome_indices_count; 6 | extern const float _const_data_skydome_pos[]; 7 | extern const int _const_data_skydome_pos_count; 8 | extern const float _const_data_skydome_nor[]; 9 | extern const int _const_data_skydome_nor_count; 10 | -------------------------------------------------------------------------------- /sources/iron.c: -------------------------------------------------------------------------------- 1 | #include IRON_C_PATH 2 | -------------------------------------------------------------------------------- /sources/iron_gc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // point_t *p = GC_ALLOC_INIT(point_t, {x: 1.5, y: 3.5}); 6 | #define GC_ALLOC_INIT(type, ...) (type *)memcpy(gc_alloc(sizeof(type)), (type[]){ __VA_ARGS__ }, sizeof(type)) 7 | 8 | void *gc_alloc(size_t size); 9 | void gc_array(void *ptr, int *length); 10 | void gc_leaf(void *ptr); 11 | void gc_root(void *ptr); 12 | void gc_unroot(void *ptr); 13 | void *gc_cut(void *ptr, size_t pos, size_t size); 14 | void *gc_realloc(void *ptr, size_t size); 15 | void gc_free(void *ptr); 16 | void gc_pause(); 17 | void gc_resume(); 18 | void gc_run(); 19 | void gc_start(void *bos); 20 | void gc_stop(); 21 | -------------------------------------------------------------------------------- /sources/iron_json.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "iron_array.h" 4 | #include "iron_map.h" 5 | #include 6 | 7 | void *json_parse(char *s); 8 | any_map_t *json_parse_to_map(char *s); 9 | 10 | void json_encode_begin(); 11 | char *json_encode_end(); 12 | void json_encode_string(char *k, char *v); 13 | void json_encode_string_array(char *k, char_ptr_array_t *a); 14 | void json_encode_f32(char *k, float f); 15 | void json_encode_i32(char *k, int i); 16 | void json_encode_null(char *k); 17 | void json_encode_f32_array(char *k, f32_array_t *a); 18 | void json_encode_i32_array(char *k, i32_array_t *a); 19 | void json_encode_bool(char *k, bool b); 20 | void json_encode_begin_array(char *k); 21 | void json_encode_end_array(); 22 | void json_encode_begin_object(); 23 | void json_encode_end_object(); 24 | void json_encode_map(any_map_t *m); 25 | -------------------------------------------------------------------------------- /sources/iron_map.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "iron_array.h" 5 | 6 | typedef struct i32_map { 7 | char_ptr_array_t *keys; 8 | i32_array_t *values; 9 | } i32_map_t; 10 | 11 | typedef struct f32_map { 12 | char_ptr_array_t *keys; 13 | f32_array_t *values; 14 | } f32_map_t; 15 | 16 | typedef struct any_map { 17 | char_ptr_array_t *keys; 18 | any_array_t *values; 19 | } any_map_t; 20 | 21 | void i32_map_set(i32_map_t *m, char *k, int v); 22 | void f32_map_set(f32_map_t *m, char *k, float v); 23 | void any_map_set(any_map_t *m, char *k, void *v); 24 | 25 | int32_t i32_map_get(i32_map_t *m, char *k); 26 | float f32_map_get(f32_map_t *m, char *k); 27 | void *any_map_get(any_map_t *m, char *k); 28 | 29 | void map_delete(any_map_t *m, char *k); 30 | any_array_t *map_keys(any_map_t *m); 31 | 32 | i32_map_t *i32_map_create(); 33 | any_map_t *any_map_create(); 34 | 35 | // imap 36 | 37 | typedef struct i32_imap { 38 | i32_array_t *keys; 39 | i32_array_t *values; 40 | } i32_imap_t; 41 | 42 | typedef struct any_imap { 43 | i32_array_t *keys; 44 | any_array_t *values; 45 | } any_imap_t; 46 | 47 | void i32_imap_set(i32_imap_t *m, int k, int v); 48 | void any_imap_set(any_imap_t *m, int k, void *v); 49 | int i32_imap_get(i32_imap_t *m, int k); 50 | void *any_imap_get(any_imap_t *m, int k); 51 | void imap_delete(any_imap_t *m, int k); 52 | i32_array_t *imap_keys(any_imap_t *m); 53 | any_imap_t *any_imap_create(); 54 | -------------------------------------------------------------------------------- /sources/iron_mat3.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "iron_mat4.h" 5 | 6 | mat3_t mat3_create(float _00, float _10, float _20, 7 | float _01, float _11, float _21, 8 | float _02, float _12, float _22); 9 | mat3_t mat3_identity(); 10 | mat3_t mat3_translation(float x, float y); 11 | mat3_t mat3_rotation(float alpha); 12 | mat3_t mat3_set_from4(mat4_t m4); 13 | mat3_t mat3_multmat(mat3_t a, mat3_t b); 14 | mat3_t mat3_nan(); 15 | bool mat3_isnan(mat3_t m); 16 | -------------------------------------------------------------------------------- /sources/iron_obj.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "iron_armpack.h" 7 | 8 | typedef struct raw_mesh { 9 | struct i16_array *posa; 10 | struct i16_array *nora; 11 | struct i16_array *texa; 12 | struct i16_array *cola; 13 | struct u32_array *inda; 14 | int vertex_count; 15 | int index_count; 16 | float scale_pos; 17 | float scale_tex; 18 | char *name; 19 | bool has_next; // File contains multiple objects 20 | uint64_t pos; 21 | struct any_array *udims; // u32_array_t[] - Indices split per udim tile 22 | int udims_u; // Number of horizontal udim tiles 23 | int udims_v; 24 | void *vertex_arrays; // vertex_array_t[] 25 | void *index_arrays; // index_array_t[] 26 | } raw_mesh_t; 27 | 28 | raw_mesh_t *obj_parse(buffer_t *file_bytes, char split_code, uint64_t start_pos, bool udim); 29 | void obj_destroy(raw_mesh_t *part); 30 | -------------------------------------------------------------------------------- /sources/iron_quat.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "iron_vec4.h" 5 | #include "iron_mat4.h" 6 | 7 | quat_t quat_create(float x, float y, float z, float w); 8 | quat_t quat_from_axis_angle(vec4_t axis, float angle); 9 | quat_t quat_from_mat(mat4_t m); 10 | quat_t quat_from_rot_mat(mat4_t m); 11 | quat_t quat_mult(quat_t a, quat_t b); 12 | quat_t quat_norm(quat_t q); 13 | quat_t quat_clone(quat_t q); 14 | vec4_t quat_get_euler(quat_t q); 15 | quat_t quat_from_euler(float x, float y, float z); 16 | quat_t quat_lerp(quat_t from, quat_t to, float s); 17 | float quat_dot(quat_t a, quat_t b); 18 | quat_t quat_from_to(vec4_t v0, vec4_t v1); 19 | -------------------------------------------------------------------------------- /sources/iron_string.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "iron_array.h" 6 | 7 | char *string_join(char *a, char *b); 8 | char *string_copy(char *a); 9 | int string_length(char *str); 10 | bool string_equals(char *a, char *b); 11 | char *i32_to_string(int32_t i); 12 | char *i32_to_string_hex(int32_t i); 13 | char *i64_to_string(int64_t i); 14 | char *u64_to_string(uint64_t i); 15 | char *f32_to_string(float f); 16 | char *f32_to_string_with_zeros(float f); 17 | 18 | void string_strip_trailing_zeros(char *str); 19 | int32_t string_index_of(char *s, char *search); 20 | int32_t string_index_of_pos(char *s, char *search, int pos); 21 | int32_t string_last_index_of(char *s, char *search); 22 | any_array_t *string_split(char *s, char *sep); 23 | char *string_array_join(any_array_t *a, char *separator); 24 | char *string_replace_all(char *s, char *search, char *replace); 25 | char *substring(char *s, int32_t start, int32_t end); 26 | char *string_from_char_code(int32_t c); 27 | int32_t char_code_at(char *s, int32_t i); 28 | char *char_at(char *s, int32_t i); 29 | bool starts_with(char *s, char *start); 30 | bool ends_with(char *s, char *end); 31 | char *to_lower_case(char *s); 32 | char *to_upper_case(char *s); 33 | char *trim_end(char *str); 34 | int string_utf8_decode(const char *str, int *i); 35 | -------------------------------------------------------------------------------- /sources/iron_ui_ext.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "iron_ui.h" 4 | 5 | float ui_float_input(ui_handle_t *handle, char *label, int align, float precision); 6 | char *ui_file_browser(ui_handle_t *handle, bool folders_only); 7 | int ui_inline_radio(ui_handle_t *handle, char_ptr_array_t *texts, int align); 8 | int ui_color_wheel(ui_handle_t *handle, bool alpha, float w, float h, bool color_preview, void (*picker)(void *), void *data); 9 | char *ui_text_area(ui_handle_t *handle, int align, bool editable, char *label, bool word_wrap); 10 | void ui_begin_menu(); 11 | void ui_end_menu(); 12 | bool _ui_menu_button(char *text); 13 | void ui_hsv_to_rgb(float cr, float cg, float cb, float *out); 14 | void ui_rgb_to_hsv(float cr, float cg, float cb, float *out); 15 | 16 | uint8_t ui_color_r(uint32_t color); 17 | uint8_t ui_color_g(uint32_t color); 18 | uint8_t ui_color_b(uint32_t color); 19 | uint8_t ui_color_a(uint32_t color); 20 | uint32_t ui_color(uint8_t r, uint8_t g, uint8_t b, uint8_t a); 21 | 22 | extern bool ui_text_area_line_numbers; 23 | extern bool ui_text_area_scroll_past_end; 24 | extern ui_text_coloring_t *ui_text_area_coloring; 25 | -------------------------------------------------------------------------------- /sources/iron_vec2.c: -------------------------------------------------------------------------------- 1 | #include "iron_vec2.h" 2 | 3 | #include 4 | #include 5 | 6 | vec2_t vec2_create(float x, float y) { 7 | vec2_t v; 8 | v.x = x; 9 | v.y = y; 10 | return v; 11 | } 12 | 13 | float vec2_len(vec2_t v) { 14 | return sqrtf(v.x * v.x + v.y * v.y); 15 | } 16 | 17 | vec2_t vec2_set_len(vec2_t v, float length) { 18 | float current_length = vec2_len(v); 19 | if (current_length == 0) { 20 | return v; 21 | } 22 | float mul = length / current_length; 23 | v.x *= mul; 24 | v.y *= mul; 25 | return v; 26 | } 27 | 28 | vec2_t vec2_mult(vec2_t v, float f) { 29 | v.x *= f; 30 | v.y *= f; 31 | return v; 32 | } 33 | 34 | vec2_t vec2_add(vec2_t a, vec2_t b) { 35 | a.x += b.x; 36 | a.y += b.y; 37 | return a; 38 | } 39 | 40 | vec2_t vec2_sub(vec2_t a, vec2_t b) { 41 | a.x -= b.x; 42 | a.y -= b.y; 43 | return a; 44 | } 45 | 46 | float vec2_cross(vec2_t a, vec2_t b) { 47 | return a.x * b.y - a.y * b.x; 48 | } 49 | 50 | vec2_t vec2_norm(vec2_t v) { 51 | float n = vec2_len(v); 52 | if (n > 0.0) { 53 | float inv_n = 1.0f / n; 54 | v.x *= inv_n; 55 | v.y *= inv_n; 56 | } 57 | return v; 58 | } 59 | 60 | float vec2_dot(vec2_t a, vec2_t b) { 61 | return a.x * b.x + a.y * b.y; 62 | } 63 | 64 | vec2_t vec2_nan() { 65 | vec2_t v; 66 | v.x = NAN; 67 | return v; 68 | } 69 | 70 | bool vec2_isnan(vec2_t v) { 71 | return isnan(v.x); 72 | } 73 | -------------------------------------------------------------------------------- /sources/iron_vec2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "iron_vec4.h" 5 | 6 | vec2_t vec2_create(float x, float y); 7 | float vec2_len(vec2_t v); 8 | vec2_t vec2_set_len(vec2_t v, float length); 9 | vec2_t vec2_mult(vec2_t a, float f); 10 | vec2_t vec2_add(vec2_t a, vec2_t b); 11 | vec2_t vec2_sub(vec2_t a, vec2_t b); 12 | float vec2_cross(vec2_t a, vec2_t b); 13 | vec2_t vec2_norm(vec2_t v); 14 | float vec2_dot(vec2_t a, vec2_t b); 15 | vec2_t vec2_nan(); 16 | bool vec2_isnan(vec2_t v); 17 | -------------------------------------------------------------------------------- /sources/iron_vec3.c: -------------------------------------------------------------------------------- 1 | #include "iron_vec3.h" 2 | 3 | #include 4 | #include 5 | -------------------------------------------------------------------------------- /sources/iron_vec3.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /sources/iron_vec4.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define mat4_t kinc_matrix4x4_t 4 | #define mat3_t kinc_matrix3x3_t 5 | #define quat_t kinc_quaternion_t 6 | #define vec4_t kinc_vector4_t 7 | #define vec3_t kinc_vector3_t 8 | #define vec2_t kinc_vector2_t 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include "iron_mat4.h" 15 | 16 | vec4_t vec4_create(float x, float y, float z, float w); 17 | vec4_t vec4_cross(vec4_t a, vec4_t b); 18 | vec4_t vec4_add(vec4_t a, vec4_t b); 19 | vec4_t vec4_fadd(vec4_t a, float x, float y, float z, float w); 20 | vec4_t vec4_norm(vec4_t a); 21 | vec4_t vec4_mult(vec4_t v, float f); 22 | float vec4_dot(vec4_t a, vec4_t b); 23 | vec4_t vec4_clone(vec4_t v); 24 | vec4_t vec4_lerp(vec4_t from, vec4_t to, float s); 25 | vec4_t vec4_apply_proj(vec4_t a, mat4_t m); 26 | vec4_t vec4_apply_mat(vec4_t a, mat4_t m); 27 | vec4_t vec4_apply_mat4(vec4_t a, mat4_t m); 28 | vec4_t vec4_apply_axis_angle(vec4_t a, vec4_t axis, float angle); 29 | vec4_t vec4_apply_quat(vec4_t a, quat_t q); 30 | bool vec4_equals(vec4_t a, vec4_t b); 31 | bool vec4_almost_equals(vec4_t a, vec4_t b, float prec); 32 | float vec4_len(vec4_t a); 33 | vec4_t vec4_sub(vec4_t a, vec4_t b); 34 | vec4_t vec4_exp(vec4_t a); 35 | float vec4_dist(vec4_t v1, vec4_t v2); 36 | float vec4_fdist(float v1x, float v1y, float v1z, float v2x, float v2y, float v2z); 37 | vec4_t vec4_reflect(vec4_t a, vec4_t n); 38 | vec4_t vec4_clamp(vec4_t a, float min, float max); 39 | vec4_t vec4_x_axis(); 40 | vec4_t vec4_y_axis(); 41 | vec4_t vec4_z_axis(); 42 | vec4_t vec4_nan(); 43 | bool vec4_isnan(vec4_t v); 44 | -------------------------------------------------------------------------------- /sources/kinc/audio1/a1unit.c: -------------------------------------------------------------------------------- 1 | #include "audio.h" 2 | 3 | #include 4 | 5 | struct kinc_a1_channel { 6 | kinc_a1_sound_t *sound; 7 | float position; 8 | bool loop; 9 | volatile float volume; 10 | volatile float pitch; 11 | }; 12 | 13 | struct kinc_a1_stream_channel { 14 | kinc_a1_sound_stream_t *stream; 15 | int position; 16 | }; 17 | 18 | struct kinc_internal_video_channel { 19 | struct kinc_internal_video_sound_stream *stream; 20 | int position; 21 | }; 22 | 23 | #include "audio.c.h" 24 | #include "sound.c.h" 25 | #include "soundstream.c.h" 26 | -------------------------------------------------------------------------------- /sources/kinc/audio2/audio.c: -------------------------------------------------------------------------------- 1 | #define KINC_IMPLEMENTATION_AUDIO2 2 | 3 | #include "audio.h" 4 | -------------------------------------------------------------------------------- /sources/kinc/color.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | /*! \file color.h 8 | \brief Provides some utility functionality for handling 32 bit ARGB color values. 9 | */ 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | /// 16 | /// Splits up an 32 bit ARGB color value into its components. 17 | /// 18 | void kinc_color_components(uint32_t color, float *red, float *green, float *blue, float *alpha); 19 | 20 | #define KINC_COLOR_BLACK 0xff000000 21 | #define KINC_COLOR_WHITE 0xffffffff 22 | #define KINC_COLOR_RED 0xffff0000 23 | #define KINC_COLOR_BLUE 0xff0000ff 24 | #define KINC_COLOR_GREEN 0xff00ff00 25 | #define KINC_COLOR_MAGENTA 0xffff00ff 26 | #define KINC_COLOR_YELLOW 0xffffff00 27 | #define KINC_COLOR_CYAN 0xff00ffff 28 | 29 | #ifdef KINC_IMPLEMENTATION_ROOT 30 | #define KINC_IMPLEMENTATION 31 | #endif 32 | 33 | #ifdef KINC_IMPLEMENTATION 34 | 35 | void kinc_color_components(uint32_t color, float *red, float *green, float *blue, float *alpha) { 36 | *alpha = ((color & 0xff000000) >> 24) / 255.0f; 37 | *red = ((color & 0x00ff0000) >> 16) / 255.0f; 38 | *green = ((color & 0x0000ff00) >> 8) / 255.0f; 39 | *blue = (color & 0x000000ff) / 255.0f; 40 | } 41 | 42 | #endif 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | -------------------------------------------------------------------------------- /sources/kinc/global.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /*! \file global.h 4 | \brief Provides basic functionality that's used all over the place. There's usually no need to manually include this. 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | #define KINC_LITTLE_ENDIAN 11 | 12 | #ifdef _MSC_VER 13 | #define KINC_INLINE static __forceinline 14 | #else 15 | #define KINC_INLINE static __attribute__((always_inline)) inline 16 | #endif 17 | 18 | #ifdef _MSC_VER 19 | #define KINC_MICROSOFT 20 | #endif 21 | 22 | #if defined(_WIN32) 23 | 24 | #ifndef KINC_CONSOLE 25 | #define KINC_WINDOWS 26 | #endif 27 | 28 | #elif defined(__APPLE__) 29 | 30 | #include 31 | 32 | #if TARGET_OS_IPHONE 33 | 34 | #if !defined(KINC_TVOS) 35 | #define KINC_IOS 36 | #endif 37 | 38 | #define KINC_APPLE_SOC 39 | 40 | #else 41 | 42 | #define KINC_MACOS 43 | 44 | #if defined(__arm64__) 45 | #define KINC_APPLE_SOC 46 | #endif 47 | 48 | #endif 49 | 50 | #define KINC_POSIX 51 | 52 | #elif defined(__linux__) 53 | 54 | #if !defined(KINC_ANDROID) 55 | #define KINC_LINUX 56 | #endif 57 | 58 | #define KINC_POSIX 59 | 60 | #endif 61 | 62 | int kickstart(int argc, char **argv); 63 | -------------------------------------------------------------------------------- /sources/kinc/graphics2/g2_ext.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void arm_g2_fill_circle(float cx, float cy, float radius, int segments); 4 | void arm_g2_draw_circle(float cx, float cy, float radius, int segments, float strength); 5 | void arm_g2_draw_cubic_bezier(float *x, float *y, int segments, float strength); 6 | -------------------------------------------------------------------------------- /sources/kinc/graphics4/constantlocation.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | /*! \file constantlocation.h 9 | \brief Provides the constant_location-struct which is used for setting constants/uniforms in a shader. 10 | */ 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | typedef struct kinc_g4_constant_location { 17 | kinc_g4_constant_location_impl_t impl; 18 | } kinc_g4_constant_location_t; 19 | 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | -------------------------------------------------------------------------------- /sources/kinc/graphics4/g4unit.c: -------------------------------------------------------------------------------- 1 | #include "graphics.c.h" 2 | #include "pipeline.c.h" 3 | #include "rendertarget.c.h" 4 | #include "vertexbuffer.c.h" 5 | -------------------------------------------------------------------------------- /sources/kinc/graphics4/graphics.c.h: -------------------------------------------------------------------------------- 1 | #include "graphics.h" 2 | 3 | static int antialiasing_samples; 4 | 5 | int kinc_g4_antialiasing_samples(void) { 6 | return antialiasing_samples; 7 | } 8 | 9 | void kinc_g4_set_antialiasing_samples(int samples) { 10 | antialiasing_samples = samples; 11 | } 12 | -------------------------------------------------------------------------------- /sources/kinc/graphics4/rendertarget.c.h: -------------------------------------------------------------------------------- 1 | #include "rendertarget.h" 2 | 3 | void kinc_g4_render_target_init(kinc_g4_render_target_t *renderTarget, int width, int height, kinc_g4_render_target_format_t format, int depthBufferBits, 4 | int stencilBufferBits) { 5 | kinc_g4_render_target_init_with_multisampling(renderTarget, width, height, format, depthBufferBits, stencilBufferBits, 1); 6 | } 7 | 8 | void kinc_g4_render_target_init_cube(kinc_g4_render_target_t *renderTarget, int cubeMapSize, kinc_g4_render_target_format_t format, int depthBufferBits, 9 | int stencilBufferBits) { 10 | kinc_g4_render_target_init_cube_with_multisampling(renderTarget, cubeMapSize, format, depthBufferBits, stencilBufferBits, 1); 11 | } -------------------------------------------------------------------------------- /sources/kinc/graphics4/textureunit.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | /*! \file textureunit.h 8 | \brief Provides a texture-unit-struct which is used for setting textures in a shader. 9 | */ 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | typedef struct kinc_g4_texture_unit { 16 | int stages[KINC_G4_SHADER_TYPE_COUNT]; 17 | } kinc_g4_texture_unit_t; 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /sources/kinc/graphics4/usage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /*! \file usage.h 4 | \brief Provides the usage enum. 5 | */ 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | typedef enum kinc_g4_usage { 12 | KINC_G4_USAGE_STATIC, 13 | KINC_G4_USAGE_DYNAMIC, 14 | KINC_G4_USAGE_READABLE 15 | } kinc_g4_usage_t; 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /sources/kinc/graphics4/vertexbuffer.c.h: -------------------------------------------------------------------------------- 1 | #include "vertexbuffer.h" 2 | 3 | static void init_vertex_element(kinc_g4_vertex_element_t *element, const char *name, kinc_g4_vertex_data_t data) { 4 | element->name = name; 5 | element->data = data; 6 | } 7 | 8 | void kinc_g4_vertex_structure_init(kinc_g4_vertex_structure_t *structure) { 9 | structure->size = 0; 10 | structure->instanced = false; 11 | } 12 | 13 | void kinc_g4_vertex_structure_add(kinc_g4_vertex_structure_t *structure, const char *name, kinc_g4_vertex_data_t data) { 14 | init_vertex_element(&structure->elements[structure->size++], name, data); 15 | } 16 | 17 | void kinc_g4_set_vertex_buffer(kinc_g4_vertex_buffer_t *buffer) { 18 | kinc_g4_vertex_buffer_t *buffers[1] = {buffer}; 19 | kinc_g4_set_vertex_buffers(buffers, 1); 20 | } 21 | -------------------------------------------------------------------------------- /sources/kinc/graphics5/commandlist.c.h: -------------------------------------------------------------------------------- 1 | #include "commandlist.h" 2 | -------------------------------------------------------------------------------- /sources/kinc/graphics5/constantlocation.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | /*! \file constantlocation.h 8 | \brief Provides the constant_location-struct which is used for setting constants/uniforms in a shader. 9 | */ 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | typedef struct kinc_g5_constant_location { 16 | ConstantLocation5Impl impl; 17 | } kinc_g5_constant_location_t; 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /sources/kinc/graphics5/g5unit.c: -------------------------------------------------------------------------------- 1 | #include "commandlist.c.h" 2 | #include "constantbuffer.c.h" 3 | #include "graphics.c.h" 4 | #include "pipeline.c.h" 5 | #include "rendertarget.c.h" 6 | #include "sampler.c.h" 7 | #include "texture.c.h" 8 | -------------------------------------------------------------------------------- /sources/kinc/graphics5/graphics.c.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGL_1_X 2 | 3 | #include "graphics.h" 4 | 5 | static int samples = 1; 6 | 7 | int kinc_g5_antialiasing_samples(void) { 8 | return samples; 9 | } 10 | 11 | void kinc_g5_set_antialiasing_samples(int samples_) { 12 | samples = samples_; 13 | } 14 | 15 | bool kinc_g5_fullscreen = false; 16 | 17 | // void Graphics5::setVertexBuffer(VertexBuffer& vertexBuffer) { 18 | // VertexBuffer* vertexBuffers[1] = {&vertexBuffer}; 19 | // setVertexBuffers(vertexBuffers, 1); 20 | //} 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /sources/kinc/graphics5/rendertarget.c.h: -------------------------------------------------------------------------------- 1 | #include "rendertarget.h" 2 | 3 | void kinc_g5_render_target_init(kinc_g5_render_target_t *render_target, int width, int height, kinc_g5_render_target_format_t format, int depthBufferBits, 4 | int stencilBufferBits) { 5 | kinc_g5_render_target_init_with_multisampling(render_target, width, height, format, depthBufferBits, stencilBufferBits, 1); 6 | } 7 | 8 | void kinc_g5_render_target_init_framebuffer(kinc_g5_render_target_t *render_target, int width, int height, kinc_g5_render_target_format_t format, 9 | int depthBufferBits, int stencilBufferBits) { 10 | kinc_g5_render_target_init_framebuffer_with_multisampling(render_target, width, height, format, depthBufferBits, stencilBufferBits, 1); 11 | } 12 | 13 | void kinc_g5_render_target_init_cube(kinc_g5_render_target_t *render_target, int cubeMapSize, kinc_g5_render_target_format_t format, int depthBufferBits, 14 | int stencilBufferBits) { 15 | kinc_g5_render_target_init_cube_with_multisampling(render_target, cubeMapSize, format, depthBufferBits, stencilBufferBits, 1); 16 | } 17 | -------------------------------------------------------------------------------- /sources/kinc/graphics5/sampler.c.h: -------------------------------------------------------------------------------- 1 | #include "sampler.h" 2 | 3 | void kinc_g5_sampler_options_set_defaults(kinc_g5_sampler_options_t *options) { 4 | options->u_addressing = KINC_G5_TEXTURE_ADDRESSING_CLAMP; 5 | options->v_addressing = KINC_G5_TEXTURE_ADDRESSING_CLAMP; 6 | options->w_addressing = KINC_G5_TEXTURE_ADDRESSING_CLAMP; 7 | 8 | options->magnification_filter = KINC_G5_TEXTURE_FILTER_POINT; 9 | options->minification_filter = KINC_G5_TEXTURE_FILTER_POINT; 10 | options->mipmap_filter = KINC_G5_MIPMAP_FILTER_POINT; 11 | 12 | options->lod_min_clamp = 0.0f; 13 | options->lod_max_clamp = 32.0f; 14 | 15 | options->is_comparison = false; 16 | options->compare_mode = KINC_G5_COMPARE_MODE_ALWAYS; 17 | 18 | options->max_anisotropy = 1; 19 | } 20 | -------------------------------------------------------------------------------- /sources/kinc/graphics5/texture.c.h: -------------------------------------------------------------------------------- 1 | #include "texture.h" 2 | 3 | /* 4 | Graphics5::Texture::Texture(Kore::Reader& reader, const char* format, bool readable) : Image(reader, format, readable) { 5 | _init(format, readable); 6 | } 7 | 8 | Graphics5::Texture::Texture(const char* filename, bool readable) { 9 | FileReader reader(filename); 10 | Image::init(reader, filename, readable); 11 | _init(filename, readable); 12 | } 13 | 14 | Graphics5::Texture::Texture(void* data, int size, const char* format, bool readable) { 15 | BufferReader reader(data, size); 16 | Image::init(reader, format, readable); 17 | _init(format, readable); 18 | } 19 | 20 | Graphics5::Texture::Texture(void* data, int width, int height, int format, bool readable) : Image(data, width, height, Image::Format(format), readable) { 21 | _init("", readable); 22 | } 23 | */ 24 | 25 | bool kinc_g5_texture_unit_equals(kinc_g5_texture_unit_t *unit1, kinc_g5_texture_unit_t *unit2) { 26 | for (int i = 0; i < KINC_G5_SHADER_TYPE_COUNT; ++i) { 27 | if (unit1->stages[i] != unit2->stages[i]) { 28 | return false; 29 | } 30 | } 31 | return true; 32 | } 33 | -------------------------------------------------------------------------------- /sources/kinc/graphics5/textureunit.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | /*! \file textureunit.h 9 | \brief Provides a texture-unit-struct which is used for setting textures in a shader. 10 | */ 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | typedef struct kinc_g5_texture_unit { 17 | int stages[KINC_G5_SHADER_TYPE_COUNT]; 18 | } kinc_g5_texture_unit_t; 19 | 20 | bool kinc_g5_texture_unit_equals(kinc_g5_texture_unit_t *unit1, kinc_g5_texture_unit_t *unit2); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | -------------------------------------------------------------------------------- /sources/kinc/graphics5/vertexstructure.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | /*! \file vertexstructure.h 8 | \brief Provides types for setting up the structure of vertices in a vertex-buffer. 9 | */ 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | typedef kinc_g4_vertex_data_t kinc_g5_vertex_data_t; 16 | 17 | // typedef kinc_g4_vertex_attribute_t kinc_g5_vertex_attribute_t; 18 | 19 | typedef kinc_g4_vertex_element_t kinc_g5_vertex_element_t; 20 | 21 | typedef kinc_g4_vertex_structure_t kinc_g5_vertex_structure_t; 22 | 23 | /// 24 | /// Initializes a vertex-structure. 25 | /// 26 | /// The structure to initialize 27 | /// 28 | static inline void kinc_g5_vertex_structure_init(kinc_g5_vertex_structure_t *structure) { 29 | kinc_g4_vertex_structure_init(structure); 30 | } 31 | 32 | /// 33 | /// Adds an element to a vertex-structure. 34 | /// 35 | /// The structure to add an element to 36 | /// The name to use for the new element 37 | /// The type of data to assign for the new element 38 | /// 39 | static inline void kinc_g5_vertex_structure_add(kinc_g5_vertex_structure_t *structure, const char *name, kinc_g5_vertex_data_t data) { 40 | kinc_g4_vertex_structure_add(structure, name, data); 41 | } 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | -------------------------------------------------------------------------------- /sources/kinc/input/acceleration.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | /*! \file acceleration.h 6 | \brief Provides data provided by acceleration-sensors. 7 | */ 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /// 14 | /// Sets the acceleration-callback which is called with measured acceleration-data in three dimensions. 15 | /// 16 | /// The callback 17 | void kinc_acceleration_set_callback(void (*value)(float /*x*/, float /*y*/, float /*z*/)); 18 | 19 | void kinc_internal_on_acceleration(float x, float y, float z); 20 | 21 | #ifdef KINC_IMPLEMENTATION_INPUT 22 | #define KINC_IMPLEMENTATION 23 | #endif 24 | 25 | #ifdef KINC_IMPLEMENTATION 26 | 27 | #include 28 | #include 29 | 30 | void (*acceleration_callback)(float /*x*/, float /*y*/, float /*z*/) = NULL; 31 | 32 | void kinc_acceleration_set_callback(void (*value)(float /*x*/, float /*y*/, float /*z*/)) { 33 | acceleration_callback = value; 34 | } 35 | 36 | void kinc_internal_on_acceleration(float x, float y, float z) { 37 | if (acceleration_callback != NULL) { 38 | acceleration_callback(x, y, z); 39 | } 40 | } 41 | 42 | #endif 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | -------------------------------------------------------------------------------- /sources/kinc/input/inputunit.c: -------------------------------------------------------------------------------- 1 | #define KINC_IMPLEMENTATION_INPUT 2 | 3 | #include "acceleration.h" 4 | #include "gamepad.h" 5 | #include "keyboard.h" 6 | #include "mouse.h" 7 | #include "pen.h" 8 | #include "rotation.h" 9 | #include "surface.h" 10 | -------------------------------------------------------------------------------- /sources/kinc/input/rotation.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | /*! \file rotation.h 6 | \brief Provides support for rotation-sensors. 7 | */ 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /// 14 | /// Sets the rotation-callback which is called when the device is rotated. Act quickly when this is called for a desktop-system. 15 | /// 16 | /// The callback 17 | void kinc_rotation_set_callback(void (*value)(float /*x*/, float /*y*/, float /*z*/)); 18 | 19 | void kinc_internal_on_rotation(float x, float y, float z); 20 | 21 | #ifdef KINC_IMPLEMENTATION_INPUT 22 | #define KINC_IMPLEMENTATION 23 | #endif 24 | 25 | #ifdef KINC_IMPLEMENTATION 26 | 27 | #include 28 | #include 29 | 30 | static void (*rotation_callback)(float /*x*/, float /*y*/, float /*z*/) = NULL; 31 | 32 | void kinc_rotation_set_callback(void (*value)(float /*x*/, float /*y*/, float /*z*/)) { 33 | rotation_callback = value; 34 | } 35 | 36 | void kinc_internal_on_rotation(float x, float y, float z) { 37 | if (rotation_callback != NULL) { 38 | rotation_callback(x, y, z); 39 | } 40 | } 41 | 42 | #endif 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | -------------------------------------------------------------------------------- /sources/kinc/io/iounit.c: -------------------------------------------------------------------------------- 1 | #define KINC_IMPLEMENTATION_IO 2 | 3 | #include "filereader.h" 4 | #include "filewriter.h" 5 | -------------------------------------------------------------------------------- /sources/kinc/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2024 the Kinc Development Team 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 19 | 3. This notice may not be removed or altered from any source distribution. 20 | -------------------------------------------------------------------------------- /sources/kinc/math/core.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | /*! \file core.h 6 | \brief Just a few very simple additions to math.h 7 | the C-lib. 8 | */ 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | #define KINC_PI 3.141592654 15 | #define KINC_TAU 6.283185307 16 | 17 | float kinc_cot(float x); 18 | float kinc_round(float value); 19 | float kinc_abs(float value); 20 | float kinc_min(float a, float b); 21 | float kinc_max(float a, float b); 22 | int kinc_mini(int a, int b); 23 | int kinc_maxi(int a, int b); 24 | float kinc_clamp(float value, float minValue, float maxValue); 25 | 26 | #ifdef KINC_IMPLEMENTATION_MATH 27 | #define KINC_IMPLEMENTATION 28 | #endif 29 | 30 | #ifdef KINC_IMPLEMENTATION 31 | 32 | #include 33 | 34 | float kinc_cot(float x) { 35 | return cosf(x) / sinf(x); 36 | } 37 | 38 | float kinc_round(float value) { 39 | return floorf(value + 0.5f); 40 | } 41 | 42 | float kinc_abs(float value) { 43 | return value < 0 ? -value : value; 44 | } 45 | 46 | float kinc_min(float a, float b) { 47 | return a > b ? b : a; 48 | } 49 | 50 | float kinc_max(float a, float b) { 51 | return a > b ? a : b; 52 | } 53 | 54 | int kinc_mini(int a, int b) { 55 | return a > b ? b : a; 56 | } 57 | 58 | int kinc_maxi(int a, int b) { 59 | return a > b ? a : b; 60 | } 61 | 62 | float kinc_clamp(float value, float minValue, float maxValue) { 63 | return kinc_max(minValue, kinc_min(maxValue, value)); 64 | } 65 | 66 | #endif 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | -------------------------------------------------------------------------------- /sources/kinc/math/mathunit.c: -------------------------------------------------------------------------------- 1 | #define KINC_IMPLEMENTATION_MATH 2 | 3 | #include "core.h" 4 | #include "matrix.h" 5 | #include "random.h" 6 | -------------------------------------------------------------------------------- /sources/kinc/math/quaternion.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core.h" 4 | 5 | /*! \file quaternion.h 6 | \brief Provides a basic quaternion type. 7 | */ 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | typedef struct kinc_quaternion { 14 | float x; 15 | float y; 16 | float z; 17 | float w; 18 | } kinc_quaternion_t; 19 | 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | -------------------------------------------------------------------------------- /sources/kinc/math/vector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core.h" 4 | 5 | /*! \file vector.h 6 | \brief Provides basic vector types. 7 | */ 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | typedef struct kinc_vector2 { 14 | float x; 15 | float y; 16 | } kinc_vector2_t; 17 | 18 | typedef struct kinc_vector3 { 19 | float x; 20 | float y; 21 | float z; 22 | } kinc_vector3_t; 23 | 24 | typedef struct kinc_vector4 { 25 | float x; 26 | float y; 27 | float z; 28 | float w; 29 | } kinc_vector4_t; 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | -------------------------------------------------------------------------------- /sources/kinc/network/http.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | /*! \file http.h 8 | \brief Provides a simple http-API. 9 | */ 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #define KINC_HTTP_GET 0 16 | #define KINC_HTTP_POST 1 17 | #define KINC_HTTP_PUT 2 18 | #define KINC_HTTP_DELETE 3 19 | 20 | typedef void (*kinc_http_callback_t)(int error, int response, const char *body, void *callbackdata); 21 | 22 | /// 23 | /// Fires off an http request. 24 | /// 25 | void kinc_http_request(const char *url, const char *path, const char *data, int port, bool secure, int method, const char *header, 26 | kinc_http_callback_t callback, void *callbackdata); 27 | 28 | #ifdef KINC_IMPLEMENTATION_NETWORK 29 | #define KINC_IMPLEMENTATION 30 | #endif 31 | 32 | #ifdef KINC_IMPLEMENTATION 33 | 34 | #if !defined KINC_MACOS && !defined KINC_IOS && !defined KINC_WINDOWS 35 | 36 | #include 37 | 38 | void kinc_http_request(const char *url, const char *path, const char *data, int port, bool secure, int method, const char *header, 39 | kinc_http_callback_t callback, void *callbackdata) { 40 | assert(false); // not implemented for the current system, please send a pull-request 41 | } 42 | 43 | #endif 44 | 45 | #endif 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | -------------------------------------------------------------------------------- /sources/kinc/network/networkunit.c: -------------------------------------------------------------------------------- 1 | #define KINC_IMPLEMENTATION_NETWORK 2 | 3 | #include "http.h" 4 | #include "socket.h" 5 | -------------------------------------------------------------------------------- /sources/kinc/readme.md: -------------------------------------------------------------------------------- 1 | Mini-Kinc based on revision 370f433110c7341ecbc319537493c72375662fb5. 2 | Do not modify, create a pull-request at https://github.com/Kode/Kinc instead. 3 | -------------------------------------------------------------------------------- /sources/kinc/rootunit.c: -------------------------------------------------------------------------------- 1 | #define KINC_IMPLEMENTATION_ROOT 2 | 3 | #include "color.h" 4 | #include "error.h" 5 | #include "log.h" 6 | 7 | #include "image.h" 8 | #include "memory.h" 9 | #include "string.h" 10 | #include "system.h" 11 | #include "window.h" 12 | 13 | bool kinc_debugger_attached(void) { 14 | return false; 15 | } 16 | -------------------------------------------------------------------------------- /sources/kinc/threads/atomic.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | /*! \file atomic.h 8 | \brief Provides atomics aka interlocked operations. 9 | */ 10 | -------------------------------------------------------------------------------- /sources/kinc/threads/fiber.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | /*! \file fiber.h 8 | \brief The fiber-API is experimental and only supported on a few system. 9 | */ 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | typedef struct kinc_fiber { 16 | kinc_fiber_impl_t impl; 17 | } kinc_fiber_t; 18 | 19 | /// 20 | /// Uses the current thread as a fiber. 21 | /// 22 | /// The fiber-object to initialize using the current thread 23 | void kinc_fiber_init_current_thread(kinc_fiber_t *fiber); 24 | 25 | /// 26 | /// Initializes a fiber. 27 | /// 28 | /// The fiber-object to initialize 29 | /// The function to be run in the fiber-context 30 | /// A parameter to be provided to the fiber-function when it starts running 31 | void kinc_fiber_init(kinc_fiber_t *fiber, void (*func)(void *param), void *param); 32 | 33 | /// 34 | /// Destroys a fiber. 35 | /// 36 | /// The fiber to destroy 37 | void kinc_fiber_destroy(kinc_fiber_t *fiber); 38 | 39 | /// 40 | /// Switch the current thread to a different fiber. 41 | /// 42 | /// The fiber to switch to 43 | void kinc_fiber_switch(kinc_fiber_t *fiber); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | -------------------------------------------------------------------------------- /sources/kinc/threads/threadlocal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | /*! \file threadlocal.h 8 | \brief Provides storage-slots for thread-specific data. 9 | */ 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | typedef struct kinc_thread_local { 16 | kinc_thread_local_impl_t impl; 17 | } kinc_thread_local_t; 18 | 19 | /// 20 | /// Initializes a thread-specific storage-slot. 21 | /// 22 | /// The storage-slot to initialize 23 | void kinc_thread_local_init(kinc_thread_local_t *local); 24 | 25 | /// 26 | /// Destroys a storage-slot. 27 | /// 28 | /// The storage-slot to destroy 29 | void kinc_thread_local_destroy(kinc_thread_local_t *local); 30 | 31 | /// 32 | /// Gets the data in the storage-slot. 33 | /// 34 | /// The slot to query 35 | void *kinc_thread_local_get(kinc_thread_local_t *local); 36 | 37 | /// 38 | /// Sets the data in the storage-slot. 39 | /// 40 | /// The slot to put the data into 41 | /// The data to put in the slot 42 | void kinc_thread_local_set(kinc_thread_local_t *local, void *data); 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | -------------------------------------------------------------------------------- /sources/libs/dir.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | typedef struct directory { 6 | void *handle; 7 | } directory; 8 | 9 | typedef struct file { 10 | bool valid; 11 | char name[256]; 12 | } file; 13 | 14 | directory open_dir(const char *dirname); 15 | file read_next_file(directory *dir); 16 | void close_dir(directory *dir); 17 | -------------------------------------------------------------------------------- /sources/libs/gc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // gc - A simple mark and sweep garbage collector for C. 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | void _gc_start(void *bos); 10 | size_t _gc_stop(); 11 | void _gc_pause(); 12 | void _gc_resume(); 13 | size_t _gc_run(); 14 | void *_gc_calloc(size_t count, size_t size); 15 | void _gc_array(void *ptr, int *length); 16 | void _gc_leaf(void *ptr); 17 | void _gc_root(void *ptr); 18 | void _gc_unroot(void *ptr); 19 | void *_gc_cut(void *ptr, size_t pos, size_t size); 20 | void *_gc_realloc(void *ptr, size_t size); 21 | void _gc_free(void *ptr); 22 | -------------------------------------------------------------------------------- /sources/libs/miniClib/assert.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef NDEBUG 4 | #define assert(condition) 5 | #else 6 | static void assert(int condition) {} 7 | #endif 8 | -------------------------------------------------------------------------------- /sources/libs/miniClib/errno.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define errno 0 4 | -------------------------------------------------------------------------------- /sources/libs/miniClib/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2024 the Kinc Development Team 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 19 | 3. This notice may not be removed or altered from any source distribution. 20 | -------------------------------------------------------------------------------- /sources/libs/miniClib/math.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | double ldexp(double x, int exp); 8 | 9 | double pow(double base, double exponent); 10 | 11 | double floor(double x); 12 | 13 | float floorf(float x); 14 | 15 | double sin(double x); 16 | 17 | float sinf(float x); 18 | 19 | double cos(double x); 20 | 21 | float cosf(float x); 22 | 23 | double tan(double x); 24 | 25 | float tanf(float x); 26 | 27 | double log(double x); 28 | 29 | double exp(double x); 30 | 31 | double sqrt(double x); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | -------------------------------------------------------------------------------- /sources/libs/miniClib/memory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | #include 8 | 9 | #ifdef __cplusplus 10 | } 11 | #endif 12 | -------------------------------------------------------------------------------- /sources/libs/miniClib/stdbool.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __cplusplus 4 | typedef _Bool bool; 5 | #define true 1 6 | #define false 0 7 | #endif 8 | -------------------------------------------------------------------------------- /sources/libs/miniClib/stdio.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #define SEEK_SET 0 11 | #define SEEK_END 1 12 | 13 | typedef int FILE; 14 | 15 | extern FILE *stdout, *stderr; 16 | 17 | int fprintf(FILE *stream, const char *format, ...); 18 | 19 | int vsnprintf(char *s, size_t n, const char *format, va_list arg); 20 | 21 | size_t fwrite(const void *ptr, size_t size, size_t count, FILE *stream); 22 | 23 | FILE *fopen(const char *filename, const char *mode); 24 | 25 | int fclose(FILE *stream); 26 | 27 | long int ftell(FILE *stream); 28 | 29 | int fseek(FILE *stream, long int offset, int origin); 30 | 31 | size_t fread(void *ptr, size_t size, size_t count, FILE *stream); 32 | 33 | int fputs(const char *str, FILE *stream); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | -------------------------------------------------------------------------------- /sources/libs/miniClib/stdlib.c: -------------------------------------------------------------------------------- 1 | #include "stdlib.h" 2 | 3 | void exit(int code) { 4 | exit(code); 5 | } 6 | 7 | long int strtol(const char *str, char **endptr, int base) { 8 | return 0; 9 | } 10 | 11 | int abs(int n) { 12 | return n < 0 ? -n : n; 13 | } 14 | 15 | long long int llabs(long long int n) { 16 | return n < 0 ? -n : n; 17 | } 18 | 19 | void qsort(void *base, size_t num, size_t size, int (*compar)(const void*,const void*)) { 20 | 21 | } 22 | -------------------------------------------------------------------------------- /sources/libs/miniClib/stdlib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef unsigned long size_t; 10 | #define EXIT_FAILURE 1 11 | 12 | void *malloc(size_t size); 13 | 14 | void *alloca(size_t size); 15 | 16 | void *realloc(void *mem, size_t size); 17 | 18 | void free(void *mem); 19 | 20 | void exit(int code); 21 | 22 | long int strtol(const char *str, char **endptr, int base); 23 | 24 | int abs(int n); 25 | 26 | long long int llabs(long long int n); 27 | 28 | void qsort(void *base, size_t num, size_t size, int (*compar)(const void *, const void *)); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /sources/libs/miniClib/string.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | void *memset(void *ptr, int value, size_t num); 10 | 11 | void *memcpy(void *destination, const void *source, size_t num); 12 | 13 | int memcmp(const void *ptr1, const void *ptr2, size_t num); 14 | 15 | size_t strlen(const char *str); 16 | 17 | char *strcpy(char *destination, const char *source); 18 | 19 | char *strncpy(char *destination, const char *source, size_t num); 20 | 21 | char *strcat(char *destination, const char *source); 22 | 23 | // built-in in Clang 24 | char *strstr(const char *str1, const char *str2); 25 | 26 | int strcmp(const char *str1, const char *str2); 27 | 28 | int strncmp(const char *str1, const char *str2, size_t num); 29 | 30 | size_t wcslen(const wchar_t *str); 31 | 32 | wchar_t *wcscpy(wchar_t *destination, const wchar_t *source); 33 | 34 | wchar_t *wcsncpy(wchar_t *destination, const wchar_t *source, size_t num); 35 | 36 | wchar_t *wcscat(wchar_t *destination, const wchar_t *source); 37 | 38 | wchar_t *wcsstr(wchar_t *str1, const wchar_t *str2); 39 | 40 | int wcscmp(const wchar_t *str1, const wchar_t *str2); 41 | 42 | int wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t num); 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | -------------------------------------------------------------------------------- /sources/libs/miniClib/time.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | #include 8 | 9 | #ifdef __cplusplus 10 | } 11 | #endif 12 | -------------------------------------------------------------------------------- /sources/libs/nfd/LICENSE: -------------------------------------------------------------------------------- 1 | This software is provided 'as-is', without any express or implied 2 | warranty. In no event will the authors be held liable for any damages 3 | arising from the use of this software. 4 | 5 | Permission is granted to anyone to use this software for any purpose, 6 | including commercial applications, and to alter it and redistribute it 7 | freely, subject to the following restrictions: 8 | 9 | 1. The origin of this software must not be misrepresented; you must not 10 | claim that you wrote the original software. If you use this software 11 | in a product, an acknowledgment in the product documentation would be 12 | appreciated but is not required. 13 | 2. Altered source versions must be plainly marked as such, and must not be 14 | misrepresented as being the original software. 15 | 3. This notice may not be removed or altered from any source distribution. 16 | 17 | -------------------------------------------------------------------------------- /sources/libs/nfd/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Native File Dialog 3 | 4 | Internal, common across platforms 5 | 6 | http://www.frogtoss.com/labs 7 | */ 8 | 9 | 10 | #ifndef _NFD_COMMON_H 11 | #define _NFD_COMMON_H 12 | 13 | #define NFD_MAX_STRLEN 256 14 | #define _NFD_UNUSED(x) ((void)x) 15 | 16 | void *NFDi_Malloc( size_t bytes ); 17 | void NFDi_Free( void *ptr ); 18 | void NFDi_SetError( const char *msg ); 19 | void NFDi_SafeStrncpy( char *dst, const char *src, size_t maxCopy ); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /sources/libs/nfd/nfd_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Native File Dialog 3 | 4 | Internal, common across platforms 5 | 6 | http://www.frogtoss.com/labs 7 | */ 8 | 9 | 10 | #ifndef _NFD_COMMON_H 11 | #define _NFD_COMMON_H 12 | 13 | #include "nfd.h" 14 | 15 | #include 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #define NFD_MAX_STRLEN 256 22 | #define _NFD_UNUSED(x) ((void)x) 23 | 24 | #define NFD_UTF8_BOM "\xEF\xBB\xBF" 25 | 26 | 27 | void *NFDi_Malloc( size_t bytes ); 28 | void NFDi_Free( void *ptr ); 29 | void NFDi_SetError( const char *msg ); 30 | int NFDi_SafeStrncpy( char *dst, const char *src, size_t maxCopy ); 31 | int32_t NFDi_UTF8_Strlen( const nfdchar_t *str ); 32 | int NFDi_IsFilterSegmentChar( char ch ); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /sources/libs/quickjs/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017-2021 Fabrice Bellard 4 | Copyright (c) 2017-2021 Charlie Gordon 5 | Copyright (c) 2023 Ben Noordhuis 6 | Copyright (c) 2023 Saúl Ibarra Corretgé 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | -------------------------------------------------------------------------------- /sources/libs/quickjs/VERSION: -------------------------------------------------------------------------------- 1 | a9594573092ce1543b2776b6d1766275989291c0 2 | https://github.com/quickjs-ng/quickjs 3 | -------------------------------------------------------------------------------- /sources/ts/audio.ts: -------------------------------------------------------------------------------- 1 | 2 | ///if arm_audio 3 | 4 | function audio_play(sound: sound_t, loop: bool = false, pitch: f32 = 1.0, unique: bool = false): audio_channel_t { 5 | return iron_play_sound(sound.sound_, loop, pitch, unique); 6 | } 7 | 8 | function audio_stop(sound: sound_t) { 9 | iron_stop_sound(sound.sound_); 10 | } 11 | 12 | ///end 13 | -------------------------------------------------------------------------------- /sources/ts/camera_data.ts: -------------------------------------------------------------------------------- 1 | 2 | function camera_data_parse(name: string, id: string): camera_data_t { 3 | let format: scene_t = data_get_scene_raw(name); 4 | let raw: camera_data_t = camera_data_get_raw_by_name(format.camera_datas, id); 5 | if (raw == null) { 6 | iron_log("Camera data '" + id + "' not found!"); 7 | } 8 | return raw; 9 | } 10 | 11 | function camera_data_get_raw_by_name(datas: camera_data_t[], name: string): camera_data_t { 12 | if (name == "") { 13 | return datas[0]; 14 | } 15 | for (let i: i32 = 0; i < datas.length; ++i) { 16 | if (datas[i].name == name) { 17 | return datas[i]; 18 | } 19 | } 20 | return null; 21 | } 22 | -------------------------------------------------------------------------------- /sources/ts/light_data.ts: -------------------------------------------------------------------------------- 1 | 2 | function light_data_parse(name: string, id: string): light_data_t { 3 | let format: scene_t = data_get_scene_raw(name); 4 | let raw: light_data_t = light_data_get_raw_by_name(format.light_datas, id); 5 | if (raw == null) { 6 | iron_log("Light data '" + id + "' not found!"); 7 | } 8 | return raw; 9 | } 10 | 11 | function light_data_get_raw_by_name(datas: light_data_t[], name: string): light_data_t { 12 | if (name == "") { 13 | return datas[0]; 14 | } 15 | for (let i: i32 = 0; i < datas.length; ++i) { 16 | if (datas[i].name == name) { 17 | return datas[i]; 18 | } 19 | } 20 | return null; 21 | } 22 | -------------------------------------------------------------------------------- /sources/ts/light_object.ts: -------------------------------------------------------------------------------- 1 | 2 | type light_object_t = { 3 | base?: object_t; 4 | data?: light_data_t; 5 | v?: mat4_t; 6 | }; 7 | 8 | function light_object_create(data: light_data_t): light_object_t { 9 | let raw: light_object_t = {}; 10 | raw.v = mat4_identity(); 11 | raw.base = object_create(false); 12 | raw.base.ext = raw; 13 | raw.base.ext_type = "light_object_t"; 14 | raw.data = data; 15 | 16 | array_push(scene_lights, raw); 17 | return raw; 18 | } 19 | 20 | function light_object_remove(raw: light_object_t) { 21 | array_remove(scene_lights, raw); 22 | if (_render_path_light == raw) { 23 | _render_path_light = null; 24 | } 25 | 26 | object_remove_super(raw.base); 27 | } 28 | 29 | function light_object_build_mat(raw: light_object_t, camera: camera_object_t) { 30 | transform_build_matrix(raw.base.transform); 31 | } 32 | 33 | function light_object_right(raw: light_object_t): vec4_t { 34 | return vec4_create(raw.v.m00, raw.v.m10, raw.v.m20); 35 | } 36 | 37 | function light_object_up(raw: light_object_t): vec4_t { 38 | return vec4_create(raw.v.m01, raw.v.m11, raw.v.m21); 39 | } 40 | 41 | function light_object_look(raw: light_object_t): vec4_t { 42 | return vec4_create(raw.v.m02, raw.v.m12, raw.v.m22); 43 | } 44 | -------------------------------------------------------------------------------- /sources/ts/particle_data.ts: -------------------------------------------------------------------------------- 1 | 2 | function particle_data_parse(name: string, id: string): particle_data_t { 3 | let format: scene_t = data_get_scene_raw(name); 4 | let raw: particle_data_t = particle_data_get_raw_by_name(format.particle_datas, id); 5 | if (raw == null) { 6 | iron_log("Particle data '" + id + "' not found!"); 7 | } 8 | return raw; 9 | } 10 | 11 | function particle_data_get_raw_by_name(datas: particle_data_t[], name: string): particle_data_t { 12 | if (name == "") { 13 | return datas[0]; 14 | } 15 | for (let i: i32 = 0; i < datas.length; ++i) { 16 | if (datas[i].name == name) { 17 | return datas[i]; 18 | } 19 | } 20 | return null; 21 | } 22 | -------------------------------------------------------------------------------- /sources/ts/time.ts: -------------------------------------------------------------------------------- 1 | 2 | let _time_last: f32 = 0.0; 3 | let _time_real_delta: f32 = 0.0; 4 | let _time_frequency: i32 = -1; 5 | 6 | function time_delta(): f32 { 7 | if (_time_frequency < 0) { 8 | _time_frequency = sys_display_frequency(); 9 | } 10 | return (1 / _time_frequency); 11 | } 12 | 13 | function time_real_delta(): f32 { 14 | return _time_real_delta; 15 | } 16 | 17 | function time_time(): f32 { 18 | return sys_time(); 19 | } 20 | 21 | function time_update() { 22 | _time_real_delta = time_time() - _time_last; 23 | _time_last = time_time(); 24 | } 25 | -------------------------------------------------------------------------------- /tools/amake/alang.md: -------------------------------------------------------------------------------- 1 | # alang 2 | 3 | alang is a TypeScript to C transpiler. A small subset of TypeScript is supported which maps well with C in order to achieve the best performance. 4 | 5 | ```ts 6 | // TS 7 | type point_t = { 8 | x: f32; 9 | y: f32; 10 | }; 11 | 12 | function add(a: point_t, b: point_t) { 13 | a.x += b.x; 14 | a.y += b.y; 15 | } 16 | 17 | function main() { 18 | let a: point_t = { x: 1.0, y: 2.0 }; 19 | let b: point_t = { x: 3.0, y: 4.0 }; 20 | add(a, b); 21 | } 22 | ``` 23 | 24 | ```c 25 | // C 26 | #include 27 | 28 | typedef struct point { 29 | f32 x; 30 | f32 y; 31 | } point_t; 32 | 33 | void add(point_t *a, point_t *b) { 34 | a->x += b->x; 35 | a->y += b->y; 36 | } 37 | 38 | void main() { 39 | point_t *a = GC_ALLOC_INIT(point_t, { x: 1.0, y: 2.0 }); 40 | point_t *b = GC_ALLOC_INIT(point_t, { x: 3.0, y: 4.0 }); 41 | add(a, b); 42 | } 43 | ``` 44 | -------------------------------------------------------------------------------- /tools/bin/linux_arm64/keepme: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armorcore/8b04fdf059977d422e57256a496caefc6291d944/tools/bin/linux_arm64/keepme -------------------------------------------------------------------------------- /tools/bin/linux_x64/amake: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armorcore/8b04fdf059977d422e57256a496caefc6291d944/tools/bin/linux_x64/amake -------------------------------------------------------------------------------- /tools/bin/macos/amake: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armorcore/8b04fdf059977d422e57256a496caefc6291d944/tools/bin/macos/amake -------------------------------------------------------------------------------- /tools/bin/windows_x64/amake.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armorcore/8b04fdf059977d422e57256a496caefc6291d944/tools/bin/windows_x64/amake.exe -------------------------------------------------------------------------------- /tools/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armorcore/8b04fdf059977d422e57256a496caefc6291d944/tools/icon.png -------------------------------------------------------------------------------- /tools/platform.sh: -------------------------------------------------------------------------------- 1 | if [[ "$OSTYPE" == "linux-gnu"* ]]; then 2 | MACHINE_TYPE=`uname -m` 3 | if [[ "$MACHINE_TYPE" == "aarch64"* ]]; then 4 | KINC_PLATFORM=linux_arm64 5 | elif [[ "$MACHINE_TYPE" == "x86_64"* ]]; then 6 | KINC_PLATFORM=linux_x64 7 | fi 8 | elif [[ "$OSTYPE" == "darwin"* ]]; then 9 | KINC_PLATFORM=macos 10 | fi 11 | -------------------------------------------------------------------------------- /tools/tcc/VERSION: -------------------------------------------------------------------------------- 1 | 0.9.27 2 | -------------------------------------------------------------------------------- /tools/tcc/include/float.h: -------------------------------------------------------------------------------- 1 | #ifndef _FLOAT_H_ 2 | #define _FLOAT_H_ 3 | 4 | #define FLT_RADIX 2 5 | 6 | /* IEEE float */ 7 | #define FLT_MANT_DIG 24 8 | #define FLT_DIG 6 9 | #define FLT_ROUNDS 1 10 | #define FLT_EPSILON 1.19209290e-07F 11 | #define FLT_MIN_EXP (-125) 12 | #define FLT_MIN 1.17549435e-38F 13 | #define FLT_MIN_10_EXP (-37) 14 | #define FLT_MAX_EXP 128 15 | #define FLT_MAX 3.40282347e+38F 16 | #define FLT_MAX_10_EXP 38 17 | 18 | /* IEEE double */ 19 | #define DBL_MANT_DIG 53 20 | #define DBL_DIG 15 21 | #define DBL_EPSILON 2.2204460492503131e-16 22 | #define DBL_MIN_EXP (-1021) 23 | #define DBL_MIN 2.2250738585072014e-308 24 | #define DBL_MIN_10_EXP (-307) 25 | #define DBL_MAX_EXP 1024 26 | #define DBL_MAX 1.7976931348623157e+308 27 | #define DBL_MAX_10_EXP 308 28 | 29 | /* horrible intel long double */ 30 | #if defined __i386__ || defined __x86_64__ 31 | 32 | #define LDBL_MANT_DIG 64 33 | #define LDBL_DIG 18 34 | #define LDBL_EPSILON 1.08420217248550443401e-19L 35 | #define LDBL_MIN_EXP (-16381) 36 | #define LDBL_MIN 3.36210314311209350626e-4932L 37 | #define LDBL_MIN_10_EXP (-4931) 38 | #define LDBL_MAX_EXP 16384 39 | #define LDBL_MAX 1.18973149535723176502e+4932L 40 | #define LDBL_MAX_10_EXP 4932 41 | 42 | #else 43 | 44 | /* same as IEEE double */ 45 | #define LDBL_MANT_DIG 53 46 | #define LDBL_DIG 15 47 | #define LDBL_EPSILON 2.2204460492503131e-16 48 | #define LDBL_MIN_EXP (-1021) 49 | #define LDBL_MIN 2.2250738585072014e-308 50 | #define LDBL_MIN_10_EXP (-307) 51 | #define LDBL_MAX_EXP 1024 52 | #define LDBL_MAX 1.7976931348623157e+308 53 | #define LDBL_MAX_10_EXP 308 54 | 55 | #endif 56 | 57 | #endif /* _FLOAT_H_ */ 58 | -------------------------------------------------------------------------------- /tools/tcc/include/stdbool.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDBOOL_H 2 | #define _STDBOOL_H 3 | 4 | /* ISOC99 boolean */ 5 | 6 | #define bool _Bool 7 | #define true 1 8 | #define false 0 9 | #define __bool_true_false_are_defined 1 10 | 11 | #endif /* _STDBOOL_H */ 12 | -------------------------------------------------------------------------------- /tools/tcc/include/varargs.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | #ifndef _VARARGS_H 7 | #define _VARARGS_H 8 | 9 | #error "TinyCC no longer implements ." 10 | #error "Revise your code to use ." 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /tools/tcc/libtcc1.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armorcore/8b04fdf059977d422e57256a496caefc6291d944/tools/tcc/libtcc1.a -------------------------------------------------------------------------------- /tools/tcc/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | printf("Hello World\n"); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /tools/tcc/make.sh: -------------------------------------------------------------------------------- 1 | ./tcc -o myprog main.c -I'./' -I'./include' -B'./' -------------------------------------------------------------------------------- /tools/tcc/tcc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armorcore/8b04fdf059977d422e57256a496caefc6291d944/tools/tcc/tcc -------------------------------------------------------------------------------- /tools/tests/cube/assets/cube.arm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armorcore/8b04fdf059977d422e57256a496caefc6291d944/tools/tests/cube/assets/cube.arm -------------------------------------------------------------------------------- /tools/tests/cube/assets/texture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armory3d/armorcore/8b04fdf059977d422e57256a496caefc6291d944/tools/tests/cube/assets/texture.png -------------------------------------------------------------------------------- /tools/tests/cube/project.js: -------------------------------------------------------------------------------- 1 | 2 | let flags = globalThis.flags; 3 | flags.with_iron = true; 4 | 5 | let project = new Project("Test"); 6 | project.add_project("../../../"); 7 | project.add_tsfiles("sources"); 8 | project.add_shaders("shaders/*.glsl"); 9 | project.add_shaders("../../../shaders/*.glsl"); 10 | project.add_assets("assets/*", { destination: "data/{name}" }); 11 | 12 | return project; 13 | -------------------------------------------------------------------------------- /tools/tests/cube/shaders/mesh.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | in vec2 tex_coord; 4 | 5 | out vec4 frag_color; 6 | 7 | uniform sampler2D my_texture; 8 | 9 | void main() { 10 | frag_color = texture(my_texture, tex_coord); 11 | } 12 | -------------------------------------------------------------------------------- /tools/tests/cube/shaders/mesh.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | in vec4 pos; 4 | in vec2 tex; 5 | 6 | out vec2 tex_coord; 7 | 8 | uniform mat4 WVP; 9 | 10 | void main() { 11 | tex_coord = tex; 12 | gl_Position = WVP * vec4(pos.xyz, 1.0); 13 | } 14 | -------------------------------------------------------------------------------- /tools/tests/cube/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./build/tsconfig.json" 3 | } 4 | -------------------------------------------------------------------------------- /tools/tests/triangle/project.js: -------------------------------------------------------------------------------- 1 | 2 | let flags = globalThis.flags; 3 | flags.with_iron = true; 4 | 5 | let project = new Project("Test"); 6 | project.add_project("../../../"); 7 | project.add_tsfiles("./"); 8 | return project; 9 | -------------------------------------------------------------------------------- /tools/to_spirv/glslang/glslang/Include/revision.h: -------------------------------------------------------------------------------- 1 | // This header is generated by the make-revision script. 2 | 3 | #define GLSLANG_PATCH_LEVEL 3743 4 | -------------------------------------------------------------------------------- /tools/to_spirv/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 the krafix development team 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 19 | 3. This notice may not be removed or altered from any source distribution. 20 | -------------------------------------------------------------------------------- /tools/to_spirv/project.js: -------------------------------------------------------------------------------- 1 | let project = new Project("to_spirv"); 2 | 3 | project.add_define("KRAFIX_LIBRARY"); 4 | project.add_cfiles("to_spirv.cpp"); 5 | 6 | project.add_include_dir("glslang"); 7 | project.add_cfiles("glslang/**"); 8 | 9 | return project; 10 | -------------------------------------------------------------------------------- /tools/wasm/README.md: -------------------------------------------------------------------------------- 1 | 2 | **Wasm (Linux, macOS or WSL)** 3 | ```bash 4 | ../../make --target wasm --compile 5 | # Copy resulting armorcore.wasm file to build/out 6 | # Copy index.html to build/out 7 | # Copy https://github.com/armory3d/armorcore/tree/main/sources/backends/data/wasm/JS-Sources to build/out 8 | # Todo: 9 | # start.js has hard-coded .wasm file name: https://github.com/armory3d/armorcore/tree/main/sources/backends/data/wasm/JS-Sources/start.js#L48 10 | # memory.c has hard-coded size: https://github.com/armory3d/armorcore/tree/main/sources/libs/miniClib/memory.c#L6 11 | ``` 12 | -------------------------------------------------------------------------------- /tools/wasm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ArmorCore 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tools/wasm/project.js: -------------------------------------------------------------------------------- 1 | 2 | let flags = globalThis.flags; 3 | flags.name = "armorcore"; 4 | flags.package = "org.armorcore"; 5 | 6 | let project = new Project(flags.name); 7 | return project; 8 | --------------------------------------------------------------------------------