Authentication-Results: mail-b.sr.ht; dkim=fail header.d=eliasnaur.com header.i=@eliasnaur.com Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) by mail-b.sr.ht (Postfix) with ESMTPS id 6969BFF0D0 for <~eliasnaur/gio@lists.sr.ht>; Sun, 17 Jan 2021 09:30:26 +0000 (UTC) Received: by mail-ej1-f43.google.com with SMTP id l9so13768038ejx.3 for <~eliasnaur/gio@lists.sr.ht>; Sun, 17 Jan 2021 01:30:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eliasnaur.com; s=google; h=mime-version:content-transfer-encoding:date:message-id:from:to:cc :subject:references:in-reply-to; bh=hnK2ZGE5wiHuyIjMqjyEzPrrwCVw0SDsxdXx/Ocz3hk=; b=n+k5aeMNDyptMyfiGsdA9A31Zqtt8A5n/dMRXz77OYw9Rzc67fu90HzpkkOM4/sUM+ /ek+rViP4lR8pyo5bzpC47FiVxcgBMQxMxGroOpbW+0ic21ecVah3mAkNJVywkEiISyx ogITnmfbiahuJbV3sd7MFSIbu1vSIkBPUBMhgQMB952C6qP7XgQMYQ8SuMl6cjYSzNa/ BgmusrFIpQDpvlKV3Boi3L5dtgZOg9OQz1/L/XU5EpX3l7w0bg5up33GLEH7cP5TmF1N VLxbrQ0zgugxlVSUlMmUNpqST1g74azwYwDIR7a8UUAAi7oiSylQqUtDY5rTtUkGByTO rPnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:content-transfer-encoding:date :message-id:from:to:cc:subject:references:in-reply-to; bh=hnK2ZGE5wiHuyIjMqjyEzPrrwCVw0SDsxdXx/Ocz3hk=; b=kHBJrNR7gD7TIXBi5xUxkhVNZj2TrQzdMY7+C9nAHiOxX/Xx5ocW6HMNi50SMF2OZj fm4cngOvJYaqmoET2iUfwOtpNveKSFqgNNihbVg07Ygr1CCp9t+vklKBStvdAyln3TIj iz1F30iM9HSVvOjERddGMyEG8zsli5l+tPM/OoYCe/8XkSeV0o/eeSQ3xuZaYoo52h/Y HqRGkf1sRNdnzJ3uYPyfmWpA652TcJcsc5odtNaNNnB1OHJk2J1PEp+DBM3QV54C3FN6 CvPA5AQlq62Izbr+0cJCp4hUwPLlPRcsJqcfLNaFPyoOtwMaOUJ5zxck2Eiz12XImbEH 4dHQ== X-Gm-Message-State: AOAM532vvEfk2EFiNPdIxWPzGSKG1UhVpH7ZXdHt53+0/85HkAoM83ZK 2U33rgWk6XIfRoDyGFqCSAPbaw== X-Google-Smtp-Source: ABdhPJzxVXnp2bJxjZmjdP9jMPUrwBJIzTtpuOVIATqm0IOQFUmFn93WSBpFh8b6sJRBzOct+/xFew== X-Received: by 2002:a17:906:4d8f:: with SMTP id s15mr10245785eju.389.1610875825393; Sun, 17 Jan 2021 01:30:25 -0800 (PST) Received: from localhost ([145.255.60.245]) by smtp.gmail.com with ESMTPSA id j23sm9153913edv.45.2021.01.17.01.30.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 17 Jan 2021 01:30:24 -0800 (PST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Sun, 17 Jan 2021 10:30:23 +0100 Message-Id: From: "Elias Naur" To: "Zhao Wang" , <~eliasnaur/gio@lists.sr.ht> Cc: Subject: Re: Injecting custom frame update to the flow? References: In-Reply-To: On Sun Jan 17, 2021 at 8:33 AM CET, Zhao Wang wrote: > Hi guys, > > I am trying to use gio to build a multi window chat client to have > main chat UI in one > window and run OpenGL ES game in another window which I hope to use Gio > Window as well as the event loop and frame updating mechanism. > > The game has its own "drawFrame" method which calls standard OpenGL ES > APIs. > And does not use gio widgets yet (might need to add some later). > I am wondering how I can inject the game's drawFrame into Gio window's > frame > update loop. > > I spent some time digging into the code, it looks to me current frame > drawing happens > in gio/gpu/GPU.Frame() method. So seems not possible without API > changes. > Is this true? If so, any advice on how to do this? > Is the game's OpenGL ES commands supposed to happen before, after, or in between Gio drawing commands? If before or after, I believe you can use the glfw example as inspiration. Specifically, use GLFW for the native window and OpenGL context, and let both the game and Gio use the same context. In the glfw example you can also see how the main program forwards mouse/keyboard input to Gio. That's where you can route input to the game as well. A more portable variant is to use an OpenGL context for the game and a separate context for Gio. If you bind a FBO with a texture target before calling Gio's Frame, you can use the resulting texture to draw on top of the game. This works because you can set up contexts so they share resources (textures etc.) without sharing state. If you haven't already considered it, I'd like to mention https://github.com/ocornut/imgui. Imgui is immediate mode like Gio, designed to be embedded, and used by many game studios for their GUI. These are all high-level ideas. You'll probably hit various issues on your way, all of which we're happy to help resolve. Portability is an important Gio feature, and your embedding use case is an important kind of portability. Elias