// © Copyright 2008 Vladimir Frolov, Moscow State University Graphics & Media Lab
#pragma once
#include <string>

#ifndef MGML_GUARDIAN
	#include "../CSL/MGML.h"
#endif

//#ifndef KD_TREE_GUARDIAN
//	#include "kd_tree.h"
//#endif

using namespace MGML;

#ifdef CERF_DLL_EXPORTS
	#define DLL_API __declspec(dllexport)
#else
	#define DLL_API __declspec(dllimport)
#endif


class DLL_API IGraphicsEngine
{
public:

	typedef unsigned int uint;
	enum {MAX_KD_TREE_NODES = 1000000};

	IGraphicsEngine(int w,int h){}
	virtual ~IGraphicsEngine() {}

	virtual void BeginDrawScene(unsigned int trace_depth, bool shadows) = 0;			// you can do some thing between this calls
	virtual void EndDrawScene() = 0;			                                      // \\ you can do some thing between this calls

	virtual void DrawScene(unsigned int trace_depth,bool shadows) 
    { BeginDrawScene(trace_depth,shadows); EndDrawScene(); }

	virtual void BuildAccelerationStructures(uint in_maxNodes = MAX_KD_TREE_NODES) = 0;

	virtual uint	AddPointLight(const PointLight& light) = 0;
	virtual uint	AddMaterial(const Material& mat) = 0;
	virtual vec2ui	AddTriangles(const Vertex4f* v,int N_vertices,
								 const uint* indices,int N_indices) = 0;
	virtual uint	AddSpheres(const Sphere4f* s,int N_spheres) = 0;

	enum {RGBA32BIT_TEXTURE_FORMAT};
	virtual uint	AddTexture(const void* memory, uint w, uint h, uint format = RGBA32BIT_TEXTURE_FORMAT) = 0;

	virtual uint	AddScene() = 0;
	virtual void	SetActiveScene(uint scnIndex) = 0;

	virtual void SetPointLight(const PointLight& light,int index) = 0;	
  virtual const PointLight&	GetPointLight(int index) const = 0;
	
  virtual void SetCamMatrix(const Matrix4x4f& mat) = 0;
  virtual const Matrix4x4f&	GetCamMatrix() const = 0;
	

	virtual const Material&		GetMaterial(int index) const = 0;
  //virtual void SetMaterials(const Material* mats,unsigned int N);
	
	enum {MAX_NUM_VERTICES = 2*1000000,
		  MAX_NUM_SPHERES  = 2048,
		  MAX_NUM_INDICES = MAX_NUM_VERTICES*3,
		  MAX_NUM_POINT_LIGHTS = 8,
		  MAX_NUM_MATERIALS = 32,
		  MAX_NUM_TEXTURES  = 8};


private:
	IGraphicsEngine(const IGraphicsEngine& rhs){}
	IGraphicsEngine& operator=(const IGraphicsEngine& rhs)
		{return *this;}

};