Graphite  Version 3
An experimental 3D geometry processing program
shader.h
Go to the documentation of this file.
1 /*
2  * OGF/Graphite: Geometry and Graphics Programming Library + Utilities
3  * Copyright (C) 2000 Bruno Levy
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  *
19  * If you modify this software, you should include a notice giving the
20  * name of the person performing the modification, the date of modification,
21  * and the reason for such modification.
22  *
23  * Contact: Bruno Levy
24  *
25  * levy@loria.fr
26  *
27  * ISA Project
28  * LORIA, INRIA Lorraine,
29  * Campus Scientifique, BP 239
30  * 54506 VANDOEUVRE LES NANCY CEDEX
31  * FRANCE
32  *
33  * Note that the GNU General Public License does not permit incorporating
34  * the Software into proprietary programs.
35  */
36 
37 #ifndef H_OGF_SCENE_GRAPH_GFX_SHADERS_SHADER_H
38 #define H_OGF_SCENE_GRAPH_GFX_SHADERS_SHADER_H
39 
40 #include <OGF/scene_graph_gfx/common/common.h>
42 #include <OGF/gom/types/node.h>
44 #include <geogram/image/image.h>
45 
51 namespace OGF {
52 
53 //_________________________________________________________
54 
55  class Grob;
56  class Node;
57 
63  gom_attribute(abstract,"true")
64  gom_class SCENE_GRAPH_GFX_API Shader : public Node {
65  public:
66 
71  Shader(Grob* grob);
72 
76  ~Shader() override;
77 
83  virtual void draw();
84 
95  virtual void pick_object(index_t object_id) = 0;
96 
103  virtual void blink();
104 
110  virtual void update();
111 
112  gom_properties:
113 
124  void set_multi(bool value);
125 
136  bool get_multi() const;
137 
142  Grob* get_grob() const {
143  return grob();
144  }
145 
146  public:
147  GLdouble* latest_modelview() {
148  return modelview_;
149  }
150 
151  GLdouble* latest_project() {
152  return project_;
153  }
154 
155  GLint* latest_viewport() {
156  return viewport_;
157  }
158 
164  bool dark_mode() const;
165 
166  protected:
167 
178  const std::string& file_name,
179  GLint filtering = GL_LINEAR, GLint wrapping = GL_CLAMP_TO_EDGE
180  );
181 
189  const std::string& name,
190  GLint filtering = GL_LINEAR, GLint wrapping = GL_CLAMP_TO_EDGE
191  );
192 
197  Grob* grob() const {
198  return grob_;
199  }
200 
201 
202  private:
203  Grob* grob_;
204  bool multi_;
205 
206  // Viewing parameters, queried when this object is drawn.
207  // Useful for picking or for drawing overlays.
208  GLdouble modelview_[16];
209  GLdouble project_[16];
210  GLint viewport_[4];
211 
212  friend class ShaderManager;
213 
214  protected:
221  };
222 
227 
228 //_________________________________________________________
229 
230 }
231 #endif
A smart pointer with reference-counted copy semantics.
Definition: smart_pointer.h:76
Base class for all 3D Graphite objects.
Definition: grob.h:68
A composite object in the GOM system.
Definition: node.h:58
Manages the Shader objects associated with a Grob.
Base class for Grob shader.
Definition: shader.h:64
virtual void pick_object(index_t object_id)=0
Draws the Grob in picking mode.
virtual void blink()
Draws the current object several times, while chaning the value of one graphic attribute (e....
Grob * get_grob() const
Gets the grob.
Definition: shader.h:142
virtual void draw()
Draws the Grob.
bool no_grob_update_
If true, then each shader update does not trigger a grob update.
Definition: shader.h:220
bool dark_mode() const
Tests whether dark mode is set.
~Shader() override
Shader destructor.
Shader(Grob *grob)
Shader constructor.
bool get_multi() const
Tests whether multi shader mode is active.
Texture * create_texture_from_colormap_name(const std::string &name, GLint filtering=GL_LINEAR, GLint wrapping=GL_CLAMP_TO_EDGE)
Creates a texture from a colormap by name.
Texture * create_texture_from_file(const std::string &file_name, GLint filtering=GL_LINEAR, GLint wrapping=GL_CLAMP_TO_EDGE)
Creates a texture from an image file.
virtual void update()
Redraws the scene.
Grob * grob() const
Gets the Grob.
Definition: shader.h:197
An OpenGL texture.
Definition: texture.h:56
geo_index_t index_t
The type for storing and manipulating indices.
Definition: numeric.h:329
Global Graphite namespace.
Definition: common.h:76
SmartPointer< Shader > Shader_var
An automatic reference-counted pointer to a Shader.
Definition: shader.h:226
The base class for all composite objects in the GOM system.
Helper class for manipulating OpenGL textures.