//////////////////////////////////////////////////////////////////////////
//                                                                      //
//  This file contains the declaration of the CShaderGenerator class.   //
//                                                                      //
//////////////////////////////////////////////////////////////////////////
#ifndef __CSHADERGENERATOR_HPP__
#define __CSHADERGENERATOR_HPP__


#include <iostream>

class CScene;
class CShaderProgram;


// This class handles the generation of a shader program that will be
// able to render a scene in real-time raytracing
class CShaderGenerator
{
public:
  static CShaderGenerator *getInstance();
  static void              freeInstance();

  void generateShader(std::ostream& o,
                      const CScene *pScene) const;
  CShaderProgram *buildShader(std::string shaderString);

private:
  // Declared private so that they can't be called
  CShaderGenerator();
  ~CShaderGenerator();

  // Declared but not defined
  CShaderGenerator(const CShaderGenerator&);
  CShaderGenerator& operator=(const CShaderGenerator&);

  // Unique instance pointer
  static CShaderGenerator *s_pInstance;

  // Shader generation functions
  void generateUniforms(std::ostream& o) const;
  void generateStructures(std::ostream& o) const;
  void generateSceneSpecific(std::ostream& o, const CScene *pScene) const;
  void generateGetIntersections(std::ostream& o, const CScene *pScene) const;
  void generateGetSurfaceColor(std::ostream& o, const CScene *pScene) const;
  void generateGenericCode(std::ostream& o) const;
};



#endif // __CSHADERGENERATOR_HPP__
