MCPcopy Create free account
hub / github.com/Kitware/VTK / Upload

Method Upload

Rendering/OpenGL2/vtkOpenGLArrayTextureBufferAdapter.cxx:39–158  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

37
38//------------------------------------------------------------------------------
39void vtkOpenGLArrayTextureBufferAdapter::Upload(vtkOpenGLRenderWindow* renderWindow, bool force)
40{
41 if ((this->Buffer && this->Buffer->IsReady()) && !force)
42 {
43 // We don't need to re-upload.
44 return;
45 }
46 if (this->Arrays.empty())
47 {
48 // There are no arrays to upload.
49 return;
50 }
51 if (this->Buffer == nullptr)
52 {
53 // We need to create the buffer.
54 this->Buffer = vtkSmartPointer<vtkOpenGLBufferObject>::New();
55 this->Buffer->SetType(this->BufferType);
56 }
57 if (this->Texture == nullptr)
58 {
59 // We need to create the texture.
60 this->Texture = vtkSmartPointer<vtkTextureObject>::New();
61 this->Texture->SetRequireTextureInteger(this->IntegerTexture);
62 this->Texture->SetContext(renderWindow);
63 }
64 std::size_t nbytes = 0;
65 vtkIdType numberOfTuples = 0;
66 int numberOfComponents = 0;
67 int vtktype = 0;
68 std::vector<vtkSmartPointer<vtkDataArray>> arraysToUpload;
69 // 1. Prepare a list of arrays to upload, also figuring out the size of the huge buffer
70 // allocation.
71 for (auto& actualArray : this->Arrays)
72 {
73 auto array = actualArray;
74 // Narrow arrays of large values to a precision supported by base-OpenGL:
75 switch (array->GetDataType())
76 {
77 case VTK_DOUBLE:
78 {
79 array = vtkSmartPointer<vtkFloatArray>::New();
80 array->DeepCopy(actualArray);
81 }
82 break;
83 case VTK_ID_TYPE:
84 {
85 // FIXME: We should check that truncating to 32 bits is OK.
86 array = vtkSmartPointer<vtkTypeInt32Array>::New();
87#if VTK_ID_TYPE_IMPL == VTK_INT
88 array->ShallowCopy(actualArray);
89#else
90 array->DeepCopy(actualArray);
91#endif
92 }
93 break;
94#if VTK_TYPE_UINT64 == VTK_UNSIGNED_LONG
95 case VTK_LONG:
96 {

Callers

nothing calls this directly

Calls 15

IsReadyMethod · 0.80
GetDataSizeMethod · 0.80
UploadRangeMethod · 0.80
GetInternalFormatMethod · 0.80
CreateTextureBufferMethod · 0.80
NewFunction · 0.50
emptyMethod · 0.45
SetTypeMethod · 0.45
SetContextMethod · 0.45
GetDataTypeMethod · 0.45
DeepCopyMethod · 0.45
ShallowCopyMethod · 0.45

Tested by

no test coverage detected