1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkShaderDeviceAdapter2.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 * @class vtkShaderDeviceAdapter2 17 * @brief an adapter to pass generic vertex attributes 18 * to the rendering pipeline. 19 * .SECTION 20 * This class is an adapter used to pass generic vertex attributes to the 21 * rendering pipeline. Since this changes based on the shading language used, 22 * this class merely defines the API and subclasses provide implementations for 23 * Cg and GL. 24 */ 25 26 #ifndef vtkShaderDeviceAdapter2_h 27 #define vtkShaderDeviceAdapter2_h 28 29 #include "vtkRenderingCoreModule.h" // For export macro 30 #include "vtkObject.h" 31 32 class vtkShaderProgram2; 33 34 class VTKRENDERINGCORE_EXPORT vtkShaderDeviceAdapter2 : public vtkObject 35 { 36 public: 37 vtkTypeMacro(vtkShaderDeviceAdapter2, vtkObject); 38 void PrintSelf(ostream &os, vtkIndent indent) override; 39 40 /** 41 * Sends a single attribute to the graphics card. 42 * The attrname parameter identifies the name of attribute. 43 * The components parameter gives the number of 44 * components in the attribute. In general, components must be between 45 * 1-4, but a rendering system may impose even more constraints. The 46 * type parameter is a VTK type enumeration (VTK_FLOAT, VTK_INT, etc.). 47 * Again, a rendering system may not support all types for all 48 * attributes. The attribute parameter is the actual data for the 49 * attribute. 50 * If offset is specified, it is added to attribute pointer \c after 51 * it has been casted to the proper type. 52 */ 53 virtual void SendAttribute(const char* attrname, int components, int type, 54 const void* attribute, 55 unsigned long offset = 0) = 0; 56 57 /** 58 * Set the shader program which is being updated by this device adapter. 59 * The shader program is not reference counted to avoid reference loops. 60 */ SetShaderProgram(vtkShaderProgram2 * program)61 void SetShaderProgram(vtkShaderProgram2* program) 62 { this->ShaderProgram = program; } 63 vtkGetObjectMacro(ShaderProgram, vtkShaderProgram2) 64 65 // Description: 66 // This method is called before rendering. This gives the shader device 67 // adapter an opportunity to collect information, such as attribute indices 68 // that it will need while rendering. 69 virtual void PrepareForRender() = 0; 70 71 protected: 72 vtkShaderDeviceAdapter2(); 73 ~vtkShaderDeviceAdapter2() override; 74 75 vtkShaderProgram2* ShaderProgram; 76 77 private: 78 vtkShaderDeviceAdapter2(const vtkShaderDeviceAdapter2&) = delete; 79 void operator=(const vtkShaderDeviceAdapter2&) = delete; 80 81 }; 82 83 #endif 84