#ifndef SWIFT_WINDOW_SHADER_H
#define SWIFT_WINDOW_SHADER_H
#include <swift/window/glad.h>
#include <GLFW/glfw3.h>
#include <swift/maths.h>
#include <swift/stdlib.h>
#include <swift/window/window.h>
#include <swift/window/render.h>
#include <swift/window/api.h>

#define SWIFT_MAX_POINT_LIGHTS 20

typedef struct swift_shader_ctx_t swift_shader_ctx_t;
typedef enum swift_shader_types_t swift_shader_types_t;
typedef struct swift_light_t swift_light_t;
typedef struct swift_light_uniform_t swift_light_uniform_t;
typedef struct swift_shader_t swift_shader_t;

enum swift_shader_types_t {
	SWIFT_SHADER_BASIC,
	SWIFT_SHADER_AMBIENT,
	SWIFT_SHADER_POINT,
	SWIFT_SHADER_TEXT,
	SWIFT_SHADER_END
};

struct swift_light_t {
	swift_vec2f_t pos;
	swift_vec4f_t col;
	float range, intensity;
};

struct swift_light_uniform_t
{
	GLuint pos;
	GLuint colour;
	GLuint range;
	GLuint intensity;
};

struct swift_shader_t {
	char type;
	GLuint program, transform, texcoords, colour, screensize;
	GLuint ambientlight, uniform_tex;
	swift_light_t *lights;
	swift_light_uniform_t *lights_uni;
};

struct swift_shader_ctx_t {
	swift_shader_t *shader;
	char *name;
};

SWIFT_WINDOW_API char *swift_load_shader(const char* path);
SWIFT_WINDOW_API bool swift_update_shader_name(swift_window_t *render,
	const char *name, swift_sprite_t *sprite);
SWIFT_WINDOW_API bool swift_update_shader(swift_window_t *window,
	swift_sprite_t *sprite);
SWIFT_WINDOW_API bool swift_init_shader_sys(void);
SWIFT_WINDOW_API bool swift_term_shader_sys(void);
SWIFT_WINDOW_API bool swift_add_shader(const char *base, const char *frag,
	const char *name, int type);
SWIFT_WINDOW_API swift_shader_ctx_t *swift_get_shader_ctx(const char *name);
SWIFT_WINDOW_API swift_shader_t *swift_get_shader(const char *name);
SWIFT_WINDOW_API bool swift_add_light(swift_shader_t *shader,
	swift_light_t *light);
SWIFT_WINDOW_API bool swift_remove_shader(const char *name);
#endif /* SWIFT_WINDOW_SHADER_H */
