-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathvtkOpenGLTextureImage.h
More file actions
143 lines (117 loc) · 4.73 KB
/
vtkOpenGLTextureImage.h
File metadata and controls
143 lines (117 loc) · 4.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*=========================================================================
Program: Visualization Toolkit
Module: $RCSfile: vtkOpenGLTextureImage.h,v $
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkOpenGLTextureImage - OpenGL actor
// .SECTION Description
// vtkOpenGLTextureImage is an interface between an vtkImageData and and
// an OpenGL 3D texture object.
// This is a work in progress, but when complete it should be possible
// to easily move data back and forth between C++/Python and GLSL
// to support volume rendering and computation when used with
// the vtkOpenGLShaderComputation class.
#ifndef __vtkOpenGLTextureImage_h
#define __vtkOpenGLTextureImage_h
#include "vtkOpenGLShaderComputation.h"
#include "vtkImageData.h"
#include "vtkAddon.h"
class VTK_ADDON_EXPORT vtkOpenGLTextureImage : public vtkObject
{
protected:
public:
static vtkOpenGLTextureImage *New();
vtkTypeMacro(vtkOpenGLTextureImage,vtkObject);
void PrintSelf(ostream& os, vtkIndent indent) override;
/* Explicitly deleted functions belong in the public interface */
vtkOpenGLTextureImage(const vtkOpenGLTextureImage&) = delete;
void operator=(const vtkOpenGLTextureImage&) = delete;
// Description:
// The ShaderComputation used to manage the OpenGL context and shaders
vtkGetObjectMacro(ShaderComputation, vtkOpenGLShaderComputation);
vtkSetObjectMacro(ShaderComputation, vtkOpenGLShaderComputation);
// Description:
// The image data that corresponds to the texture.
// Not all sizes and types of image data are supported, only
// those that map cleanly to textures. All are treated as
// 3D textures no matter the dimensions.
vtkGetObjectMacro(ImageData, vtkImageData);
vtkSetObjectMacro(ImageData, vtkImageData);
// Description:
// The id provided by glGenTextures.
// It is actually in integer that is
// an opaque mapping to a hardware structure.
// Non-zero means the texture has been generated.
// Exposed here for introspection.
vtkGetMacro(TextureName, vtkTypeUInt32);
// Description:
// True (default) to interpolate samples
vtkGetMacro(Interpolate, int);
vtkSetMacro(Interpolate, int);
// Description:
// Texture wrap mode (ClampToEdge, MirroredRepeat)
vtkGetMacro(TextureWrap, int);
vtkSetMacro(TextureWrap, int);
// Description:
// Make the image data available as GL_TEXTUREn
// where n is the texture unit. There are at least
// GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, which is variable
// by driver but must be at least 48.
// This method also checks the modification time of
// the image data to ensure the texture up to date and
// initiates the transfer if not.
void Activate(vtkTypeUInt32 unit);
// Description:
// Creates/transfers image data to texture if needed.
bool UpdateTexture();
// Description:
// Make the specified layer (slice) be the draw target.
// This is used to direct the output of the shading into
// the specified slice of the texture and can be used to
// implement volumetric algorithms. Iterated algorithms
// can be done fully on the GPU by swapping textures between
// active units and draw targets.
// Parameters:
// attachmentIndex is which color attachment to use (only valid for color)
// level is z slice to target
// attachment is 0 (color), 1 (depth), 2 (stencil), 3 (depth-stencil)
enum AttachmentPoints
{
ColorAttachmentPoint = 0,
DepthAttachmentPoint,
StencilAttachmentPoint,
DepthStencilAttachmentPoint
};
void AttachAsDrawTarget(int layer=0, int attachement=0, int attachmentIndex=0);
enum TextureWrap
{
ClampToEdge,
MirroredRepeat,
};
// Description:
// Read the texture data back into the image data
// (assumes it has been written as a target)
// Warning: probably best to only use this to read back into the same buffer that was used
// when the data was uploaded (i.e. this will assume that the vtkImageData buffer pointer
// is the right size for the data).
void ReadBack();
static vtkTypeUInt32 vtkScalarTypeToGLType(int vtk_scalar_type);
// Description:
// TODO: options for min and mag filter, wrapping...
protected:
vtkOpenGLTextureImage();
~vtkOpenGLTextureImage() override;
private:
vtkOpenGLShaderComputation *ShaderComputation;
vtkImageData *ImageData;
vtkTypeUInt32 TextureName;
int Interpolate;
unsigned long TextureMTime;
int TextureWrap;
};
#endif