anatomist  5.1.2
3D neuroimaging data viewer
volrendershader.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 
35 #ifndef ANATOMIST_OBJECT_VOLRENDERSHADER_H
36 #define ANATOMIST_OBJECT_VOLRENDERSHADER_H
37 
40 
41 #if defined( GL_FRAMEBUFFER ) || defined( GL_FRAMEBUFFER_EXT )
42 
43 namespace anatomist
44 {
45  template<typename T> class AVolume;
46 
47 
48  class VolRenderShader : public ObjectVector, public GLComponent
49  {
50  public:
51  struct Private;
52 
54  virtual ~VolRenderShader();
55 
56  virtual bool render( PrimList &, const ViewState & );
57  virtual bool Is2DObject() { return true; }
58  virtual bool Is3DObject() { return false; }
59  virtual Tree* optionTree() const;
60  virtual bool CanRemove( AObject * ) { return false; }
61 
62  void createDefaultPalette( const std::string & name = "" );
63  virtual AObjectPalette* palette();
64  virtual const AObjectPalette* palette() const;
65  virtual void setPalette( const AObjectPalette &pal );
66  virtual Material & GetMaterial();
67  virtual const Material & material() const;
68  virtual const Material* glMaterial() const;
69  virtual void SetMaterial( const Material &mat );
70  virtual bool isTransparent() const;
71  virtual bool renderingIsObserverDependent() const;
72 
73  virtual void glSetChanged( glPart, bool = true ) const;
74  virtual void glSetTexImageChanged( bool = true, unsigned tex = 0 ) const;
75  virtual void glSetTexEnvChanged( bool = true, unsigned tex = 0 ) const;
76 
77  virtual const GLComponent* glAPI() const;
78  virtual GLComponent* glAPI();
79  virtual const AObjectPalette* glPalette( unsigned tex = 0 ) const;
80 
81  virtual unsigned glDimTex( const ViewState &, unsigned tex = 0 ) const;
82  virtual bool glMakeTexImage( const ViewState &state,
83  const GLTexture &gltex, unsigned tex ) const;
84  virtual bool glMakeBodyGLL( const ViewState &state,
85  const GLList &gllist ) const;
86  virtual const GLComponent::TexExtrema &
87  glTexExtrema( unsigned tex = 0 ) const;
88  virtual GLComponent::TexExtrema & glTexExtrema( unsigned tex = 0 );
89  virtual void update(const Observable* observable, void* arg);
90 
91  bool checkObject() const;
92  std::string shaderType() const;
93  bool setShaderType( const std::string & );
94 
95  static int classType();
96 
97  protected:
98  virtual std::string viewStateID( glPart part, const ViewState & ) const;
99 
101  static std::string loadShaderFile( const std::string& filename );
102  void genTextures();
104  void createRenderTextures( int width, int height );
105  void vertex( float x, float y, float z ) const;
106  void drawQuads( float x, float y, float z ) const;
107 
108  private:
109  Private *d;
110  };
111 
112 }
113 
114 
115 #endif
116 #endif
117 
118 
119 
Base Anatomist object (abstract)
Definition: Object.h:96
std::string name() const
Name shown in control window.
Definition: Object.h:165
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
This class has to be rewritten, it's really really a shame.......
Definition: Material.h:48
it's a list, in fact...
Definition: objectVector.h:212
This class can be subclassed to represent an object that the programmer wants to have observed.
Definition: Observable.h:68
virtual GLComponent * glAPI()
virtual bool isTransparent() const
virtual const AObjectPalette * glPalette(unsigned tex=0) const
virtual GLComponent::TexExtrema & glTexExtrema(unsigned tex=0)
void createRenderTextures(int width, int height)
virtual const AObjectPalette * palette() const
virtual bool renderingIsObserverDependent() const
true only if the rendering (openGL) of the object changes with the observer position/orientation of t...
virtual std::string viewStateID(glPart part, const ViewState &) const
Makes a unique ID from a viewstate.
VolRenderShader(AObject *vol)
virtual bool Is3DObject()
Can be display in 3D windows.
virtual bool CanRemove(AObject *)
void createDefaultPalette(const std::string &name="")
function called by getOrCreatePalette() - overloadable, need not be called directly
virtual bool glMakeBodyGLL(const ViewState &state, const GLList &gllist) const
If you want to make a non-standard GL display list for the body geometry, overload this function to f...
virtual void update(const Observable *observable, void *arg)
This class is an Observer of each of the AObject it groups.
void drawQuads(float x, float y, float z) 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.
void vertex(float x, float y, float z) const
virtual const Material & material() const
virtual const GLComponent::TexExtrema & glTexExtrema(unsigned tex=0) const
virtual Material & GetMaterial()
virtual Tree * optionTree() const
Menu tree for new options, see object/optionMatcher.h.
static std::string loadShaderFile(const std::string &filename)
virtual void glSetTexImageChanged(bool=true, unsigned tex=0) const
virtual void glSetTexEnvChanged(bool=true, unsigned tex=0) const
virtual const GLComponent * glAPI() const
virtual const Material * glMaterial() const
virtual void glSetChanged(glPart, bool=true) const
virtual bool render(PrimList &, const ViewState &)
rendering (generally 2D or 3D using OpenGL).
virtual void SetMaterial(const Material &mat)
bool setShaderType(const std::string &)
virtual AObjectPalette * palette()
Normally, getOrCreatePalette() should be used instead of this function in most cases.
virtual unsigned glDimTex(const ViewState &, unsigned tex=0) const
texture dimension (1, 2 [or 3])
virtual bool Is2DObject()
Can be display in 2D windows.
virtual void setPalette(const AObjectPalette &pal)
std::string shaderType() const
std::list< carto::rc_ptr< GLItem > > PrimList
Definition: Object.h:72
ViewState holds information about how a view wants to see an object.
Definition: viewstate.h:67