Custom engines

Megacool needs to hook into your rendering pipeline to be able to capture the content and create amazing GIFs from it. For Unity we do this automatically, and for some native iOS and Android apps the defaults should work okay. If you're using your own game engine or the defaults don't work well (low fps, poor quality or nothing captured), read on to learn how to optimize this.

As long as you're using OpenGL ES 3, there's two things you need to do to make capture work efficiently:

  1. You need to tell the SDK how captures should be performed.
  2. The SDK needs to know when you've finished rendering a frame.

Both of these actions translate to a method call in the SDK, setCaptureMethod and notifyRenderComplete, respectively. As a slight optimization you can also call initRenderThread to let the SDK perform some capture initialization before capture actually starts. If this isn't done, the initialization will instead be done on the first call to notifyRenderComplete.

initRenderThread has to, like the name suggests, be called on the rendering thread in your app, after the SDK has been initialized with a call to Megacool.start(). This is the thread you're issuing drawing calls to the GPU on. If you don't have a dedicated thread for this it's probably your main thread and you can call it right after Megacool.start(). notifyRenderComplete should also be called on the rendering thread.

If you're not on OpenGL ES 3 it's a bit harder for us to do performant capture, but if you are able to get the content you want to capture into a texture we can capture from that. On both platforms there is a native function you have to call from C called mcl_set_capture_texture(void *texture_pointer). Call this after setCaptureMethod with the id<MTLTexture> on Metal or the GLuint texture name (casted to a void *) on OpenGL ES 2.

Note: The SDK doesn't currently support changing the rendering thread during the course of the game when using the low-level capture API. We're working on a fix for this. In the meantime we suggest trying the default capture method.