summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2013-03-03 13:56:50 +0000
committerLudovic Pouzenc <ludovic@pouzenc.fr>2013-03-03 13:56:50 +0000
commitdcbaaf5bb09caf07f27c03f3c3db196542668b4a (patch)
tree3d74622e716c3bc58ceeefdb422c5c1c68b4e4a9 /src
parent8c587d2243884d85bbe5fadac64258ac246617b4 (diff)
download2013-gpudataviz-dcbaaf5bb09caf07f27c03f3c3db196542668b4a.tar.gz
2013-gpudataviz-dcbaaf5bb09caf07f27c03f3c3db196542668b4a.tar.bz2
2013-gpudataviz-dcbaaf5bb09caf07f27c03f3c3db196542668b4a.zip
Standardisation des extensions.
Avancee sur l'initialisation des VBO mais je galere a trouver un (bon) moyen de charger les fonctions OpenGL qui vont bien. git-svn-id: file:///var/svn/2013-gpudataviz/trunk@17 371a6b4a-a258-45f8-9dcc-bdd82ce0ac9d
Diffstat (limited to 'src')
-rw-r--r--src/boring_parts.cpp (renamed from src/boring_parts.cc)10
-rw-r--r--src/boring_parts.hpp (renamed from src/boring_parts.h)0
-rwxr-xr-xsrc/compil.sh7
-rw-r--r--src/gpudataviz.cpp (renamed from src/gpudataviz.cc)46
-rw-r--r--src/gpudataviz.hpp (renamed from src/gpudataviz.h)0
-rw-r--r--src/gtk_includes.hpp (renamed from src/gtk_includes.h)5
-rw-r--r--src/gtk_win_main.cpp (renamed from src/gtk_win_main.cc)4
-rw-r--r--src/gtk_win_main.hpp (renamed from src/gtk_win_main.h)4
-rw-r--r--src/my_gtk_gl_scene_widget.hpp (renamed from src/my_gtk_gl_scene_widget.h)2
9 files changed, 50 insertions, 28 deletions
diff --git a/src/boring_parts.cc b/src/boring_parts.cpp
index 27ead8b..0f4ee1a 100644
--- a/src/boring_parts.cc
+++ b/src/boring_parts.cpp
@@ -1,7 +1,7 @@
-#include "boring_parts.h"
+#include "boring_parts.hpp"
// TODO : only need OpenGL things, not GTK ones for now
-//#include "gtk_includes.h"
+//#include "gtk_includes.hpp"
#define RETURN_IF_FAIL(expr) do { \
int res=(expr); \
@@ -56,7 +56,7 @@
#ifdef HAS_OPENCL
int initOpenCL(intptr_t gl_display, intptr_t gl_context, intptr_t gl_vbo) {
- cl_uint id, numPlatforms, numDevices;
+ cl_uint id, numPlatforms;
char pbuf[100];
std::string dTypeStr;
cl_platform_id *platforms, platform;
@@ -106,7 +106,7 @@ int initOpenCL(intptr_t gl_display, intptr_t gl_context, intptr_t gl_vbo) {
0
};
- std::cout << "cl_context_properties :" << std::endl;
+ std::cout << "cl_context_properties cpsGL :" << std::endl;
std::cout << "\tCL_CONTEXT_PLATFORM :" << (void *)cpsGL[1] << std::endl;
std::cout << "\tCL_GLX_DISPLAY_KHR :" << (void *)cpsGL[3] << std::endl;
std::cout << "\tCL_GL_CONTEXT_KHR :" << (void *)cpsGL[5] << std::endl;
@@ -123,7 +123,7 @@ int initOpenCL(intptr_t gl_display, intptr_t gl_context, intptr_t gl_vbo) {
device=0;
res=clGetGLContextInfoKHR_proc(cpsGL,CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR,deviceSize,&device,NULL);
if ( res!=CL_SUCCESS || device==0 ) {
- std::cerr << "clGetGLContextInfoKHR_proc(cpsGL,CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR,...) failed" << std::endl;
+ std::cerr << "clGetGLContextInfoKHR_proc(cpsGL,CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR," << deviceSize << ",...) failed" << std::endl;
std::cerr << " (return code : " << res << ")" << std::endl;
continue;
}
diff --git a/src/boring_parts.h b/src/boring_parts.hpp
index b4cd58d..b4cd58d 100644
--- a/src/boring_parts.h
+++ b/src/boring_parts.hpp
diff --git a/src/compil.sh b/src/compil.sh
index 84ed7c4..f3ca2a0 100755
--- a/src/compil.sh
+++ b/src/compil.sh
@@ -45,9 +45,10 @@ function link_cxx() {
rm -v $BUILD_PATH/* || true
-build_cxx gpudataviz.o gpudataviz.cc
-build_cxx boring_parts.o boring_parts.cc
-build_cxx gtk_win_main.o gtk_win_main.cc
+build_cxx gl_core_1_5_vbo.o gl_core_1_5_vbo.cpp
+build_cxx gpudataviz.o gpudataviz.cpp
+build_cxx boring_parts.o boring_parts.cpp
+build_cxx gtk_win_main.o gtk_win_main.cpp
link_cxx gpudataviz $BUILD_PATH/*.o
diff --git a/src/gpudataviz.cc b/src/gpudataviz.cpp
index fbc1852..a9fdb8e 100644
--- a/src/gpudataviz.cc
+++ b/src/gpudataviz.cpp
@@ -1,11 +1,10 @@
#include <iostream>
-#include "gpudataviz.h"
-#include "boring_parts.h"
//#include "gtk_includes.h"
-#include "gtk_win_main.h"
-#include "my_gtk_gl_scene_widget.h"
+#include "gtk_win_main.hpp"
+//#include "my_gtk_gl_scene_widget.hpp"
+#include "boring_parts.hpp"
#include <gdk/x11/gdkglx.h> // X11 specific
@@ -25,8 +24,6 @@
int main(int argc, char* argv[]) {
CALL_TRACE;
- int meshWidth=64, meshHeight=64; // TODO : those vars should not be hardcoded
-
// Initialize GTK
Gtk::Main gtkKit(argc, argv); // gtk itself
Gtk::GL::init(argc, argv); // gtkglextmm
@@ -41,10 +38,11 @@ int main(int argc, char* argv[]) {
Glib::RefPtr<Gdk::GL::Config> glconfig;
EXIT_IF_FAIL(2, glconfig=Gdk::GL::Config::create(glMode) );
- // Initialize the OpenGL scene
+ // Initialize the OpenGL scene widget (realization came later)
MyGTKGLSceneWidget glScene(glconfig);
- // Instantiate the GTK app
+ // Instantiate the GTK app (and realize glScene)
+ // Could exit() the program if problem with OpenGL or OpenCL
GTKWinMain gtkwinmain(glScene);
// Initialize OpenCL (only after the MyGTKGLSceneWidget realize)
@@ -78,33 +76,53 @@ 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 ***
if (!glwindow->gl_begin(get_gl_context())) {
std::cerr << "Oups : glwindow->gl_begin(get_gl_context())" << std::endl;
return;
}
- // TODO : GL_ARB_vertex_buffer_object
+ EXIT_IF_FAIL(3, Gdk::GL::query_gl_extension("GL_ARB_vertex_buffer_object") );
+
+ size_t mesh_width=64;
+ size_t mesh_height=64;
+ GLsizeiptr gl_vbo_data_size = mesh_width * mesh_height * sizeof(cl_float4);
intptr_t gl_vbo=0;
+ 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";
+ std::cerr << gluErrorString(gl_res);
+ }
+
#ifdef HAS_OPENCL
- static bool isOpenCLInitialized=false;
+// static bool isOpenCLInitialized=false;
- if (! isOpenCLInitialized) {
+// 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;
+// std::cerr << "DEBUG : begin initOpenCL()" << std::endl;
initOpenCL(gl_display, gl_context, gl_vbo); /* See boring_parts.cc */
- isOpenCLInitialized=true;
+// isOpenCLInitialized=true;
// #else
// #error initOpenCL works only for X11 systems for now
// #endif
- }
+// }
#endif
diff --git a/src/gpudataviz.h b/src/gpudataviz.hpp
index e69de29..e69de29 100644
--- a/src/gpudataviz.h
+++ b/src/gpudataviz.hpp
diff --git a/src/gtk_includes.h b/src/gtk_includes.hpp
index 4a6632f..5a60f04 100644
--- a/src/gtk_includes.h
+++ b/src/gtk_includes.hpp
@@ -1,15 +1,18 @@
#ifndef GTK_INCLUDES_H
#define GTK_INCLUDES_H
+
#include <gtkmm.h>
+//#include "gl_core_3_1.hpp"
#include <gtkglmm.h>
+//#include "gl_core_1_5_vbo.hpp"
#ifdef G_OS_WIN32
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#endif
-#include <GL/gl.h>
+//#include <GL/gl.h>
#include <GL/glu.h>
#endif /* GTK_INCLUDES_H */
diff --git a/src/gtk_win_main.cc b/src/gtk_win_main.cpp
index 8997b56..465b828 100644
--- a/src/gtk_win_main.cc
+++ b/src/gtk_win_main.cpp
@@ -1,11 +1,11 @@
-#include "gtk_win_main.h"
+#include "gtk_win_main.hpp"
GTKWinMain::GTKWinMain(MyGTKGLSceneWidget &glScene)
: m_VBox(false, 0), m_ButtonQuit("Quit"), m_GLScene(glScene)
{
set_title(WIN_MAIN_TITLE);
- set_reallocate_redraws(true); // Get automatically redrawn if any of their children changed allocation.
+// set_reallocate_redraws(true); // Get automatically redrawn if any of their children changed allocation.
// Add components to the window
add(m_VBox);
diff --git a/src/gtk_win_main.h b/src/gtk_win_main.hpp
index c377040..2a42beb 100644
--- a/src/gtk_win_main.h
+++ b/src/gtk_win_main.hpp
@@ -1,5 +1,5 @@
-#include "gtk_includes.h"
-#include "my_gtk_gl_scene_widget.h"
+#include "gtk_includes.hpp"
+#include "my_gtk_gl_scene_widget.hpp"
#define WIN_MAIN_TITLE "GPU Data Viz v0.1"
diff --git a/src/my_gtk_gl_scene_widget.h b/src/my_gtk_gl_scene_widget.hpp
index bf156ab..212f346 100644
--- a/src/my_gtk_gl_scene_widget.h
+++ b/src/my_gtk_gl_scene_widget.hpp
@@ -1,7 +1,7 @@
#ifndef MY_GTK_GL_SCENE_H
#define MY_GTK_GL_SCENE_H
-#include "gtk_includes.h"
+#include "gtk_includes.hpp"
// 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)