-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShaders.cs
39 lines (32 loc) · 1015 Bytes
/
Shaders.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using OpenTK.Graphics.OpenGL;
namespace ROQWE
{
class Shaders
{
public static int Load(string path, ShaderType type)
{
string Path = "Content/" + path;
if (!File.Exists(Path))
{
throw new FileNotFoundException("file not found at Content/" + path);
}
string Text = File.ReadAllText(Path);
int ID = GL.CreateShader(type);
GL.ShaderSource(ID, Text);
GL.CompileShader(ID);
Console.WriteLine(GL.GetShaderInfoLog(ID));
GL.GetShader(ID,ShaderParameter.CompileStatus,out int output);
if (output == 0)
{
throw new Exception($"brok :( {GL.GetShaderInfoLog(ID)}");
}
return ID;
}
}
}