GLGraphicsNext 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package GLGraphicsNext --version 1.0.0                
NuGet\Install-Package GLGraphicsNext -Version 1.0.0                
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="GLGraphicsNext" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GLGraphicsNext --version 1.0.0                
#r "nuget: GLGraphicsNext, 1.0.0"                
#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.
// Install GLGraphicsNext as a Cake Addin
#addin nuget:?package=GLGraphicsNext&version=1.0.0

// Install GLGraphicsNext as a Cake Tool
#tool nuget:?package=GLGraphicsNext&version=1.0.0                

GLGraphicsNext

The next iteration of GLGraphics

Dependencies

OpenTK

Additional information

This library is stateless and uses 100% DSA(Direct State Access) OpenGL make sure your GPU can support DSA (OpenGL 4.5+).

Commented Sample Code

���cs using GLGraphicsNext; using OpenTK.Graphics.OpenGL; using OpenTK.Mathematics; using OpenTK.Platform;

namespace Example;

internal sealed class ExampleGame : BasePal2Window { //The VertexArrayObject holding information about //how our vertices are layed out in memory and //from which buffers to pull data GLVertexArray VAO;

//The GPU side buffer that holds our vertex data
GLBuffer VertexBuffer;
//The GPU side buffer that holds our index data
GLBuffer IndexBuffer;

//The GLProgram that decides how things are rendered
GLProgram ShaderProgram;

//The source code for our vertex shader
const string vertexShaderSource =
    @"#version 330 core
    layout (location = 0) in vec3 pos;
    
    void main()
    {
        gl_Position = vec4(pos, 1.0);
    }";

//The source code for our fragment shader
const string fragmentShaderSource =
    @"#version 330 core
    out vec4 color;
    
    void main()
    {
        color = vec4(0.980, 0.118, 0.506, 1.0);
    }";

readonly float[] vertices = //Vertices for our Square
{
         0.5f,  0.5f, 0.0f,
         0.5f, -0.5f, 0.0f,
        -0.5f, -0.5f, 0.0f,
        -0.5f,  0.5f, 0.0f
};

readonly uint[] indices = [0, 1, 3, 1, 2, 3]; //Indices for our Square
protected override void InitRenderer()
{
    //The OpenGL vertex input location 0 consists of 3 float values. 
    //The data is read with an offset of zero bytes.
    VAO = new GLVertexArray();
    VAO.ConfigureLayoutFloat(0, VertexAttribType.Float, 3, 0);


    //Initialize the buffer and fill it with the data of our vertices
    VertexBuffer = new GLBuffer<float>(vertices);


    //Initialize the buffer and fill it with the data of our indices
    IndexBuffer = new GLBuffer<uint>(indices);

    //Define how many bytes we need to advance, in order to find the next vertex
    //AKA how many bytes does one vertex take up
    const int stride = 3 * sizeof(float);

    //Assign our vertex and index buffers as the current targets of
    VAO.SetVertexBuffer(VertexBuffer, stride);
    VAO.SetIndexBuffer(IndexBuffer);

    //The VertexShader part of our shader Program
    GLShader vertexShader = new(ShaderType.VertexShader, vertexShaderSource);

    //The FragmentShader part of our shader Program
    GLShader fragmentShader = new(ShaderType.FragmentShader, fragmentShaderSource);


    //Create the Compiled Shader Program
    ShaderProgram = new GLProgram();
    //Add our shader parts to the final Shader Program
    ShaderProgram.AddShader(vertexShader);
    ShaderProgram.AddShader(fragmentShader);
    //Compile the program
    ShaderProgram.LinkProgram();

    //We can remove the fragment and vertex shader parts after compiling, to free memory
    ShaderProgram.RemoveShader(vertexShader);
    ShaderProgram.RemoveShader(fragmentShader);
    vertexShader.Dispose();
    fragmentShader.Dispose();
}

protected override void FramebufferResized(Vector2i newSize)
{
    GL.Viewport(0, 0, newSize.X, newSize.Y);
}

protected override void Render()
{
    GL.ClearColor(0.600f, 0.630f, 0.535f, 1f);
    GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
    //Set our VAO as the active VAO
    VAO.Bind();
    //Set our shader program as the active Shader Program
    ShaderProgram.Bind();
    //Render our Square
    GL.DrawElements(PrimitiveType.Triangles, indices.Length, DrawElementsType.UnsignedInt, 0);

    Toolkit.OpenGL.SwapBuffers(glContext);
}

}

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1 72 12/14/2024
1.0.0 69 11/1/2024