User Interface
We follow the standard ribbon interface for UI. Further, supporting all indian scheduled languages is must. This will als enable us to support international languages in future. Please refer below actual code files for user interface design specifications. We have baseline strings say N numbers in English. Each string can have a corresponding language translation or if the language translation is empty string, than the corresponding english text shall be followed. All translations are stored in UserInterface-Text.h file.
Supporting all Indian languages is mostly a data organization + text shaping problem, not a rendering problem. Renderer will just draw glyphs; the system around it decides which string to show.
Translation Document
1// Copyright (c) 2026-Present : Ram Shanker: All rights reserved.
2#pragma once
3
4enum class UILanguage : uint8_t
5{
6 English = 0,
7
8 // 22 Indian scheduled languages
9 Hindi,
10 Bengali,
11 Telugu,
12 Marathi,
13 Tamil,
14 Urdu,
15 Gujarati,
16 Kannada,
17 Malayalam,
18 Odia,
19 Punjabi,
20 Assamese,
21 Maithili,
22 Santali,
23 Kashmiri,
24 Nepali,
25 Sindhi,
26 Konkani,
27 Manipuri,
28 Bodo,
29 Dogri,
30 Sanskrit,
31
32 // Major global engineering languages
33 ChineseSimplified,
34 ChineseTraditional,
35 Japanese,
36 Korean,
37 German,
38 French,
39 Spanish,
40 Portuguese,
41 Russian,
42 Italian,
43 Turkish,
44 Polish,
45 Dutch,
46 Swedish,
47 Czech,
48 Hungarian,
49 Ukrainian,
50 Vietnamese,
51 Thai,
52 Indonesian,
53
54 COUNT
55};
User Interface Design Document and Implementation!
1// Copyright (c) 2026-Present : Ram Shanker: All rights reserved.
2#pragma once
3
4#define WIN32_LEAN_AND_MEAN
5#include <windows.h> // MUST be before d3d12.h
6#include <d3d12.h>
7#include <d3dx12.h>
8#include <dxgi1_6.h>
9#include <wrl.h>
10#include <vector>
11#include <unordered_map>
12#include <iostream>
13
14#include "ConstantsApplication.h"
15#include "MemoryManagerGPU.h"
16#include "UserInterface-TextTranslations.h"
17#include "डेटा.h"
18#include "विश्वकर्मा.h"
19
20/*
21User Interface Design: Render the entire UI in DirectX12 itself. UI is a post-geometry overlay.
22Fundamental UI Philosophy: Immediate Mode UI (initially). Late stage, Retained mode for Top Ribbons/Active forms.
23Pipeline: RenderFrame(){ Render3DScene() RenderUIOverlay() Present() } This file represents UI part.
24Rendering Order: Clear > Render3D > DisableDepth > EnableBlend > RenderUI > Present
25UI Coordinate System : Use pixel space. Origin: (0,0) = top-left. Screen: X → right, Y → down
26Orthographic matrix: float4x4 Ortho = { 2/W, 0, 0, -1, 0, -2/H, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1 }
27This allows vertices to be placed directly in pixels.
28UI Vertex is different from 3D scene vertex because it mandatorily refers to a texture needing u/v coordinates.
29Tab 0 stores common textures and UI elements.
303 primitives:
311st: Rectangles Used for buttons / backgrounds / panels / tab bar, Rendered as: 2 triangles
322nd: Text Rendered via: glyph atlas texture, 3rd: Icons, Also from texture atlas.
33
34We will use FreeType to keep maximum cross platform code base between Windows / Linux / Mac / Android / iOS.
35HarfBuzz for Unicode shaping. Initial implementation will skip this and have ASCII characters only.
36
37At startup:
38Load font file (TTF) or desired Language / Script. ( All 18 indian scheduled languages covered. )
39Generate glyph bitmaps. Pack into texture atlas. Upload to GPU
40Glyph packing algorithm: Skyline bin packer
41
42Dedicated Root signature (uiRootSignature), Pipeline State Object (uiPipelineState)
43Vertex shader: position → clip space, uv → pass through, color → pass through
44Pixel shader: sample atlas, multiply color,
45Enable: alpha blending, Blend: SrcAlpha, InvSrcAlpha
46
47Use: DrawIndexedInstanced, No ExecuteIndirect needed. Batch everything.
48When drawing text: for each character, lookup glyph, append quad
49
50There are only 2 themes. Light and Dark. No colorful themes. System Light / Dark theme to be followed by default.
51This is to facilitate color as discipline code or visually distinguishing different UI elements.
52Our initial implementation will not have any Icons !
53During advanced stage of development, dedicated fonts depicting the icon will be constructed.
54So that same font rendering codes also generates the Icons ! No PNG embedded icon resource at all.
55Initial Memory Budget: Font atlas ~4MB, Icon atlas ~2MB, Vertex buffer ~1MB, Index buffer ~256KB
56
57UI Layout:
58----------------------------------------------
59| TAB BAR 4mm High MIN-MAX-CLOSE|
60--------------------1px-----------------------
61| RIBBON 20mm High |
62--------------------1px-----------------------
63| VIEW LIST ( Currently only 1) 4mm High |
64--------------------1px-----------------------
65| I | |Action | I |
66| C | |Pane | C |
67| O | 3D VIEWPORT |As per | O |
68| N | |Right | N |
69| S | |Buttons | S |
70----------------------------------------------
71| What next action user needs to take text |
72----------------------------------------------
73
74Pixels = Millimeters * (Monitor_DPI / 25.4f)
75
76In शंकर::InitD3DPerTab add if (tab.tabID == 0) InitUIResources(tab);
77Create the atlas texture once (committed resource, DEFAULT heap).
78Upload via Copy Queue exactly like geometry pages (reuse your upload ring buffer you are about to add).
79Mark it published immediately and never touch again.
80All text in UI shall be mandatorily any of the size : 1.5mm, 2.5mm(default), 4mm. No customizable size.
81
82Phased Rollout ( Phase 4 checklist)
83
84Phase 4A – Tab Bar only (1–2 days)
85Hard-coded tab names from publishedTabIndexes.
86Colored rects + simple text (even without atlas yet — use dummy color quads).
87Clicking changes activeTabIndex and triggers re-render.
88
89Phase 4B – Font Atlas + Text (next)
90Add stb_truetype or FreeType atlas.
91Render real tab labels + button text.
92
93Phase 4C – Ribbon Bar
94Hard-code 3–4 panels (File, Home, View).
958–10 buttons with rect + text (icons later).
96Click handlers queue actions to the active tab’s engineering thread.
97
98Phase 4D – Icons & Polish
99Custom Font for Icons.
100Hover glow, pressed state, tooltips (delayed text draw).
101
102Future: regenerate atlas on WM_DPICHANGED
103Far Future:
104Translator / AI edits: Hindi.csv, German.csv, Tamil.csv
105Build step runs: generate_ui_text_table.py
106Script generates: UserInterface-Text.generated.h
107Compiler builds: static constexpr translation tables
108Runtime: no file loading, no parsing, pure compile-time arrays
109*/
110
111
112#include <unordered_map>
113#include <d3dx12.h>
114struct UIVertex {
115 float x, y;
116 float u, v;
117 uint32_t color; // ABGR format for DX12 standard
118};
119
120struct Glyph { // Store glyph info:
121 float uvMinX, uvMinY, uvMaxX, uvMaxY; // Normalized UV coordinates in the atlas (0.0 to 1.0)
122 int width, height; // Pixel dimensions for drawing the quad
123 int bearingX, bearingY; // Positional offsets (Crucial for baseline alignment)
124 int advanceX;
125};
126
127// Use char32_t for full UTF-32 Unicode support (necessary for all languages)
128inline std::unordered_map<uint32_t, Glyph> glyphLookup; // Lookup table.
129
130struct UIButton {
131 uint32_t id; // Unique hash for immediate mode tracking
132 RECT physicalRect; // Calculated dynamically based on DPI
133 const wchar_t* label; // UTF-32 string for HarfBuzz
134 int iconIndex; // -1 = no icon, else index into sprite sheet
135 char32_t iconCodePoint;// The Unicode point for custom icon font
136 bool enabled;
137};
138
139struct UITabBarState {
140 int hoveredTab = -1;
141 int activeTab; // copied from window.activeTabIndex
142};
143
144struct DX12ResourcesUI {
145 ComPtr<ID3D12Resource> uiAtlasTexture; // 1024×1024 or 2048×2048 RGBA (or R8 for alpha-only)
146 ComPtr<ID3D12Resource> uiVertexBuffer; // Dynamic upload buffer for vertices
147 ComPtr<ID3D12Resource> uiIndexBuffer; // Dynamic upload buffer for indices
148
149 UINT8* pVertexDataBegin; // Mapped pointer for immediate writing
150 UINT8* pIndexDataBegin;
151
152 ID3D12Resource* iconAtlas; // Required ?
153 ComPtr<ID3D12PipelineState> uiPSO;
154 ComPtr<ID3D12RootSignature> uiRootSignature;
155};
156
157struct UIDrawContext {
158 UIVertex* vertexPtr;
159 uint16_t* indexPtr;
160 int vertexCount;
161 int indexCount;
162};
163
164void RenderUIOverlay(SingleUIWindow& window);code-core/MemoryUserInterface-DirectX12.cpp.
Miscellaneous philosophy:
Renderer must support these scripts:
| Script | Languages |
|---|---|
| Latin | English, German, French, Spanish, Portuguese, Polish, Dutch, Swedish, Italian |
| Cyrillic | Russian, Ukrainian |
| CJK | Chinese, Japanese |
| Hangul | Korean |
| Arabic | Urdu |
| Indic | Hindi, Bengali, Telugu, Tamil, etc |
| Thai | Thai |
| Vietnamese | Latin + diacritics |
Recommended Font Families: NotoSans-Regular NotoSansCJK-Regular NotoSansDevanagari NotoSansTamil NotoSansTelugu NotoSansThai NotoSansArabic NotoSansHebrew