GLFW and Cairo Use


GLFW and Cairo
There is little information on this, if someone has something to say at this point, please tell me, pros and cons combinations of these two libraries.

Kind regards,

Hi @Rafal, welcome to the GLFW forum,

GLFW is an Open Source, multi-platform library for OpenGL, OpenGL ES and Vulkan development on the desktop. It provides a simple API for creating windows, contexts and surfaces, receiving input and events.

Cairo is a 2D canvas drawing API, primarily focussed on the CPU doing the rendering. You can combine Cairo and OpenGL (or Vulkan), as per their documentation:

I would personally not use Cairo in combination with OpenGL/Vulkan, butwould instead use an API designed for use with GPU rendering APIs directly, such as NanoVG or Dear ImGui.



(post deleted by author)

(post deleted by author)

Alternative to xlib backed cairo surface would be to do regular image surface with cairo_image_surface_create and then uploading it with glTexImage2D (or similar GL functions) and rendering with OpenGL primitives. That would integrate better with OpenGL applications and allow better performance as image upload happens in background OpenGL driver thread. It would also allow better portability (which is glfw goal) - as xlib works only on Linux, but image surface would work on any OS, Windows, macOS, Linux.

(post deleted by author)

Only reason is performance reason, so you have more control of how/when the cairo result is uploaded to OpenGL texture and used. With xlib you don’t have control over that. If you plan to use OpenGL then sooner or later you will want control over that, otherwise there’s no reason to use OpenGL.

(post deleted by author)