OpenGL GPU Selection • Cross-Platform • Drop‑In Shim • Zero Code Changes
GLGpuSelect is a drop‑in replacement for opengl32.dll (Windows) and — coming soon — libGL.so (Linux), enabling per‑application GPU routing for any OpenGL app. No modifications, no global OS tweaks: just swap in the shim and pick your integrated or discrete GPU.
- Installation
- Quick Start
- Usage
- Examples & Documentation
- Repository Structure
- Contributing
- Releases & Changelog
- License
- Topics
- Xmake: https://xmake.io/#/
git clone https://github.com/ArthurVasseur/GLGpuSelect.git
cd GLGpuSelect| Flag | Description | Default |
|---|---|---|
--examples |
Build example applications | no |
--profiling |
Enable profiling hooks | no |
--tests |
Build unit tests | no |
--asserts |
Enable runtime assertions | no |
--logging |
Enable verbose logging | no |
xmake config -m debug --examples=y --profiling=y --tests=y --asserts=y --logging=yTo integrate this project into a CMake-based workflow, refer to xrepo-cmake
xmake # compile
xmake install -o /usr/local # or your chosen pathThen copy the libGLGpuSelect.so or opengl32.dll to your OpenGL app directory.
# Select GPU by OS adapter index (0 = first GPU, 1 = second, etc.)
export GLGPUS_ADAPTER_OS_INDEX=1
./your_opengl_app#include <GLGpuSelect.h>
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
uint32_t deviceCount = 0;
uint32_t result = glgpusEnumerateDevices(&deviceCount, NULL);
if (result != 0)
return EXIT_FAILURE;
AdapterInfo* adapters = malloc(deviceCount * sizeof(AdapterInfo));
result = glgpusEnumerateDevices(&deviceCount, adapters);
if (result != 0)
return EXIT_FAILURE;
printf("Available devices:\n");
for (uint32_t i = 0; i < deviceCount; ++i)
{
printf("\t%s\n", adapters[i].Name);
}
glgpusChooseDevice(adapters[0].Uuid);
free(adapters);
//Then call your OpenGL init code here ChoosePixelFormat, on windows, eglChooseConfig on Linux, etc.
return EXIT_SUCCESS;
}We welcome contributions!
- Fork the repo
- Create a branch (
git checkout -b feat/awesome) - Commit (
git commit -m "Add awesome feature") - Push (
git push origin feat/awesome) - Open a Pull Request
See CONTRIBUTING.md for guidelines on code style, testing, and reviews.
Dual‑licensed under:
- GPL‑3.0 (open‑source): See LICENSE
- Commercial: See COMMERCIAL_LICENSE.txt
opengl, gpu-selection, gpu-affinity, gpu-routing, multi-gpu, wgl, egl, nvoptimus, amd-powerxpress, cross-platform, drop-in, shim, xmake, c-api, environment-variables, performance, hardware-acceleration, rendering, game-development, gpl-3.0, dual-license