Skip to content

Commit

Permalink
making using our OpenGL optional
Browse files Browse the repository at this point in the history
  • Loading branch information
MrScautHD committed Jun 9, 2024
1 parent bd30685 commit 6dc629c
Show file tree
Hide file tree
Showing 11 changed files with 6,015 additions and 5,926 deletions.
6 changes: 6 additions & 0 deletions Raylib-CSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raylib-CSharp.Samples", "src\Raylib-CSharp.Samples\Raylib-CSharp.Samples.csproj", "{3260131D-2B07-44D5-B829-F2BB5BC2058B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raylib-CSharp.OpenGL", "src\Raylib-CSharp.OpenGL\Raylib-CSharp.OpenGL.csproj", "{338DEE5E-F7FA-46D7-A94F-F33DD1DFF53D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -32,6 +34,10 @@ Global
{3260131D-2B07-44D5-B829-F2BB5BC2058B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3260131D-2B07-44D5-B829-F2BB5BC2058B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3260131D-2B07-44D5-B829-F2BB5BC2058B}.Release|Any CPU.Build.0 = Release|Any CPU
{338DEE5E-F7FA-46D7-A94F-F33DD1DFF53D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{338DEE5E-F7FA-46D7-A94F-F33DD1DFF53D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{338DEE5E-F7FA-46D7-A94F-F33DD1DFF53D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{338DEE5E-F7FA-46D7-A94F-F33DD1DFF53D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4,043 changes: 4,043 additions & 0 deletions src/Raylib-CSharp.OpenGL/Apis/GlApi.cs

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions src/Raylib-CSharp.OpenGL/Contexts/IBindingsContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Raylib_CSharp.OpenGL.Contexts;

public interface IBindingsContext {

/// <summary>
/// Retrieves the address of an exported function or variable from the specified dynamic-link library (DLL).
/// </summary>
/// <param name="procName">The name of the exported function or variable.</param>
/// <returns>The address of the exported function or variable.</returns>
nint GetProcAddress(string procName);
}
10 changes: 10 additions & 0 deletions src/Raylib-CSharp.OpenGL/GLSync.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Raylib_CSharp.OpenGL;

public struct GLSync {

public nint Value;

public GLSync(nint value) {
this.Value = value;
}
}
1,882 changes: 1,882 additions & 0 deletions src/Raylib-CSharp.OpenGL/Gl.cs

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions src/Raylib-CSharp.OpenGL/Raylib-CSharp.OpenGL.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Raylib_CSharp.OpenGL</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

</Project>
44 changes: 44 additions & 0 deletions src/Raylib-CSharp.Test/NativeBindingsContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Raylib_CSharp.OpenGL.Contexts;
using Raylib_CSharp.Rendering.Gl.Contexts;

namespace Raylib_CSharp.Test;

public class NativeBindingsContext : IDisposable, IBindingsContext {

private NativeGlContext _context;

public bool HasDisposed { get; private set; }

/// <summary>
/// Represents a context for native bindings in OpenGL.
/// </summary>
public NativeBindingsContext() {
this._context = new NativeGlContext();
}

public nint GetProcAddress(string procName) {
return this._context.GetProcAddress(procName);
}

/// <summary>
/// Disposes of the object, allowing for proper resource cleanup and finalization.
/// </summary>
public void Dispose() {
if (this.HasDisposed) return;

this.Dispose(true);
GC.SuppressFinalize(this);
this.HasDisposed = true;
}

/// <summary>
/// Releases the managed resources used by the object (disposing), and optionally releases the unmanaged.
/// resources (not disposing).
/// </summary>
/// <param name="disposing">A boolean value indicating whether the method is being called from, dispose method directly (true) or from the finalizer (false).</param>
protected void Dispose(bool disposing) {
if (disposing) {
this._context.Dispose();
}
}
}
10 changes: 6 additions & 4 deletions src/Raylib-CSharp.Test/Program.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
using System.Numerics;
using Raylib_CSharp;
using Raylib_CSharp.Apis;
using Raylib_CSharp.Camera.Cam3D;
using Raylib_CSharp.Colors;
using Raylib_CSharp.Fonts;
using Raylib_CSharp.Geometry;
using Raylib_CSharp.Images;
using Raylib_CSharp.IO;
using Raylib_CSharp.Logging;
using Raylib_CSharp.OpenGL;
using Raylib_CSharp.Rendering;
using Raylib_CSharp.Rendering.Gl.Contexts;
using Raylib_CSharp.Test;
using Raylib_CSharp.Textures;
using Raylib_CSharp.Unsafe.Spans.Data;
using Raylib_CSharp.Windowing;
Expand Down Expand Up @@ -110,9 +113,8 @@

Image testImage = Image.GenColor(100, 100, Color.Green);

NativeGlContext Context = new NativeGlContext();

Gl.Init();
NativeBindingsContext context = new NativeBindingsContext();
Gl.Init(context);

//Span<Matrix4x4> matrix = new(new Matrix4x4[1]);
//matrix[1] = new Matrix4x4();
Expand Down Expand Up @@ -147,4 +149,4 @@
model.Unload();

Window.Close();
Gl.Destroy();
context.Dispose();
1 change: 1 addition & 0 deletions src/Raylib-CSharp.Test/Raylib-CSharp.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Raylib-CSharp.OpenGL\Raylib-CSharp.OpenGL.csproj" />
<ProjectReference Include="..\Raylib-CSharp\Raylib-CSharp.csproj"/>
</ItemGroup>

Expand Down
Loading

0 comments on commit 6dc629c

Please sign in to comment.