VTK  9.7.20260712
vtkOpenGLArrayTextureBufferAdapter.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
27
28#ifndef vtkOpenGLArrayTextureBufferAdapter_h
29#define vtkOpenGLArrayTextureBufferAdapter_h
30
31#include "vtkDataArray.h"
33#include "vtkRenderingOpenGL2Module.h"
34#include "vtkSmartPointer.h"
35#include "vtkTextureObject.h"
36#include "vtkWindow.h"
37
38#include <cstddef> // for std::size_t
39#include <vector>
40
41VTK_ABI_NAMESPACE_BEGIN
43
44class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLArrayTextureBufferAdapter
45{
46public:
47 std::vector<vtkSmartPointer<vtkDataArray>> Arrays;
54
57 vtkDataArray* array, bool asScalars, bool* integerTexture = nullptr);
60 const vtkOpenGLArrayTextureBufferAdapter&) = default;
61
62 void Upload(vtkOpenGLRenderWindow* renderWindow, bool force = false);
63
65
67
74 void SetUploaded(bool uploaded) { this->Uploaded = uploaded; }
75 bool GetUploaded() const { return this->Uploaded; }
77
79
88 void SetOwnsTexture(bool ownsTexture) { this->OwnsTexture = ownsTexture; }
89 bool GetOwnsTexture() const { return this->OwnsTexture; }
91
93
101 void SetPendingReset(bool pendingReset) { this->PendingReset = pendingReset; }
102 bool GetPendingReset() const { return this->PendingReset; }
104
105private:
113 void UploadImpl(vtkOpenGLRenderWindow* renderWindow);
114
116 struct NarrowedArrayInfo
117 {
118 std::size_t ByteLength = 0;
119 vtkIdType TexelCount = 0;
120 int NumComps = 0;
121 int Vtktype = 0;
122 };
123
128 NarrowedArrayInfo AppendNarrowed(vtkDataArray* array, std::vector<unsigned char>& dest) const;
129
132 struct SubArrayUpload
133 {
134 const void* SourceId = nullptr;
135 vtkMTimeType MTime = 0;
136 std::size_t ByteOffset = 0;
137 std::size_t ByteLength = 0;
138 vtkIdType TexelOffset = 0;
139 vtkIdType TexelCount = 0;
140 };
141 struct UploadedLayout
142 {
143 std::vector<SubArrayUpload> Subs;
144 std::size_t TotalBytes = 0;
145 vtkIdType TotalTuples = 0;
146 int NumComps = 0;
147 int Vtktype = 0;
148 bool Scalars = false;
149 bool Valid = false;
150 };
151 UploadedLayout LastUpload;
153 bool Uploaded = false;
155 bool OwnsTexture = true;
157 bool PendingReset = false;
158};
159
160VTK_ABI_NAMESPACE_END
161#endif
162// Need to skip header testing since we do not inherit vtkObject:
163// VTK-HeaderTest-Exclude: vtkOpenGLArrayTextureBufferAdapter.h
void SetPendingReset(bool pendingReset)
Get/set the pending-reset flag used to recycle an adapter across rebuild cycles.
void Upload(vtkOpenGLRenderWindow *renderWindow, bool force=false)
void ReleaseGraphicsResources(vtkWindow *window)
bool GetUploaded() const
Get/set the "already uploaded" guard.
bool GetOwnsTexture() const
Get/set who owns this adapter's Texture/Buffer.
vtkOpenGLArrayTextureBufferAdapter(const vtkOpenGLArrayTextureBufferAdapter &)=default
vtkOpenGLArrayTextureBufferAdapter & operator=(const vtkOpenGLArrayTextureBufferAdapter &)=default
std::vector< vtkSmartPointer< vtkDataArray > > Arrays
vtkOpenGLArrayTextureBufferAdapter(vtkDataArray *array, bool asScalars, bool *integerTexture=nullptr)
void SetOwnsTexture(bool ownsTexture)
Get/set who owns this adapter's Texture/Buffer.
void SetUploaded(bool uploaded)
Get/set the "already uploaded" guard.
vtkSmartPointer< vtkOpenGLBufferObject > Buffer
bool GetPendingReset() const
Get/set the pending-reset flag used to recycle an adapter across rebuild cycles.
OpenGL rendering window.
Hold a reference to a vtkObjectBase instance.
window superclass for vtkRenderWindow
Definition vtkWindow.h:62
@ Valid
Cell is in a good state.
#define vtkDataArray
int vtkIdType
Definition vtkType.h:363
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:318