Esempio n. 1
0
/*
 *  Initialize OpenCL
 */
void InitCL()
{
   cl_int err;
   //  Initialize OpenCL
   nloc = InitGPU(1,devid,context,queue);
   //  Allocate memory for array on device
   Dpos[0] = clCreateBuffer(context,CL_MEM_READ_WRITE,N*sizeof(float3),NULL,&err);
   Dpos[1] = clCreateBuffer(context,CL_MEM_READ_WRITE,N*sizeof(float3),NULL,&err);
   Dvel    = clCreateBuffer(context,CL_MEM_READ_WRITE,N*sizeof(float3),NULL,&err);
   Dm      = clCreateBuffer(context,CL_MEM_WRITE_ONLY,N*sizeof(float) ,NULL,&err);
   if (err) Fatal("Cannot create array on device\n");
   //  Compile kernel
   prog = clCreateProgramWithSource(context,1,&source,0,&err);
   if (err) Fatal("Cannot create program\n");
   if (clBuildProgram(prog,0,NULL,NULL,NULL,NULL))
   {
      char log[1048576];
      if (clGetProgramBuildInfo(prog,devid,CL_PROGRAM_BUILD_LOG,sizeof(log),log,NULL))
         Fatal("Cannot get build log\n");
      else
         Fatal("Cannot build program\n%s\n",log);
   }
   kernel = clCreateKernel(prog,"Move",&err);
   if (err) Fatal("Cannot create kernel\n");
}
void mitk::GPUVolumeMapper3D::InitVtkMapper(mitk::BaseRenderer *renderer)
{
  if (IsRAYEnabled(renderer))
  {
    DeinitCPU(renderer);
    if (!InitRAY(renderer))
    {
      GPU_WARN << "hardware renderer can't initialize ... falling back to software renderer";
      goto fallback;
    }
  }
  else if (IsGPUEnabled(renderer))
  {
    DeinitCPU(renderer);
    DeinitRAY(renderer);
    if (!InitGPU(renderer))
    {
      GPU_WARN << "hardware renderer can't initialize ... falling back to software renderer";
      goto fallback;
    }
  }
  else
  {
  fallback:
    DeinitRAY(renderer);
    InitCPU(renderer);
  }
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool CameraRendererRGB565GL2::Init()
{
   //Clean previous state if any
   UnInit();
   mInitialized = InitGPU();
         
   return mInitialized;
}
Esempio n. 4
0
void PolygonClass::GeneratePoligon(int a_nSides, float a_fSize)
{
	GLfloat theta = 0;
	for (int i = 0; i < a_nSides; i++) 
	{
		theta += static_cast<GLfloat>(2*M_PI/a_nSides);
		AddVertexPosition(vector3(	static_cast<GLfloat>(cos(theta)) * a_fSize,
							static_cast<GLfloat>(sin(theta)) * a_fSize,
							0.0f));
		AddVertexColor( 1.0f, 1.0f, 1.0f);
		AddVertexUV( 0.0f, 0.0f);
		AddVertexNormal(0.0f, 0.0f, 0.0f);
		AddVertexTangent(0.0f, 0.0f, 0.0f);
	}
	InitGPU();
}
Esempio n. 5
0
void mitk::GPUVolumeMapper3D::InitVtkMapper(mitk::BaseRenderer* renderer)
{
// Only with VTK 5.6 or above
#if ((VTK_MAJOR_VERSION > 5) || ((VTK_MAJOR_VERSION==5) && (VTK_MINOR_VERSION>=6) ))
  if(IsRAYEnabled(renderer))
  {
    DeinitCPU(renderer);
    DeinitGPU(renderer);
    if(!InitRAY(renderer))
    {
      GPU_WARN << "hardware renderer can't initialize ... falling back to software renderer";
      goto fallback;
    }
  }
  else
#endif
  if(IsGPUEnabled(renderer))
  {
    DeinitCPU(renderer);
// Only with VTK 5.6 or above
#if ((VTK_MAJOR_VERSION > 5) || ((VTK_MAJOR_VERSION==5) && (VTK_MINOR_VERSION>=6) ))
    DeinitRAY(renderer);
#endif
    if(!InitGPU(renderer))
    {
      GPU_WARN << "hardware renderer can't initialize ... falling back to software renderer";
      goto fallback;
    }
  }
  else
  {
    fallback:
    DeinitGPU(renderer);
// Only with VTK 5.6 or above
#if ((VTK_MAJOR_VERSION > 5) || ((VTK_MAJOR_VERSION==5) && (VTK_MINOR_VERSION>=6) ))
    DeinitRAY(renderer);
#endif
    InitCPU(renderer);
  }
}