Harrison 51cfc84cc7 More progress on shader implementation.
Changed engine OpenGL version to 4.1.

Added OpenGL program pipeline handles.

Added fragment shaders.

Some class name changes.
2020-05-28 23:22:44 -05:00

32 lines
938 B
C#

using System;
using System.Runtime.InteropServices;
using SDL2;
using SlatedGameToolkit.Framework.Exceptions;
using SlatedGameToolkit.Framework.Graphics.Window;
namespace SlatedGameToolkit.Framework.Graphics.OpenGL.Shaders
{
public class GLFragmentShader : GLShader {
public GLFragmentShader(WindowContext context, string shader) : base() {
Handle = createShader(GLEnums.GL_FRAGMENT_SHADER);
shaderSource(Handle, 1, shader, null);
compileShader(Handle);
uint logLength;
string shaderLog;
getShaderLogInfo(Handle, 1024, out logLength, out shaderLog);
if (logLength > 0) {
Dispose();
throw new OpenGLException(shaderLog);
}
}
public override void Dispose()
{
deleteShader(Handle);
}
~GLFragmentShader() {
Dispose();
}
}
}