From 8c587d2243884d85bbe5fadac64258ac246617b4 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sat, 2 Mar 2013 20:20:32 +0000 Subject: Version C++ qui arrive a initialiser OpenCL sans trop de merdouilles specifiques. Un dur labeur... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reste à retourner les pointeurs où il faut, faire la partie VBO, l'affichage du VBO et lancer un premier kernel git-svn-id: file:///var/svn/2013-gpudataviz/trunk@16 371a6b4a-a258-45f8-9dcc-bdd82ce0ac9d --- src/boring_parts.cc | 188 +++++++++++++++++++++++++++------------------------- 1 file changed, 98 insertions(+), 90 deletions(-) (limited to 'src/boring_parts.cc') diff --git a/src/boring_parts.cc b/src/boring_parts.cc index bc25f8f..27ead8b 100644 --- a/src/boring_parts.cc +++ b/src/boring_parts.cc @@ -1,7 +1,5 @@ #include "boring_parts.h" - - // TODO : only need OpenGL things, not GTK ones for now //#include "gtk_includes.h" @@ -20,22 +18,52 @@ } \ } while(0) -int initLibs() { - -#ifdef HAS_OPENCL - RETURN_IF_FAIL( initOpenCL() ); -#endif /*HAS_OPENCL*/ - return 0; -} +/* From http://stackoverflow.com/questions/4317062/opengl-how-to-check-if-the-user-supports-glgenbuffers +#ifndef STRINGIFY + #define STRINGIFY(x) #x +#endif +#ifdef WIN32 + #include + #define glGetProcAddress(a) wglGetProcAddress(a) +#endif +#ifdef X11 + #define glGetProcAddress(a) glXGetProcAddress ( \ + reinterpret_cast(a) \ + ) +#endif + +#ifndef GetExtension + #define GetExtension(Type, ExtenName) \ + ExtenName = (Type) \ + glGetProcAddress(STRINGIFY(ExtenName)); \ + if(!ExtenName) \ + { \ + std:cout << "Your Computer Does Not " \ + << "Support GL Extension: " \ + << STRINGIFY(ExtenName) \ + << std::endl; \ + exit(1); \ + } \ + else \ + { \ + std::cout << "Loaded Extension: " \ + << STRINGIFY(ExtenName) \ + << std::endl; \ + } +#endif +*/ #ifdef HAS_OPENCL -int initOpenCL() { +int initOpenCL(intptr_t gl_display, intptr_t gl_context, intptr_t gl_vbo) { cl_uint id, numPlatforms, numDevices; char pbuf[100]; std::string dTypeStr; cl_platform_id *platforms, platform; - cl_device_id *devices, device; + cl_device_id /* *devices, */device; + cl_context cl_ctx; + cl_command_queue cl_commandQueue; + bool usableDeviceFound=false; // Get platform count CL_RETURN_VAL_IF_FAIL(1, @@ -55,97 +83,77 @@ int initOpenCL() { // Enumerate platforms and grab informations for(id=0;id 0 ) ) return 12; - - // Allocate room for all devices IDs - devices = new cl_device_id[numDevices]; - - // Get devices IDs - CL_RETURN_VAL_IF_FAIL(13, - clGetDeviceIDs(platform,CL_DEVICE_TYPE_ALL,numDevices,devices,&numDevices) - ); - // Enumerate devices and grab informations - for(id=0;id