#pragma once

#include "PhongShader.h"
#include <QGLViewer/qglviewer.h>
#include <QString>
#include "Mesh.h"


class GLViewer : public QGLViewer  {
  Q_OBJECT
public:
  inline void setMesh (const Mesh & m) { mesh = m; }
  inline const Mesh & getMesh () const { return mesh; }
  inline Mesh & getMesh () { return mesh; }
  void open (const QString & filename);
protected :
  void init();
  void draw ();
  QString helpString() const;
  void keyPressEvent (QKeyEvent * e);
private:
  void initLights ();
  void setSunriseLight ();
  void setSingleSpotLight ();
  void setDefaultMaterial ();
  void setShaderValues ();
  void drawPhongModel ();
  void drawSolidModel ();
  void drawMesh (bool flat);
  void initGLList ();
  Mesh mesh;
  PhongShader * phongShader;

  GLuint glID;

  float diffuseRef;
  float specRef;
  float shininess;

  typedef enum {Solid, Phong} RenderingMode;
  RenderingMode mode;
  bool wireframe;
};

// Some Emacs-Hints -- please don't remove:
//
//  Local Variables:
//  mode:C++
//  tab-width:4
//  End:
