ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/OpenCL/examples/juliaflight
(Generate patch)

Comparing OpenCL/examples/juliaflight (file contents):
Revision 1.4 by root, Tue May 1 00:33:28 2012 UTC vs.
Revision 1.5 by root, Tue Oct 22 17:25:38 2013 UTC

14# find and use the first opencl device that let's us get a shared opengl context 14# find and use the first opencl device that let's us get a shared opengl context
15my $platform; 15my $platform;
16my $dev; 16my $dev;
17my $ctx; 17my $ctx;
18 18
19sub get_context {
19for (OpenCL::platforms) { 20 for (OpenCL::platforms) {
20 $platform = $_; 21 $platform = $_;
21 for ($platform->devices) { 22 for ($platform->devices) {
22 $dev = $_; 23 $dev = $_;
23 $ctx = $platform->context ([OpenCL::GLX_DISPLAY_KHR, undef, OpenCL::GL_CONTEXT_KHR, undef], [$dev]) 24 $ctx = eval { $platform->context ([OpenCL::GLX_DISPLAY_KHR, undef, OpenCL::GL_CONTEXT_KHR, undef], [$dev]) }
24 and last; 25 and return;
26 }
25 } 27 }
28
29 die "cannot find suitable OpenCL device\n";
26} 30}
27 31
28$ctx 32get_context;
29 or die "cannot find suitable OpenCL device\n";
30 33
31print "using ", $dev->name, "\n"; 34print "using ", $dev->name, "\n";
32 35
33my $queue = $ctx->queue ($dev); 36my $queue = $ctx->queue ($dev);
34 37

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines