Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gpugeometry.h
Go to the documentation of this file.
1 /*
2  This file is part of Mitsuba, a physically based rendering system.
3 
4  Copyright (c) 2007-2014 by Wenzel Jakob and others.
5 
6  Mitsuba is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License Version 3
8  as published by the Free Software Foundation.
9 
10  Mitsuba 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, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #pragma once
20 #if !defined(__MITSUBA_HW_GPUGEOMETRY_H_)
21 #define __MITSUBA_HW_GPUGEOMETRY_H_
22 
23 #include <mitsuba/hw/renderer.h>
24 
26 
27 class Shader;
28 
29 /** \brief Abstract geometry storage on a graphics card
30  * \ingroup libhw
31  */
33 public:
34  /// Create an empty geometry object
35  GPUGeometry(const TriMesh *mesh);
36 
37  /// Return the name of this geometry object
38  inline std::string getName() const { return m_mesh->getName(); }
39 
40  /// Return the associated triangle mesh
41  inline const TriMesh *getTriMesh() const { return m_mesh.get(); }
42 
43  /// Upload the geometry object
44  virtual void init() = 0;
45 
46  /// Refresh (re-upload) the geometry object
47  virtual void refresh() = 0;
48 
49  /// Bind the geometry object
50  virtual void bind() = 0;
51 
52  /// Unbind the geometry object
53  virtual void unbind() = 0;
54 
55  /// Free the geometry object from GPU memory
56  virtual void cleanup() = 0;
57 
58  /// Return an (auxiliary) shader instance associated with the geometry
59  inline Shader *getShader() { return m_shader; }
60 
61  /// Return an (auxiliary) shader instance associated with the geometry
62  inline const Shader *getShader() const { return m_shader; }
63 
64  /// Set an (auxiliary) shader instance associated with the geometry
65  inline void setShader(Shader *shader) { m_shader = shader; }
66 
67  /// Return a string representation
68  std::string toString() const;
69 
71 protected:
72  /// Virtual destructor
73  virtual ~GPUGeometry();
74 protected:
75  ref<const TriMesh> m_mesh;
76  Shader *m_shader;
77 };
78 
80 
81 #endif /* __MITSUBA_HW_GPUGEOMETRY_H_ */
std::string getName() const
Return the name of this geometry object.
Definition: gpugeometry.h:38
const Shader * getShader() const
Return an (auxiliary) shader instance associated with the geometry.
Definition: gpugeometry.h:62
Abstract triangle mesh base class.
Definition: trimesh.h:68
void setShader(Shader *shader)
Set an (auxiliary) shader instance associated with the geometry.
Definition: gpugeometry.h:65
Shader base class for use with a VPL-style renderer.
Definition: shader.h:54
#define MTS_EXPORT_HW
Definition: platform.h:114
Shader * getShader()
Return an (auxiliary) shader instance associated with the geometry.
Definition: gpugeometry.h:59
#define MTS_NAMESPACE_BEGIN
Definition: platform.h:137
#define MTS_DECLARE_CLASS()
This macro must be used in the initial definition in classes that derive from Object.
Definition: class.h:158
Reference counting helper.
Definition: ref.h:40
Abstract geometry storage on a graphics card.
Definition: gpugeometry.h:32
Parent of all Mitsuba classes.
Definition: object.h:38
virtual std::string toString() const
Return a human-readable string representation of the object&#39;s contents.
#define MTS_NAMESPACE_END
Definition: platform.h:138
const TriMesh * getTriMesh() const
Return the associated triangle mesh.
Definition: gpugeometry.h:41