#ifndef BLUECORE_RENDERDEVICE_H
#define BLUECORE_RENDERDEVICE_H

#include "RenderWindow.h"
#include "Camera.h"
#include "Material.h"
#include "Utilities/Buffer.h"
#include "Utilities/Referenced.h"
#include "Utilities/sigslot.h"

namespace BlueCore
{

class RenderDevice : public Referenced, public sigslot::has_slots<>
{
private:
	int _ViewportWidth, _ViewportHeight;

	void WindowResizeSlot(int width, int height);
	void WindowCloseSlot();

	ref_ptr<RenderWindow> _RenderWindow;
	ref_ptr<Camera> _Camera;

	unsigned int _ActiveTextures;

public:

	RenderDevice(RenderWindow* renderWindow);
	~RenderDevice();

	int getViewportWidth();
	int getViewportHeight();

	void begin2D();
	void end2D();

	void begin3D(Camera *);
	void end3D();

	void clear();
	void swap();

	void setAmbientLight(float r, float g, float b);
	void setMaterial(Material *);

	void setTexture(unsigned int unit, Texture* texture, bool last = false);
	void setShaderProgram(ShaderProgram shader_program);
	void setTexture(ShaderProgram shader_program, unsigned int texture,
			const std::string &name);

	void pushAbsoluteTransformation(const Vector3&, const Quaternion&);
	void pushTransformation(const Vector3&, const Quaternion&);
	void popTransformation();
	void setupProjectionMatrix();
	void setupViewMatrix();

	sigslot::signal0<> DeviceShutdownSignal;

	//Buffer<ShadowFace> &_ShadowFaces;
};

} // namespaced BlueCore

#endif // BLUECORE_RENDERDEVICE_H
