Go to the documentation of this file.
18 #ifndef viskores_interop_internal_TransferToOpenGL_h
19 #define viskores_interop_internal_TransferToOpenGL_h
44 class SMPTransferResource :
public viskores::interop::internal::TransferResource
49 :
viskores::interop::internal::TransferResource()
53 this->resize<T>(numberOfValues);
56 ~SMPTransferResource() {}
61 if (this->Size != numberOfValues)
63 this->Size = numberOfValues;
64 T* storage =
new T[
static_cast<std::size_t
>(this->Size)];
75 T* storage =
reinterpret_cast<T*
>(this->TempStorage.get());
84 T* storage =
reinterpret_cast<T*
>(this->TempStorage.get());
89 std::unique_ptr<viskores::UInt8[]> TempStorage;
95 template <
class ValueType,
class StorageTag,
class DeviceAdapterTag>
103 const GLsizeiptr size =
104 static_cast<GLsizeiptr
>(
sizeof(ValueType)) *
static_cast<GLsizeiptr
>(numberOfValues);
107 viskores::interop::internal::SMPTransferResource* resource =
108 dynamic_cast<viskores::interop::internal::SMPTransferResource*
>(state.
GetResource());
117 glBufferData(state.
GetType(), size, 0, GL_DYNAMIC_DRAW);
123 resource->resize<ValueType>(numberOfValues);
132 resource =
new viskores::interop::internal::SMPTransferResource(ValueType(), numberOfValues);
137 auto resourceHandle = resource->handle<ValueType>(numberOfValues);
138 Algorithm::Copy(handle, resourceHandle);
141 glBufferSubData(state.
GetType(), 0, size, resource->as<ValueType>());
144 template <
class ValueType,
class DeviceAdapterTag>
156 const GLsizeiptr size =
static_cast<GLsizeiptr
>(
sizeof(ValueType)) *
165 glBufferData(state.
GetType(), size, 0, GL_DYNAMIC_DRAW);
174 glBufferSubData(state.
GetType(), 0, size, memory);
184 template <
typename ValueType,
class DeviceAdapterTag>
191 if (!this->State.HasType())
193 this->State.DeduceAndSetType(ValueType());
197 template <
typename StorageTag>
202 if (!glIsBuffer(*this->State.GetHandle()))
204 glGenBuffers(1, this->State.GetHandle());
208 glBindBuffer(this->State.GetType(), *this->State.GetHandle());
225 detail::CopyFromHandle(handle, this->State, DeviceAdapterTag());
239 #if VISKORES_DEVICE_ADAPTER == VISKORES_DEVICE_ADAPTER_CUDA
243 #endif //viskores_interop_internal_TransferToOpenGL_h
void SetSize(viskores::Int64 size)
Definition: BufferState.h:145
Struct containing device adapter algorithms.
Definition: DeviceAdapterAlgorithm.h:49
viskores::interop::internal::TransferResource * GetResource()
Definition: BufferState.h:171
GLenum GetType() const
return what OpenGL buffer type we are bound to
Definition: BufferState.h:118
ReadPortalType PrepareForInput(viskores::cont::DeviceAdapterId device, viskores::cont::Token &token) const
Prepares this array to be used as an input to an operation in the execution environment.
Definition: ArrayHandle.h:615
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
#define VISKORES_CONT
Definition: ExportMacros.h:65
Groups connected points that have the same field value.
Definition: Atomic.h:27
viskores::cont::ArrayPortalToIterators< PortalType >::IteratorType ArrayPortalToIteratorBegin(const PortalType &portal)
Convenience function for converting an ArrayPortal to a begin iterator.
Definition: ArrayPortalToIterators.h:189
Manages the state for transferring an ArrayHandle to opengl.
Definition: BufferState.h:64
viskores::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:482
void TransferToOpenGL(const viskores::cont::ArrayHandle< ValueType, StorageTag > &handle, BufferState &state, DeviceAdapterTag)
Manages transferring an ArrayHandle to opengl .
Definition: TransferToOpenGL.h:49
#define VISKORES_ASSERT(condition)
Definition: Assert.h:51
void SetCapacity(viskores::Int64 capacity)
Definition: BufferState.h:168
uint8_t UInt8
Base type to use for 8-bit unsigned integer numbers.
Definition: Types.h:177
void SetResource(viskores::interop::internal::TransferResource *resource)
Definition: BufferState.h:174
bool ShouldRealloc(viskores::Int64 desiredSize) const
Definition: BufferState.h:158
viskores::cont::ArrayHandleBasic< T > make_ArrayHandle(const T *array, viskores::Id numberOfValues, viskores::CopyFlag copy)
A convenience function for creating an ArrayHandle from a standard C array.
Definition: ArrayHandleBasic.h:285
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:43