
#ifndef TSCENE_H_INCLUDED
#define TSCENE_H_INCLUDED

#include <windows.h>
#include <string>
#include <deque>
#include <GL/glew.h>

//
#include "../ECO/OUtils.h"
#include "../ECO/OTextureList.h"
#include "../ECO/OKeyboard.h"
#include "../ECO/OCamera.h"
#include "../ECO/skyEarth/OSkyEarth.h"
#include "../ECO/OBillboard.h"
#include "../ECO/OPickRay.h"

// interface
#include "../ECO/interface/OLabel.h"
#include "../ECO/interface/OLabel.h"
#include "../ECO/interface/OButton.h"
#include "../ECO/interface/OButtonRbt.h"
#include "../ECO/interface/OButtonCkd.h"
#include "../ECO/interface/OListBox.h"
#include "../ECO/interface/OFboBuffer.h"

// shader
#include "../ECO/shader/OShLight.h"
//
#include "../ECO/defered/ODBuffer.h"
#include "../ECO/defered/ODshNull.h"
#include "../ECO/defered/ODshGeo.h"
#include "../ECO/defered/ODshDir.h"
#include "../ECO/defered/ODshPoint.h"
//
#include "../ECO/defered/ODBuffer_water.h"
#include "../ECO/defered/ODshMask.h"
#include "../ECO/defered/ODshFreeze.h"
#include "../ECO/defered/ODshColor.h"

#include "../ECO/shader/OShLight.h"
#include "../ECO/shader/OShLight_pbr.h"
#include "../ECO/shader/OShParticle3d.h"
#include "../ECO/shader/OShGlow.h"
#include "../ECO/shader/OShBillboard.h"

#include "../ECO/postprocess/OppAliasing.h"
#include "../ECO/postprocess/OppFog.h"
#include "../ECO/postprocess/OppRain.h"
#include "../ECO/postprocess/OppSnow.h"
#include "../ECO/postprocess/OppOutline.h"

// interface
#include "TpnlSky.h"
#include "TpnlLstAnim.h"

// objet
#include "Tzone.h"
#include "Tdeco.h"
#include "Tperso.h"
#include "Tobjet.h"

#include "Tlake3d_low_1.h"
#include "Tlake3d_med_1.h"
//#include "Tlake3d_hig_1.h"
#include "Tsea3d_low_1.h"

#include "Tfontaine.h"
#include "Tbassin.h"
#include "Tflag_med.h"
#include "Tflag_low.h"
#include "Tbarrel_pbr.h"
#include "Tmeca.h"
#include "Tfire1.h"
#include "Ttorche.h"

#include "Tgrass_geo.h"
#include "Tgrass_ins.h"
#include "Ttree.h"
#include "Twood.h"


class Tscene
{
public:
	Tscene();
	~Tscene();

	void        close();
	void        create();

    void        resize(int width_old, int height_old, int width, int height);
	void        run();

	// --- module cycle
	void        cycle();

	// --- module draw
	void        draw();
	void        _draw_models();
	void        _draw_reflection();

	// --- module event
	void		keyDown(OKeyboard& keyboard);

	void		mouseDownL(int x, int y);
	void		mouseDownR(int x, int y);
	void		mouseMove(int x, int y);
	//void		mouseUp();
	void		mouseWheel(int delta);

    // --- module interface
    void        interface_create(OTextureList& textureList);
    void        interface_draw();
    void        interface_init_lst_action(int idx);
    void        interface_init_lst_anim(int idx);
    bool        interface_mouseDownL(int x, int y);
    bool        interface_mouseMove(int x, int y);
    bool        interface_mouseWheel(int delta);
    void        interface_shift();

	// --- module load
	void        load();
	void        load_init();
	void        load_end();
	void        load_site();
	void        load_ile_se();
	void        load_ile_so();
	void        load_ile_ne();

	// --- module lumiere
	void        light_init(float hour);

	// --- module perso
	void        perso_set_equipement(Tobjet& objet);
	void        perso_set_effect(size_t idx, int bt);

	// --- module picking
	void        pick_ray(int x, int y);
	void        pick_ray_move(int x, int y);

private:

    bool        m_running;
	float		m_backColor[4];
    OMat4       m_proj3d;
    OCamera     camera;
    OTextureList textureList;
    OPickRay    pickRay;

    // ---interface
	OLabel              lblInfo0, lblInfo1;
	TpnlSky             pnlSky;
    uint64_t            m_msg_tps; // pour info1

    OButtonRbt          rbtEau;
    OButtonRbt          rbtProcess;

    int                 m_mode_interface; // selon ile

    // ile sud est
    OButtonRbt          rbtShader;
    OButtonRbt          rbtPerso;
    std::deque<OButton> btObjet;
    std::vector<int>    ref_object;
    std::deque<OButton> btEffect;
    TpnlLstAnim         pnlLstAnim;

    // ile sud ouest
    OImage              imgClick;
    //TpnlLstAnim         pnlLstAction;

    // ile nord est
    OButtonRbt          rbtGrass;
    OButtonRbt          rbtTree;

    // ---shader
    int                 m_mode_shader;
    ODBuffer            defered_buffer;
    ODBuffer_water      water_buffer;
    ODshNull            dshNull;
    ODshGeo             dshGeo;
    ODshDir             dshDir;
    ODshPoint           dshPoint;
    //
    ODshMask            dshMask;
    ODshFreeze          dshFreeze;
    //
    OShLight_pbr        shLight_pbr;
    OShLight            shLight;
    OShParticle3d       shParticle3d;
    OShBillboard        shBillboard;
    OShGlow             shGlow;

    OFboBuffer          fboPostProcess;
    OppAliasing         ppAliasing;
    OppRain             ppRain;
    OppSnow             ppSnow;
    OppFog              ppFog;
    OppOutline          ppOutline;
    size_t              m_select_size;

    // ---objet
    OSkyEarth           skyEarth;
    std::deque<Tzone>   zone;
	std::deque<Tdeco>   deco;
	std::deque<Tobjet>  objet;
    std::deque<Tperso>  perso;
    int                 m_perso_en_cours;
    //
    Tfontaine           fontaine;
    Tbassin             bassin;
    Tflag_med           flag_med;
    Tflag_low           flag_low;
    Tbarrel_pbr         barrel;
    std::deque<OBillboard> billboard;
    std::deque<Tmeca>   meca;
    int                 m_meca_en_cours;
    Tfire1              fire1;
    std::deque<Ttorche> torche;
    //
    Tgrass_geo          grass_geo;
    Tgrass_ins          grass_ins;
    Ttree               tree;
    Twood               wood;

	// ---

	Tlake3d_low_1       lake3d_low;
	Tlake3d_med_1       lake3d_med;
	//Tlake3d_hig_1       lake3d_hig;
    Tsea3d_low_1        sea3d_low;
};

#endif
