If you use OpenGL.Net, and you're willing to improve the project, your contributions are welcome.
If you find something wrong during the development, you can open an issue to get help. The issue should specify all information that helps to identify the problem. The minimal information to be included should be:
- OpenGL.Net version and configuration;
- Operating system;
- GPU device driver vendor, if correlated with the problem.
The common reasons for creating an issue:
- Unexpected exceptions: if you get an unexpected exception from OpenGL.Net, the issue should specify the exception stack and message.
- Missing OpenGL API: if you expect a GL command, a GL constant or an enumeration, but it is missing or wrong, you can create an issue about it; you can go further by checking the local
gl.xmlspecification, and if it is reasonable, create an issue to the Khronos GitHub repository. - Toolkit integration: you can run OpenGL.Net with any toolkit on any(*) platform, just find the display and window handles. You can open an issue for requesting a support library for integrating some toolkit.
- Missing feature: you can request any feature implementation, if it is related to the project target.
This repository contains both handwritten runtime code and generated OpenGL bindings. Before editing generated symbols, read the sections below.
- The OpenGL bindings (many
Gl.*,Egl.*,Wgl.*,Glx.*files) are produced by the code generator inBindingsGen/. Generated files contain the comment "This file is automatically generated" near the top. - Do not manually edit files that contain the "This file is automatically generated" marker. Changes to generated output must be done by:
- Updating the generator (
BindingsGen/) or its documentation handlers, or - Updating the GL specification inputs (see next section).
- Updating the generator (
- The GL specification XML files used by the generator (
GLSpecs/such asgl.xml,egl.xml,wgl.xml,glx.xml) are included as a git submodule. They can no longer be modified directly in this repository as plain files. - To propose changes to a specification you must update the submodule reference or contribute upstream to the canonical Khronos repositories. Typical workflow:
- Fork or contribute to the upstream Khronos XML repository where the spec originates.
- Open a PR upstream if the change should be accepted by the spec maintainers.
- In this repository update the
GLSpecssubmodule to point to the desired commit and open a PR that updates the submodule reference (and, if needed, the generated sources produced byBindingsGen).
- If you are unsure whether a change belongs in the spec or in the generator, open an issue first and describe the proposed modification.
Preferred full rebuild in Visual Studio 2022 is described in the repo docs. For command-line / VS Code users, use the provided tasks (see below):
- Run the
Restoretask to restore NuGet packages (dotnet restore OpenGL.Net.sln). - Run the
BuildorMSBuild (VS 2022)task.BindingsGenis a .NET Framework (net48) app and must be built with the Visual Studio 2022 build environment; theBuildtask callsvcvars64.batand MSBuild for this purpose. - Run the
Generate APIstask. This executesBindingsGen.exefromBindingsGen/bin/Release/and writes generated C# files intoOpenGL.Net/.
Tip: the workspace contains ready-to-run VS Code tasks: Restore, Build, and Generate APIs. Use them in sequence to regenerate bindings.
BindingsGentargets .NET Framework and requires MSBuild and the Visual Studio 2022 build tools (thevcvars64environment). On CI, prefer a Windows build agent with Visual Studio installed.- Many project files use
AllowUnsafeBlocksand platform-specific settings. Follow platform-targeting settings in the.csprojfiles when running samples or tests.
- Create an issue first for non-trivial changes unless the change is a simple typo or documentation fix.
- Use a feature branch named
branch_<short-description>or similar; keep commits focused and documented. - For changes that affect generated code, include the generator changes or updated
GLSpecssubmodule reference and regenerated outputs in the same PR. Clearly state the regeneration steps in the PR description. - Add or update tests where appropriate. Unit tests are present in
OpenGL.Net.*.Testprojects. - Ensure the solution builds in Release configuration with the usual
vcvars64/MSBuild environment. CI may run different targets; include platform/bitness notes if relevant. - Follow the existing code style and conventions: generated API code uses
partialclasses and many small files grouped by extension/feature; handwritten libraries follow the repository's prevailing naming and layout.
- Respect the generated code structure; add new generator output using the same partial-class splitting and directory layout used by the generator.
- Avoid introducing breaking changes to public APIs without discussion.
- If you add any native interop or unsafe code, make sure the corresponding project allows unsafe blocks (
AllowUnsafeBlocksin the.csproj).
- There are multiple test projects (
OpenGL.Net.Test,OpenGL.Net.Objects.Test, etc.). Run tests after making changes. - Samples may depend on native dependencies and specific platform bitness. Check
Prefer32BitandPlatformTargetin sample project files when running locally.
- The change implements or documents the requested feature/bugfix.
- Tests were added or updated if relevant.
- The solution builds in Release configuration using Visual Studio 2022 / MSBuild.
- Generated files were not edited by hand; generator or
GLSpecssubmodule was updated instead if needed.
If you like the project, or if it has saved you time, or you just want to offer a free beer to me, you can .