Esempio n. 1
0
static gboolean
_gdk_win32_gl_context_impl_make_current (GdkGLContext *glcontext,
                                         GdkGLDrawable *draw,
                                         GdkGLDrawable *read)
{
  GdkGLWindowImplWin32 *impl;
  HDC hdc;
  HGLRC hglrc;

  g_return_val_if_fail (GDK_IS_WIN32_GL_CONTEXT (glcontext), FALSE);
  g_return_val_if_fail (GDK_IS_WIN32_GL_WINDOW (draw), FALSE);

  if (GDK_GL_WINDOW_IS_DESTROYED (GDK_GL_WINDOW (draw)) ||
      GDK_GL_CONTEXT_IS_DESTROYED (glcontext))
    return FALSE;

  impl = GDK_GL_WINDOW_IMPL_WIN32 (GDK_GL_WINDOW (draw)->impl);

  /* Get DC. */
  hdc = GDK_GL_WINDOW_IMPL_WIN32_HDC_GET (impl);

  /* Get GLRC. */
  hglrc = GDK_GL_CONTEXT_HGLRC (glcontext);

  GDK_GL_NOTE_FUNC_IMPL ("wglMakeCurrent");

  if (!wglMakeCurrent (hdc, hglrc))
    {
      g_warning ("wglMakeCurrent() failed");
      _gdk_gl_context_set_gl_drawable (glcontext, NULL);
      /* currently unused. */
      /* _gdk_gl_context_set_gl_drawable_read (glcontext, NULL); */
      return FALSE;
    }

  _gdk_gl_context_set_gl_drawable (glcontext, draw);
  /* currently unused. */
  /* _gdk_gl_context_set_gl_drawable_read (glcontext, read); */

  if (_GDK_GL_CONFIG_AS_SINGLE_MODE (impl->glconfig))
    {
      /* We do this because we are treating a double-buffered frame
         buffer as a single-buffered frame buffer because the system
         does not appear to export any suitable single-buffered
         visuals (in which the following are necessary). */
      glDrawBuffer (GL_FRONT);
      glReadBuffer (GL_FRONT);
    }

  GDK_GL_NOTE (MISC, _gdk_gl_print_gl_info ());

  /*
   * Do *NOT* release DC.
   *
   * With some graphics card, DC owned by rendering thread will be needed.
   */

  return TRUE;
}
Esempio n. 2
0
/*< private >*/
GdkGLContextImpl *
_gdk_win32_gl_context_impl_new (GdkGLContext  *glcontext,
                                GdkGLDrawable *gldrawable,
                                GdkGLContext  *share_list,
                                gboolean       direct,
                                int            render_type)
{
  GdkGLConfig *glconfig;
  HDC hdc;
  HGLRC hglrc;
  GdkGLContextImplWin32 *share_impl = NULL;

  GDK_GL_NOTE_FUNC_PRIVATE ();

  /*
   * Create an OpenGL rendering context.
   */

  glconfig = gdk_gl_drawable_get_gl_config (gldrawable);

  /* Get DC. */
  hdc = gdk_win32_gl_window_get_hdc (GDK_GL_WINDOW (gldrawable));
  if (hdc == NULL)
    return NULL;

  GDK_GL_NOTE_FUNC_IMPL ("wglCreateContext");

  hglrc = wglCreateContext (hdc);

  /* Release DC. */
  gdk_win32_gl_window_release_hdc (GDK_GL_WINDOW (gldrawable));

  if (hglrc == NULL)
    return NULL;

  if (share_list != NULL && GDK_IS_GL_CONTEXT (share_list))
    {
      GDK_GL_NOTE_FUNC_IMPL ("wglShareLists");

      share_impl = GDK_GL_CONTEXT_IMPL_WIN32 (share_list);
      if (!wglShareLists (share_impl->hglrc, hglrc))
        {
          wglDeleteContext (hglrc);
          return NULL;
        }
    }

  /*
   * Instantiate the GdkGLContextImplWin32 object.
   */

  return gdk_win32_gl_context_impl_new_common (glcontext,
                                               glconfig,
                                               share_list,
                                               render_type,
                                               hglrc,
                                               FALSE);
}
Esempio n. 3
0
void
gdk_gl_window_swap_buffers (GdkGLDrawable *gldrawable)
{
  g_return_if_fail (GDK_IS_GL_WINDOW(gldrawable));

  Display *xdisplay = GDK_GL_CONFIG_XDISPLAY (GDK_GL_WINDOW (gldrawable)->glconfig);
  Window glxwindow = GDK_GL_WINDOW (gldrawable)->glxwindow;

  if (glxwindow == None)
    return;

  GDK_GL_NOTE_FUNC_IMPL ("glXSwapBuffers");

  glXSwapBuffers (xdisplay, glxwindow);
}
Esempio n. 4
0
GdkGLConfig*
gdk_gl_window_get_gl_config (GdkGLDrawable *gldrawable)
{
  g_return_val_if_fail (GDK_IS_GL_WINDOW (gldrawable), NULL);

  return GDK_GL_WINDOW (gldrawable)->glconfig;
}
Esempio n. 5
0
gboolean
gdk_gl_window_make_context_current (GdkGLDrawable *draw, GdkGLContext *glcontext)
{
  GdkGLDrawable *read = draw;
  GdkGLConfig *glconfig;
  Window glxwindow;
  GLXContext glxcontext;

  g_return_val_if_fail (GDK_IS_GL_WINDOW (draw), FALSE);
  g_return_val_if_fail (GDK_IS_GL_CONTEXT_IMPL_X11 (glcontext), FALSE);

  glconfig = GDK_GL_WINDOW (draw)->glconfig;
  glxwindow = GDK_GL_WINDOW (draw)->glxwindow;
  glxcontext = GDK_GL_CONTEXT_GLXCONTEXT (glcontext);

  if (glxwindow == None || glxcontext == NULL)
    return FALSE;

  GDK_GL_NOTE (MISC, g_message (" -- Window: screen number = %d", GDK_SCREEN_XNUMBER (gdk_drawable_get_screen (GDK_DRAWABLE (draw)))));
  GDK_GL_NOTE (MISC, g_message (" -- Window: visual id = 0x%lx", GDK_VISUAL_XVISUAL (gdk_drawable_get_visual (GDK_DRAWABLE (draw)))->visualid));

  GDK_GL_NOTE_FUNC_IMPL ("glXMakeCurrent");

  if (!glXMakeCurrent (GDK_GL_CONFIG_XDISPLAY (glconfig), glxwindow, glxcontext))
    {
      g_warning ("glXMakeCurrent() failed");
      _gdk_gl_context_set_gl_drawable (glcontext, NULL);
      return FALSE;
    }

  _gdk_gl_context_set_gl_drawable (glcontext, draw);

  if (_GDK_GL_CONFIG_AS_SINGLE_MODE (glconfig))
    {
      /* We do this because we are treating a double-buffered frame
         buffer as a single-buffered frame buffer because the system
         does not appear to export any suitable single-buffered
         visuals (in which the following are necessary). */
      glDrawBuffer (GL_FRONT);
      glReadBuffer (GL_FRONT);
    }

  GDK_GL_NOTE (MISC, _gdk_gl_print_gl_info ());

  return TRUE;
}
Esempio n. 6
0
static GdkGLConfig *
_gdk_gl_window_get_gl_config (GdkGLDrawable *gldrawable)
{
  GdkGLWindow *glwindow;

  g_return_val_if_fail(GDK_IS_GL_WINDOW(gldrawable), NULL);

  glwindow = GDK_GL_WINDOW (gldrawable);

  return GDK_GL_WINDOW_IMPL_GET_CLASS (glwindow->impl)->get_gl_config (glwindow);
}
Esempio n. 7
0
static void
_gdk_gl_window_wait_gdk (GdkGLDrawable *gldrawable)
{
  GdkGLWindow *glwindow;

  g_return_if_fail(GDK_IS_GL_WINDOW(gldrawable));

  glwindow = GDK_GL_WINDOW (gldrawable);

  GDK_GL_WINDOW_IMPL_GET_CLASS (glwindow->impl)->wait_gdk (glwindow);
}
Esempio n. 8
0
static gboolean
_gdk_gl_window_is_double_buffered (GdkGLDrawable *gldrawable)
{
  GdkGLWindow *glwindow;

  g_return_val_if_fail(GDK_IS_GL_WINDOW(gldrawable), FALSE);

  glwindow = GDK_GL_WINDOW (gldrawable);

  return GDK_GL_WINDOW_IMPL_GET_CLASS (glwindow->impl)->is_double_buffered (glwindow);
}
Esempio n. 9
0
static void
_gdk_win32_gl_context_impl_make_uncurrent (GdkGLContext *glcontext)
{
  GdkGLDrawable *gldrawable = _gdk_win32_gl_context_impl_get_gl_drawable (glcontext);

  g_return_if_fail(gldrawable != NULL);

  GdkGLWindowImplWin32 *impl = GDK_GL_WINDOW_IMPL_WIN32 ( GDK_GL_WINDOW (gldrawable)->impl);

  /* Release DC. */
  GDK_GL_WINDOW_IMPL_WIN32_HDC_RELEASE (impl);
}
Esempio n. 10
0
static void
gdk_gl_window_impl_win32_finalize (GObject *object)
{
  GdkGLWindowImplWin32 *impl = GDK_GL_WINDOW_IMPL_WIN32 (object);

  GDK_GL_NOTE_FUNC_PRIVATE ();

  _gdk_win32_gl_window_impl_destroy (GDK_GL_WINDOW (object));

  g_object_unref (G_OBJECT (impl->glconfig));

  G_OBJECT_CLASS (gdk_gl_window_impl_win32_parent_class)->finalize (object);
}
Esempio n. 11
0
static void
gdk_gl_window_finalize (GObject *object)
{
  GdkGLWindow *glwindow = GDK_GL_WINDOW (object);

  GDK_GL_NOTE_FUNC_PRIVATE ();

  if (glwindow->window != NULL)
    g_object_remove_weak_pointer (G_OBJECT (glwindow->window),
                                  (gpointer *) &(glwindow->window));

  G_OBJECT_CLASS (gdk_gl_window_parent_class)->finalize (object);
}
Esempio n. 12
0
static void
gdk_gl_window_finalize (GObject *object)
{
  GdkGLWindow *glwindow = GDK_GL_WINDOW (object);

  GDK_GL_NOTE_FUNC_PRIVATE ();

  if (glwindow->drawable)
    g_object_remove_weak_pointer (G_OBJECT (glwindow->drawable), (gpointer *) &(glwindow->drawable));

  _gdk_gl_window_destroy (glwindow);

  g_object_unref (G_OBJECT (glwindow->glconfig));

  G_OBJECT_CLASS (gdk_gl_window_parent_class)->finalize (object);
}
Esempio n. 13
0
static GdkGLContext *
_gdk_gl_window_create_gl_context  (GdkGLDrawable *gldrawable,
                                   GdkGLContext  *share_list,
                                   gboolean       direct,
                                   int            render_type)
{
  GdkGLWindow *glwindow;

  g_return_val_if_fail(GDK_IS_GL_WINDOW(gldrawable), NULL);

  glwindow = GDK_GL_WINDOW (gldrawable);

  return GDK_GL_WINDOW_IMPL_GET_CLASS (glwindow->impl)->create_gl_context (glwindow,
                                                                           share_list,
                                                                           direct,
                                                                           render_type);
}