VTK
vtkShaderProgram.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkShaderProgram.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*
16  * Copyright 2004 Sandia Corporation.
17  * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
18  * license for use of this work by or on behalf of the
19  * U.S. Government. Redistribution and use in source and binary forms, with
20  * or without modification, are permitted provided that this Notice and any
21  * statement of authorship are reproduced on all copies.
22  */
23 
52 #ifndef __vtkShaderProgram_h
53 #define __vtkShaderProgram_h
54 
55 #include "vtkObject.h"
56 
57 class vtkActor;
58 class vtkCollection;
60 class vtkRenderer;
61 class vtkRenderWindow;
62 class vtkShader;
63 class vtkWindow;
64 class vtkXMLMaterial;
66 
67 // manages all shaders defined in the XML file
68 // especially the part about sending things to the card
70 {
71 public:
72  vtkTypeMacro(vtkShaderProgram, vtkObject);
73  void PrintSelf(ostream &os, vtkIndent indent);
74 
75  // .Description:
76  // Accessors for the Material.
77  vtkGetObjectMacro( Material, vtkXMLMaterial);
78  virtual void SetMaterial( vtkXMLMaterial* );
79 
80  // .Description:
81  // Add shaders. Returns the index of the shader.
82  int AddShader(vtkShader* shader);
83 
85  void RemoveShader(int index);
86 
88  void RemoveShader(vtkShader* shader);
89 
91  vtkCollectionIterator* NewShaderIterator();
92 
94  int GetNumberOfShaders();
95 
96  // .Description
97  // This static function creates concrete shaders of a specific type. This is
98  // used to create a shader of the langauge specified in the XML file.
99  static vtkShaderProgram* CreateShaderProgram( int type );
100 
101  // .Description
102  // Read the material file to get necessary shader info. Synchronize with
103  // delegate shaders.
104  virtual void ReadMaterial();
105 
106  // .Description
107  // Load, compile, install and initialize shaders. These operations may
108  // be delegated to the shaders themselves or handled in descendants of
109  // this class.
110  virtual void Render( vtkActor*, vtkRenderer* )=0;
111 
113 
117  virtual void AddShaderVariable(const char* name, int numVars, int* x);
118  virtual void AddShaderVariable(const char* name, int numVars, float* x);
119  virtual void AddShaderVariable(const char* name, int numVars, double* x);
121 
123  virtual void PostRender(vtkActor*, vtkRenderer*);
124 
128  virtual void ReleaseGraphicsResources(vtkWindow *);
129 
131 
133  vtkGetObjectMacro(ShaderDeviceAdapter, vtkShaderDeviceAdapter);
135 
136 protected:
138  ~vtkShaderProgram();
139 
143 
144  vtkSetMacro(GLExtensionsLoaded, int);
145  vtkGetMacro(GLExtensionsLoaded, int);
146  int GLExtensionsLoaded;
147  virtual void LoadExtensions(vtkRenderWindow*) {}
148 
149  // Subclasses must set the shader device apater of the right type.
150  void SetShaderDeviceAdapter(vtkShaderDeviceAdapter*);
151 
153 
155  virtual vtkShader* NewShader() =0;
156 private:
157  vtkShaderProgram(const vtkShaderProgram&); // Not Implemented
158  void operator=(const vtkShaderProgram&); // Not Implemented
160 
161  vtkShaderDeviceAdapter* ShaderDeviceAdapter;
162 };
163 #endif //__vtkShaderProgram_h
encapsulates a VTK Material description.
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:49
vtkCollection * ShaderCollection
abstract base class for most VTK objects
Definition: vtkObject.h:60
vtkCollectionIterator * ShaderCollectionIterator
abstract specification for renderers
Definition: vtkRenderer.h:69
an adapter to pass generic vertex attributes to the rendering pipeline. .SECTION This class is an ada...
vtkXMLMaterial * Material
window superclass for vtkRenderWindow
Definition: vtkWindow.h:35
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:37
virtual void LoadExtensions(vtkRenderWindow *)
#define VTK_RENDERING_EXPORT
iterator through a vtkCollection.
create a window for renderers to draw into
create and manipulate unsorted lists of objects
Definition: vtkCollection.h:51