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

#include "IGraphicsEngine.h"
#include "Common_Graphics_Engine.h"
#include "rtlib.h"

class DLL_API Ray_Tracer: public Common_Graphics_Engine
{
public:

  Ray_Tracer(int w, int h): Common_Graphics_Engine(w,h) {}
  ~Ray_Tracer() {}

  virtual void PrintPerfInfo(std::ostream& out) {};

  virtual void BeginDrawScene(const Ray3f* a_rays, int a_maxSize, int a_traceDepth, bool a_shadows) = 0;	
  virtual void GetColorsToBuffer(vec4f* a_colors, int a_maxSize) = 0;			                                      

	class DLL_API RT_Core : public SSE_Aligned_Object
	{
	public:
		typedef Ray3f Ray;
		typedef RAYTR::Hit Hit;
		
		virtual void SetMatrix(const Matrix4x4f& m);
		virtual void TraverseRays(Ray* in_out_rays, RAYTR::Hit* out_hits, size_t in_N) = 0;
		virtual void TraverseRays(Ray* in_out_rays, RAYTR::Hit* out_hits, size_t in_width, size_t in_height) = 0;
	
	protected:
		Matrix4x4f mRaysTransfrom;
	};

	virtual Ray_Tracer::RT_Core* GetRTCore() = 0;

	typedef Common_Graphics_Engine Base;

protected:

	void calcWorldMatrix();
};