1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkOpenGLPainterDeviceAdapter.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 
24 // .NAME vtkOpenGLPainterDeviceAdapter - An adapter between a vtkPainter and a rendering device.
25 //
26 // .SECTION Description
27 //
28 // An adapter between vtkPainter and the OpenGL rendering system.  Only a
29 // handful of attributes with special meaning are supported.  The OpenGL
30 // attribute used for each attribute is given below.
31 //
32 // \verbatim
33 // vtkDataSetAttributes::NORMALS          glNormal
34 // vtkDataSetAttributes:::SCALARS         glColor
35 // vtkDataSetAttributes::TCOORDS          glTexCoord
36 // vtkDataSetAttributes::NUM_ATTRIBUTES   glVertex
37 // \endverbatim
38 //
39 
40 #ifndef vtkOpenGLPainterDeviceAdapter_h
41 #define vtkOpenGLPainterDeviceAdapter_h
42 
43 #include "vtkRenderingOpenGLModule.h" // For export macro
44 #include "vtkPainterDeviceAdapter.h"
45 
46 // To switch off deprecated warning about
47 // vtkPainterDeviceAdapter::MakeVertexEmphasisWithStencilCheck
48 #if defined(_MSC_VER)
49 #pragma warning(push)
50 #pragma warning(disable:4996)
51 #endif
52 
53 class VTKRENDERINGOPENGL_EXPORT vtkOpenGLPainterDeviceAdapter :
54   public vtkPainterDeviceAdapter
55 {
56 public:
57   vtkTypeMacro(vtkOpenGLPainterDeviceAdapter, vtkPainterDeviceAdapter);
58   static vtkOpenGLPainterDeviceAdapter *New();
59   virtual void PrintSelf(ostream &os, vtkIndent indent);
60 
61   // Description:
62   // Converts mode from VTK_* to GL_* and calls glBegin.
63   virtual void BeginPrimitive(int mode);
64 
65   // Description:
66   // Calls glEnd.
67   virtual void EndPrimitive();
68 
69   // Description:
70   // Returns if the given attribute type is supported by the device.
71   // Returns 1 is supported, 0 otherwise.
72   virtual int IsAttributesSupported(int attribute);
73 
74   // Description:
75   // Calls one of glVertex*, glNormal*, glColor*, or glTexCoord*.
76   virtual void SendAttribute(int index, int components, int type,
77                              const void *attribute, vtkIdType offset=0);
78 
79   // Description:
80   // Calls glMultiTex
81   virtual void SendMultiTextureCoords(int numcomp, int type, const void *attribute,
82                                       int idx, vtkIdType offset);
83 
84   // Description:
85   // Calls one of glVertexPointer, glNormalPointer, glColorPointer, or
86   // glTexCoordPointer.
87   virtual void SetAttributePointer(int index, int numcomponents, int type,
88                                    int stride, const void *pointer);
89 
90   // Description:
91   // Calls glEnableClientState or glDisableClientState.
92   virtual void EnableAttributeArray(int index);
93   virtual void DisableAttributeArray(int index);
94 
95   // Description:
96   // Calls glDrawArrays.  Mode is converted from VTK_* to GL_*.
97   virtual void DrawArrays(int mode, vtkIdType first, vtkIdType count);
98 
99   // Description:
100   // Calls glDrawElements.  Mode and type are converted from VTK_* to GL_*.
101   virtual void DrawElements(int mode, vtkIdType count, int type, void *indices);
102 
103   // Description:
104   // Returns true if renderer is a vtkOpenGLRenderer.
105   virtual int Compatible(vtkRenderer *renderer);
106 
107   // Description:
108   // @deprecated code that needs access directly to OpenGL state should
109   // manage it locally.
110   // Turns lighting on and off.
111   VTK_LEGACY(virtual void MakeLighting(int mode));
112 
113   // Description:
114   // @deprecated code that needs access directly to OpenGL state should
115   // manage it locally.
116   // Returns current lighting setting.
117   VTK_LEGACY(virtual int QueryLighting());
118 
119   // Description:
120   // @deprecated code that needs access directly to OpenGL state should
121   // manage it locally.
122   // Turns antialiasing on and off.
123   VTK_LEGACY(virtual void MakeMultisampling(int mode));
124 
125   // Description:
126   // @deprecated code that needs access directly to OpenGL state should
127   // manage it locally.
128   // Returns current antialiasing setting.
129   VTK_LEGACY(virtual int QueryMultisampling());
130 
131   // Description:
132   // @deprecated code that needs access directly to OpenGL state should
133   // manage it locally.
134   // Turns blending on and off.
135   VTK_LEGACY(virtual void MakeBlending(int mode));
136 
137   // Description:
138   // @deprecated code that needs access directly to OpenGL state should
139   // manage it locally.
140   // Returns current blending setting.
141   VTK_LEGACY(virtual int QueryBlending());
142 
143   // Description:
144   // Turns emphasis of vertices on or off for vertex selection.
145   // When emphasized verts are drawn nearer to the camera and are drawn
146   // larger than normal to make selection of them more reliable.
147   virtual void MakeVertexEmphasis(bool mode);
148 
149   // Description:
150   // Control use of the stencil buffer (for vertex selection).
151   virtual void Stencil(int on);
152   virtual void WriteStencil(vtkIdType value);
153   virtual void TestStencil(vtkIdType value);
154 
155 protected:
156   vtkOpenGLPainterDeviceAdapter();
157   ~vtkOpenGLPainterDeviceAdapter();
158 
159   double PointSize;
160   double RangeNear;
161   double RangeFar;
162   int MaxStencil;
163   bool Initialized;
164 private:
165   vtkOpenGLPainterDeviceAdapter(const vtkOpenGLPainterDeviceAdapter &);  // Not implemented.
166   void operator=(const vtkOpenGLPainterDeviceAdapter &);  // Not implemented.
167 };
168 
169 #if defined(_MSC_VER)
170 #pragma warning(pop)
171 #endif
172 
173 #endif
174