Ajout de l'ensemble du workspace.
[GPU.git] / WCudaMSE / API_Bilat_FreeGlut_Tools / INC / GLUTWindow.h
diff --git a/WCudaMSE/API_Bilat_FreeGlut_Tools/INC/GLUTWindow.h b/WCudaMSE/API_Bilat_FreeGlut_Tools/INC/GLUTWindow.h
new file mode 100755 (executable)
index 0000000..fe7a137
--- /dev/null
@@ -0,0 +1,200 @@
+#ifndef GLUT_WINDOW_CUSTOMISER_A_H\r
+#define GLUT_WINDOW_CUSTOMISER_A_H\r
+\r
+#include "envFreeGlutTools.h"\r
+#include "Panel_A.h"\r
+#include "GLConfig.h"\r
+#include "Displayable_A.h"\r
+#include <thread> //requier compilation flags -std=c++0x\r
+#include <string>\r
+\r
+using std::string;\r
+using std::thread;\r
+\r
+#define DEFAULT_GLUT_DISPLAY_MODE GLUT_DOUBLE|GLUT_DEPTH|GLUT_RGBA\r
+\r
+/**\r
+ * Etat d'une GLUTWindow\r
+ * A un instant t, elle ne peux avoir qu'un seul �tat, soit CREATED,RUNNING ou DESTROYED.\r
+ * L'�tat NOT_CREATED est utiliser � la construction de l'objet et fait office d'�tat "NULL" ou sans �tat\r
+ */\r
+enum GLUT_WINDOW_CUSTOMISER_STATE\r
+    {\r
+    NOT_CREATED,\r
+    CREATED,\r
+    RUNNING,\r
+    DESTROYED\r
+    };\r
+\r
+/**\r
+ * But :\r
+ *     Permet de customiser une fenetre  FreeGLUT.\r
+ *\r
+ * Note :\r
+ *\r
+ *     Seul les methodes init et display sont obligatoire.\r
+ *\r
+ * Attention :\r
+ *\r
+ *     la fonction idleFun est appel� de mani�re fr�n�tique ! A utiliser a vos risque et p�rile.\r
+ */\r
+class CBI_FREEGLUT_TOOLS GLUTWindow: public Panel_A\r
+    {\r
+    public:\r
+       /*--------------------------------------*\\r
+        |*             Constructor             *|\r
+        \*-------------------------------------*/\r
+\r
+       GLUTWindow(Displayable_A* ptrDisplayable, string title, int width, int height, int pxFrame = 0, int pyFrame = 0, int glutDisplayMode =\r
+       DEFAULT_GLUT_DISPLAY_MODE);\r
+\r
+       /*--------------------------------------*\\r
+        |*             Destructor              *|\r
+        \*-------------------------------------*/\r
+\r
+       virtual ~GLUTWindow();\r
+\r
+       /*--------------------------------------*\\r
+        |*             Callbacks               *|\r
+        \*-------------------------------------*/\r
+\r
+       virtual void display(void);\r
+       virtual void release(void);\r
+       virtual void reshape(int w, int h);\r
+       virtual void mouseMoved(int x, int y);\r
+       virtual void mouseWheelChanged(int wheel, int direction, int x, int y);\r
+       virtual void mousePressed(int button, int state, int x, int y);\r
+       virtual void keyPressed(unsigned char key, int x, int y);\r
+       virtual void specialKeyPressed(int key, int x, int y);\r
+       virtual void closeWindow();\r
+\r
+       /**\r
+        * PostRendu est appeler apres GLUTWindowManager::runALL.\r
+        *\r
+        * Elle est dans son propre thread. (un thread par fen�tre).\r
+        *\r
+        * GLUTWindow ne stop pas le thread explicitement. Donc si il y a une boucle infinie, il faut utiliser l'etat de la fenetre comme crit�re d'arret.\r
+        *\r
+        * Par exemple\r
+        *\r
+        *      isDestroyed\r
+        *      isRunning\r
+        *\r
+        *  Interuption du thread\r
+        *\r
+        *      try\r
+        *          {\r
+        *           ....\r
+        *          }\r
+        *      catch (boost::thread_interrupted&)\r
+        *          {\r
+        *           ...\r
+        *          }\r
+        */\r
+       virtual void postRendu();\r
+\r
+       /**\r
+        * Fonction appel� a chaque fois que glut n'a rien � faire dans la mainLoop.\r
+        * CaD s'il n'y a pas d'�venents utilisateur (souris,clavier,joystick,repaint,etc...)\r
+        */\r
+       virtual void idleFunc();\r
+\r
+       /*--------------------------------------*\\r
+        |*             Methodes                *|\r
+        \*-------------------------------------*/\r
+\r
+       /**\r
+        * Don't Use !\r
+        * Only used by GLUTWindowManagers !\r
+        * Will start the postRenduThread\r
+        */\r
+       void startWindow();\r
+\r
+       /**\r
+        * call display()\r
+        */\r
+       void repaint() const;\r
+\r
+       /*--------------------------------------*\\r
+        |*             Get                     *|\r
+        \*-------------------------------------*/\r
+\r
+       int getFrameWidth(void) const;\r
+\r
+       int getFrameHeight(void) const;\r
+\r
+       int getFramePositionX(void) const;\r
+\r
+       int getFramePositionY(void) const;\r
+\r
+       int getGLUTDisplayMode(void) const;\r
+\r
+       unsigned int getGLUTWindowID(void) const;\r
+\r
+       string getTitle(void) const;\r
+\r
+       Displayable_A* getPtrDisplayable();\r
+\r
+       TextRenderer_A* getTextRenderer();\r
+\r
+       FontLoader_A* getFontLoader();\r
+\r
+       /*--------------------------------------*\\r
+        |*             Is                      *|\r
+        \*-------------------------------------*/\r
+\r
+       bool isRunning() const;\r
+\r
+       bool isCreated() const;\r
+\r
+       bool isDestroyed() const;\r
+\r
+       bool isDisplaying() const;\r
+\r
+       /*--------------------------------------*\\r
+        |*             Set                     *|\r
+        \*-------------------------------------*/\r
+\r
+       /**\r
+        * Don't Use !\r
+        * Only used by GLUTWindowManagers !\r
+        */\r
+       void setState(GLUT_WINDOW_CUSTOMISER_STATE state);\r
+\r
+       /*--------------------------------------*\\r
+        |*             Private                 *|\r
+        \*-------------------------------------*/\r
+\r
+    private:\r
+       ModifierType getModifier();\r
+\r
+       void startThreadPostRendu();\r
+\r
+       /*--------------------------------------*\\r
+        |*             Attributs               *|\r
+        \*-------------------------------------*/\r
+\r
+    private:\r
+\r
+       // Input\r
+       Displayable_A* ptrDisplayable;\r
+       string title;\r
+       int pxFrame;\r
+       int pyFrame;\r
+       int width;\r
+       int height;\r
+       int glutDisplayMode;\r
+\r
+       //Tools\r
+       TextRenderer_A* ptrTextRenderer;\r
+       FontLoader_A* ptrFontLoader;\r
+       int lastFPS;\r
+       bool displaying;\r
+       GLUT_WINDOW_CUSTOMISER_STATE state;\r
+       unsigned int glutWindowId;\r
+\r
+       // Animation\r
+       thread threadPostRendu;\r
+    };\r
+\r
+#endif\r