Modern OpenGL bindings for C#.
OpenGL.Net is a comprehensive C# binding for OpenGL, OpenGL ES, and related APIs. It provides strongly-typed, fully documented access to modern OpenGL functionality with automatic error checking, extension management, and cross-platform support.
- Features
- Supported APIs
- Platform & Framework Support
- Installation
- Getting Started
- Building from Source
- Documentation
- Acknowledgements
- License
- Generated from Official Specifications: Bindings are automatically generated from the latest official Khronos XML specifications
- Type Safety: Strongly typed enumerants and function signatures
- Memory Safety: Function pointer wrappers with safe and unsafe parameter variants, automatically pinning managed memory when necessary
- Smart Context Management: Automatic entry point aliasing - the function loader is context-aware, allowing you to share code between OpenGL and OpenGL ES
- Comprehensive Documentation: All OpenGL entry points are fully documented with official manual pages
- Extension Support: Automatic querying of OpenGL extensions and implementation limits
- Debug Features:
- Automatic error checking after each OpenGL command (Debug builds only)
- Integrated call logging for debugging (Debug builds only)
- Math Library: Vector, matrix, and color data structures with
System.Numerics.Vectorsupport - Function Overloading: Multiple convenient overloads for OpenGL entry points
- ANGLE Support: Compatible with ANGLE backend for running OpenGL ES on DirectX
For a more object-oriented approach to OpenGL, see OpenGL.Net.Objects.
- OpenGL 4.6 - Full support including compatibility profile
- OpenGL ES 3.2 - Complete support, including OpenGL ES 1.0
- OpenGL SC 2.0 - Safety Critical profile (OpenGL SC 1.0 is not supported)
- WGL - Windows OpenGL interface
- GLX 1.4 - X Window System OpenGL interface
- EGL 1.5 - Native Platform Interface for embedded systems
- Broadcom VideoCore IV - Raspberry Pi GPU support
- GLU - OpenGL Utility Library (tessellator commands only)
The easiest way to use OpenGL.Net is via NuGet. Open the Package Manager Console and run:
Install-Package OpenGL.NetIf you want to restrict the available OpenGL profile:
Install-Package OpenGL.Net.CoreProfile # Core profile only
Install-Package OpenGL.Net.ES2Profile # OpenGL ES 2.0 profile
Install-Package OpenGL.Net.SC2Profile # OpenGL SC 2.0 profileInstall-Package OpenGL.Net.MathInstall-Package OpenGL.Net.WinForms # Windows Forms
Install-Package OpenGL.Net.Xamarin.Android # Xamarin Android
Install-Package OpenGL.Net.VideoCore # Raspberry Pi
Install-Package OpenGL.Net.GTK3 # GTK# 3Install-Package OpenGL.Net.Objectsusing OpenGL;
// Initialize OpenGL
Gl.Initialize();
// Check OpenGL version
Console.WriteLine($"OpenGL Version: {Gl.CurrentVersion}");
// Use OpenGL functions
Gl.ClearColor(0.0f, 0.0f, 0.0f, 1.0f);
Gl.Clear(ClearBufferMask.ColorBufferBit);using OpenGL;
using OpenGL.Net.WinForms;
// Use the GlControl in your form
var glControl = new GlControl();
glControl.Render += (sender, e) =>
{
Gl.Clear(ClearBufferMask.ColorBufferBit);
// Your rendering code here
};For complete examples, see the Samples directory, including the comprehensive Hello Triangle sample.
- Windows: Visual Studio 2022 (or Visual Studio 2017/2015 for older solution files)
- Linux/macOS: Mono 4.5+ or .NET Core SDK
git clone https://github.com/luca-piccioni/OpenGL.Net.git
cd OpenGL.Net
msbuild /p:Configuration=Release OpenGL.Net.sln- Wiki - Comprehensive project documentation
- How Do I... - Common usage patterns and recipes
- Samples - Example applications for various platforms
- Hello Triangle - Comprehensive, documented starter application
OpenGL.Net is built with the help of many excellent tools and services:
OpenGL.Net is released under the MIT License.
Copyright © 2015-2025 Luca Piccioni
Previous versions of the project were licensed under LGPL2. The license was changed to MIT to ensure maximum compatibility across all platforms and use cases, aligning with the spirit of the .NET Foundation.
Note: While OpenGL 4.6 (released July 2017) remains the latest version of OpenGL, the Khronos Group has shifted focus to Vulkan for future graphics API development. OpenGL.Net continues to provide comprehensive support for OpenGL 4.6 and OpenGL ES 3.2, which remain widely used across many platforms and applications.



