package com.danitheskunk.skunkworks.backends.gl;

import static org.lwjgl.opengl.GL46.*;

public class Shader {
	private final int shader;

	public Shader(String source, int type) {

		shader = glCreateShader(type);
		glShaderSource(shader, source);
		glCompileShader(shader);

		int[] ret = {0};
		glGetShaderiv(shader, GL_COMPILE_STATUS, ret);
		if(ret[0] == GL_FALSE) {
			var errmsg = glGetShaderInfoLog(shader);
			glDeleteShader(shader);
			throw new RuntimeException("Shader error:\n" + errmsg);
		}
	}

	public int getShader() {
		return shader;
	}
}
