I am wondering how was first graphic or image libraries created,I know C and Python ,I want to create plotting application,and I cant imagine these libraries(QT,OpenGL,Vulkan) written by C,how can I create my image library,I just want to create basic graphic library.

  • 2
    $\begingroup$ "I cant imagine these libraries(QT,OpenGL,Vulkan) written by C" Well, Qt is written in C++ predominantly, so obviously that. It's also not a graphics library. Overall, this question is very unclear as to exactly what it is you're trying ask about. What do you mean by "computer graphics library" or "image library" and so forth? $\endgroup$ Jul 2, 2019 at 19:12

1 Answer 1


You're asking about two different types of library. OpenGL and Vulkan aren't just libraries: they're hardware interfaces. They are implemented by GPU vendors so that application developers can access the GPU, like a special kind of hardware driver. They're implemented in C or C++ and the core functionality is implemented by writing some structures in memory that the GPU itself can understand, then writing to registers on the GPU to make it read those structures and do the work. There isn't any C code in OpenGL to transform triangles, compute their projection onto the screen, and shade them, because that work is all done by the GPU.

OTOH, Qt and Gtk are libraries for making applications. A lot of their work isn't about graphics: they provide a framework for applications to manage themes and interactivity, letting the application developer wire together different parts of the application with callbacks. This is just normal library code. They also provide GUI classes such as buttons and checkboxes. These will each have something like a "draw" function which draws the graphics on the screen. A few years ago this would commonly have been implemented using the OS's 2D drawing API (e.g. GDI on Windows), which offers operations like "draw a filled rectangle", "blit an image", but nowadays they're more likely to use OpenGL or Vulkan operations. The UI components are defined in images and they're used as textures to generate the image of the whole window via a sequence of OpenGL draw calls.

You wouldn't implement OpenGL or Vulkan: this is something that GPU vendors create. You can't really do it yourself without detailed knowledge of the GPU hardware. (However, Mesa is an example of a software implementation of OpenGL, which doesn't depend on any GPU.)

If you wanted to implement a GUI library like Qt, you might start by defining an abstract Widget class with a draw method, and then implementing concrete subclasses of it to draw particular GUI components. Add extra methods and functionality as you need it.

To be honest, I don't think that would be a valuable project to work on. There are many smaller GUI frameworks already, and another toy one is not going to improve the world. You might treat it as just a learning project, but I think you'd learn more by studying one of the existing frameworks and writing an interesting GUI application on top of it.

  • $\begingroup$ Actually, OpenGL is only the specification. Mesa is only one implementation of the OpenGL specification. This just to be extra pendantic. $\endgroup$
    – Paul92
    Jul 5, 2019 at 13:58
  • 1
    $\begingroup$ @Paul92 That's why I described Mesa as "a software implementation of OpenGL" in my answer. I don't think the distinction between the Khronos specs and single-implementation libraries like Qt and Gtk is really the crucial distinction in the context of the OP's question, so I've tried to write an answer that's correct without going off on that tangent. If you have a specific clarification you'd like to make, feel free to edit. $\endgroup$
    – Dan Hulme
    Jul 5, 2019 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.