Skip to content

Commit 03d5960

Browse files
committed
Release imgui modules 0.0.1
0 parents  commit 03d5960

20 files changed

Lines changed: 912 additions & 0 deletions

File tree

.gitattributes

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*.cppm linguist-language=cpp
2+
*.cppm linguist-detectable=true
3+
*.cppm linguist-documentation=false
4+
5+
*.mpp linguist-language=cpp
6+
*.mpp linguist-detectable=true
7+
*.mpp linguist-documentation=false

.github/workflows/ci.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: ci-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
mcpp:
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 30
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Install Xlings
26+
env:
27+
XLINGS_NON_INTERACTIVE: 1
28+
run: |
29+
curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/refs/heads/main/tools/other/quick_install.sh | bash
30+
echo "$HOME/.xlings/subos/current/bin" >> "$GITHUB_PATH"
31+
32+
- name: Install project tools
33+
run: |
34+
xlings update
35+
xlings install
36+
37+
- name: Show mcpp version
38+
run: mcpp --version
39+
40+
- name: Build library
41+
run: mcpp build
42+
43+
- name: Run tests
44+
run: mcpp test
45+
46+
- name: Run headless example
47+
run: |
48+
cd examples/basic
49+
mcpp run
50+
51+
- name: Build GLFW/OpenGL3 example
52+
run: |
53+
cd examples/glfw_opengl3
54+
mcpp build

.gitignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# mcpp
2+
target/
3+
gcm.cache/
4+
mcpp.lock
5+
compile_commands.json
6+
imgui.ini
7+
8+
# xlings project environment
9+
.xlings/
10+
11+
# Compiled Object files
12+
*.slo
13+
*.lo
14+
*.o
15+
*.obj
16+
17+
# Precompiled Headers
18+
*.gch
19+
*.pch
20+
21+
# Linker files
22+
*.ilk
23+
24+
# Debugger Files
25+
*.pdb
26+
27+
# Compiled Dynamic libraries
28+
*.so
29+
*.dylib
30+
*.dll
31+
32+
# Compiled Static libraries
33+
*.lai
34+
*.la
35+
*.a
36+
*.lib
37+
38+
# Executables
39+
*.exe
40+
*.out
41+
*.app
42+
43+
# Debug information files
44+
*.dwo
45+
*.d

.xlings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"workspace": {
3+
"xim:mcpp": "0.0.44"
4+
}
5+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 imgui module contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# imgui
2+
3+
C++23 module package for Dear ImGui on mcpp.
4+
5+
This package uses `compat.imgui` for upstream Dear ImGui sources and provides
6+
module interfaces for the core API plus GLFW/OpenGL3 backend entry points.
7+
8+
## Modules
9+
10+
- `imgui.core`
11+
- Core Dear ImGui context, frame, widget, and draw-data APIs.
12+
- `imgui.backend.glfw`
13+
- GLFW platform backend plus a small GLFW window/context helper surface.
14+
- `imgui.backend.opengl3`
15+
- OpenGL3 renderer backend.
16+
- `imgui.backend.glfw_opengl3`
17+
- Convenience module that re-exports core, GLFW, and OpenGL3 backend modules
18+
and provides combined lifecycle helpers.
19+
20+
## Dependencies
21+
22+
The root package depends on:
23+
24+
- `compat.imgui = "1.92.8"`
25+
- `compat.glfw = "3.4"`
26+
- `compat.opengl = "2026.05.31"`
27+
28+
The repository does not vendor Dear ImGui sources. Source and header files come
29+
from compat packages through mcpp dependency metadata.
30+
31+
## Quick Start
32+
33+
```bash
34+
mcpp build
35+
mcpp test
36+
cd examples/basic
37+
mcpp run
38+
```
39+
40+
Expected headless example output:
41+
42+
```text
43+
Dear ImGui 1.92.8 module frame ok
44+
```
45+
46+
## Backend Example
47+
48+
The GLFW/OpenGL3 example builds on CI but should be run only in an environment
49+
with a working display and OpenGL context:
50+
51+
```bash
52+
cd examples/glfw_opengl3
53+
mcpp build
54+
mcpp run
55+
```
56+
57+
## Consumer Usage
58+
59+
```toml
60+
[dependencies]
61+
imgui = "0.0.1"
62+
```
63+
64+
Then import the modules you need:
65+
66+
```cpp
67+
import imgui.core;
68+
import imgui.backend.glfw_opengl3;
69+
70+
int main() {
71+
ImGuiContext* context = ImGui::CreateContext();
72+
ImGui::SetCurrentContext(context);
73+
ImGui::DestroyContext(context);
74+
}
75+
```
76+
77+
## Module Surface
78+
79+
`src/core.cppm` wraps `imgui.h` through a global module fragment and exports a
80+
tested core API surface:
81+
82+
- Types: `ImGuiContext`, `ImFontAtlas`, `ImGuiIO`, `ImDrawData`, `ImVec2`.
83+
- Functions: context lifecycle, `GetIO`, `NewFrame`, `Begin`, `Button`,
84+
`TextUnformatted`, `End`, `Render`, and `GetDrawData`.
85+
86+
Backend modules adapt the official Dear ImGui backend headers internally and
87+
export explicit wrapper functions. Consumer code should only need module
88+
imports for the surfaces exposed by this package.
89+
90+
## Verification
91+
92+
The `0.0.1` release state is verified with mcpp `0.0.44`:
93+
94+
- `mcpp build`
95+
- `mcpp test`
96+
- `cd examples/basic && mcpp run`
97+
- `cd examples/glfw_opengl3 && mcpp build`
98+
99+
## License
100+
101+
The wrapper code in this repository is MIT licensed. Dear ImGui is MIT licensed
102+
and provided by the `compat.imgui` package.

