-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit cf7422c
Showing
41 changed files
with
2,511 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
bin/ | ||
obj/ | ||
/packages/ | ||
riderModule.iml | ||
/_ReSharper.Caches/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
xcopy "C:\Users\richard may clarkson\RiderProjects\shdr\shdr\Resource" "C:\Users\richard may clarkson\RiderProjects\shdr\shdr\bin\Debug\net6.0\Resource" /E /H /C /R /Q /Y | ||
xcopy "C:\Users\richard may clarkson\RiderProjects\shdr\shdr\Resource" "C:\Users\richard may clarkson\RiderProjects\shdr\shdr\bin\Release\net6.0\Resource" /E /H /C /R /Q /Y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"sdk": { | ||
"version": "6.0.0", | ||
"rollForward": "latestMajor", | ||
"allowPrerelease": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "shdr", "shdr\shdr.csproj", "{5F7BB6FD-5D0B-4E3A-8D87-295F9802F734}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{5F7BB6FD-5D0B-4E3A-8D87-295F9802F734}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{5F7BB6FD-5D0B-4E3A-8D87-295F9802F734}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{5F7BB6FD-5D0B-4E3A-8D87-295F9802F734}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{5F7BB6FD-5D0B-4E3A-8D87-295F9802F734}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Method/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /></s:String> | ||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=TypesAndNamespaces/@EntryIndexedValue"><Policy Inspect="True" Prefix="__" Suffix="" Style="aa_bb" /></s:String> | ||
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue"><AssemblyExplorer>
 | ||
<Assembly Path="C:\Users\richard may clarkson\RiderProjects\shdr\shdr\bin\Debug\net6.0\NAudio.Core.dll" />
 | ||
</AssemblyExplorer></s:String></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
using OpenTK.Graphics.OpenGL4; | ||
|
||
namespace shdr.Engine | ||
{ | ||
public class __fbo | ||
{ | ||
private static int _active; | ||
private static readonly Dictionary<int, __fbo> _frames = new(); | ||
private readonly bool _useDepth; | ||
private int _colorAttachment; | ||
private int _depthAttachment; | ||
public int handle; | ||
private int _height; | ||
private int _width; | ||
|
||
public __fbo(int width, int height) | ||
{ | ||
_width = width; | ||
_height = height; | ||
_useDepth = false; | ||
handle = -1; | ||
init(); | ||
_frames[handle] = this; | ||
} | ||
|
||
public __fbo(int width, int height, bool useDepth) | ||
{ | ||
_width = width; | ||
_height = height; | ||
_useDepth = useDepth; | ||
handle = -1; | ||
init(); | ||
_frames[handle] = this; | ||
} | ||
|
||
private void dispose() | ||
{ | ||
GL.DeleteFramebuffer(handle); | ||
GL.DeleteTexture(_colorAttachment); | ||
if (_useDepth) GL.DeleteTexture(_depthAttachment); | ||
} | ||
|
||
private void init() | ||
{ | ||
if (handle != -1) dispose(); | ||
|
||
handle = GL.GenFramebuffer(); | ||
bind(); | ||
_colorAttachment = GL.GenTexture(); | ||
GL.BindTexture(TextureTarget.Texture2D, _colorAttachment); | ||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest); | ||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest); | ||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, | ||
(int)TextureWrapMode.ClampToBorder); | ||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, | ||
(int)TextureWrapMode.ClampToBorder); | ||
GL.TexStorage2D(TextureTarget2d.Texture2D, 1, SizedInternalFormat.Rgba8, _width, _height); | ||
GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, | ||
TextureTarget.Texture2D, _colorAttachment, 0); | ||
if (_useDepth) | ||
{ | ||
_depthAttachment = GL.GenTexture(); | ||
GL.BindTexture(TextureTarget.Texture2D, _depthAttachment); | ||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, | ||
(int)TextureMinFilter.Nearest); | ||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, | ||
(int)TextureMagFilter.Nearest); | ||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureCompareMode, | ||
(int)TextureCompareMode.None); | ||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, | ||
(int)TextureWrapMode.ClampToEdge); | ||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, | ||
(int)TextureWrapMode.ClampToEdge); | ||
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.DepthComponent, _width, _height, 0, | ||
PixelFormat.DepthComponent, PixelType.UnsignedInt, IntPtr.Zero); | ||
GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthAttachment, | ||
TextureTarget.Texture2D, _depthAttachment, 0); | ||
} | ||
|
||
FramebufferErrorCode status = GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer); | ||
if (status != FramebufferErrorCode.FramebufferComplete) | ||
throw new Exception( | ||
$"Incomplete Framebuffer! {status} should be {FramebufferErrorCode.FramebufferComplete}"); | ||
|
||
unbind(); | ||
} | ||
|
||
private void _resize(int width, int height) | ||
{ | ||
_width = width; | ||
_height = height; | ||
init(); | ||
} | ||
|
||
public static void resize(int width, int height) | ||
{ | ||
foreach (KeyValuePair<int, __fbo> frame in _frames) frame.Value._resize(width, height); | ||
} | ||
|
||
public void bind_color(TextureUnit unit) | ||
{ | ||
GL.ActiveTexture(unit); | ||
GL.BindTexture(TextureTarget.Texture2D, _colorAttachment); | ||
} | ||
|
||
public int bind_depth(TextureUnit unit) | ||
{ | ||
if (!_useDepth) throw new Exception("Trying to bind depth texture of a framebuffer without depth!"); | ||
GL.ActiveTexture(unit); | ||
GL.BindTexture(TextureTarget.Texture2D, _depthAttachment); | ||
return _depthAttachment; | ||
} | ||
|
||
public void bind() | ||
{ | ||
if (handle == _active) return; | ||
GL.BindFramebuffer(FramebufferTarget.Framebuffer, handle); | ||
_active = handle; | ||
} | ||
|
||
public void blit(int handle = 0) | ||
{ | ||
GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, this.handle); | ||
GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, handle); | ||
GL.BlitFramebuffer(0, 0, _width, _height, 0, 0, _width, _height, ClearBufferMask.ColorBufferBit, | ||
BlitFramebufferFilter.Nearest); | ||
unbind(); | ||
} | ||
|
||
public static void unbind() | ||
{ | ||
GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0); | ||
_active = 0; | ||
} | ||
} | ||
} |
Oops, something went wrong.