I’ve made an c++ app that uses offscreen rendering using GLFW and glad and then transfer back the data to CPU.
Now I want to do the same thing but on mobile. I wanted to know what are the main difficulties that I’m going to encounter and what are the easiest and best tools that I would need.
From what I read on the net, it will be a difficult challenge to get an offscreen glContext on android (I dont know if that’s the case for IOS too).
Also, I would like to know what tools do I need since I think glad wont work for ios and android.
What are the other challenges I need to expect?
You didn’t really give us much on what aspects of the solution are important to you. For instance, is performance (e.g. frame rate, latency, etc.) important, or do you just want to get it to work?
For the platform(s) you’re interested in, check support for rendering to: 1) Framebuffer Objects (FBOs), 2) P-buffers, and 3) Pixmaps. The first is completely a feature of OpenGL ES, whereas the latter two would be a feature of EGL.
For Apple, if the devices you’re targetting don’t have decent OpenGL ES support, you may need to end-run around Apple’s desire to force you down the Metal path by using a GLES -> Metal shim (e.g. MoltenGL, Zink on top of MoltenVK, or similar), as many devs/users are having to do for Vulkan support on Apple with MoltenVK.
As far as performance, just be aware that mobile GPU rendering is structured around the very limited bandwidth of ordinary DRAM, so rasterization is often performed a frame or two after CPU submission. The implication for your readback-to-CPU use case is that the latency of reading back the framebuffer may be a few frames. There are buffering techniques you can use to try to avoid bottlenecking the whole pipeline with your readbacks, but that will take some tuning. Best to consult the GPU vendor docs for recommendations on how to make this efficient with their drivers.
Thank you for your answer.
To answer your question, yes I’m looking for a high frame rate solution and I’m not looking for much data transfer, only few points’ data.
I also wanted to know how is handling the opengl Context done on mobile. For instance, from what I read, when the user rotates the phone, I will have to destroy and recreate a glContext.