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