Kha SDK

repository·main·Indexed 23 days ago

https://github.com/kode/kha

A low-level SDK for building portable games and media applications using the Haxe programming language. Kha features a generational API design for graphics and audio, supports hardware-accelerated 2D and 3D graphics, and utilizes the krafix shader-compiler for cross-compilation. It supports a wide range of platforms including Web (HTML5, Node.js), Desktop (Windows, Linux, macOS, FreeBSD), Mobile (Android, iOS, tvOS), and various consoles.

Tokens
827
Snippets
3
Records
7
Agent score
82%

What's inside Kha

  1. Overview of Kha SDK

    main

    Kha is a low-level SDK designed for building games and media applications in a portable manner. It is built on the Haxe programming language and utilizes the krafix shader-compiler to cross-compile code and optimize assets for a wide variety of systems.

    Key characteristics include:

    • Generational API Design: Provides a generational approach to graphics and audio APIs to maximize performance on each target.
    • High Performance: Supports hardware-accelerated 2D and high-end 3D graphics, with fallback support (e.g., HTML5 canvas).
    • Portability: Can run on top of other game engines (like Unity3D) and can be compiled into C# or Java libraries.
    • Shader Cross-Compilation: Allows writing shaders in GLSL which are then cross-compiled for specific targets.
  2. Install hxnodejs

    main

    You can install hxnodejs using Haxelib. Use the released version via the standard install command, or use the GitHub URL to get the latest version.

    • Released version: haxelib install hxnodejs
    • Latest from GitHub: haxelib git hxnodejs https://github.com/HaxeFoundation/hxnodejs
    haxelib install hxnodejs
  3. Compile Haxe code for Node.JS

    main

    To compile Haxe code that uses hxnodejs into a JavaScript file compatible with Node.JS, use the haxe compiler with the -lib hxnodejs flag.

    It is recommended to add the -D js-es=6 flag to produce cleaner JavaScript output, as Node.JS is ES6-compliant.

  4. Install and compile zlib on Unix-like systems

    main

    To compile the zlib library and run the included test programs on most Unix-like systems, use the following sequence of commands:

    1. Run the configuration script: ./configure
    2. Compile and run tests: make test
    3. Install the library: make install (only if the tests pass)
    ./configure
    make test
    make install
  5. Quick example: Create an Echo server

    main

    This example demonstrates how to use the js.node.Net module to create a simple TCP echo server in Haxe.

    class Main {
        static function main() {
            var server = js.node.Net.createServer(function(socket) {
                socket.write("Echo server\n\n");
                socket.pipe(socket);
            });
            server.listen(1337, "127.0.0.1");
        }
    }
  6. Supported platforms for Kha

    main

    Kha supports a vast array of platforms, ranging from web and desktop to mobile and consoles:

    • Web: HTML5 (WebGL 2, WebGL, canvas, or WebWorker), Node.js (for server versions).
    • Desktop: Windows (Direct3D 12, 11, 9, Vulkan, or OpenGL), Linux (Vulkan or OpenGL), macOS (Metal or OpenGL), FreeBSD.
    • Mobile: Android (Vulkan or OpenGL), iOS (Metal or OpenGL), tvOS.
    • Embedded/Other: Raspberry Pi, Universal Windows Platform (UWP), Java and AWT, C# and Windows Presentation Foundation (WPF).
    • Consoles: PlayStation 4, PlayStation 5, Xbox One, Xbox Series X|S, Nintendo Switch, and Nintendo Switch 2.

    Note: Console-specific code is not public. Access requires registration with Microsoft, Nintendo, or Sony and contacting the Kha team.