Exemple #1
0
/**
 * gdk_x11_gl_query_glx_extension:
 * @glconfig: a #GdkGLConfig.
 * @extension: name of GLX extension.
 *
 * Determines whether a given GLX extension is supported.
 *
 * Return value: TRUE if the GLX extension is supported, FALSE if not
 *               supported.
 **/
gboolean
gdk_x11_gl_query_glx_extension (GdkGLConfig *glconfig, const char  *extension)
{
  static const char *extensions = NULL;
  const char *start;
  char *where, *terminator;
  int major, minor;

  g_return_val_if_fail (GDK_IS_GL_CONFIG(glconfig), FALSE);

  /* Extension names should not have spaces. */
  where = strchr (extension, ' ');
  if (where || *extension == '\0')
    return FALSE;

  if (extensions == NULL)
    {
      /* Be careful not to call glXQueryExtensionsString if it
         looks like the server doesn't support GLX 1.1.
         Unfortunately, the original GLX 1.0 didn't have the notion
         of GLX extensions. */

      glXQueryVersion (GDK_GL_CONFIG_XDISPLAY (glconfig), &major, &minor);

      if ((major == 1 && minor < 1) || (major < 1))
        return FALSE;

      int screen_num = GDK_GL_CONFIG(glconfig)->screen_num;
      extensions = glXQueryExtensionsString (GDK_GL_CONFIG_XDISPLAY (glconfig), screen_num);
    }

  /* It takes a bit of care to be fool-proof about parsing
     the GLX extensions string.  Don't be fooled by
     sub-strings,  etc. */
  start = extensions;
  for (;;)
    {
      where = strstr (start, extension);
      if (where == NULL)
        break;

      terminator = where + strlen (extension);

      if (where == start || *(where - 1) == ' ')
        if (*terminator == ' ' || *terminator == '\0')
          {
            GDK_GL_NOTE (MISC, g_message (" - %s - supported", extension));
            return TRUE;
          }

      start = terminator;
    }

  GDK_GL_NOTE (MISC, g_message (" - %s - not supported", extension));

  return FALSE;
}
Exemple #2
0
static int lglext_widget_set_gl_capability(lua_State* L)
{
	luaL_checktype(L, 1, LUA_TUSERDATA);
	luaL_checktype(L, 2, LUA_TUSERDATA);
	luaL_checktype(L, 3, LUA_TBOOLEAN);
	luaL_checktype(L, 4, LUA_TNUMBER);

	Object* obj1 = lua_touserdata(L, 1);
	Object* obj2 = lua_touserdata(L, 2);

	gboolean res = gtk_widget_set_gl_capability(GTK_WIDGET(obj1->pointer),
		GDK_GL_CONFIG(obj2->pointer), NULL, lua_toboolean(L, 3),
		lua_tointeger(L, 4));

	lua_pushboolean(L, res);

	return 1;
}