Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYOpenGLRenderer.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14  */
15 
27 #ifndef __TY_OPENGL_RENDERER__
28 #define __TY_OPENGL_RENDERER__
29 
30 #ifdef _WIN32
31  #include <windows.h>
32 #endif
33 #include <GL/gl.h>
34 #include <GL/glu.h>
35 
37 
39 
43 
44 class TYGeometryNode;
45 
51 {
52 
53 public:
54 private:
58  TYOpenGLRenderer(const TYOpenGLRenderer&); // Not implemented.
62  void operator=(const TYOpenGLRenderer&); // Not implemented.
63 
64 public:
69 
74 
78  void init(int width, int height);
79 
83  void updateDisplayList(void);
92  void updateDisplayListOverlay(TYGeometryNode* pElement, TYGeometryNode* pDansCeRepere);
93 
101  int OpenGLUpdateGeometry(GLenum mode = GL_RENDER, int x = 0, int y = 0);
102 
110  void OpenGLDeviceRender(GLenum mode = GL_RENDER, int x = 0, int y = 0);
111 
119  void OpenGLRender(GLenum mode = GL_RENDER, int x = 0, int y = 0);
120 
125  void Render();
126 
131  {
132  _pElement = pElt;
133  }
134 
139  {
140  _pElement->deepCopy(pElt);
141  }
142 
147  {
148  return _pElement;
149  }
150 
154  void drawElement(GLenum mode = GL_RENDER);
155 
161  void addOGLElement(OGLElement* pOGLElement);
162 
163  void addLight(OGLLightElement* pOGLElementLight);
164  void removeLights();
165  std::vector<OGLLightElement*> getLights();
166 
167  void setActiveCamera(OGLCamera* pCamera)
168  {
169  _pActiveCamera = pCamera;
170  };
172  {
173  return _pActiveCamera;
174  };
175 
176  void setBackground(double* bgColor)
177  {
178  _pBackgroundColor[0] = bgColor[0];
179  _pBackgroundColor[1] = bgColor[1];
180  _pBackgroundColor[2] = bgColor[2];
181  };
182 
188  void removeOGLElement(OGLElement* pOGLElement);
189 
190  void setRenderType(int renderType)
191  {
192  m_renderType = renderType;
193  };
194 
195  void addSelectedElement(TYElement* pElement);
196  void removeSelectedElement(TYElement* pElement);
198  void setModelerElement(TYElement* pElement);
200 
201 protected:
204 
206  GLuint _displayList;
211 
212  std::vector<OGLElement*> _tabOGLElement;
213 
215  std::vector<TYElement*> _tabSelectedElements;
216 
218  std::vector<OGLLightElement*> _tabLights;
219 
222  int m_width;
223  int m_height;
224 
226 
230 };
231 
232 #endif // __TY_OPENGL_RENDERER__
All base classes related to 3D manipulation.
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYElement.cpp:307
Realise le rendu VTK et le rendu OpenGL.
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 removeOGLElement(OGLElement *pOGLElement)
TYOpenGLRenderer(const TYOpenGLRenderer &)
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.
void setBackground(double *bgColor)
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
GLuint _polygoneMode
Mode de rendu.
std::vector< OGLElement * > _tabOGLElement
double * _pBackgroundColor
void setRenderType(int renderType)
std::vector< OGLLightElement * > getLights()
GLuint _displayListOverlay
Display liste pour les deplacements.
void setActiveCamera(OGLCamera *pCamera)
void deepCopyElement(LPTYElement pElt)
void setModelerElement(TYElement *pElement)
LPTYElement getElement()
void setElement(LPTYElement pElt)
void init(int width, int height)
OGLCamera * getActiveCamera()
void operator=(const TYOpenGLRenderer &)
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