29 static const float ElementPickerTolerance = 0.01f;
35 displayList = glGenLists(1);
38 GLenum errorCode = glGetError();
39 const unsigned char* sError = gluErrorString(errorCode);
40 printf(
"Erreur OpenGL %d : %s\n", errorCode, sError);
74 glColor3f(1.0, 0.0, 0.0);
77 glEnable(GL_LIGHTING);
78 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
80 static GLfloat ambient[] = { 0.1f, 0.1f, 0.1f, 1.0f };
81 static GLfloat ambientBIS[] = { 0.8f, 0.8f, 0.8f, 0.8f };
82 static GLfloat diffuse[] = { 0.8f, 0.8f, 0.8f, 1.0f };
83 static GLfloat specular[] = { 0.8f, 0.8f, 0.8f, 1.0f };
84 static GLfloat shininess = 50.;
85 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientBIS);
86 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient);
87 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse);
88 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular);
89 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
92 glViewport(0, 0, width, height);
93 glMatrixMode(GL_PROJECTION);
111 if (pElement->
isA(
"TYGeometryNode"))
149 GLint polygon_mode[2];
150 glGetIntegerv(GL_POLYGON_MODE, polygon_mode);
155 glPolygonMode(GL_FRONT_AND_BACK, polygon_mode[0]);
169 glMatrixMode(GL_MODELVIEW);
174 glMatrixMode(GL_MODELVIEW);
189 for (
int il = 0; il <
_tabLights.size(); il++)
195 float colorSpec[] = { 0.0, 0.0, 0.0, 1.0 };
196 float colorShine[] = { 127.0 };
197 glMaterialfv(GL_FRONT, GL_SPECULAR, colorSpec);
198 glMaterialfv(GL_FRONT, GL_SHININESS, colorShine);
199 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
200 glEnable(GL_COLOR_MATERIAL);
203 glEnable(GL_LINE_SMOOTH);
205 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
206 glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
208 glEnable(GL_NORMALIZE);
209 glEnable(GL_DEPTH_TEST);
212 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
214 if (mode == GL_SELECT)
219 glGetFloatv(GL_PROJECTION_MATRIX, proj);
221 glGetIntegerv(GL_VIEWPORT, viewport);
223 glMatrixMode(GL_PROJECTION);
226 gluPickMatrix((GLdouble)x, (GLdouble)y, 5, 5, viewport);
229 glMatrixMode(GL_MODELVIEW);
233 glMatrixMode(GL_PROJECTION);
241 std::vector<TYElement*>::iterator iterElements;
250 pTYElementGraphic->
display(GL_COMPILE);
257 glMatrixMode(GL_MODELVIEW);
270 std::vector<OGLElement*>::iterator iter;
286 pGraphObj =
_pElement->getGraphicObject();
288 if (dynamic_cast<TYSiteNode*>(
_pElement) !=
nullptr)
291 if (pParent && pParent->
isA(
"TYProjet"))
293 pGraphObj = pParent->getGraphicObject();
297 glRotatef(-90.0, 1.0, 0.0, 0.0);
298 if (pGraphObj) { pGraphObj->
display(mode); }
304 bool _bFinded =
false;
305 std::vector<OGLElement*>::iterator iter;
336 std::vector<OGLElement*>::iterator iter;
337 bool _bFinded =
false;
352 bool _bFinded =
false;
353 std::vector<TYElement*>::iterator iter;
369 std::vector<TYElement*>::iterator iter;
370 bool _bFinded =
false;
bool GetADisplayList(GLuint &displayList)
GLuint _displayListOverlay
Display liste pour les deplacements.
void init(int width, int height)
void addOGLElement(OGLElement *pOGLElement)
TYGeometryNode * GetGeoNodeParent() const
double * _pBackgroundColor
void getPosition(double &x, double &y, double &z)
void updateDisplayList(void)
TYElement * _pElement
Element a representer.
classe graphique pour un GeometryNode
bool isA(const char *className) const
void drawElement(GLenum mode=GL_RENDER)
void setSize(int w, int h)
Realise le rendu VTK et le rendu OpenGL (fichier header)
TYElement * getParent() const
std::vector< OGLLightElement * > _tabLights
static OBox _globalBoundingBox
std::vector< OGLElement * > _tabOGLElement
std::vector< TYElement * > _tabSelectedElements
void updateDisplayListOverlay(TYGeometryNode *pElement, TYGeometryNode *pDansCeRepere)
void clearTabSelectedElement()
int OpenGLUpdateGeometry(GLenum mode=GL_RENDER, int x=0, int y=0)
static TYGeometryNode * GetGeoNode(TYElement *pElement)
void removeOGLElement(OGLElement *pOGLElement)
void removeSelectedElement(TYElement *pElement)
classe graphique pour un element de base
GLuint _displayList
Display liste globale.
void addSelectedElement(TYElement *pElement)
void addLight(OGLLightElement *pOGLElementLight)
void displayPushingParentMatrix(GLenum mode, TYGeometryNode *pDansCeRepere)
OGLCamera * _pActiveCamera
void OpenGLRender(GLenum mode=GL_RENDER, int x=0, int y=0)
void OpenGLDeviceRender(GLenum mode=GL_RENDER, int x=0, int y=0)
virtual void display(GLenum mode=GL_RENDER)
std::vector< OGLLightElement * > getLights()