LightGL 1.0.9

dotnet add package LightGL --version 1.0.9
                    
NuGet\Install-Package LightGL -Version 1.0.9
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LightGL" Version="1.0.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LightGL" Version="1.0.9" />
                    
Directory.Packages.props
<PackageReference Include="LightGL" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LightGL --version 1.0.9
                    
#r "nuget: LightGL, 1.0.9"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LightGL@1.0.9
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LightGL&version=1.0.9
                    
Install as a Cake Addin
#tool nuget:?package=LightGL&version=1.0.9
                    
Install as a Cake Tool

LightGL - A Lightweight OpenGL C# Wrapper Library

LightGL is a lightweight C# wrapper library for OpenGL, offering a concise, efficient, and cross-platform graphics rendering solution.

LightGL is built specifically for high-performance graphics rendering. Its call efficiency is almost identical to that of native C/C++ implementations, outperforming general-purpose OpenGL wrapper libraries.

Wiki: https://deepwiki.com/unknowall/LightGL , https://zread.ai/unknowall/LightGL

Core Features

Lightweight & Dependency-Free

  • Pure C# implementation of OpenGL wrapper with zero third-party dependencies, relying solely on system-native OpenGL drivers and the .NET runtime
  • Streamlined code structure with core logic focused on the essence of rendering, facilitating easy understanding and extension
  • Compact generated library size for hassle-free deployment with no extra dependency burden

Cross-Platform Support

  • Unified interface design compatible with mainstream operating systems including Windows, Linux, and macOS
  • OpenGL context management implemented via a platform abstraction layer, enabling cross-platform operation without code modification
  • Compatible with OpenGL 3.2+ and mainstream graphics card drivers
  • The unified IGlContext interface provides dedicated implementations for different operating systems:
    • Windows: Built on WGL, supporting OpenGL 3.2+
    • Linux: Built on GLX, supporting the X11 window system with complete OpenGL context management for Linux platforms
    • macOS: Built on Cocoa’s NSOpenGLContext, supporting macOS’s native OpenGL framework
    • Android: Built on EGL (Embedded System Graphics Library) interface

Comprehensive Feature Wrapper

  • Core functionality coverage: shader management, buffer objects, texture processing, matrix/vector operations, etc.
  • Offers a simplified API that reduces the complexity of using native OpenGL interfaces
  • Includes out-of-the-box demo projects demonstrating complete rendering workflows

Battle-Tested in Real-World Projects

Environment Requirements

  • Development Environment: Visual Studio 2022+ or any IDE supporting .NET 6.0+
  • Runtime Environment: .NET 6.0+ runtime
  • Hardware Requirements: Graphics card supporting OpenGL 3.2+ with corresponding drivers installed

Quick Start

1. Get the Project

git clone https://github.com/unknowall/LightGL.git

2. Build the Project

  • Open the solution LightGL.sln
  • Select the target platform (Windows/Linux/macOS)
  • Build the project

3. Integration & Usage

Reference the LightGL in your C# project, Refer to the following sample code to quickly implement basic rendering:

// 1. Create OpenGL context (window handle example)
IntPtr windowHandle = YourWindow.GetHandle(); // Replace with your actual window handle
IGlContext context = GlContextFactory.CreateFromWindowHandle(windowHandle, 3, 2, GlProfile.Core);
context.MakeCurrent();

// 2. Initialize shaders
var vertexShaderCode = @"
attribute vec4 position;
attribute vec2 texCoord;
varying vec2 v_texCoord;
void main() {
    gl_Position = position;
    v_texCoord = texCoord;
}";

var fragmentShaderCode = @"
uniform sampler2D u_texture;
varying vec2 v_texCoord;
void main() {
    gl_FragColor = texture2D(u_texture, v_texCoord);
}";

GLShader shader = new GLShader(vertexShaderCode, fragmentShaderCode);

// 3. Create vertex buffer
float[] vertices = {
    -1.0f, -1.0f, 0.0f, 0.0f, // Bottom-left
     1.0f, -1.0f, 1.0f, 0.0f, // Bottom-right
     1.0f,  1.0f, 1.0f, 1.0f, // Top-right
    -1.0f,  1.0f, 0.0f, 1.0f  // Top-left
};
GLBuffer vertexBuffer = GLBuffer.Create();
vertexBuffer.SetData(vertices);

// 4. Create texture
GLTexture2D texture = GLTexture2D.Create()
    .SetFormat(TextureFormat.RGBA)
    .SetSize(2, 2)
    .SetData(new uint[] { 0xFF0000FF, 0xFF00FFFF, 0xFFFF00FF, 0xFFFFFFFF });

// 5. Render loop
bool running = true;
while (running)
{
    // Clear buffers
    GL.ClearColor(0.1f, 0.1f, 0.1f, 1.0f);
    GL.Clear(GL.GL_COLOR_BUFFER_BIT);
    
    // Bind resources and draw
    shader.Use();
    shader.SetUniform("u_texture", texture);
    vertexBuffer.Bind();
    GL.DrawArrays(GL.GL_TRIANGLE_FAN, 0, 4);
    
    // Swap buffers
    context.SwapBuffers();
    
    // Handle window events (implement based on your windowing framework)
    HandleWindowEvents(ref running);
}

// Release resources
shader.Dispose();
vertexBuffer.Dispose();
texture.Dispose();
context.Dispose();

Run the Demo

  1. After building the solution, launch the Demo project
  2. The demo showcases core workflows: window creation, context initialization, shader compilation, texture rendering, etc.
  3. Demo source code can be directly referenced for quick migration to your own projects

Contribution Guidelines

  1. Submit Issues: Report bugs, suggest features, or ask questions
  2. Submit Pull Requests (PRs):
    • Fork this repository
    • Create a feature branch (feature/xxx) or a bugfix branch (fix/xxx)
    • Commit your code and ensure successful compilation
    • Open a Pull Request with a clear description of your changes
  3. Code Style: Follow C# coding standards to maintain concise and readable code

License

This project is licensed under the MIT License, which permits:

  • Commercial use, modification, and distribution
  • Private use
  • No requirement to disclose modified source code (original copyright notice must be retained)

Contact & Feedback

  • For questions or suggestions, feel free to submit Issues or Pull Requests
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.9 88 2/21/2026
1.0.8 90 2/11/2026
1.0.7 90 2/4/2026
1.0.6 94 1/24/2026
1.0.5 95 1/9/2026
1.0.4 97 12/31/2025
1.0.3 101 12/30/2025
1.0.2 99 12/30/2025
1.0.1 96 12/30/2025
1.0.0 96 12/30/2025