Sharpgl
Use OpenGL in .NET applications. SharpGL wraps all modern OpenGL features and offers a powerful scene graph to aid development.
Install / Use
/learn @dwmkerr/SharpglREADME
SharpGL
Unlock the power of OpenGL in any .NET application. SharpGL wraps all modern OpenGL features, provides helpful wrappers for advanced objects like Vertex Buffer Arrays and shaders, as well as offering a powerful Scene Graph and utility library to help you build your projects.

Check out the Samples, they're a great place to start learning how to use SharpGL.
<!-- vim-markdown-toc GFM -->- Getting Started
- Compatibility
- Developer Guide
- Sample Applications
- WinForms - Ducky Sample
- WinForms - Extensions Sample
- WinForms - Hit Test Sample
- WinForms - Modern OpenGL Sample
- WinForms - Native Textures Sample
- WinForms - Particle Systems Sample
- WinForms - Polygon Loading
- WinForms - Radial Blue
- WinForms - Render Contexts Sample
- WinForms - Render Trigger Sample
- WinForms - Scene Sample
- WinForms - SharpGL Textures Sample
- WinForms - Simple Drawing Sample
- WPF - Cel Shading Sample
- WPF - Drawing Mechanisms Sample
- WPF - FastGL
- WPF - Object Loading Sample
- WPF - Simple Shader Sample
- WPF - Tea Pot Sample
- WPF - Text Rendering Sample
- WPF - Two Dimensional Rendering Sample
- Documentation
- SharpGL Visual Studio Extensions
- Credits, Sponsorship & Thanks
- Built with SharpGL
Getting Started
SharpGL is made up of a number of packages, you can install whichever package or packages you need!
| Package | Link | Overview |
|---------|------|----------|
| SharpGL | | All OpenGL functions wrapped and ready to execute, as well as all OpenGL extensions. |
|
SharpGL.SceneGraph | | The SceneGraph library contains a full class library which models key 3D entities. |
|
SharpGL.Serialization | | The Serialization library contains utilities to load data from Discreet, Wavefront and Caligari file formats. |
|
SharpGL.WPF | | SharpGL for WPF includes the Core as well as OpenGL controls to drop into your WPF app. |
|
SharpGL.WinForms | | SharpGL for WinForms includes the Core as well as OpenGL controls to drop into your WinForms app. |
Install SharpGL packages with NuGet, either by using the Package Explorer or the Package Manager tool, e.g:
PM> Install-Package SharpGL
Compatibility
SharpGL has built in support for OpenGL support, newer functions can be loaded on demand as needed. The table below shows the compatibility across frameworks and platforms.
OpenGL
Currently SharpGL has built in bindings for OpenGL 4.0 - functions from later versions can be loaded at runtime as needed.
Framework Compatibility
All components support the .NET Framework 4.0 onwards, .NET Core 3.0 onwards and .NET Standard 2.1 onwards. Some components also support earlier versions.
| Component | .NET Framework | .NET Core | .NET Standard |
|-----------|----------------|-----------|---------------|
| SharpGL | 4.0+ | 2.0+ | 2.0+ |
| SharpGL.SceneGraph | 4.0+ | 2.0+ | 2.0+ |
| SharpGL.Serialization | 4.0+ | 2.0+ | 2.0+ |
| SharpGL.WinForms | 4.0+ | 3.0+ | 2.1+ |
| SharpGL.WPF | 4.0+ | 3.0+ | 2.1+ |
Platform Compatibility
Compatibility across platforms is supported via framework specific components.
| Platform | Support |
|----------|---------------|
| WinForms on Microsoft Windows | ✅ via SharpGL.WinForms |
| WPF on Microsoft Windows | ✅ via SharpGL.WPF |
| UWP on Microsoft Windows | ❌ Work in Progress |
| Xamarin on Microsoft Windows | ❌ Work in Progress |
| Xamarin on MacOS | ❌ Work in Progress |
| Xamarin on Linux | ❌ Work in Progress |
Legacy Versions
The Visual Studio 2017 version of the codebase, which supports the .NET Framework only, is available on the release/2.x branch. However, this branch will not be maintained going forwards. The current mainline still supports the .NET Framework.
Developer Guide
To build the code, clone the repo and open the SharpGL, Samples or Tools solution. The Extensions solution is used for the Visual Studio Project Templates and requires additional components - you can find out more on the Wiki on the 'Developing SharpGL' page.
You can also use the following scripts to run the processes:
| Script | Notes |
|----------------|-------------------------------------------------------------------------------------------------------------------------|
| config.ps1 | Ensure your machine can run builds by installing necessary components such as nunit. Should only need to be run once. |
| build.ps1 | Build all solutions. Ensures that we build both 32/64 bit versions of native components. |
| test.ps1 | Run all tests, including those in samples. |
| coverage.ps1 | Create a coverage report. Reports are written to ./artifacts/coverage |
| pack.ps1 | Create all of the SharpGL NuGet packages, which are copied to ./artifacts/packages. |
These scripts will generate various artifacts which may be useful to review:
artifacts\
\tests # NUnit Test Reports
\coverage # Coverage Reports
\packages # NuGet Packages
Build Pipelines
Test the main build pipeline with act:
# Install act. See: https://github.com/nektos/act
brew install act
# Run the main pipeline to test release please
act -j main -s GITHUB_TOKEN=<token>
Releasing
To make and publish a release:
- Update the
*.csprojfiles with the new version number - Create the version tag (e.g.
git tag v3.2.1) - Push the code and tags (e.g.
git push --follow-tags)
AppVeyor will automatically push the release to NuGet and GitHub.
Sample Applications
There are a large number of sample applications that show how to use SharpGL. Check out the 'Samples' solution to see the samples that are available.
WinForms - Ducky Sample
This sample shows how to load an object file with materials, using the Serialization library. It also has great support for internationalization (thanks odalet)!
This sample demonstrates:
- Loading
*.objfiles and associated materials - Building polygons from
*.objfiles - Arcball rotation
Note that this sample uses immediate mode OpenGL, which is officially deprecated.
WinForms - Extensions Sample
This sample shows how to use OpenGL extensions. It demonstrates this by using the 'bump map' extensions.
Note that this sample uses immediate mode OpenGL, which is officially deprecated.
<img width="640" alt="Extensions Sample" src="assets/samples/WinFormsExtensionsSample.png" />WinForms - Hit Test Sample
This sample shows how to use to perform hit testing with SharpGL. It uses the Scene Graph to support this.
Note that this sample uses immediate mode OpenGL, which is officially deprecated.
<img width="640" alt="Extensions Sample" src="assets/samples/WinFormsHitTestSample.png" />WinForms - Modern OpenGL Sample
This sample shows how to use modern OpenGL capabilities which are Shader based, by showing a vertex and fragment shader.
<img width="640" alt="Extensions Sample" src="assets/samples/ModernOpenGLSampleLarge.png" />WinForms - Native Textures Sample
This sample shows how to load textures into OpenGL using pure OpenGL functions. However, the Texture object from the SceneGraph will be much easier to use!
Note that this sample uses immediate mode OpenGL, which is officially deprecated.
<img width="640" alt
