Added an easy way to get attribute location for shaders.
This commit is contained in:
parent
60fa54ccf9
commit
c62ec58c8f
@ -39,10 +39,15 @@ namespace RecrownedGTK.Graphics.Render.Shader {
|
|||||||
if ((log = GL.GetShaderInfoLog(fragShader)) == "") {
|
if ((log = GL.GetShaderInfoLog(fragShader)) == "") {
|
||||||
throw new ArgumentException("Error while compiling fragment shader: " + log, "fragmentPath");
|
throw new ArgumentException("Error while compiling fragment shader: " + log, "fragmentPath");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Creates the shader program.
|
||||||
handle = GL.CreateProgram();
|
handle = GL.CreateProgram();
|
||||||
|
|
||||||
|
//Attaches shader to program and links it.
|
||||||
GL.AttachShader(handle, vertShader);
|
GL.AttachShader(handle, vertShader);
|
||||||
GL.AttachShader(handle, fragShader);
|
GL.AttachShader(handle, fragShader);
|
||||||
GL.LinkProgram(handle);
|
GL.LinkProgram(handle);
|
||||||
|
|
||||||
GL.DetachShader(handle, vertShader);
|
GL.DetachShader(handle, vertShader);
|
||||||
GL.DetachShader(handle, fragShader);
|
GL.DetachShader(handle, fragShader);
|
||||||
GL.DeleteShader(vertShader);
|
GL.DeleteShader(vertShader);
|
||||||
@ -53,6 +58,10 @@ namespace RecrownedGTK.Graphics.Render.Shader {
|
|||||||
GL.UseProgram(handle);
|
GL.UseProgram(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int GetAttribLocation(string attributeName) {
|
||||||
|
return GL.GetAttribLocation(handle, attributeName);
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing) {
|
protected virtual void Dispose(bool disposing) {
|
||||||
if (IsDisposed) {
|
if (IsDisposed) {
|
||||||
return;
|
return;
|
||||||
@ -72,7 +81,7 @@ namespace RecrownedGTK.Graphics.Render.Shader {
|
|||||||
~Shader() {
|
~Shader() {
|
||||||
Dispose(false);
|
Dispose(false);
|
||||||
}
|
}
|
||||||
public static Shader CreateBasic2D() {
|
public static Shader CreateBasicShader() {
|
||||||
Shader shader = new Shader("Graphics/Render/Shader/default.vert", "Graphics/Render/Shader/default.frag");
|
Shader shader = new Shader("Graphics/Render/Shader/default.vert", "Graphics/Render/Shader/default.frag");
|
||||||
return shader;
|
return shader;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user