

struct testresultt
{
  i64 solvingtick;
  i64 prerenderingtick;
  i64 renderingtick;
  i32 framequ;

  void init();
};


class controlobj : public IObject
{
public:
    controlobj(void) 
        : m_hWnd(NULL)
    {}
    virtual ~controlobj(void) {}

// IObject
    STDMETHOD(Connect)(HWND); 
    STDMETHOD(Disconnect)(void);

    // allocates memory, init internal data,
    // either defaults or those ones set by SetData() (see below)
    STDMETHOD(Initialize)(void);
    // stops process, deallocates memory..
    STDMETHOD(Terminate)(void); 

    // sets data bunch.. the exact structure is discussible
    STDMETHOD(SetData)(void* data);	
    // supply a bunch of results.. 
    // the exact structure is discussible as well..
    STDMETHOD(GetData)(void* data);	

    // redirects Windows messages, or sends custom commands (e.g. Ping())
    STDMETHOD(ProcessMessage)(HWND, UINT, WPARAM, LPARAM, LRESULT*);

// Other CTask methods

private:

    HWND m_hWnd;
    char progdir[MAX_PATH];

    i32 screenw;
    i32 screenh;
    rnumt screenscalex;
    rnumt screenscaley;
    i32 renderiset;
    bool flshadows;
    bool flqualityshadows;
    bool fltextures;
    char modelname[MAX_PATH];
    i32 starttestframenum;
    i32 finishtestframenum;
    double step;
    i32 iterationqu;

    bool flwindow;
    bool flsystemmemory;
    bool flfreeview;

    i32 viewscreenx0;
    i32 viewscreeny0;
    i32 viewscreenw;
    i32 viewscreenh;
    rnumt viewsizex;
    rnumt viewsizey;

    rvectort viewpoint;
    basisobj viewbasis;

    pixelformatt pixelformat;
    sceneguidt sceneguid;
    renderguidt renderguid;
    texturerguidt texturerguid;

    i32 startsystemtime;
    i32 systemtime;
    i32 framequ;
    double deltat;

    bool flsystemactive;

    testresultt testresults;

    bool fltest;
    bool flquit;
    bool fltestperformed;

  		char fillstr[200];
    HFONT infofont;
    HDC dc1,dc2;
    double cineenergy;
    double potentialenergy;
    double energyleak;
    double impulsex,impulsey,impulsez;
    i32 curframequ;


    void outtext(string s, i32 x, i32 y, byte r, byte g, byte b); 
    void showparameters();

    void shiftviewleft(rnumt l);
    void shiftviewright(rnumt l);
    void shiftviewup(rnumt l);
    void shiftviewdown(rnumt l);
    void shiftviewforward(rnumt l);
    void shiftviewbackward(rnumt l);

    void rotateviewleft(rnumt phi);
    void rotateviewright(rnumt phi);
    void rotateviewup(rnumt phi);
    void rotateviewdown(rnumt phi);
    void rotateviewaxialforward(rnumt phi);
    void rotateviewaxialbackward(rnumt phi);

    void rotatescene(i32 axis, rnumt phi);
    void rotatesceneleft(rnumt phi);
    void rotatesceneright(rnumt phi);
    void rotatesceneup(rnumt phi);
    void rotatescenedown(rnumt phi);
    void roatesceneaxialforward(rnumt phi);
    void rotatesceneaxialbackward(rnumt phi);

    bool control();

    void init();
};


// This function is exported from the task_xxx.dll
IObject* WINAPI CreateObject(void);

