H3D API  2.4.1
ShaderProgram.h
Go to the documentation of this file.
1 // Copyright 2004-2019, SenseGraphics AB
3 //
4 // This file is part of H3D API.
5 //
6 // H3D API is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // H3D API is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with H3D API; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // A commercial license is also available. Please contact us at
21 // www.sensegraphics.com for more information.
22 //
23 //
27 //
29 #ifndef __SHADERPROGRAM_H__
30 #define __SHADERPROGRAM_H__
31 
32 #include <H3D/X3DNode.h>
33 #include <H3D/X3DUrlObject.h>
36 #include <H3D/SFString.h>
37 
38 #ifdef HAVE_CG
39 #include <GL/glew.h>
40 #include <Cg/cg.h>
41 #include <Cg/cgGL.h>
42 #endif
43 
44 namespace H3D {
45 
64  class H3DAPI_API ShaderProgram :
65  public X3DNode,
66  public X3DUrlObject,
68  public H3DDisplayListObject {
69  public:
70 
72  ShaderProgram( Inst< SFNode > _metadata = 0,
73  Inst< DisplayList > _displayList = 0,
74  Inst< MFString > _url = 0,
75  Inst< SFString > _type = 0 );
76 
77 #ifdef HAVE_CG
79  virtual ~ShaderProgram();
80 
82  virtual void enableCGShaderProgram();
83 
85  virtual void disableCGShaderProgram();
86 
88  virtual void initCGShaderProgram();
89 
91  virtual void destroyCGShaderProgram();
92 
96  virtual void setCGProfile( const string &profile );
97 
99  virtual void render();
100 
103  virtual bool addField( const string &_name,
104  const Field::AccessType &access,
105  Field *field );
106 #endif
107 
110  virtual string defaultXMLContainerField() {
111  return "programs";
112  }
113 
120  H3DUniquePtr< SFString > type;
121 
124 
125  protected:
126 #ifdef HAVE_CG
127  CGprofile cg_profile;
128  CGcontext cg_context;
129  CGprogram cg_program;
130  string cg_profile_string;
131  string source_url;
132 #endif
133  };
134 }
135 
136 #endif
137 
Header file for H3DDisplayListObject.
Contains the SFString field class.
Header file for X3DNode, X3D scene-graph node.
Header file for X3DProgrammableShaderObject.
Header file for X3DUrlObject, X3D scene-graph node.
The Field class.
Definition: Field.h:46
AccessType
The different access types that a field can have.
Definition: Field.h:53
This abstract interface class is the base class for all node types that wants to create an OpenGL dis...
Definition: H3DDisplayListObject.h:54
The ShaderProgram node provides the source and interface to a self contained program that occupies on...
Definition: ShaderProgram.h:68
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: ShaderProgram.h:123
virtual string defaultXMLContainerField()
Returns the default xml containerField attribute value.
Definition: ShaderProgram.h:110
H3DUniquePtr< SFString > type
The type field indicates whether this object shall be compiled as a vertex shader,...
Definition: ShaderProgram.h:120
This abstract node type is the base type for all nodes in the X3D system.
Definition: X3DNode.h:65
This abstract node type is the base type for all node types that specify arbitrary fields for interfa...
Definition: X3DProgrammableShaderObject.h:64
This abstract interface is inherited by all nodes that contain data located on the World Wide Web,...
Definition: X3DUrlObject.h:51
H3D API namespace.
Definition: Anchor.h:38
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194