anatomist  5.1.2
3D neuroimaging data viewer
glmobject.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 #ifndef ANA_MOBJECT_GLMOBJECT_H
35 #define ANA_MOBJECT_GLMOBJECT_H
36 
39 
40 namespace anatomist
41 {
42  class Shader;
43 
49  class GLMObject : public MObject, public GLComponent
50  {
51  public:
53  virtual ~GLMObject();
54 
55  virtual const GLComponent* glAPI() const { return this; }
56  virtual GLComponent* glAPI() { return this; }
57 
58  virtual const Material *glMaterial() const;
59  virtual Material & GetMaterial();
60  virtual const Material & material() const;
61  virtual const AObjectPalette* glPalette( unsigned tex = 0 ) const;
62  virtual void update( const Observable*, void* );
63  virtual bool render( PrimList &, const ViewState & vs );
64 
65  virtual void glSetChanged( glPart, bool x = true ) const;
66  virtual void glClearHasChangedFlags() const;
67  virtual unsigned glNumVertex( const ViewState & ) const;
68  virtual const GLfloat* glVertexArray( const ViewState & ) const;
70  virtual const GLfloat* glNormalArray( const ViewState & ) const;
71  virtual unsigned glPolygonSize( const ViewState & ) const;
72  virtual unsigned glNumPolygon( const ViewState & ) const;
74  virtual const GLuint* glPolygonArray( const ViewState & ) const;
75 
76  virtual void glSetTexImageChanged( bool x = true, unsigned tex = 0 ) const;
77  virtual void glSetTexEnvChanged( bool x = true, unsigned tex = 0 ) const;
78  virtual TexInfo & glTexInfo( unsigned tex = 0 ) const;
79  virtual const TexExtrema & glTexExtrema( unsigned tex = 0 ) const;
80  virtual TexExtrema & glTexExtrema( unsigned tex = 0 );
81  virtual unsigned glNumTextures() const;
82  virtual unsigned glNumTextures( const ViewState & ) const;
83  virtual glTextureMode glTexMode( unsigned tex = 0 ) const;
84  virtual void glSetTexMode( glTextureMode mode, unsigned tex = 0 );
85  virtual float glTexRate( unsigned tex = 0 ) const;
86  virtual void glSetTexRate( float rate, unsigned tex = 0 );
87  virtual glTextureFiltering glTexFiltering( unsigned tex = 0 ) const;
88  virtual void glSetTexFiltering( glTextureFiltering x, unsigned tex = 0 );
89  virtual void glSetTexRGBInterpolation( bool x, unsigned tex = 0 );
90  virtual bool glTexRGBInterpolation( unsigned tex = 0 ) const;
91  virtual glAutoTexturingMode glAutoTexMode( unsigned tex = 0 ) const;
93  unsigned tex = 0 );
94  virtual const float *glAutoTexParams( unsigned coord = 0,
95  unsigned tex = 0 ) const;
96  virtual void glSetAutoTexParams( const float* params, unsigned coord = 0,
97  unsigned tex = 0 );
98  virtual bool glTexImageChanged( unsigned tex = 0 ) const;
99  virtual bool glTexEnvChanged( unsigned tex = 0 ) const;
100  virtual unsigned glDimTex( const ViewState &, unsigned tex = 0 ) const;
101  virtual unsigned glTexCoordSize( const ViewState &,
102  unsigned tex = 0 ) const;
103  virtual const GLfloat* glTexCoordArray( const ViewState &,
104  unsigned tex = 0 ) const;
105 
106  virtual bool glMakeTexImage( const ViewState & state,
107  const GLTexture & gltex, unsigned tex ) const;
108  virtual bool glMakeTexEnvGLL( const ViewState & state,
109  const GLList & gllist, unsigned tex ) const;
110  virtual void glSetMaterialGLL( const std::string & state, RefGLItem x );
111  virtual void glSetTexNameGLL( const std::string & state, RefGLItem x,
112  unsigned tex = 0 );
113  virtual GLPrimitives glMaterialGLL( const ViewState & state ) const;
115  unsigned tex = 0 ) const;
116  virtual GLPrimitives glTexEnvGLL( const ViewState &,
117  unsigned tex = 0 ) const;
118  virtual void glGarbageCollector( int nkept = -1 );
119 /* virtual void glBeforeBodyGLL( const ViewState & state,
120  GLPrimitives & pl ) const;
121  virtual void glAfterBodyGLL( const ViewState & state,
122  GLPrimitives & pl ) const;*/
124  virtual const AObjectPalette* palette() const;
125 
126  // new functions
127  virtual GLComponent* glGeometry( const ViewState & );
128  virtual GLComponent* glTexture( const ViewState & , unsigned n = 0 );
129  virtual const GLComponent* glGeometry( const ViewState & ) const;
130  virtual const GLComponent* glTexture( const ViewState & ,
131  unsigned n = 0 ) const;
132  virtual std::string viewStateID( glPart part, const ViewState & ) const;
133  virtual void setShaderParameters(const Shader &shader, const ViewState & state) const;
134 
135  protected:
138  virtual bool glToRef( const Referential* objref, GLPrimitives & pl ) const;
139 
140  private:
141  struct Private;
142  Private *d;
143  };
144 
145 }
146 
147 
148 #endif
149 
150 
Base class for all OpenGL objects in Anatomist (with OpenGL display lists)
Definition: glcomponent.h:67
glPart
GL object parts, each driving a GL list.
Definition: glcomponent.h:114
A Multi-object with OpenGL rendering capabilities.
Definition: glmobject.h:50
virtual glAutoTexturingMode glAutoTexMode(unsigned tex=0) const
virtual glTextureFiltering glTexFiltering(unsigned tex=0) const
virtual void glSetTexEnvChanged(bool x=true, unsigned tex=0) const
virtual TexInfo & glTexInfo(unsigned tex=0) const
virtual GLComponent * glTexture(const ViewState &, unsigned n=0)
virtual const GLfloat * glNormalArray(const ViewState &) const
normals array (optional), default=0 (no normals, flat shaded faces)
virtual void glSetTexFiltering(glTextureFiltering x, unsigned tex=0)
virtual AObjectPalette * palette()
Normally, getOrCreatePalette() should be used instead of this function in most cases.
virtual const Material * glMaterial() const
virtual void glSetTexNameGLL(const std::string &state, RefGLItem x, unsigned tex=0)
virtual unsigned glNumPolygon(const ViewState &) const
virtual void setShaderParameters(const Shader &shader, const ViewState &state) const
virtual void update(const Observable *, void *)
This class is an Observer of each of the AObject it groups.
virtual void glSetTexRate(float rate, unsigned tex=0)
virtual GLPrimitives glTexEnvGLL(const ViewState &, unsigned tex=0) const
virtual const GLuint * glPolygonArray(const ViewState &) const
number of vertices per polygon (default = 3: triangles)
virtual GLComponent * glGeometry(const ViewState &)
virtual unsigned glNumTextures(const ViewState &) const
virtual unsigned glNumVertex(const ViewState &) const
virtual Material & GetMaterial()
virtual bool glTexImageChanged(unsigned tex=0) const
virtual const GLfloat * glTexCoordArray(const ViewState &, unsigned tex=0) const
virtual bool glToRef(const Referential *objref, GLPrimitives &pl) const
get to geometry object referential before drawing.
virtual float glTexRate(unsigned tex=0) const
virtual void glSetAutoTexParams(const float *params, unsigned coord=0, unsigned tex=0)
virtual void glSetAutoTexMode(glAutoTexturingMode mode, unsigned tex=0)
virtual bool render(PrimList &, const ViewState &vs)
rendering (generally 2D or 3D using OpenGL).
virtual void glSetTexImageChanged(bool x=true, unsigned tex=0) const
virtual GLPrimitives glTexNameGLL(const ViewState &, unsigned tex=0) const
virtual const GLfloat * glVertexArray(const ViewState &) const
virtual const float * glAutoTexParams(unsigned coord=0, unsigned tex=0) const
virtual bool glMakeTexImage(const ViewState &state, const GLTexture &gltex, unsigned tex) const
If you make non-standard textures (ie not from a palette), overload this function to fill gltex.
virtual TexExtrema & glTexExtrema(unsigned tex=0)
virtual bool glTexRGBInterpolation(unsigned tex=0) const
virtual const AObjectPalette * palette() const
virtual GLComponent * glAPI()
Definition: glmobject.h:56
virtual void glClearHasChangedFlags() const
virtual const Material & material() const
virtual const TexExtrema & glTexExtrema(unsigned tex=0) const
virtual glTextureMode glTexMode(unsigned tex=0) const
virtual unsigned glNumTextures() const
virtual void glSetTexRGBInterpolation(bool x, unsigned tex=0)
virtual void glSetTexMode(glTextureMode mode, unsigned tex=0)
virtual void glSetMaterialGLL(const std::string &state, RefGLItem x)
virtual void glSetChanged(glPart, bool x=true) const
virtual bool glMakeTexEnvGLL(const ViewState &state, const GLList &gllist, unsigned tex) const
virtual const AObjectPalette * glPalette(unsigned tex=0) const
virtual const GLComponent * glTexture(const ViewState &, unsigned n=0) const
virtual std::string viewStateID(glPart part, const ViewState &) const
Makes a unique ID from a viewstate.
virtual void glGarbageCollector(int nkept=-1)
Frees unused display lists.
virtual unsigned glTexCoordSize(const ViewState &, unsigned tex=0) const
texture array size (must be >= numVertex to work), defalut=0
virtual GLPrimitives glMaterialGLL(const ViewState &state) const
virtual const GLComponent * glGeometry(const ViewState &) const
virtual bool glTexEnvChanged(unsigned tex=0) const
virtual const GLComponent * glAPI() const
Definition: glmobject.h:55
virtual unsigned glPolygonSize(const ViewState &) const
number of vertices per polygon (default = 3: triangles)
virtual unsigned glDimTex(const ViewState &, unsigned tex=0) const
texture dimension (1, 2 [or 3])
Multi-object : base abstract class for objects that contain others.
Definition: MObject.h:235
This class has to be rewritten, it's really really a shame.......
Definition: Material.h:48
This class can be subclassed to represent an object that the programmer wants to have observed.
Definition: Observable.h:68
Referential: marker for transformations, with an associated color.
Definition: Referential.h:55
std::list< carto::rc_ptr< GLItem > > PrimList
Definition: Object.h:72
std::list< RefGLItem > GLPrimitives
Definition: primitive.h:156
ViewState holds information about how a view wants to see an object.
Definition: viewstate.h:67