• S


    [...] because I think nobody dares to go first?

    That was exactly the case 😅

    To make up for that inconvenience I actually made a sample for you (I already added it to

    Great, I'll check it! — I didn't put anything about your reply in the other side, so you can act realistic with your reply to the first message 😉

    posted in Kode read more
  • S


    I'm trying to advance in my understanding of Kha cross-platform build system, basically to answer the question How to use native C/C++ code with Kha in Android and Linux?

    I'm aware of the existence of

    • haxebullet — but it only supports (JavaScript and) Hashlink, which isn't the main native target of Kha.
    • haxerecast — looks outdated, doesn't compile to Linux nor Android, at least from Linux.
    • share_kha — selected as the main example to create native library bindings for Kha in the wiki, but again it is outdated, it doesn't compile for Android (at least from Linux) and I would be much more interested in a cross-platform native library.

    Anything that should be working nowadays?

    posted in Kode read more
  • S

    @Robert it turns out it's already reported →

    Sorry for the noise 😁 .

    posted in Kode read more
  • S


    What target are you using?

    Krom on Linux, with latest Kha.

    You'd instead just call g.drawIndexedVertices(0, 6);

    That works! But, what if I want to change uniforms between the drawing of diferent objects with the same buffers? — just like in the Armory example, I'm still don't know why that works, if should, and why mine doesn't 😕 .

    posted in Kode read more
  • S


    From almost a year I've been playing with Armory, Iron and Kha, to try to understand how this amazing set of technologies work during my incursion in the incredible interesting game programming world — and now I'm stuck with something I don't understand.

    I'm trying to modify this example → — simply adding another triangle to both the vertices and indices arrays, to try to paint both of them setting the buffers only once (relevant modified lines are only the addition to vertices and indices and the lines above 107 Draw! commet):

    import kha.Framebuffer;
    import kha.Color;
    import kha.Shaders;
    import kha.graphics4.PipelineState;
    import kha.graphics4.VertexStructure;
    import kha.graphics4.VertexBuffer;
    import kha.graphics4.IndexBuffer;
    import kha.graphics4.FragmentShader;
    import kha.graphics4.VertexShader;
    import kha.graphics4.VertexData;
    import kha.graphics4.Usage;
    class Empty {
    	// An array of 3 vectors representing 3 vertices to form a triangle
    	static var vertices:Array<Float> = [
    	   -1.0, -1.0, 0.0, // Bottom-left
    	    1.0, -1.0, 0.0, // Bottom-right
    			0.0,  1.0, 0.0,  // Top
    			-1.0, 1.0, 0.0, // Bottom-left
    	    0.0, -1.0, -1.0, // Bottom-right
    	    0.0,  1.0, 0.0,  // Top
    	// Indices for our triangle, these will point to vertices above
    	static var indices:Array<Int> = [
    		0, // Bottom-left
    		1, // Bottom-right
    		2,  // Top
    		3, // Bottom-left
    		4, // Bottom-right
    		5,  // Top
    	var vertexBuffer:VertexBuffer;
    	var indexBuffer:IndexBuffer;
    	var pipeline:PipelineState;
    	public function new() {
    		// Define vertex structure
    		var structure = new VertexStructure();
            structure.add("pos", VertexData.Float3);
            // Save length - we only store position in vertices for now
            // Eventually there will be texture coords, normals,...
            var structureLength = 3;
    		// Compile pipeline state
    		// Shaders are located in 'Sources/Shaders' directory
            // and Kha includes them automatically
    		pipeline = new PipelineState();
    		pipeline.inputLayout = [structure];
    		pipeline.fragmentShader = Shaders.simple_frag;
    		pipeline.vertexShader = Shaders.simple_vert;
    		pipeline.colorAttachmentCount = 1;
    		pipeline.colorAttachments[0] = kha.graphics4.TextureFormat.RGBA32;
    		pipeline.depthStencilAttachment = kha.graphics4.DepthStencilFormat.Depth16;
    		// Create vertex buffer
    		vertexBuffer = new VertexBuffer( / 3), // Vertex count - 3 floats per vertex
    			structure, // Vertex structure
    			Usage.StaticUsage // Vertex data will stay the same
    		// Copy vertices to vertex buffer
    		var vbData = vertexBuffer.lock();
    		for (i in 0...vbData.length) {
    			vbData.set(i, vertices[i]);
    		// Create index buffer
    		indexBuffer = new IndexBuffer(
    			indices.length, // 3 indices for our triangle
    			Usage.StaticUsage // Index data will stay the same
    		// Copy indices to index buffer
    		var iData = indexBuffer.lock();
    		for (i in 0...iData.length) {
    			iData[i] = indices[i];
    	public function render(frames:Array<Framebuffer>) {
    		// A graphics object which lets us perform 3D operations
    		var g = frames[0].g4;
    		// Begin rendering
            // Clear screen to black
    		// Bind state we want to draw with
    		// Bind data we want to draw
    		// Draw!
    		g.drawIndexedVertices(0, 3);
    		g.drawIndexedVertices(3, 3);
    		// End rendering

    But if I don't discomment the setVertexBuffer line between the two drawIndexedVertices, only the first triangle gets painted — or I can choose to draw the second one if I comment the first drawIndexedVertices.

    So... what am I doing wrong? The thing tha makes it more strange to me, is that I can see this working fine, and I don't find the relevant differences 😅;L97 .

    Thanks a lot for your time 🙂

    posted in Kode read more