VTK-m  2.0
SetOpenGLDevice.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 #ifndef vtk_m_cuda_interop_SetOpenGLDevice_h
11 #define vtk_m_cuda_interop_SetOpenGLDevice_h
12 
13 #include <cuda.h>
14 #include <cuda_gl_interop.h>
15 
17 
18 namespace vtkm
19 {
20 namespace interop
21 {
22 namespace cuda
23 {
24 
25 static void SetCudaGLDevice(int id)
26 {
27 //With Cuda 5.0 cudaGLSetGLDevice is deprecated and shouldn't be needed
28 //anymore. But it seems that macs still require you to call it or we
29 //segfault
30 #ifdef __APPLE__
31  cudaError_t cError = cudaGLSetGLDevice(id);
32 #else
33  cudaError_t cError = cudaSetDevice(id);
34 #endif
35  if (cError != cudaSuccess)
36  {
37  std::string cuda_error_msg("Unable to setup cuda/opengl interop. Error: ");
38  cuda_error_msg.append(cudaGetErrorString(cError));
39  throw vtkm::cont::ErrorExecution(cuda_error_msg);
40  }
41 }
42 }
43 }
44 } //namespace
45 
46 #endif //vtk_m_cuda_interop_SetOpenGLDevice_h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
ErrorExecution.h
vtkm::cont::ErrorExecution
This class is thrown in the control environment whenever an error occurs in the execution environment...
Definition: ErrorExecution.h:25