<p>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.</p>

<p>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.</p>

<p>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, <em>Mesa</em> is an example of a software implementation of OpenGL, which doesn't depend on any GPU.)</p>

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

<p>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.</p>

CC BY-SA 4.0
2019-07-05T13:58:06.310Z
Actually, OpenGL is only the specification. Mesa is only one implementation of the OpenGL specification. This just to be extra pendantic.
Paul92
CC BY-SA 4.0
2019-07-05T14:14:30.320Z
@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.
Dan Hulme
CC BY-SA 4.0
2019-07-05T08:02:30.687Z
2019-07-05T08:02:30.687Z
Dan Hulme
<p>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.</p>

CC BY-SA 4.0
2019-07-02T19:12:07.850Z
"*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?
Nicol Bolas
<opengl><vulkan>
How was computer graphics libraries or gtk,qt programmed?
Huseyin Okan Demir
# How was computer graphics libraries or gtk,qt programmed?

(Asked by: username_0 on 2019-07-02)

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.

**Tags:** opengl, vulkan

> **Comments:**
> **username_1**: "*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?  

---

## 1 answers

### Answer by username_2 on 2019-07-05. Score: 4

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.

> **Comments:**
> **username_3**: Actually, OpenGL is only the specification. Mesa is only one implementation of the OpenGL specification. This just to be extra pendantic.  
> **username_2**: @username_3 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.  

---

