#define NO_SDL_GLEXT

#include <GL/glew.h>
#include <SDL/SDL_OpenGL.h>
#include <GL/gl.h>
#include <GL/glu.h>

#include "demo_init_gl.h"
#include "demo_screen.h"
#include "demo_script.h"
#include "demo_timer.h"

#include "part_intro.h"
#include "part_bump.h"
#include "part_fire.h"
#include "part_blur.h"
#include "part_emboss.h"
#include "part_water.h"
#include "part_voronoi.h"
#include "part_implicit_plasma.h"
#include "part_implicit_spheres.h"
#include "part_landscape.h"
#include "part_shading.h"
#include "part_envmap.h"
#include "part_implicit_polar.h"
#include "part_multieffects.h"

// ================
// ==== Script ====
// ================

int start_timer = 0;
int curr_part = MULTIEFFECTS;

bool change_part = true;

void UpdateStartTimer()
{
	start_timer = Ticks();
}

void NewPart(int part)
{
	curr_part = part;
	change_part = true;
}

int GetPart()
{
	return curr_part;
}

void Script()
{
	if (change_part)
	{
		UpdateStartTimer();
		InitFuckingOpenGL();
		change_part = false;
	}

	int part_timer = Ticks() - start_timer;

	switch(curr_part)
	{
		case INTRO:
			intro_run(part_timer);
		break;

		case BUMP:
			bump_run(part_timer);
		break;

		case EMBOSS:
			emboss_run(part_timer);
		break;

		case FIRE:
			fire_run(part_timer);
		break;

		case BLUR:
			blur_run(part_timer);
		break;

		case WATER:
			water_run(part_timer);
		break;

		case VORONOI:
			voronoi_run(part_timer);
		break;

		case IMPLICIT_PLASMA:
			implicit_plasma_run(part_timer);
		break;

		case IMPLICIT_SPHERES:
			implicit_spheres_run(part_timer);
		break;

		case LANDSCAPE:
			landscape_run(part_timer);
		break;

		case SHADING:
			shading_run(part_timer);
		break;

		case ENVMAP:
			envmap_run(part_timer);
		break;

		case POLAR:
			implicit_polar_run(part_timer);
		break;

		case MULTIEFFECTS:
			multieffects_run(part_timer);
		break;

		default:
		break;
	}
}
