package ru.dbotthepony.kstarbound.client.gl

import org.lwjgl.opengl.GL11.*

@Suppress("unused")
data class BlendFunc(
	val sourceColor: Func,
	val destinationColor: Func,
	val sourceAlpha: Func,
	val destinationAlpha: Func
) {
	constructor() : this(
		Func.ONE,
		Func.ZERO,
		Func.ONE,
		Func.ZERO
	)

	constructor(source: Func, destination: Func) : this(
		source,
		destination,
		source,
		destination
	)

	enum class Func(val enum: Int) {
		ZERO(GL_ZERO),
		ONE(GL_ONE),
		SRC_COLOR(GL_SRC_COLOR),
		ONE_MINUS_SRC_COLOR(GL_ONE_MINUS_SRC_COLOR),
		SRC_ALPHA(GL_SRC_ALPHA),
		ONE_MINUS_SRC_ALPHA(GL_ONE_MINUS_SRC_ALPHA),
		DST_ALPHA(GL_DST_ALPHA),
		ONE_MINUS_DST_ALPHA(GL_ONE_MINUS_DST_ALPHA),
		DST_COLOR(GL_DST_COLOR),
		ONE_MINUS_DST_COLOR(GL_ONE_MINUS_DST_COLOR),
		SRC_ALPHA_SATURATE(GL_SRC_ALPHA_SATURATE);
	}

	companion object {
		val DEFAULT = BlendFunc()
		val MULTIPLY_WITH_ALPHA = BlendFunc(Func.SRC_ALPHA, Func.ONE_MINUS_SRC_ALPHA)
		val ADDITIVE = BlendFunc(Func.ONE, Func.ONE)

		val ONLY_ALPHA = BlendFunc(
			Func.ZERO,
			Func.ONE,
			Func.ONE,
			Func.ZERO
		)

		val ONLY_BLEND_ALPHA = BlendFunc(
			Func.ZERO,
			Func.ONE,
			Func.ONE,
			Func.ONE
		)

		val ONLY_COLOR = BlendFunc(
			Func.ONE,
			Func.ZERO,
			Func.ZERO,
			Func.ONE
		)

		val MULTIPLY_BY_SRC = BlendFunc(
			Func.ZERO,
			Func.SRC_COLOR,
			Func.ONE,
			Func.ZERO
		)
	}
}