Correct unsigned to signed warnings in opengl interop code.

This commit is contained in:
Robert Maynard 2015-08-25 15:41:10 -04:00
parent d014b13432
commit 611cc4d06b
2 changed files with 16 additions and 27 deletions

@ -35,24 +35,25 @@ namespace detail
template<class ValueType, class StorageTag, class DeviceAdapterTag>
VTKM_CONT_EXPORT
void CopyFromHandle(
void CopyFromHandle(
vtkm::cont::ArrayHandle<ValueType, StorageTag>& handle,
GLenum type,
DeviceAdapterTag)
{
//Generic implementation that will work no matter what. We copy the data
//in the given handle to a temporary handle using the basic storage tag.
//We then ensure the data is available in the control environment by
//We then ensure the data is available in the control environment by
//synchronizing the control array. Last, we steal the array and pass the
//iterator to the rendering system
const vtkm::Id numberOfValues = handle.GetNumberOfValues();
std::size_t size = sizeof(ValueType) * numberOfValues;
const std::size_t size =
sizeof(ValueType) * static_cast<std::size_t>(numberOfValues);
//Copy the data from its specialized Storage container to a basic storage
vtkm::cont::ArrayHandle<ValueType, vtkm::cont::StorageTagBasic> tmpHandle;
vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapterTag>::Copy(handle, tmpHandle);
//Synchronize the arrays to ensure the most current data is available in the
//Synchronize the arrays to ensure the most current data is available in the
//control environment
tmpHandle.SyncControlArray();
@ -61,7 +62,7 @@ void CopyFromHandle(
//Detach the current buffer
glBufferData(type, size, 0, GL_DYNAMIC_DRAW);
//Allocate the memory and set it as static draw and copy into opengl
glBufferSubData(type,0,size,temporaryStorage);
@ -70,7 +71,7 @@ void CopyFromHandle(
template<class ValueType, class DeviceAdapterTag>
VTKM_CONT_EXPORT
void CopyFromHandle(
void CopyFromHandle(
vtkm::cont::ArrayHandle<ValueType, vtkm::cont::StorageTagBasic>& handle,
GLenum type,
DeviceAdapterTag)
@ -79,9 +80,10 @@ void CopyFromHandle(
//that allows us to directly hook into the data. We pull the data
//back to the control enviornment using PerpareForInput and give an iterator
//from the portal to OpenGL to upload to the rendering system
//This also works because we know that this class isn't used for cuda interop,
//This also works because we know that this class isn't used for cuda interop,
//instead we are specialized
std::size_t size = sizeof(ValueType) * handle.GetNumberOfValues();
const std::size_t size =
sizeof(ValueType) * static_cast<std::size_t>(handle.GetNumberOfValues());
//Detach the current buffer
glBufferData(type, size, 0, GL_DYNAMIC_DRAW);

@ -61,7 +61,7 @@ private:
data.resize(length);
vtkm::Id pos = 0;
for(iterator i = data.begin(); i != data.end(); ++i, ++pos)
{ *i=T(pos); }
{ *i=TestValue(pos,T()); }
std::random_shuffle(data.begin(),data.end());
return vtkm::cont::make_ArrayHandle(data);
@ -131,7 +131,7 @@ private:
//get the size of the buffer
int bytesInBuffer = 0;
glGetBufferParameteriv(type, GL_BUFFER_SIZE, &bytesInBuffer);
int size = ( bytesInBuffer / sizeof(T) );
const std::size_t size = ( static_cast<std::size_t>(bytesInBuffer) / sizeof(T) );
//get the buffer contents and place it into a vector
std::vector<T> data;
@ -141,25 +141,12 @@ private:
return data;
}
//make a random value that we can test when loading constant values
template<typename T>
static
T MakeRandomValue(T)
{
return T(rand());
}
struct TransferFunctor
{
// std::size_t Size;
// GLuint GLHandle;
template <typename T>
void operator()(const T t) const
{
//this->Size = 10;
std::size_t Size = 10;
const std::size_t Size = 10;
GLuint GLHandle;
//verify that T is able to be transfer to openGL.
//than pull down the results from the array buffer and verify
@ -206,10 +193,10 @@ private:
"Array Handle failed to transfer properly");
}
//verify this work for a constant value array handle
T constantValue = MakeRandomValue(t);
vtkm::cont::ArrayHandleConstant<T> constant(constantValue, Size);
T constantValue = TestValue(2,T()); //verified by die roll
vtkm::cont::ArrayHandleConstant<T> constant(constantValue,
static_cast<vtkm::Id>(Size) );
SafelyTransferArray(constant,GLHandle);
is_buffer = glIsBuffer(GLHandle);
VTKM_TEST_ASSERT(is_buffer==true,