#pragma once

#define RGFW_IMPLEMENTATION
#include "../external/rgfw/RGFW.h"

#include "assets.h"

typedef enum Pipeline_e
{
	PIPELINE_PBR,
	//PIPELINE_GUI,
	PIPELINE_MAX,
} Pipeline;

typedef struct PipelineCreateInfo
{
	char *vertex_shader;
	char *fragment_shader;
} PipelineCreateInfo;

typedef unsigned int VertexBuffer;
typedef unsigned int IndexBuffer;
typedef unsigned int PipelineHandle;
typedef unsigned int ShaderHandle;
typedef unsigned int VertexArray;
typedef unsigned int UBO;

typedef struct MeshBuffer
{
	VertexArray  array;
	VertexBuffer vertex;
	IndexBuffer  index;
	u32					 draw_count;
} MeshBuffer;

typedef struct Renderer
{
	RGFW_window 	 *window;
	PipelineHandle pipelines[PIPELINE_MAX];
	MeshBuffer		 models[MODEL_ASSET_MAX];
} Renderer;

// ::Init::Decl::

static b32 Init(Renderer *renderer);
static PipelineHandle CreatePipeline();
static VertexBuffer CreateVertexBuffer();
static IndexBuffer CreateIndexBuffer();
static VertexArray CreateVertexArray();
static ShaderHandle CreateShader(int type);
static PipelineHandle BuildPipeline(PipelineCreateInfo *create_info);
static MeshBuffer	CreateMeshBuffer(char *asset);
static UBO CreateUBO(rawptr data, u32 size);
static b32 BuildShader(ShaderHandle *handle,  char *asset);

// ::Textures::Decl::

static u32 CreateTexture(rawptr data, u32 width, u32 height);

// ::Draw::Decl::

static void DrawMeshBuffer(MeshBuffer *mesh);

