<p>I've been playing around with OpenGL and I'm trying to build out my own UI component library containing things like buttons, text views, labels, views, etc. Eventually I want to abstract it <strong>similar</strong> to iOS UIKit where I can just call <code>UIButton()</code> or <code>UIView()</code> and just generate that UI element. Before I let my imagination go, I am still trying to understand the most effective way to actually develop the initial library. Eventually I want it to be a combination of 2D and 3D graphics. Should I build all the components in say Blender and export the bmp file as a texture and use that? I don't think that's a viable option because eventually I want to add text in runtime to the UI elements and eventually re-shape the size based on constantly changing variables. Even better, is there already a library with this extracted? Similar to CoreGraphics/UIKit?</p>

CC BY-SA 4.0
2020-10-06T08:18:38.533Z
If creating library is your goal, that's ok. If you just need UI for testing - check ImGui project. ; Regarding your question - it depends how complicated your library is going to be. I've achieved similar results to ImGui with using very simple shaders with single color. To create text, I've used Rastertek font engine - http://www.rastertek.com/dx11tut12.html - it was working reasonably well, at least for my purposes. I don't understand part about mixing 2D and 3D graphics. What do you mean by that?
DirectX_Programmer
CC BY-SA 4.0
2020-10-06T18:06:18.950Z
+1 for [dear imgui](https://github.com/ocornut/imgui) if you're looking for a ready made UI library you can plug into an OpenGL renderer, that allows creating UI elements in code by calling functions, and everything is dynamic. Or if you want to develop your own, you could still look at that for design inspiration.
Nathan Reed
<opengl><2d-graphics>
Creating a UI component library from scratch
joethemow
# Creating a UI component library from scratch

(Asked by: username_0 on 2020-10-06)

I've been playing around with OpenGL and I'm trying to build out my own UI component library containing things like buttons, text views, labels, views, etc. Eventually I want to abstract it **similar** to iOS UIKit where I can just call `UIButton()` or `UIView()` and just generate that UI element. Before I let my imagination go, I am still trying to understand the most effective way to actually develop the initial library. Eventually I want it to be a combination of 2D and 3D graphics. Should I build all the components in say Blender and export the bmp file as a texture and use that? I don't think that's a viable option because eventually I want to add text in runtime to the UI elements and eventually re-shape the size based on constantly changing variables. Even better, is there already a library with this extracted? Similar to CoreGraphics/UIKit?

**Tags:** opengl, 2d-graphics

> **Comments:**
> **username_1**: If creating library is your goal, that's ok. If you just need UI for testing - check ImGui project. ; Regarding your question - it depends how complicated your library is going to be. I've achieved similar results to ImGui with using very simple shaders with single color. To create text, I've used Rastertek font engine - http://www.rastertek.com/dx11tut12.html - it was working reasonably well, at least for my purposes. I don't understand part about mixing 2D and 3D graphics. What do you mean by that?  
> **username_2**: +1 for [dear imgui](https://github.com/ocornut/imgui) if you're looking for a ready made UI library you can plug into an OpenGL renderer, that allows creating UI elements in code by calling functions, and everything is dynamic. Or if you want to develop your own, you could still look at that for design inspiration.  

---

## 0 answers

