Пример #1
0
static void
gdk_gl_config_impl_win32_init (GdkGLConfigImplWin32 *self)
{
  GDK_GL_NOTE_FUNC_PRIVATE ();

  memset (&self->pfd, 0, sizeof(self->pfd));
  GDK_GL_NOTE_FUNC_PRIVATE ();
  self->screen = NULL;
  GDK_GL_NOTE_FUNC_PRIVATE ();
  self->depth = 0;
}
Пример #2
0
static void
gdk_gl_window_init (GdkGLWindow *self)
{
  GDK_GL_NOTE_FUNC_PRIVATE ();

  self->window = NULL;
}
Пример #3
0
static void
gdk_gl_config_finalize (GObject *object)
{
  GDK_GL_NOTE_FUNC_PRIVATE ();

  G_OBJECT_CLASS (parent_class)->finalize (object);
}
Пример #4
0
void
_gdk_gl_pixmap_destroy (GdkGLPixmap *glpixmap)
{
  GdkGLPixmapImplWin32 *impl = GDK_GL_PIXMAP_IMPL_WIN32 (glpixmap);

  GDK_GL_NOTE_FUNC_PRIVATE ();

  if (impl->is_destroyed)
    return;

  if (impl->hdc_gl == wglGetCurrentDC ())
    {
      glFinish ();

      GDK_GL_NOTE_FUNC_IMPL ("wglMakeCurrent");
      wglMakeCurrent (NULL, NULL);
    }

  DeleteDC (impl->hdc_gl);
  impl->hdc_gl = NULL;

  DeleteDC (impl->hdc_gdk);
  impl->hdc_gdk = NULL;

  g_object_unref (G_OBJECT (impl->pixmap_gl));
  impl->pixmap_gl = NULL;

  impl->is_destroyed = TRUE;
}
Пример #5
0
static void
gdk_gl_context_class_init (GdkGLContextClass *klass)
{
  GObjectClass *object_class = G_OBJECT_CLASS (klass);

  GDK_GL_NOTE_FUNC_PRIVATE ();
}
Пример #6
0
/*< private >*/
void
_gdk_gl_context_set_gl_drawable (GdkGLContext  *glcontext,
                                 GdkGLDrawable *gldrawable)
{
  GdkGLContextImplWin32 *impl = GDK_GL_CONTEXT_IMPL_WIN32 (glcontext->impl);

  GDK_GL_NOTE_FUNC_PRIVATE ();

  if (impl->gldrawable == gldrawable)
    return;

  if (impl->gldrawable != NULL)
    {
      g_object_remove_weak_pointer (G_OBJECT (impl->gldrawable),
                                    (gpointer *) &(impl->gldrawable));
      impl->gldrawable = NULL;
    }

  if (gldrawable != NULL && GDK_IS_GL_DRAWABLE (gldrawable))
    {
      impl->gldrawable = gldrawable;
      g_object_add_weak_pointer (G_OBJECT (impl->gldrawable),
                                 (gpointer *) &(impl->gldrawable));
    }
}
Пример #7
0
static GdkColormap *
gdk_gl_config_setup_colormap (GdkScreen             *screen,
                              PIXELFORMATDESCRIPTOR *pfd,
                              gboolean               is_rgba)
{
  GDK_GL_NOTE_FUNC_PRIVATE ();

  if (is_rgba)
    {
      /*
       * For RGBA mode.
       */

      /* System default colormap. */

      GDK_GL_NOTE (MISC, g_message (" -- Colormap: system default"));

      return g_object_ref (G_OBJECT (gdk_screen_get_system_colormap (screen)));
    }
  else
    {
      /*
       * For color index mode.
       */

      /* New private colormap. */

      GDK_GL_NOTE (MISC, g_message (" -- Colormap: new allocated writable"));

      return gdk_colormap_new (gdk_screen_get_system_visual (screen), TRUE);
    }

  /* not reached */
  return NULL;
}
Пример #8
0
void
_gdk_gl_window_destroy (GdkGLWindow *glwindow)
{
  GdkGLWindowImplX11 *impl = GDK_GL_WINDOW_IMPL_X11 (glwindow);
  Display *xdisplay;
  GdkGL_GLX_MESA_release_buffers *mesa_ext;

  GDK_GL_NOTE_FUNC_PRIVATE ();

  if (impl->is_destroyed)
    return;

  xdisplay = GDK_GL_CONFIG_XDISPLAY (impl->glconfig);

  if (impl->glxwindow == glXGetCurrentDrawable ())
    {
      glXWaitGL ();

      GDK_GL_NOTE_FUNC_IMPL ("glXMakeCurrent");
      glXMakeCurrent (xdisplay, None, NULL);
    }

  /* If GLX_MESA_release_buffers is supported. */
  mesa_ext = gdk_gl_get_GLX_MESA_release_buffers (impl->glconfig);
  if (mesa_ext)
    {
      GDK_GL_NOTE_FUNC_IMPL ("glXReleaseBuffersMESA");
      mesa_ext->glXReleaseBuffersMESA (xdisplay, impl->glxwindow);
    }

  impl->glxwindow = None;

  impl->is_destroyed = TRUE;
}
Пример #9
0
void
_gdk_gl_pixmap_destroy (GdkGLPixmap *glpixmap)
{
  GdkGLPixmapImplX11 *impl = GDK_GL_PIXMAP_IMPL_X11 (glpixmap);
  Display *xdisplay;

  GDK_GL_NOTE_FUNC_PRIVATE ();

  if (impl->is_destroyed)
    return;

  xdisplay = GDK_GL_CONFIG_XDISPLAY (impl->glconfig);

  if (impl->glxpixmap == glXGetCurrentDrawable ())
    {
      glXWaitGL ();

      GDK_GL_NOTE_FUNC_IMPL ("glXMakeCurrent");
      glXMakeCurrent (xdisplay, None, NULL);
    }

  GDK_GL_NOTE_FUNC_IMPL ("glXDestroyGLXPixmap");
  glXDestroyGLXPixmap (xdisplay, impl->glxpixmap);

  impl->glxpixmap = None;

  impl->is_destroyed = TRUE;
}
Пример #10
0
static void
_gdk_win32_gl_window_impl_destroy (GdkGLWindow *glwindow)
{
  GdkGLWindowImplWin32 *impl = GDK_GL_WINDOW_IMPL_WIN32 (glwindow->impl);

  GDK_GL_NOTE_FUNC_PRIVATE ();

  if (impl->is_destroyed)
    return;

  /* Get DC. */
  if (impl->hdc == NULL)
    {
      impl->hdc = GetDC (impl->hwnd);
      if (impl->hdc == NULL)
        return;
    }

  if (impl->hdc == wglGetCurrentDC ())
    {
      glFinish ();

      GDK_GL_NOTE_FUNC_IMPL ("wglMakeCurrent");
      wglMakeCurrent (NULL, NULL);
    }

  /* Release DC. */
  if (impl->need_release_dc)
    ReleaseDC (impl->hwnd, impl->hdc);
  impl->hdc = NULL;

  impl->hwnd = NULL;

  impl->is_destroyed = TRUE;
}
Пример #11
0
static void
gdk_gl_pixmap_sync_gdk (GdkGLPixmap *glpixmap)
{
  GdkGLPixmapImplWin32 *impl;
  int width, height;
  HBITMAP hbitmap_old;

  g_return_if_fail (GDK_IS_GL_PIXMAP_IMPL_WIN32 (glpixmap));

  GDK_GL_NOTE_FUNC_PRIVATE ();

  impl = GDK_GL_PIXMAP_IMPL_WIN32 (glpixmap);

  width = impl->width;
  height = impl->height;

  /*
   * Copy GDK bitmap to OpenGL bitmap.
   */

  hbitmap_old = SelectObject (impl->hdc_gdk, impl->hbitmap_gdk);
  if (hbitmap_old == NULL)
    {
      g_warning ("cannot select DIB");
      return;
    }

  if (!StretchBlt (impl->hdc_gl,  0, 0,      width,  height,
		   impl->hdc_gdk, 0, height, width, -height,
		   SRCCOPY))
    g_warning ("StretchBlt() failed");

  SelectObject (impl->hdc_gdk, hbitmap_old);
}
Пример #12
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);
}
Пример #13
0
static PangoFont *
gdk_gl_font_use_pango_font_common (PangoFontMap               *font_map,
                                   const PangoFontDescription *font_desc,
                                   int                         first,
                                   int                         count,
                                   int                         list_base)
{
  PangoFont *font = NULL;
  gchar *charset = NULL;
  PangoXSubfont subfont_id;
  gchar *xlfd = NULL;
  PangoXFontCache *font_cache;
  XFontStruct *fs;

  GDK_GL_NOTE_FUNC_PRIVATE ();

  font = pango_font_map_load_font (font_map, NULL, font_desc);
  if (font == NULL)
    {
      g_warning ("cannot load PangoFont");
      goto FAIL;
    }

  charset = gdk_gl_font_charset_for_locale ();
  if (!pango_x_find_first_subfont (font, &charset, 1, &subfont_id))
    {
      g_warning ("cannot find PangoXSubfont");
      font = NULL;
      goto FAIL;
    }

  xlfd = pango_x_font_subfont_xlfd (font, subfont_id);
  if (xlfd == NULL)
    {
      g_warning ("cannot get XLFD");
      font = NULL;
      goto FAIL;
    }

  font_cache = pango_x_font_map_get_font_cache (font_map);

  fs = pango_x_font_cache_load (font_cache, xlfd);

  glXUseXFont (fs->fid, first, count, list_base);

  pango_x_font_cache_unload (font_cache, fs);

 FAIL:

  if (charset != NULL)
    g_free (charset);

  if (xlfd != NULL)
    g_free (xlfd);

  return font;
}
Пример #14
0
static void
gdk_gl_window_class_init (GdkGLWindowClass *klass)
{
  GObjectClass *object_class = G_OBJECT_CLASS (klass);

  GDK_GL_NOTE_FUNC_PRIVATE ();

  object_class->finalize = gdk_gl_window_finalize;
}
Пример #15
0
static void
gdk_gl_config_impl_win32_class_init (GdkGLConfigImplWin32Class *klass)
{
  GObjectClass *object_class = G_OBJECT_CLASS (klass);

  GDK_GL_NOTE_FUNC_PRIVATE ();

  object_class->finalize = gdk_gl_config_impl_win32_finalize;
}
Пример #16
0
static void
gdk_gl_pixmap_impl_x11_class_init (GdkGLPixmapImplX11Class *klass)
{
  GObjectClass *object_class = G_OBJECT_CLASS (klass);

  GDK_GL_NOTE_FUNC_PRIVATE ();

  object_class->finalize = gdk_gl_pixmap_impl_x11_finalize;
}
Пример #17
0
/* private at present... */
gboolean
_gdk_x11_gl_overlay_get_info (GdkVisual        *visual,
                              GdkGLOverlayInfo *overlay_info)
{
  __SOVPropArray *sov_props;
  VisualID xvisualid;
  int i;

  GDK_GL_NOTE_FUNC_PRIVATE ();

  g_return_val_if_fail (GDK_IS_VISUAL (visual), FALSE);
  g_return_val_if_fail (overlay_info != NULL, FALSE);

  /* Get SOV properties. */

#ifdef GDKGLEXT_MULTIHEAD_SUPPORT
  sov_props = gdk_gl_overlay_get_sov_props (gdk_visual_get_screen (visual));
#else  /* GDKGLEXT_MULTIHEAD_SUPPORT */
  sov_props = gdk_gl_overlay_get_sov_props (NULL);
#endif /* GDKGLEXT_MULTIHEAD_SUPPORT */

  /* Look up SOV property for the visual. */

  xvisualid = GDK_VISUAL_XVISUAL (visual)->visualid;

  for (i = 0; i < sov_props->num; i++)
    {
      if ((VisualID) (sov_props->prop[i].overlay_visual) == xvisualid)
        {
          overlay_info->visual           = visual;
          overlay_info->transparent_type = sov_props->prop[i].transparent_type;
          overlay_info->value            = sov_props->prop[i].value;
          overlay_info->layer            = sov_props->prop[i].layer;

          GDK_GL_NOTE (MISC, g_message (" -- overlay visual"));
          GDK_GL_NOTE (MISC, g_print ("transparent_type = %d\n",
                                      overlay_info->transparent_type));
          GDK_GL_NOTE (MISC, g_print ("value = %u\n",
                                      overlay_info->value));
          GDK_GL_NOTE (MISC, g_print ("layer = %d\n",
                                      overlay_info->layer));

          return TRUE;
        }
    }

  /* meaningless */
  overlay_info->visual           = visual;
  overlay_info->transparent_type = GDK_GL_OVERLAY_TRANSPARENT_NONE;
  overlay_info->value            = 0;
  overlay_info->layer            = 0;

  GDK_GL_NOTE (MISC, g_message (" -- not overlay visual"));
      
  return FALSE;
}
Пример #18
0
static GdkGLContext *
gdk_gl_context_lookup (HGLRC hglrc)
{
  GDK_GL_NOTE_FUNC_PRIVATE ();

  if (gl_context_ht == NULL)
    return NULL;

  return g_hash_table_lookup (gl_context_ht, hglrc);
}
Пример #19
0
static void gdk_gl_context_class_init(GdkGLContextClass *klass)
{
	GObjectClass *object_class = G_OBJECT_CLASS(klass);

	GDK_GL_NOTE_FUNC_PRIVATE();

	parent_class = g_type_class_peek_parent(klass);

	object_class->finalize = gdk_gl_context_finalize;
}
Пример #20
0
static void
gdk_gl_window_impl_x11_class_init (GdkGLWindowImplX11Class *klass)
{
  GObjectClass *object_class = G_OBJECT_CLASS (klass);

  GDK_GL_NOTE_FUNC_PRIVATE ();

  parent_class = g_type_class_peek_parent (klass);

  object_class->finalize = gdk_gl_window_impl_x11_finalize;
}
Пример #21
0
static GdkGLContextImpl *
gdk_win32_gl_context_impl_new_common (GdkGLContext  *glcontext,
                                      GdkGLConfig   *glconfig,
                                      GdkGLContext  *share_list,
                                      int            render_type,
                                      HGLRC          hglrc,
                                      gboolean       is_foreign)
{
  GdkGLContextImpl *impl;
  GdkGLContextImplWin32 *win32_impl;

  GDK_GL_NOTE_FUNC_PRIVATE ();

  /*
   * Instantiate the GdkGLContextImplWin32 object.
   */

  impl = g_object_new (GDK_TYPE_GL_CONTEXT_IMPL_WIN32, NULL);
  win32_impl = GDK_GL_CONTEXT_IMPL_WIN32 (impl);

  win32_impl->hglrc = hglrc;

  if (share_list != NULL && GDK_IS_GL_CONTEXT (share_list))
    {
      win32_impl->share_list = share_list;
      g_object_ref (G_OBJECT (win32_impl->share_list));
    }
  else
    {
      win32_impl->share_list = NULL;
    }

  win32_impl->render_type = render_type;

  win32_impl->glconfig = glconfig;
  g_object_ref (G_OBJECT (win32_impl->glconfig));

  win32_impl->gldrawable = NULL;
  win32_impl->gldrawable_read = NULL;

  win32_impl->is_foreign = is_foreign;

  win32_impl->is_destroyed = FALSE;

  glcontext->impl = impl;

  /*
   * Insert into the GL context hash table.
   */

  gdk_gl_context_insert (glcontext);

  return impl;
}
Пример #22
0
static void
gdk_gl_config_impl_win32_finalize (GObject *object)
{
  GdkGLConfigImplWin32 *impl = GDK_GL_CONFIG_IMPL_WIN32 (object);

  GDK_GL_NOTE_FUNC_PRIVATE ();

  g_object_unref (G_OBJECT (impl->colormap));

  G_OBJECT_CLASS (gdk_gl_config_impl_win32_parent_class)->finalize (object);
}
Пример #23
0
static void
gdk_gl_window_gl_drawable_interface_init (GdkGLDrawableClass *iface)
{
  GDK_GL_NOTE_FUNC_PRIVATE ();

  iface->create_gl_context  = _gdk_gl_window_create_gl_context;
  iface->is_double_buffered = _gdk_gl_window_is_double_buffered;
  iface->swap_buffers       = _gdk_gl_window_swap_buffers;
  iface->wait_gl            = _gdk_gl_window_wait_gl;
  iface->wait_gdk           = _gdk_gl_window_wait_gdk;
  iface->get_gl_config      = _gdk_gl_window_get_gl_config;
}
Пример #24
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);
}
Пример #25
0
static void
gdk_gl_window_impl_win32_init (GdkGLWindowImplWin32 *self)
{
  GDK_GL_NOTE_FUNC_PRIVATE ();

  self->hwnd = NULL;
  memset (&self->pfd, 0, sizeof(self->pfd));
  self->pixel_format = 0;
  self->glconfig = NULL;
  self->hdc = NULL;
  self->is_destroyed = 0;
  self->need_release_dc = 0;
}
Пример #26
0
static void
gdk_gl_pixmap_impl_x11_finalize (GObject *object)
{
  GdkGLPixmapImplX11 *impl = GDK_GL_PIXMAP_IMPL_X11 (object);

  GDK_GL_NOTE_FUNC_PRIVATE ();

  _gdk_gl_pixmap_destroy (GDK_GL_PIXMAP (object));

  g_object_unref (G_OBJECT (impl->glconfig));

  G_OBJECT_CLASS (parent_class)->finalize (object);
}
Пример #27
0
static void
gdk_gl_pixmap_finalize (GObject *object)
{
  GdkGLPixmap *glpixmap = GDK_GL_PIXMAP (object);

  GDK_GL_NOTE_FUNC_PRIVATE ();

  if (glpixmap->drawable != NULL)
    g_object_remove_weak_pointer (G_OBJECT (glpixmap->drawable),
                                  (gpointer *) &(glpixmap->drawable));

  G_OBJECT_CLASS (parent_class)->finalize (object);
}
Пример #28
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);
}
Пример #29
0
static void
gdk_gl_context_impl_win32_init (GdkGLContextImplWin32 *self)
{
  GDK_GL_NOTE_FUNC_PRIVATE ();

  self->hglrc = NULL;
  self->share_list = NULL;
  self->render_type = 0;
  self->glconfig = NULL;
  self->gldrawable = NULL;
  self->gldrawable_read = NULL;
  self->is_destroyed = 0;
  self->is_foreign = 0;
}
Пример #30
0
static void
gdk_gl_pixmap_impl_x11_gl_drawable_interface_init (GdkGLDrawableClass *iface)
{
  GDK_GL_NOTE_FUNC_PRIVATE ();

  iface->create_new_context   = _gdk_x11_gl_context_new;
  iface->make_context_current =  gdk_gl_pixmap_impl_x11_make_context_current;
  iface->is_double_buffered   =  gdk_gl_pixmap_impl_x11_is_double_buffered;
  iface->swap_buffers         =  gdk_gl_pixmap_impl_x11_swap_buffers;
  iface->wait_gl              = _gdk_gl_drawable_impl_x11_wait_gl;
  iface->wait_gdk             = _gdk_gl_drawable_impl_x11_wait_gdk;
  iface->gl_begin             =  gdk_gl_pixmap_impl_x11_make_context_current;
  iface->gl_end               =  gdk_gl_pixmap_impl_x11_gl_end;
  iface->get_gl_config        =  gdk_gl_pixmap_impl_x11_get_gl_config;
  iface->get_size             = _gdk_gl_pixmap_get_size;
}