From 3ffda80f95478f4e73765f8b7ceb1bbf54ea97ee Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sat, 5 Jan 2013 09:07:16 +0000 Subject: - Ajout de quelques tests et messages dans compil.sh. - Suppression des majuscules de my_gtk_gl_scene.h - Ajout de quelques #define pour pouvoir compiler sans OpenCL (+ changement appel initOpenCL() -> initLibs() dans gpudataviz.cc) git-svn-id: file:///var/svn/2013-gpudataviz/trunk@3 371a6b4a-a258-45f8-9dcc-bdd82ce0ac9d --- src/boring_parts.cc | 4 ++++ src/boring_parts.h | 14 +++++++++++--- src/compil.sh | 26 ++++++++++++++++++-------- src/gpudataviz.cc | 6 +++--- src/gtk_win_main.h | 2 +- src/my_GTK_GL_scene.h | 23 ----------------------- src/my_gtk_gl_scene.h | 23 +++++++++++++++++++++++ 7 files changed, 60 insertions(+), 38 deletions(-) delete mode 100644 src/my_GTK_GL_scene.h create mode 100644 src/my_gtk_gl_scene.h diff --git a/src/boring_parts.cc b/src/boring_parts.cc index 3affae9..5e240c2 100644 --- a/src/boring_parts.cc +++ b/src/boring_parts.cc @@ -18,11 +18,14 @@ int initLibs() { // FIXME : unused +#ifdef HAS_OPENCL RETURN_IF_FAIL( initOpenCL() ); +#endif /*HAS_OPENCL*/ return 0; } +#ifdef HAS_OPENCL int initOpenCL() { cl_uint id, numPlatforms, numDevices; char pbuf[100]; @@ -98,4 +101,5 @@ int initOpenCL() { return 0; } +#endif /*HAS_OPENCL*/ diff --git a/src/boring_parts.h b/src/boring_parts.h index fc4e09b..431a46f 100644 --- a/src/boring_parts.h +++ b/src/boring_parts.h @@ -1,8 +1,16 @@ #include + +#ifdef HAS_OPENCL #include -#include "gtk_includes.h" +int initOpenCL(); +#else +// Quick and dirty cl_float4 replacement +typedef union { + float s[4]; + struct{ float x, y, z, w; }; + struct{ float s0, s1, s2, s3; }; +} cl_float4; +#endif /*HAS_OPENCL*/ int initLibs(); -int initOpenCL(); -int initGTK(); diff --git a/src/compil.sh b/src/compil.sh index 4afcc2e..bc21245 100755 --- a/src/compil.sh +++ b/src/compil.sh @@ -2,24 +2,34 @@ clear -set -x +#set -x CXX="g++ -Wall -g" BUILD_PATH="../build" AMDAPP_PATH="/opt/AMDAPP" +DEFINES="" INCLUDES="" LIBS="" # OpenCL -INCLUDES="$INCLUDES -I $AMDAPP_PATH/include" -LIBS="$LIBS -lOpenCL" +if [ -d "$AMDAPP_PATH/include" ] +then DEFINES="-DHAS_OPENCL" + INCLUDES="$INCLUDES -I $AMDAPP_PATH/include" + LIBS="$LIBS -lOpenCL" +else echo "WARNING : invalid AMDAPP_PATH : '$AMDAPP_PATH'" +fi # GTKGLEXT -INCLUDES="$INCLUDES $(pkg-config --cflags gtkglextmm-1.2)" -LIBS="$LIBS $(pkg-config --libs gtkglextmm-1.2)" - -set +x +if pkg-config --modversion gtkglextmm-1.2 gdkmm-2.4 > /dev/null +then INCLUDES="$INCLUDES $(pkg-config --cflags gtkglextmm-1.2)" + LIBS="$LIBS $(pkg-config --libs gtkglextmm-1.2)" +else echo "ERROR : pkg-config is unavailable or gtkglextmm-1.2 developpemnt files are not installed" + echo "On Ubuntu (12.04, 12.10) you can resolve that with :" + echo " sudo apt-get install pkg-config libgtkmm-2.4-dev libgtkglextmm-x11-1.2-dev" + exit 1 +fi +#set +x function build_cxx() { echo "$PS4$CXX \$INCLUDES -o $BUILD_PATH/$1 -c $2" @@ -33,7 +43,7 @@ function link_cxx() { $CXX $* -o $BUILD_PATH/$out $LIBS } -rm $BUILD_PATH/* || true +rm -v $BUILD_PATH/* || true build_cxx gpudataviz.o gpudataviz.cc build_cxx boring_parts.o boring_parts.cc diff --git a/src/gpudataviz.cc b/src/gpudataviz.cc index bcd498e..6f1ebd0 100644 --- a/src/gpudataviz.cc +++ b/src/gpudataviz.cc @@ -3,7 +3,7 @@ #include "gpudataviz.h" #include "boring_parts.h" #include "gtk_win_main.h" -#include "my_GTK_GL_scene.h" +#include "my_gtk_gl_scene.h" // Macro to make things readable in main() function #define EXIT_IF_FAIL(val, expr) do { \ @@ -36,8 +36,8 @@ int main(int argc, char* argv[]) { Glib::RefPtr glconfig; EXIT_IF_FAIL(2, glconfig=Gdk::GL::Config::create(glMode) ); - // Initialize OpenCL - EXIT_IF_FAIL(3, initOpenCL()==0 ); // See boring_parts.cc + // 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)); diff --git a/src/gtk_win_main.h b/src/gtk_win_main.h index d5338ed..ab14a4a 100644 --- a/src/gtk_win_main.h +++ b/src/gtk_win_main.h @@ -1,5 +1,5 @@ #include "gtk_includes.h" -#include "my_GTK_GL_scene.h" +#include "my_gtk_gl_scene.h" #define WIN_MAIN_TITLE "GPU Data Viz v0.1" diff --git a/src/my_GTK_GL_scene.h b/src/my_GTK_GL_scene.h deleted file mode 100644 index dc8afbe..0000000 --- a/src/my_GTK_GL_scene.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef MY_GTK_GL_SCENE_H -#define MY_GTK_GL_SCENE_H - -#include "gtk_includes.h" - -// Class that will contain all the OpenGL logic for displaying the OpenCL computed data -// Implementation is kept in gpudataviz.cc (I want to keep interesting code part in this file) - -// TODO : rename it to MyGTKGLSceneWidget -class MyGTKGLScene : public Gtk::DrawingArea, public Gtk::GL::Widget -{ - public: - MyGTKGLScene(Glib::RefPtr &glconfig); - virtual ~MyGTKGLScene(); - - protected: - virtual void on_size_request(Gtk::Requisition* requisition); - virtual void on_realize(); - virtual bool on_configure_event(GdkEventConfigure* event); - virtual bool on_expose_event(GdkEventExpose* event); -}; - -#endif /*MY_GTK_GL_SCENE_H*/ diff --git a/src/my_gtk_gl_scene.h b/src/my_gtk_gl_scene.h new file mode 100644 index 0000000..dc8afbe --- /dev/null +++ b/src/my_gtk_gl_scene.h @@ -0,0 +1,23 @@ +#ifndef MY_GTK_GL_SCENE_H +#define MY_GTK_GL_SCENE_H + +#include "gtk_includes.h" + +// Class that will contain all the OpenGL logic for displaying the OpenCL computed data +// Implementation is kept in gpudataviz.cc (I want to keep interesting code part in this file) + +// TODO : rename it to MyGTKGLSceneWidget +class MyGTKGLScene : public Gtk::DrawingArea, public Gtk::GL::Widget +{ + public: + MyGTKGLScene(Glib::RefPtr &glconfig); + virtual ~MyGTKGLScene(); + + protected: + virtual void on_size_request(Gtk::Requisition* requisition); + virtual void on_realize(); + virtual bool on_configure_event(GdkEventConfigure* event); + virtual bool on_expose_event(GdkEventExpose* event); +}; + +#endif /*MY_GTK_GL_SCENE_H*/ -- cgit v1.2.3