From a5bf134265abfd108c3566a998038475151fc710 Mon Sep 17 00:00:00 2001 From: Julien Isorce Date: Sat, 12 Jul 2008 13:24:30 +0000 Subject: [PATCH] [122/906] better implementation of gst_gl_display_set_window_id for win32. (change the window of the current wglcontext instead of reinit everything, and so avoid some problems about opengl objects that could be init in the previous wglcontext and so no usable in the newer wglcontext, it what the case for the first texture) This newer implementation has not been made yet on linux git-svn-id: svn://svn.wobow.com/GStreamer_playground/gst-plugins-gl@582 93df14bb-0f41-7a43-8087-d3e2a2f0e464 --- gst-libs/gst/gl/gstgldisplay.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/gst-libs/gst/gl/gstgldisplay.c b/gst-libs/gst/gl/gstgldisplay.c index e2e9a50b71..275983b9b8 100644 --- a/gst-libs/gst/gl/gstgldisplay.c +++ b/gst-libs/gst/gl/gstgldisplay.c @@ -86,7 +86,7 @@ static void gst_gl_display_thread_do_download_draw (GstGLDisplay* display); static GHashTable* gst_gl_display_map = NULL; //all glut functions and opengl primitives are called in this thread -static GThread* gst_gl_display_glutThread = NULL; +static GThread* gst_gl_display_gl_thread = NULL; //-timepoped by glutIdleFunc static GAsyncQueue* gst_gl_display_messageQueue = NULL; @@ -437,12 +437,13 @@ gst_gl_display_finalize (GObject* object) if (display->use_fbo_stuff) display->use_fbo_stuff = NULL; - //at this step, the next condition imply that the last display has been pushed + //at this step, the next condition implies that + //the last display has been removed if (g_hash_table_size (gst_gl_display_map) == 0) { - g_thread_join (gst_gl_display_glutThread); + g_thread_join (gst_gl_display_gl_thread); g_print ("gl thread joined\n"); - gst_gl_display_glutThread = NULL; + gst_gl_display_gl_thread = NULL; g_async_queue_unref (gst_gl_display_messageQueue); g_hash_table_unref (gst_gl_display_map); gst_gl_display_map = NULL; @@ -468,6 +469,7 @@ gst_gl_display_thread_func (GstGLDisplay *display) //Should be pass through a glimagesink property glutInit(&argc, &argv); glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION); + //glutSetOption(GLUT_RENDERING_CONTEXT, GLUT_USE_CURRENT_CONTEXT); glutIdleFunc (gst_gl_display_thread_loop); @@ -1683,7 +1685,7 @@ gst_gl_display_create_context (GstGLDisplay *display, { gst_gl_display_messageQueue = g_async_queue_new (); gst_gl_display_map = g_hash_table_new (g_direct_hash, g_direct_equal); - gst_gl_display_glutThread = g_thread_create ( + gst_gl_display_gl_thread = g_thread_create ( (GThreadFunc) gst_gl_display_thread_func, display, TRUE, NULL); g_cond_wait (display->cond_create_context, display->mutex); } @@ -1926,19 +1928,26 @@ gst_gl_display_set_window_id (GstGLDisplay* display, gulong winId) { static gint y_pos = 0; +#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) + + gst_gl_display_lock (display); + display->winId = winId; + gst_gl_display_post_message (GST_GL_DISPLAY_ACTION_CHANGE_CONTEXT, display); + g_cond_wait (display->cond_change_context, display->mutex); + gst_gl_display_unlock (display); + +#else + gst_gl_display_lock (display); - //display->winId = winId; - //gst_gl_display_post_message (GST_GL_DISPLAY_ACTION_CHANGE_CONTEXT, display); gst_gl_display_post_message (GST_GL_DISPLAY_ACTION_DESTROY_CONTEXT, display); - //g_cond_wait (display->cond_change_context, display->mutex); g_cond_wait (display->cond_destroy_context, display->mutex); gst_gl_display_unlock (display); if (g_hash_table_size (gst_gl_display_map) == 0) { - g_thread_join (gst_gl_display_glutThread); + g_thread_join (gst_gl_display_gl_thread); g_print ("gl thread joined when setting winId\n"); - gst_gl_display_glutThread = NULL; + gst_gl_display_gl_thread = NULL; g_async_queue_unref (gst_gl_display_messageQueue); g_hash_table_unref (gst_gl_display_map); gst_gl_display_map = NULL; @@ -1954,6 +1963,7 @@ gst_gl_display_set_window_id (GstGLDisplay* display, gulong winId) //init colorspace conversion if needed gst_gl_display_init_upload (display, display->upload_video_format, display->upload_width, display->upload_height); +#endif }