package com.danitheskunk.skunkworks.backends.gl;

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

public class Program {
	private final Shader fragment;
	private final int program;
	private final Shader vertex;
	public Program(String vertexSource, String fragmentSource) {
		vertex = new Shader(vertexSource, GL_VERTEX_SHADER);
		fragment = new Shader(fragmentSource, GL_FRAGMENT_SHADER);
		program = glCreateProgram();
		glAttachShader(program, vertex.getShader());
		glAttachShader(program, fragment.getShader());

		glLinkProgram(program);
	}

	public int getAttribLocation(String attrib) {
		return glGetAttribLocation(program, attrib);
	}

	public Shader getFragment() {
		return fragment;
	}

	public int getProgram() {
		return program;
	}

	public int getUniformLocation(String attrib) {
		return glGetUniformLocation(program, attrib);
	}

	public Shader getVertex() {
		return vertex;
	}

	public void use() {
		glUseProgram(program);
	}
}
