27 static const float ElementPickerTolerance = 0.01f;
33 displayList = glGenLists(1);
36 GLenum errorCode = glGetError();
37 const unsigned char* sError = gluErrorString(errorCode);
38 printf(
"Erreur OpenGL %d : %s\n", errorCode, sError);
73 glColor3f(1.0, 0.0, 0.0);
76 glEnable(GL_LIGHTING);
77 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
79 static GLfloat ambient[] = {0.1f, 0.1f, 0.1f, 1.0f};
80 static GLfloat ambientBIS[] = {0.8f, 0.8f, 0.8f, 0.8f};
81 static GLfloat diffuse[] = {0.8f, 0.8f, 0.8f, 1.0f};
82 static GLfloat specular[] = {0.8f, 0.8f, 0.8f, 1.0f};
83 static GLfloat shininess = 50.;
84 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientBIS);
85 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient);
86 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse);
87 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular);
88 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
90 glViewport(0, 0, width, height);
91 glMatrixMode(GL_PROJECTION);
109 if (pElement->
isA(
"TYGeometryNode"))
150 GLint polygon_mode[2];
151 glGetIntegerv(GL_POLYGON_MODE, polygon_mode);
156 glPolygonMode(GL_FRONT_AND_BACK, polygon_mode[0]);
167 glMatrixMode(GL_MODELVIEW);
172 glMatrixMode(GL_MODELVIEW);
186 for (
int il = 0; il <
_tabLights.size(); il++)
192 float colorSpec[] = {0.0, 0.0, 0.0, 1.0};
193 float colorShine[] = {127.0};
194 glMaterialfv(GL_FRONT, GL_SPECULAR, colorSpec);
195 glMaterialfv(GL_FRONT, GL_SHININESS, colorShine);
196 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
197 glEnable(GL_COLOR_MATERIAL);
200 glEnable(GL_LINE_SMOOTH);
202 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
203 glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
205 glEnable(GL_NORMALIZE);
206 glEnable(GL_DEPTH_TEST);
209 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
211 if (mode == GL_SELECT)
216 glGetFloatv(GL_PROJECTION_MATRIX, proj);
218 glGetIntegerv(GL_VIEWPORT, viewport);
220 glMatrixMode(GL_PROJECTION);
223 gluPickMatrix((GLdouble)x, (GLdouble)y, 5, 5, viewport);
226 glMatrixMode(GL_MODELVIEW);
230 glMatrixMode(GL_PROJECTION);
238 std::vector<TYElement*>::iterator iterElements;
248 if (*iterElements !=
nullptr)
251 if (pTYElementGraphic !=
nullptr)
262 glMatrixMode(GL_MODELVIEW);
275 std::vector<OGLElement*>::iterator iter;
291 pGraphObj =
_pElement->getGraphicObject();
296 if (pParent && pParent->
isA(
"TYProjet"))
298 pGraphObj = pParent->getGraphicObject();
302 glRotatef(-90.0, 1.0, 0.0, 0.0);
312 bool _bFinded =
false;
313 std::vector<OGLElement*>::iterator iter;
344 std::vector<OGLElement*>::iterator iter;
345 bool _bFinded =
false;
359 bool _bFinded =
false;
360 std::vector<TYElement*>::iterator iter;
376 std::vector<TYElement*>::iterator iter;
377 bool _bFinded =
false;
bool GetADisplayList(GLuint &displayList)
Realise le rendu VTK et le rendu OpenGL (fichier header)
void getPosition(double &x, double &y, double &z)
void setSize(int w, int h)
bool isA(const char *className) const
static OBox _globalBoundingBox
virtual void display(TYElement *pModelerElement=nullptr, GLenum mode=GL_RENDER)
TYElement * getParent() const
classe graphique pour un GeometryNode
void displayPushingParentMatrix(TYElement *pModelerElement, GLenum mode, TYGeometryNode *pDansCeRepere)
TYGeometryNode * GetGeoNodeParent() const
static TYGeometryNode * GetGeoNode(TYElement *pElement)
std::vector< TYElement * > _tabSelectedElements
Elements selectionnes.
void updateDisplayList(void)
void removeSelectedElement(TYElement *pElement)
void addLight(OGLLightElement *pOGLElementLight)
void updateDisplayListOverlay(TYGeometryNode *pElement, TYGeometryNode *pDansCeRepere)
void addOGLElement(OGLElement *pOGLElement)
void clearTabSelectedElement()
void removeOGLElement(OGLElement *pOGLElement)
TYElement * getModelerElement()
std::vector< OGLLightElement * > _tabLights
Liste des lumieres dans la scene 3D.
void OpenGLRender(GLenum mode=GL_RENDER, int x=0, int y=0)
GLuint _displayList
Display liste globale.
int OpenGLUpdateGeometry(GLenum mode=GL_RENDER, int x=0, int y=0)
void OpenGLDeviceRender(GLenum mode=GL_RENDER, int x=0, int y=0)
OGLCamera * _pActiveCamera
std::vector< OGLElement * > _tabOGLElement
double * _pBackgroundColor
std::vector< OGLLightElement * > getLights()
GLuint _displayListOverlay
Display liste pour les deplacements.
void setModelerElement(TYElement *pElement)
void init(int width, int height)
void drawElement(GLenum mode=GL_RENDER)
void addSelectedElement(TYElement *pElement)
TYElement * _pElement
Element a representer.
TYElement * _pModelerElement
0 --> render all, 1 --> render 2D, 2 --> render 3D