> For the complete documentation index, see [llms.txt](https://vgui-framework.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vgui-framework.gitbook.io/docs/readme.md).

# Introduction

C++17 immediate-mode UI with a DirectX 11 renderer and a theme inspired by CS 1.6. The library has no ImGui dependency and uses no Valve source code.

## Guides

1. [Getting started](/docs/getting-started.md): builds, DLL linking, Win32 and the frame loop.
2. [API reference](/docs/api.md): widgets, parameters and return values.
3. [Examples](/docs/examples.md): tabs, IDs, layout and themes.
4. [Architecture](/docs/architecture.md): rendering, input and widget implementation.
5. [FAQ](/docs/faq.md): common mistakes and current limits.
6. [External rendering](/docs/external-rendering.md): host devices, render targets, images and recovery.

## Quick example

Keep widget values in your application and submit the UI each frame:

```cpp
// Keep these between frames.
vgui::Rect window{20, 20, 400, 260};
bool sound = true;
float volume = 0.65f;

// Inside the application loop.
if (ui.begin_frame()) {
    ui.begin_window("test", window);
    ui.checkbox("Sound", sound);
    ui.slider("Volume", volume, 0.0f, 1.0f);
    if (ui.button("Reset")) volume = 0.65f;
    ui.end_window();
    ui.end_frame();
}
```

[demo/main.cpp](https://github.com/insomfaze/vgui-framework/blob/main/demo/main.cpp) is a complete desktop application. [examples/settings.cpp](https://github.com/insomfaze/vgui-framework/blob/main/examples/settings.cpp) shows a small settings menu that is also compiled and exercised by the tests.

## Basic rules

* Use one `Context` per HWND, on the window's UI thread.
* Forward WndProc messages to `window_message()` and return its result when handled.
* If `begin_frame()` returns false, skip UI submission and `end_frame()`.
* Balance all begin/end and push/pop calls.
* Widget data belongs to the caller. References to that data are not kept between frames.
* Keep labels stable. `test##audio` displays `test` but uses the full label as its ID.
* Coordinates are logical pixels at 96 DPI; automatic scaling follows the window DPI.
* Text is UTF-8. Enable per-monitor DPI awareness before creating windows.
* Buttons return true on activation; value controls return true when their value changes.

The API is still evolving. See [vgui.hpp](https://github.com/insomfaze/vgui-framework/blob/main/include/vgui.hpp) for public declarations; headers in `src/` are private. Planned widgets are listed in [TODO.md](https://github.com/insomfaze/vgui-framework/blob/main/TODO.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://vgui-framework.gitbook.io/docs/readme.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `build a script that syncs our docs to a CMS` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
