summaryrefslogtreecommitdiff
path: root/src/gpudataviz.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpudataviz.cpp')
-rw-r--r--src/gpudataviz.cpp54
1 files changed, 24 insertions, 30 deletions
diff --git a/src/gpudataviz.cpp b/src/gpudataviz.cpp
index a9fdb8e..72ee472 100644
--- a/src/gpudataviz.cpp
+++ b/src/gpudataviz.cpp
@@ -1,6 +1,7 @@
#include <iostream>
+#include <GL/glew.h>
//#include "gtk_includes.h"
#include "gtk_win_main.hpp"
//#include "my_gtk_gl_scene_widget.hpp"
@@ -45,85 +46,78 @@ int main(int argc, char* argv[]) {
// Could exit() the program if problem with OpenGL or OpenCL
GTKWinMain gtkwinmain(glScene);
- // Initialize OpenCL (only after the MyGTKGLSceneWidget realize)
- //EXIT_IF_FAIL(3, initLibs()==0 ); // See boring_parts.cc
-
+ // Run the app
gtkKit.run(gtkwinmain);
return 0;
}
/* MyGTKGLSceneWidget implementation
- I want to keep interesting code part in this file
- in natural reading order
+ I want to keep interesting code part in this file in natural reading order
*/
MyGTKGLSceneWidget::MyGTKGLSceneWidget(Glib::RefPtr<Gdk::GL::Config> &glconfig) {
set_gl_capability(glconfig);
Gdk::EventMask mask = Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_MOTION_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK;
set_events(mask); // The containing window should have those attributes too
- this->camera.rx = this->camera.ry = 0.0f; this->camera.tz = -3.0f;
+ this->camera.rx = 0.0f; this->camera.ry = 0.0f; this->camera.tz = -3.0f;
}
MyGTKGLSceneWidget::~MyGTKGLSceneWidget() { }
void MyGTKGLSceneWidget::on_size_request(Gtk::Requisition* requisition) {
CALL_TRACE; // Technical stuff : GTK call this to ask the widget minimal size
- *requisition = Gtk::Requisition();
+ *requisition = Gtk::Requisition();
requisition->width = 320; requisition->height = 240;
}
void MyGTKGLSceneWidget::on_realize() {
CALL_TRACE; // This one runs once at window creation time
// It's time to setup GL things that don't change on each frame
-
- GLenum gl_res;
-
Gtk::DrawingArea::on_realize();
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
-
// *** OpenGL BEGIN ***
+ GLenum gl_res;
if (!glwindow->gl_begin(get_gl_context())) {
std::cerr << "Oups : glwindow->gl_begin(get_gl_context())" << std::endl;
return;
}
EXIT_IF_FAIL(3, Gdk::GL::query_gl_extension("GL_ARB_vertex_buffer_object") );
+ EXIT_IF_FAIL(4, glewInit() == 0 );
- size_t mesh_width=64;
- size_t mesh_height=64;
+ size_t mesh_width=512, mesh_height=512, group_size=256; // TODO : not here
+
+ GLuint gl_vbo=0;
GLsizeiptr gl_vbo_data_size = mesh_width * mesh_height * sizeof(cl_float4);
- intptr_t gl_vbo=0;
+ std::cout << "gl_vbo_data_size==" << gl_vbo_data_size << std::endl;
glGenBuffers(1, &gl_vbo);
glBindBuffer(GL_ARRAY_BUFFER, gl_vbo);
- /*
- STREAM : The data store contents will be modified once and used at most a few times.
- STATIC : The data store contents will be modified once and used many times.
- DYNAMIC : The data store contents will be modified repeatedly and used many times.
- */
glBufferData(GL_ARRAY_BUFFER, gl_vbo_data_size, NULL, GL_DYNAMIC_DRAW);
- if ( gl_res=glGetError() ) {
- std::cerr << "glBufferData(). Unable to allocate " << gl_vbo_data_size << "bytes in VRAM";
+ gl_res=glGetError();
+ if ( gl_res != GL_NO_ERROR ) {
+ std::cerr << "glBufferData(). Unable to allocate " << gl_vbo_data_size << "bytes in VRAM" << std::endl;
std::cerr << gluErrorString(gl_res);
+ EXIT_IF_FAIL(5, false);
}
-#ifdef HAS_OPENCL
-// static bool isOpenCLInitialized=false;
-
-// if (! isOpenCLInitialized) {
+//#ifdef HAS_OPENCL
// #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;
+ int cl_res = clKit.initCL(gl_display, gl_context, gl_vbo, mesh_width, mesh_height, group_size);
+ EXIT_IF_FAIL(cl_res, cl_res==0);
+
+// std::cerr << "DEBUG : begin initOpenCL()" << std::endl;
+// int cl_res = initOpenCL(gl_display, gl_context, gl_vbo); /* See boring_parts.cpp */
+// EXIT_IF_FAIL(cl_res, cl_res==0);
// #else
// #error initOpenCL works only for X11 systems for now
// #endif
// }
-#endif
+//#endif
// Programmatically create rendering lists : opengl will able to replay that efficiently
@@ -155,7 +149,7 @@ void MyGTKGLSceneWidget::on_realize() {
bool MyGTKGLSceneWidget::on_configure_event(GdkEventConfigure* event) {
CALL_TRACE ; // This one runs mainly when GTK GL Widget is resized
- // See boring_parts.cc. In short : gluPerspective(60.0, aspect, 0.1, 10.0);
+ // See boring_parts.cpp. In short : gluPerspective(60.0, aspect, 0.1, 10.0);
return updateGLProjectionMatrix(get_gl_context(), get_gl_window(), get_width(), get_height());
}