Graphite Version 3
An experimental 3D geometry processing program
Loading...
Searching...
No Matches
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
51namespace 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
67 enum Transparency {
68 TRANSP_OPAQUE,
69 TRANSP_BLEND,
70 TRANSP_ACCUM
71 };
72
77 Shader(Grob* grob);
78
82 ~Shader() override;
83
89 virtual void draw();
90
101 virtual void pick_object(index_t object_id) = 0;
102
109 virtual void blink();
110
116 virtual void update();
117
118 gom_properties:
119
124 Grob* get_grob() const {
125 return grob();
126 }
127
131 virtual void set_transparency(Transparency x);
132
133 Transparency get_transparency() const {
134 return transparency_;
135 }
136
137 public:
138 GLdouble* latest_modelview() {
139 return modelview_;
140 }
141
142 GLdouble* latest_project() {
143 return project_;
144 }
145
146 GLint* latest_viewport() {
147 return viewport_;
148 }
149
155 bool dark_mode() const;
156
161 const std::string& name, const Any& value
162 ) override;
163
164 protected:
165
166
177 const std::string& file_name,
178 GLint filtering = GL_LINEAR, GLint wrapping = GL_CLAMP_TO_EDGE
179 );
180
188 const std::string& name,
189 GLint filtering = GL_LINEAR, GLint wrapping = GL_CLAMP_TO_EDGE
190 );
191
196 Grob* grob() const {
197 return grob_;
198 }
199
200
201 private:
202 Grob* grob_;
203
204 // Viewing parameters, queried when this object is drawn.
205 // Useful for picking or for drawing overlays.
206 GLdouble modelview_[16];
207 GLdouble project_[16];
208 GLint viewport_[4];
209
210 friend class ShaderManager;
211
212 protected:
219
220 Transparency transparency_;
221 };
222
227
228//_________________________________________________________
229
230}
231#endif
A smart pointer with reference-counted copy semantics.
A class that stores a variable of arbitrary type.
Definition any.h:62
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
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.
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....
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 draw()
Draws the Grob.
bool set_property(const std::string &name, const Any &value) override
Sets an individual property.
bool no_grob_update_
If true, then each shader update does not trigger a grob update.
Definition shader.h:218
bool dark_mode() const
Tests whether dark mode is set.
~Shader() override
Shader destructor.
Shader(Grob *grob)
Shader constructor.
Grob * grob() const
Gets the Grob.
Definition shader.h:196
virtual void set_transparency(Transparency x)
Transparent rendering mode.
virtual void update()
Redraws the scene.
An OpenGL texture.
Definition texture.h:56
geo_index_t index_t
The type for storing and manipulating indices.
Definition numeric.h:330
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.