Skip to content

Commit

Permalink
ctrl s
Browse files Browse the repository at this point in the history
  • Loading branch information
4sval committed Oct 12, 2022
1 parent d047b56 commit e3e5689
Show file tree
Hide file tree
Showing 17 changed files with 642 additions and 690 deletions.
2 changes: 1 addition & 1 deletion FModel/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static class Constants
public static readonly FGuid ZERO_GUID = new(0U);

public const float SCALE_DOWN_RATIO = 0.01F;
public const uint SAMPLES_COUNT = 4;
public const int SAMPLES_COUNT = 4;

public const string WHITE = "#DAE5F2";
public const string GRAY = "#BBBBBB";
Expand Down
10 changes: 1 addition & 9 deletions FModel/FModel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@
<None Remove="Resources\framebuffer.vert" />
<None Remove="Resources\outline.frag" />
<None Remove="Resources\outline.vert" />
<None Update="glfw3.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<ExcludeFromSingleFile>True</ExcludeFromSingleFile>
</None>
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -141,14 +137,10 @@
<PackageReference Include="NVorbis" Version="0.10.4" />
<PackageReference Include="Oodle.NET" Version="1.0.1" />
<PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.1" />
<PackageReference Include="OpenTK" Version="4.7.5" />
<PackageReference Include="RestSharp" Version="108.0.1" />
<PackageReference Include="Serilog" Version="2.11.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Silk.NET.Input" Version="2.16.0" />
<PackageReference Include="Silk.NET.Input.Extensions" Version="2.16.0" />
<PackageReference Include="Silk.NET.OpenGL" Version="2.16.0" />
<PackageReference Include="Silk.NET.OpenGL.Extensions.ImGui" Version="2.16.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.3" />
<PackageReference Include="SkiaSharp.HarfBuzz" Version="2.88.0" />
<PackageReference Include="SkiaSharp.Svg" Version="1.60.0" />
</ItemGroup>
Expand Down
36 changes: 14 additions & 22 deletions FModel/Views/Snooper/BufferObject.cs
Original file line number Diff line number Diff line change
@@ -1,56 +1,48 @@
using System;
using Silk.NET.OpenGL;
using OpenTK.Graphics.OpenGL4;

namespace FModel.Views.Snooper;

public class BufferObject<TDataType> : IDisposable where TDataType : unmanaged
{
private uint _handle;
private BufferTargetARB _bufferType;
private GL _gl;
private readonly int _handle;
private readonly BufferTarget _bufferTarget;

public BufferObject(GL gl, BufferTargetARB bufferType)
private BufferObject(BufferTarget bufferTarget)
{
_gl = gl;
_bufferType = bufferType;
_bufferTarget = bufferTarget;
_handle = GL.GenBuffer();

_handle = _gl.GenBuffer();
Bind();
}

public unsafe BufferObject(GL gl, Span<TDataType> data, BufferTargetARB bufferType) : this(gl, bufferType)
public unsafe BufferObject(TDataType[] data, BufferTarget bufferTarget) : this(bufferTarget)
{
fixed (void* d = data)
{
_gl.BufferData(bufferType, (nuint) (data.Length * sizeof(TDataType)), d, BufferUsageARB.StaticDraw);
}
GL.BufferData(bufferTarget, data.Length * sizeof(TDataType), data, BufferUsageHint.StaticDraw);
}

public unsafe void Update(int offset, TDataType data)
{
_gl.BufferSubData(_bufferType, offset * sizeof(TDataType), (nuint) sizeof(TDataType), data);
GL.BufferSubData(_bufferTarget, (IntPtr) (offset * sizeof(TDataType)), sizeof(TDataType), ref data);
}

public unsafe void Update(Span<TDataType> data)
public unsafe void Update(TDataType[] data)
{
fixed (void* d = data)
{
_gl.BufferSubData(_bufferType, 0, (nuint) (data.Length * sizeof(TDataType)), d);
}
GL.BufferSubData(_bufferTarget, IntPtr.Zero, data.Length * sizeof(TDataType), data);
}

public void Bind()
{
_gl.BindBuffer(_bufferType, _handle);
GL.BindBuffer(_bufferTarget, _handle);
}

public void Unbind()
{
_gl.BindBuffer(_bufferType, 0);
GL.BindBuffer(_bufferTarget, 0);
}

public void Dispose()
{
_gl.DeleteBuffer(_handle);
GL.DeleteBuffer(_handle);
}
}
2 changes: 1 addition & 1 deletion FModel/Views/Snooper/Cube.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public Cube(UObject owner, string name, string type, UMaterialInterface unrealMa
};

Sections = new Section[1];
Sections[0] = new Section(0, (uint) Indices.Length, 0, unrealMaterial);
Sections[0] = new Section(0, Indices.Length, 0, unrealMaterial);

AddInstance(Transform.Identity);
}
Expand Down
Loading

0 comments on commit e3e5689

Please sign in to comment.