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/gpudataviz.cc | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'src/gpudataviz.cc') diff --git a/src/gpudataviz.cc b/src/gpudataviz.cc index e6e4ca5..fbc1852 100644 --- a/src/gpudataviz.cc +++ b/src/gpudataviz.cc @@ -7,6 +7,8 @@ #include "gtk_win_main.h" #include "my_gtk_gl_scene_widget.h" +#include // X11 specific + // Macro to make things readable in main() function #define EXIT_IF_FAIL(val, expr) do { \ if ( ! (expr) ) { \ @@ -39,18 +41,15 @@ int main(int argc, char* argv[]) { Glib::RefPtr glconfig; EXIT_IF_FAIL(2, glconfig=Gdk::GL::Config::create(glMode) ); - // Initialize OpenCL (if available) - EXIT_IF_FAIL(3, initLibs()==0 ); // See boring_parts.cc - - // Initialize host work memory (array for all the vertex coordinates computed by OpenCL and displayed by OpenGL) - cl_float4 *hostWorkMem = (cl_float4 *) calloc(meshWidth * meshHeight, sizeof(cl_float4)); - EXIT_IF_FAIL(4, hostWorkMem); - // Initialize the OpenGL scene MyGTKGLSceneWidget glScene(glconfig); - // Instantiate and run the GTK app + // Instantiate the GTK app GTKWinMain gtkwinmain(glScene); + + // Initialize OpenCL (only after the MyGTKGLSceneWidget realize) + //EXIT_IF_FAIL(3, initLibs()==0 ); // See boring_parts.cc + gtkKit.run(gtkwinmain); return 0; @@ -88,6 +87,27 @@ void MyGTKGLSceneWidget::on_realize() { return; } + // TODO : GL_ARB_vertex_buffer_object + intptr_t gl_vbo=0; + +#ifdef HAS_OPENCL + static bool isOpenCLInitialized=false; + + if (! isOpenCLInitialized) { +// #ifdef X11 + intptr_t gl_context = (intptr_t)glXGetCurrentContext(); + intptr_t gl_display = (intptr_t)glXGetCurrentDisplay(); + + std::cerr << "DEBUG : begin initOpenCL()" << std::endl; + initOpenCL(gl_display, gl_context, gl_vbo); /* See boring_parts.cc */ + isOpenCLInitialized=true; +// #else +// #error initOpenCL works only for X11 systems for now +// #endif + } +#endif + + // Programmatically create rendering lists : opengl will able to replay that efficiently GLUquadricObj* qobj = gluNewQuadric(); gluQuadricDrawStyle(qobj, GLU_FILL); -- cgit v1.2.3