1 #ifndef GLUT_WINDOW_CUSTOMISER_A_H
2 #define GLUT_WINDOW_CUSTOMISER_A_H
4 #include "envFreeGlutTools.h"
7 #include "Displayable_A.h"
8 #include <thread> //requier compilation flags -std=c++0x
14 #define DEFAULT_GLUT_DISPLAY_MODE GLUT_DOUBLE|GLUT_DEPTH|GLUT_RGBA
17 * Etat d'une GLUTWindow
18 * A un instant t, elle ne peux avoir qu'un seul �tat, soit CREATED,RUNNING ou DESTROYED.
19 * L'�tat NOT_CREATED est utiliser � la construction de l'objet et fait office d'�tat "NULL" ou sans �tat
21 enum GLUT_WINDOW_CUSTOMISER_STATE
31 * Permet de customiser une fenetre FreeGLUT.
35 * Seul les methodes init et display sont obligatoire.
39 * la fonction idleFun est appel� de mani�re fr�n�tique ! A utiliser a vos risque et p�rile.
41 class CBI_FREEGLUT_TOOLS GLUTWindow
: public Panel_A
44 /*--------------------------------------*\
46 \*-------------------------------------*/
48 GLUTWindow(Displayable_A
* ptrDisplayable
, string title
, int width
, int height
, int pxFrame
= 0, int pyFrame
= 0, int glutDisplayMode
=
49 DEFAULT_GLUT_DISPLAY_MODE
);
51 /*--------------------------------------*\
53 \*-------------------------------------*/
55 virtual ~GLUTWindow();
57 /*--------------------------------------*\
59 \*-------------------------------------*/
61 virtual void display(void);
62 virtual void release(void);
63 virtual void reshape(int w
, int h
);
64 virtual void mouseMoved(int x
, int y
);
65 virtual void mouseWheelChanged(int wheel
, int direction
, int x
, int y
);
66 virtual void mousePressed(int button
, int state
, int x
, int y
);
67 virtual void keyPressed(unsigned char key
, int x
, int y
);
68 virtual void specialKeyPressed(int key
, int x
, int y
);
69 virtual void closeWindow();
72 * PostRendu est appeler apres GLUTWindowManager::runALL.
74 * Elle est dans son propre thread. (un thread par fen�tre).
76 * 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.
83 * Interuption du thread
89 * catch (boost::thread_interrupted&)
94 virtual void postRendu();
97 * Fonction appel� a chaque fois que glut n'a rien � faire dans la mainLoop.
98 * CaD s'il n'y a pas d'�venents utilisateur (souris,clavier,joystick,repaint,etc...)
100 virtual void idleFunc();
102 /*--------------------------------------*\
104 \*-------------------------------------*/
108 * Only used by GLUTWindowManagers !
109 * Will start the postRenduThread
116 void repaint() const;
118 /*--------------------------------------*\
120 \*-------------------------------------*/
122 int getFrameWidth(void) const;
124 int getFrameHeight(void) const;
126 int getFramePositionX(void) const;
128 int getFramePositionY(void) const;
130 int getGLUTDisplayMode(void) const;
132 unsigned int getGLUTWindowID(void) const;
134 string
getTitle(void) const;
136 Displayable_A
* getPtrDisplayable();
138 TextRenderer_A
* getTextRenderer();
140 FontLoader_A
* getFontLoader();
142 /*--------------------------------------*\
144 \*-------------------------------------*/
146 bool isRunning() const;
148 bool isCreated() const;
150 bool isDestroyed() const;
152 bool isDisplaying() const;
154 /*--------------------------------------*\
156 \*-------------------------------------*/
160 * Only used by GLUTWindowManagers !
162 void setState(GLUT_WINDOW_CUSTOMISER_STATE state
);
164 /*--------------------------------------*\
166 \*-------------------------------------*/
169 ModifierType
getModifier();
171 void startThreadPostRendu();
173 /*--------------------------------------*\
175 \*-------------------------------------*/
180 Displayable_A
* ptrDisplayable
;
189 TextRenderer_A
* ptrTextRenderer
;
190 FontLoader_A
* ptrFontLoader
;
193 GLUT_WINDOW_CUSTOMISER_STATE state
;
194 unsigned int glutWindowId
;
197 thread threadPostRendu
;