starting compute shader for tetrahedron intersections

This commit is contained in:
2018-04-09 18:22:02 -04:00
parent f175dd84f4
commit 6539dd5ee6
9 changed files with 303 additions and 127 deletions

View File

@@ -1,20 +1,53 @@
using OpenTK.Graphics.OpenGL4;
using System;
using System.Collections.Generic;
using OpenTK.Graphics.OpenGL4;
namespace Platformer.Util
{
public class Program : GlObj
{
public Program() : base(GL.CreateProgram())
{
}
public class Program : GlObj
{
private Dictionary<string, int> _unifCache;
private Dictionary<string, int> _attrCache;
private Dictionary<string, int> _unifBlockCache;
public static Program Link(params Shader[] shaders)
{
var p = new Program();
foreach (var s in shaders)
GL.AttachShader(p, s);
GL.LinkProgram(p);
return p;
}
}
public Program() : base(GL.CreateProgram())
{
_unifCache = new Dictionary<string, int>();
_attrCache = new Dictionary<string, int>();
_unifBlockCache = new Dictionary<string, int>();
}
public int UnifLoc(string name)
{
if (!_unifCache.ContainsKey(name))
_unifCache[name] = GL.GetUniformLocation(this, name);
return _unifCache[name];
}
public int UnifBlockInd(string name)
{
if (!_unifBlockCache.ContainsKey(name))
_unifBlockCache[name] = GL.GetUniformBlockIndex(this, name);
return _unifBlockCache[name];
}
public int AttrLoc(string name)
{
if (!_attrCache.ContainsKey(name))
_attrCache[name] = GL.GetAttribLocation(this, name);
return _attrCache[name];
}
public static Program Link(params Shader[] shaders)
{
var p = new Program();
foreach (var s in shaders)
GL.AttachShader(p, s);
GL.LinkProgram(p);
Console.Error.WriteLine(GL.GetProgramInfoLog(p));
return p;
}
}
}