summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2013-02-16 23:29:34 +0000
committerLudovic Pouzenc <ludovic@pouzenc.fr>2013-02-16 23:29:34 +0000
commitee1b8631b3f0aed4aa43f460f268e73f19620634 (patch)
tree9cb63e2d15143e95aa179930aecd8c9e67825588
parent868875dabcd009b6706fdaf7808330eafe90ffe7 (diff)
download2013-gpudataviz-ee1b8631b3f0aed4aa43f460f268e73f19620634.tar.gz
2013-gpudataviz-ee1b8631b3f0aed4aa43f460f268e73f19620634.tar.bz2
2013-gpudataviz-ee1b8631b3f0aed4aa43f460f268e73f19620634.zip
Ajout de quelques bouts. Il manque pas grand chose pour avoir OpenCL là dedans, je pense
git-svn-id: file:///var/svn/2013-gpudataviz/trunk@10 371a6b4a-a258-45f8-9dcc-bdd82ce0ac9d
-rw-r--r--tests/poc_c/main.c55
1 files changed, 52 insertions, 3 deletions
diff --git a/tests/poc_c/main.c b/tests/poc_c/main.c
index 78eaf15..2b86f0f 100644
--- a/tests/poc_c/main.c
+++ b/tests/poc_c/main.c
@@ -18,6 +18,8 @@ gboolean gl_area_on_draw (GtkObject* area, GdkEventExpose* event, gpointer data)
return FALSE;
}
+ printf("on_draw_glx_current_context==%p\n", (void *)glXGetCurrentContext());
+
GtkAllocation allocation;
gtk_widget_get_allocation (GTK_WIDGET (area), &allocation);
GLdouble viewport_width = (GLdouble) allocation.width;
@@ -76,7 +78,9 @@ int main(int argc, char *argv[]) {
GdkGLConfig* gl_config;
GdkGLContext* gl_context;
+ GdkGLDrawable* drawable;
GLXContext glx_context; // X11 specific
+ Display *glx_display; // X11 specific
gboolean res;
gtk_init(&argc, &argv);
@@ -97,8 +101,8 @@ int main(int argc, char *argv[]) {
gl_config = gdk_gl_config_new_by_mode(GDK_GL_MODE_RGBA | GDK_GL_MODE_DOUBLE | GDK_GL_MODE_DEPTH);
res = gtk_widget_set_gl_capability(GTK_WIDGET(gl_area), gl_config,
/* GdkGLContext *share_list */ NULL,
- /* gboolean direct */ TRUE,
- /* int render_type */ GDK_GL_RGBA_TYPE);
+ /* gboolean direct */ TRUE,
+ /* int render_type */ GDK_GL_RGBA_TYPE);
if ( !res ) {
fputs ("Failed to set_gl_capability(gl_area)\n", stderr);
return EXIT_FAILURE;
@@ -114,15 +118,60 @@ int main(int argc, char *argv[]) {
fputs ("Failed to get_gl_context(gl_area)\n", stderr);
return EXIT_FAILURE;
}
+ drawable = gtk_widget_get_gl_drawable(GTK_WIDGET(gl_area));
+ res = gdk_gl_drawable_gl_begin(drawable, gl_context);
/* BEGIN : X11 specific */
- glx_context=gdk_x11_gl_context_get_glxcontext(gl_context);
+
+ /*
+ glx_context=gdk_x11_gl_context_get_glxcontext(gl_context);
if ( !glx_context) {
fputs ("Failed to gdk_x11_gl_context_get_glxcontext(gl_context)\n", stderr);
return EXIT_FAILURE;
}
printf("glx_context==%p\n", (void *)glx_context);
+ */
+ glx_context=glXGetCurrentContext();
+ if ( !glx_context ) {
+ fputs ("Failed to glXGetCurrentContext()", stderr);
+ return EXIT_FAILURE;
+ }
+ glx_display=glXGetCurrentDisplay();
+ if ( !glx_display ) {
+ fputs ("Failed to glXGetCurrentDisplay()", stderr);
+ return EXIT_FAILURE;
+ }
+
+ printf("glx_current_context==%p\n", (void *)glx_context);
+ printf("glx_current_display==%p\n", (void *)glx_display);
/* END : X11 specific */
+ gdk_gl_drawable_gl_end (drawable);
+
+ //TODO OpenCL init (platform pointer). In a while loop for trying all ?
+
+ /* BEGIN : X11 specific */
+ cl_context_properties cpsGL[] = { CL_CONTEXT_PLATFORM, (cl_context_properties)platform,
+ CL_GLX_DISPLAY_KHR, (intptr_t) glx_display,
+ CL_GL_CONTEXT_KHR, (intptr_t) glx_context, 0
+ };
+
+ /*
+ if (!clGetGLContextInfoKHR)
+ {
+ clGetGLContextInfoKHR = (clGetGLContextInfoKHR_fn) clGetExtensionFunctionAddressForPlatform(platform, "clGetGLContextInfoKHR");
+ if (!clGetGLContextInfoKHR)
+ {
+ std::cout << "Failed to query proc address for clGetGLContextInfoKHR";
+ }
+ }
+
+
+*/
+
+
+
+
+
gtk_main();
return EXIT_SUCCESS;