docs/architecture.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Architecture
2+
3+
This repository adapts Dear ImGui to the mcpp module workflow while keeping
4+
upstream source ownership in compat packages.
5+
6+
## Goals
7+
8+
- Let consumers use explicit module imports:
9+
- `import imgui.core;`
10+
- `import imgui.backend.glfw;`
11+
- `import imgui.backend.opengl3;`
12+
- `import imgui.backend.glfw_opengl3;`
13+
- Keep the package source small: module wrappers and backend implementation
14+
translation units only.
15+
- Use `compat.imgui`, `compat.glfw`, and `compat.opengl` as the source and
16+
header providers.
17+
- Provide both a headless core example and a real GLFW/OpenGL3 window example.
18+
19+
## Layout
20+
21+
```text
22+
.
23+
|-- mcpp.toml
24+
|-- src/
25+
| |-- core.cppm
26+
| `-- backends/
27+
| |-- glfw.cppm
28+
| |-- opengl3.cppm
29+
| |-- glfw_opengl3.cppm
30+
| |-- glfw_impl.cpp
31+
| `-- opengl3_impl.cpp
32+
|-- tests/
33+
| |-- imgui_test.cpp
34+
| `-- backend_test.cpp
35+
`-- examples/
36+
|-- basic/
37+
`-- glfw_opengl3/
38+
```
39+
40+
## Package Configuration
41+
42+
The root `mcpp.toml` declares package `imgui`, lists the module wrappers and
43+
backend implementation translation units, and depends on compat packages:
44+
45+
```toml
46+
[build]
47+
sources = [
48+
"src/core.cppm",
49+
"src/backends/glfw.cppm",
50+
"src/backends/opengl3.cppm",
51+
"src/backends/glfw_opengl3.cppm",
52+
"src/backends/glfw_impl.cpp",
53+
"src/backends/opengl3_impl.cpp",
54+
]
55+
56+
[dependencies]
57+
compat.imgui = "1.92.8"
58+
compat.glfw = "3.4"
59+
compat.opengl = "2026.05.31"
60+
```
61+
62+
The wrapper package does not vendor `third_party/imgui`. Upstream headers,
63+
core sources, and backend files are read from `compat.imgui`.
64+
65+
## Module Wrappers
66+
67+
`src/core.cppm` adapts upstream `imgui.h` internally, then exports selected
68+
types and functions with explicit `using` declarations. This keeps consumer code
69+
on `import imgui.core;` instead of requiring direct header usage.
70+
71+
Backend module interfaces similarly adapt the official backend headers
72+
internally and export explicit wrapper functions. The implementation `.cpp`
73+
files compile upstream backend sources from `compat.imgui/backends` so consumers
74+
do not need to copy backend sources into their own package.
75+
76+
## Validation
77+
78+
Primary proof points:
79+
80+
```bash
81+
mcpp build
82+
mcpp test
83+
cd examples/basic && mcpp run
84+
cd ../glfw_opengl3 && mcpp build
85+
```
86+
87+
The GLFW/OpenGL3 example is a real windowed example. It is build-checked in
88+
headless CI and intended to be run on a machine with a working display/OpenGL
89+
context.

examples/basic/mcpp.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "imgui-basic"
3+
version = "0.1.0"
4+
description = "Headless consumer for the imgui.core module"
5+
license = "MIT"
6+
7+
[toolchain]
8+
linux = "llvm@20.1.7"
9+
10+
[dependencies]
11+
imgui = { path = "../.." }

examples/basic/src/main.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import std;
2+
import imgui.core;
3+
4+
int main() {
5+
ImGuiContext* context = ImGui::CreateContext();
6+
ImGui::SetCurrentContext(context);
7+
8+
ImGuiIO& io = ImGui::GetIO();
9+
io.DisplaySize = ImVec2 { 320.0f, 240.0f };
10+
unsigned char* fontPixels = nullptr;
11+
int fontWidth = 0;
12+
int fontHeight = 0;
13+
io.Fonts->GetTexDataAsRGBA32(&fontPixels, &fontWidth, &fontHeight);
14+
15+
ImGui::NewFrame();
16+
bool open = true;
17+
ImGui::Begin("mcpp imgui", &open);
18+
ImGui::TextUnformatted("hello from import imgui.core");
19+
ImGui::End();
20+
ImGui::Render();
21+
22+
std::println("Dear ImGui {} module frame ok", ImGui::GetVersion());
23+
ImGui::DestroyContext(context);
24+
return 0;
25+
}

examples/glfw_opengl3/mcpp.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "imgui-glfw-opengl3"
3+
version = "0.1.0"
4+
description = "GLFW and OpenGL3 consumer for imgui backend modules"
5+
license = "MIT"
6+
7+
[toolchain]
8+
linux = "llvm@20.1.7"
9+
10+
[dependencies]
11+
imgui = { path = "../.." }

0 commit comments

Comments
 (0)