Beispiel #1
0
static int
GLXExtensionSupported(Display *dpy, const char *extension)
{
  const char *s;

  s = glXQueryExtensionsString(dpy, DefaultScreen(dpy));
  if(s != NULL && check_ext_string(s, extension))
    return 1;

  s = glXGetClientString(dpy, GLX_EXTENSIONS);
  if(s != NULL && check_ext_string(s, extension))
    return 1;

  return 0;
}
Beispiel #2
0
static int queryClient(Display *dpy, int screen)
{
#ifdef GLX_MESA_allocate_memory
  char *extensions;

  extensions = (char *)glXQueryExtensionsString(dpy, screen);
  if (!extensions || !strstr(extensions,"GLX_MESA_allocate_memory")) {
    return 0;
  }

  return 1;
#else
  return 0;
#endif
}
Beispiel #3
0
/**
 * Determine whether or not a GLX extension is supported.
 */
static int
is_glx_extension_supported(Display *dpy, const char *query)
{
   const int scrnum = DefaultScreen(dpy);
   const char *glx_extensions = NULL;
   const size_t len = strlen(query);
   const char *ptr;

   if (glx_extensions == NULL) {
      glx_extensions = glXQueryExtensionsString(dpy, scrnum);
   }

   ptr = strstr(glx_extensions, query);
   return ((ptr != NULL) && ((ptr[len] == ' ') || (ptr[len] == '\0')));
}
int _glfwPlatformExtensionSupported(const char* extension)
{
    const GLubyte* extensions;

    // Get list of GLX extensions
    extensions = (const GLubyte*) glXQueryExtensionsString(_glfw.x11.display,
                                                           _glfw.x11.screen);
    if (extensions != NULL)
    {
        if (_glfwStringInExtensionString(extension, extensions))
            return GL_TRUE;
    }

    return GL_FALSE;
}
    void investigate_swapcontrol_support() {

      if (has_checked_extensions) return; // Already calculated, no need to calculate it more.

      // TODO: The second argument to glXQueryExtensionsString is screen number,
      // and it is unknown if the value 0 is generally correct for calling that function.
      // For more information, see the following pages:
      // http://pic.dhe.ibm.com/infocenter/aix/v6r1/index.jsp?topic=%2Fcom.ibm.aix.opengl%2Fdoc%2Fopenglrf%2FglXQueryExtensionsString.htm
      const char *glx_extensions = glXQueryExtensionsString(enigma::x11::disp, 0);

      ext_swapcontrol_supported = strstr(glx_extensions, "GLX_EXT_swap_control");
      mesa_swapcontrol_supported = strstr(glx_extensions, "GLX_MESA_swap_control");

      has_checked_extensions = true;
    }
Beispiel #6
0
static bool gfx_ctx_x_bind_api(void *data, enum gfx_ctx_api api,
      unsigned major, unsigned minor)
{
   (void)data;

   g_major = major;
   g_minor = minor;
   x_api   = api;

   switch (api)
   {
      case GFX_CTX_OPENGL_API:
#ifdef HAVE_OPENGL
         return true;
#else
         break;
#endif
      case GFX_CTX_OPENGL_ES_API:
#ifdef HAVE_OPENGLES2
         {
            Display     *dpy = XOpenDisplay(NULL);
            const char *exts = glXQueryExtensionsString(dpy, DefaultScreen(dpy));
            bool ret         = exts && strstr(exts,
                  "GLX_EXT_create_context_es2_profile");
            XCloseDisplay(dpy);
            if (ret && g_major < 3)
            {
               g_major = 2; /* ES 2.0. */
               g_minor = 0;
            }
            return ret;
         }
#else
         break;
#endif
      case GFX_CTX_VULKAN_API:
#ifdef HAVE_VULKAN
         return true;
#else
         break;
#endif
      case GFX_CTX_NONE:
      default:
         break;
   }

   return false;
}
Beispiel #7
0
bool GLXGraphicsystem::init(Display* x11Display, Window x11Window)
{
    LOG_DEBUG("GLXGraphicsystem", "init");
    m_x11display = x11Display;
    m_window = x11Window;

    if (!m_x11display)
    {
        LOG_ERROR("GLXGraphicsystem", "given display is null");
        return false;
    }

    if (!m_window)
    {
        LOG_ERROR("GLXGraphicsystem", "given windowid is 0");
        return false;
    }

    XVisualInfo* windowVis = GetMatchingVisual(m_x11display);

    LOG_DEBUG("GLXGraphicsystem", "Initialising opengl");
    m_context = glXCreateContext(m_x11display, windowVis, 0, GL_TRUE);
    if (!m_context)
    {
        LOG_ERROR("GLXGraphicsystem", "Couldn't create GLX context!");
        return false;
    }
    LOG_DEBUG("GLXGraphicsystem", "Make GLX Context current");
    glXMakeCurrent(m_x11display, m_window, m_context);
    glEnable (GL_BLEND);
    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glClearColor(0.0, 0.0, 0.0, 1.0);
    glEnable(GL_TEXTURE_2D);
    glMatrixMode(GL_MODELVIEW);
    const char *ext;
    ext = glXQueryExtensionsString(m_x11display, 0);
    if (!strstr(ext, "GLX_EXT_texture_from_pixmap") )
    {
        m_zerocopy = false;
    }
    else
    {
        m_zerocopy = true;
    }

    LOG_DEBUG("GLXGraphicsystem", "Initialised");
    return true;
}
Beispiel #8
0
static bool CheckGLXext (Display *dpy, unsigned snum, const char *ext)
{
    const char *exts = glXQueryExtensionsString (dpy, snum);
    const size_t extlen = strlen (ext);

    while (*exts)
    {
        exts += strspn (exts, " ");

        size_t len = strcspn (exts, " ");
        if (len == extlen && !memcmp (exts, ext, extlen))
            return true;
        exts += len;
    }
    return false;
}
Beispiel #9
0
const char * getPlatformExtensions ()
{
    initExtensions ();                      // since we will need it for platform-specific extensions

#ifdef  _WIN32                              // check Windoze extensions
    if ( wglGetExtensionsStringARB == NULL )
    	return "";

    return wglGetExtensionsStringARB ( wglGetCurrentDC () );
#else                                       // check GLX extensions
    Display * display = glXGetCurrentDisplay ();
    int       screen  = DefaultScreen        ( display );

    return glXQueryExtensionsString ( display, screen );
#endif
}
Beispiel #10
0
GLboolean FWindow::Linux_InitializeGL()
{
	if(!Context)
	{
		Context = glXCreateContext(
			WindowManager::GetDisplay(),
			VisualInfo, 0, GL_TRUE);

		if(Context)
		{
			
			glXMakeCurrent(WindowManager::GetDisplay(),
			WindowHandle, Context);

			XWindowAttributes l_Attributes;

			XGetWindowAttributes(WindowManager::GetDisplay(),
			WindowHandle, &l_Attributes);
			Position[0] = l_Attributes.x;
			Position[1] = l_Attributes.y;

			const char* ExtensionsAvailable = 0;

			ExtensionsAvailable = glXQueryExtensionsString(WindowManager::GetDisplay(), 0);

			if(!ExtensionsAvailable)
			{
				PrintWarningMessage(WARNING_NOGLEXTENSIONS);
			}

			else
			{
				InitGLExtensions();
			}
			ContextCreated = GL_TRUE;
			return FOUNDATION_OKAY;
		}
	}

	else
	{
		PrintErrorMessage(ERROR_EXISTINGCONTEXT);
		return FOUNDATION_ERROR;	
	}

	return FOUNDATION_ERROR;
}
Beispiel #11
0
static void visualAttribs( Display * dpy, XVisualInfo * vi, VisualAttribs * attribs )
{
    memset( attribs, 0, sizeof( VisualAttribs ) );

    attribs->id = vi->visualid;
    attribs->c_class = vi->c_class;
    attribs->depth = vi->depth;
    attribs->redMask = vi->red_mask;
    attribs->greenMask = vi->green_mask;
    attribs->blueMask = vi->blue_mask;
    attribs->colormapSize = vi->colormap_size;
    attribs->bitsPerRGB = vi->bits_per_rgb;

    if ( glXGetConfig( dpy, vi, GLX_USE_GL, &attribs->supportsGL ) != 0 )
        return;
    attribs->accumAlphaSize = 0;
    glXGetConfig( dpy, vi, GLX_BUFFER_SIZE, &attribs->bufferSize );
    glXGetConfig( dpy, vi, GLX_LEVEL, &attribs->level );
    glXGetConfig( dpy, vi, GLX_RGBA, &attribs->rgba );
    glXGetConfig( dpy, vi, GLX_DOUBLEBUFFER, &attribs->doubleBuffer );
    glXGetConfig( dpy, vi, GLX_STEREO, &attribs->stereo );
    glXGetConfig( dpy, vi, GLX_AUX_BUFFERS, &attribs->auxBuffers );
    glXGetConfig( dpy, vi, GLX_RED_SIZE, &attribs->redSize );
    glXGetConfig( dpy, vi, GLX_GREEN_SIZE, &attribs->greenSize );
    glXGetConfig( dpy, vi, GLX_BLUE_SIZE, &attribs->blueSize );
    glXGetConfig( dpy, vi, GLX_ALPHA_SIZE, &attribs->alphaSize );
    glXGetConfig( dpy, vi, GLX_DEPTH_SIZE, &attribs->depthSize );
    glXGetConfig( dpy, vi, GLX_STENCIL_SIZE, &attribs->stencilSize );
    glXGetConfig( dpy, vi, GLX_ACCUM_RED_SIZE, &attribs->accumRedSize );
    glXGetConfig( dpy, vi, GLX_ACCUM_GREEN_SIZE, &attribs->accumGreenSize );
    glXGetConfig( dpy, vi, GLX_ACCUM_BLUE_SIZE, &attribs->accumBlueSize );
    glXGetConfig( dpy, vi, GLX_ACCUM_ALPHA_SIZE, &attribs->accumAlphaSize );

    attribs->transparent = 0; // transparent pixel missing
    attribs->numSamples = 0; // multisample tests missing
    attribs->numMultisample = 0;

#if defined(GLX_EXT_visual_rating)
    const char *ext = glXQueryExtensionsString( dpy, vi->screen );
    if ( ext && strstr( ext, "GLX_EXT_visual_rating" ) )
        glXGetConfig(dpy, vi, GLX_VISUAL_CAVEAT_EXT, &attribs->visualCaveat);
    else
        attribs->visualCaveat = GLX_NONE_EXT;
#else
    attribs->visualCaveat = 0;
#endif
}
bool GLPlatformContext::supportsGLXExtension(Display* display, const String& name)
{
    static HashSet<String> supportedExtensions;

    if (!supportedExtensions.size()) {
        if (!display)
            return false;

        String rawExtensions = glXQueryExtensionsString(display, DefaultScreen(display));
        supportedExtensions = parseExtensions(rawExtensions);
    }

    if (supportedExtensions.contains(name))
        return true;

    return false;
}
char * COpenGLExtentions::GetXGLExtensions()
{
	Display *dpDisplay;

	// Connect to X Server
	dpDisplay = XOpenDisplay(NULL);
	if(dpDisplay == NULL)
		throw nova::NovaExp("COpenGLExtentions::GetXGLExtensions() - can not connect to X server!", BAD_OPERATION);

	if(!glXQueryExtension(dpDisplay, NULL, NULL))
		return NULL;

	char * str = glXQueryExtensionsString(dpDisplay, DefaultScreen(dpDisplay));
	XCloseDisplay(dpDisplay);

	return str;
}
Beispiel #14
0
static GLXPixmap make_pixmap( Display *dpy, Window win,
			       unsigned int width, unsigned int height,
                               Pixmap *pixmap)
{
   Pixmap pm;
   GLXPixmap glxpm;
   XWindowAttributes attr;

   pm = XCreatePixmap( dpy, win, width, height, visinfo->depth );
   if (!pm) {
      printf("Error: XCreatePixmap failed\n");
      exit(-1);
   }

   XGetWindowAttributes( dpy, win, &attr );

   printf("pm %lx\n", pm);
   /*
    * IMPORTANT:
    *   Use the glXCreateGLXPixmapMESA funtion when using Mesa because
    *   Mesa needs to know the colormap associated with a pixmap in order
    *   to render correctly.  This is because Mesa allows RGB rendering
    *   into any kind of visual, not just TrueColor or DirectColor.
    */
#ifdef GLX_MESA_pixmap_colormap
   if (strstr(glXQueryExtensionsString(dpy, 0), "GLX_MESA_pixmap_colormap")) {
      /* stand-alone Mesa, specify the colormap */
      glxpm = glXCreateGLXPixmapMESA( dpy, visinfo, pm, attr.colormap );
   }
   else {
      glxpm = glXCreateGLXPixmap( dpy, visinfo, pm );
   }
#else
   /* This will work with Mesa too if the visual is TrueColor or DirectColor */
   glxpm = glXCreateGLXPixmap( dpy, visinfo, pm );
#endif

   if (!glxpm) {
      printf("Error: GLXCreateGLXPixmap failed\n");
      exit(-1);
   }

   *pixmap = pm;

   return glxpm;
}
Beispiel #15
0
void
init(void) {
    display = XOpenDisplay(NULL);
    if (!display) {
        std::cerr << "error: unable to open display " << XDisplayName(NULL) << "\n";
        exit(1);
    }

    screen = DefaultScreen(display);

    int major = 0, minor = 0;
    glXQueryVersion(display, &major, &minor);
    glxVersion = (major << 8) | minor;

    extensions = glXQueryExtensionsString(display, screen);
    has_GLX_ARB_create_context = checkExtension("GLX_ARB_create_context", extensions);
}
Beispiel #16
0
bool CWinSystemX11GL::CreateNewWindow(const CStdString& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction)
{
  if(!CWinSystemX11::CreateNewWindow(name, fullScreen, res, userFunction))
    return false;

  m_glxext  = " ";
  m_glxext += (const char*)glXQueryExtensionsString(m_dpy, DefaultScreen(m_dpy));
  m_glxext += " ";

  CLog::Log(LOGDEBUG, "GLX_EXTENSIONS:%s", m_glxext.c_str());

  /* any time window is recreated we need new pointers */
  if (IsExtSupported("GLX_OML_sync_control"))
    m_glXGetSyncValuesOML = (Bool (*)(Display*, GLXDrawable, int64_t*, int64_t*, int64_t*))glXGetProcAddress((const GLubyte*)"glXGetSyncValuesOML");
  else
    m_glXGetSyncValuesOML = NULL;

  if (IsExtSupported("GLX_OML_sync_control"))
    m_glXSwapBuffersMscOML = (int64_t (*)(Display*, GLXDrawable, int64_t, int64_t, int64_t))glXGetProcAddress((const GLubyte*)"glXSwapBuffersMscOML");
  else
    m_glXSwapBuffersMscOML = NULL;

  if (IsExtSupported("GLX_SGI_video_sync"))
    m_glXWaitVideoSyncSGI = (int (*)(int, int, unsigned int*))glXGetProcAddress((const GLubyte*)"glXWaitVideoSyncSGI");
  else
    m_glXWaitVideoSyncSGI = NULL;

  if (IsExtSupported("GLX_SGI_video_sync"))
    m_glXGetVideoSyncSGI = (int (*)(unsigned int*))glXGetProcAddress((const GLubyte*)"glXGetVideoSyncSGI");
  else
    m_glXGetVideoSyncSGI = NULL;

  if (IsExtSupported("GLX_SGI_swap_control") )
    m_glXSwapIntervalSGI = (int (*)(int))glXGetProcAddress((const GLubyte*)"glXSwapIntervalSGI");
  else
    m_glXSwapIntervalSGI = NULL;

  if (IsExtSupported("GLX_MESA_swap_control"))
    m_glXSwapIntervalMESA = (int (*)(int))glXGetProcAddress((const GLubyte*)"glXSwapIntervalMESA");
  else
    m_glXSwapIntervalMESA = NULL;


  return true;
}
Beispiel #17
0
static void screenInfo( Display *dpy, int scrnum, QString &infotext )
{
    const char *serverVendor = glXQueryServerString( dpy, scrnum, GLX_VENDOR );
    const char *serverVersion = glXQueryServerString( dpy, scrnum, GLX_VERSION );
    const char *serverExtensions = glXQueryServerString( dpy, scrnum, GLX_EXTENSIONS );
    const char *clientVendor = glXGetClientString( dpy, GLX_VENDOR );
    const char *clientVersion = glXGetClientString( dpy, GLX_VERSION );
    const char *clientExtensions = glXGetClientString( dpy, GLX_EXTENSIONS );
    const char *glxExtensions = glXQueryExtensionsString( dpy, scrnum );
    const char *glVendor = (const char *) glGetString( GL_VENDOR );
    const char *glRenderer = (const char *) glGetString( GL_RENDERER );
    const char *glVersion = (const char *) glGetString( GL_VERSION );
    const char *glExtensions = (const char *) glGetString( GL_EXTENSIONS );
    const char *gluVersion = (const char *) gluGetString( (GLenum) GLU_VERSION );
    const char *gluExtensions = (const char *) gluGetString( (GLenum) GLU_EXTENSIONS );

    infotext.sprintf( "%sServer GLX vendor string: %s\n", infotext.ascii(), serverVendor );
    infotext.sprintf( "%sServer GLX version string: %s\n", infotext.ascii(), serverVersion );
    infotext.sprintf( "%sServer GLX extensions:\n", infotext.ascii() );

    infotext += QString( serverExtensions ).replace( ' ', '\n' ) + "\n\n";

    infotext.sprintf( "%sClient GLX vendor string: %s\n", infotext.ascii(), clientVendor );
    infotext.sprintf( "%sClient GLX version string: %s\n", infotext.ascii(), clientVersion );
    infotext.sprintf( "%sClient GLX extensions:\n", infotext.ascii() );

    infotext += QString( clientExtensions ).replace( ' ', '\n' ) + "\n\n";

    infotext.sprintf( "%sGLX extensions:\n", infotext.ascii() );

    infotext += QString( glxExtensions ).replace( ' ', '\n' ) + "\n\n";

    infotext.sprintf( "%sOpenGL vendor string: %s\n", infotext.ascii(), glVendor );
    infotext.sprintf( "%sOpenGL renderer string: %s\n", infotext.ascii(), glRenderer );
    infotext.sprintf( "%sOpenGL version string: %s\n", infotext.ascii(), glVersion );
    infotext.sprintf( "%sOpenGL extensions:\n", infotext.ascii() );

    infotext += QString( glExtensions ).replace( ' ', '\n' ) + "\n\n";

    infotext.sprintf( "%sGLU version: %s\n", infotext.ascii(), gluVersion );
    infotext.sprintf( "%sGLU extensions:\n", infotext.ascii() );

    infotext += QString( gluExtensions ).replace( ' ', '\n' ) + "\n\n";
}
Beispiel #18
0
/* Returns 1 if the specified GLX extension is present, 0 if not. */
static int
is_glx_extension_present (Display * dpy, int screen, char * ext)
{
    const char * str = glXQueryExtensionsString (dpy, screen);
    if (!str)
        return 0;

    const char * a = str;
    int extlen = strlen (ext);
    while (*a) {
        int len = strcspn (a, " ");
        if (extlen == len && !strncmp (ext, a, len))
            return 1;
        a += len;
        if (*a)
            a++;
    }
    return 0;
}
Beispiel #19
0
static
void
check_glx_extensions(void)
{
    const char *glx_ext_str = glXQueryExtensionsString(display.x, 0);
    if (!glx_ext_str)
        return;

    display.glx_arb_create_context = !!strstr(glx_ext_str, "GLX_ARB_create_context");
    display.glx_arb_create_context_profile = !!strstr(glx_ext_str,
                                                      "GLX_ARB_create_context_profile");
    display.glx_ext_create_context_es2_profile = !!strstr(glx_ext_str,
                                                          "GLX_EXT_create_context_es2_profile");
    display.glXCreateContextAttribsARB = (glx_create_context_attribs_arb_f)
        glXGetProcAddressARB((const GLubyte *)"glXCreateContextAttribsARB");
    display.glXBindTexImageEXT = (glx_bind_tex_image_ext_f)
        glXGetProcAddress((GLubyte *)"glXBindTexImageEXT");
    display.glXReleaseTexImageEXT = (glx_release_tex_image_ext_f)
        glXGetProcAddress((GLubyte *)"glXReleaseTexImageEXT");
}
Beispiel #20
0
static int check_glx_extention(const char *ext) {
	if (!ext || strchr(ext, ' ') || *ext == '\0') {
		return 0;
	}
	const char *exts = glXQueryExtensionsString(_gl_display, _gl_screen);
	if (!exts) {
		return 0;
	}

	const char *start = exts;
	while (1) {
		const char *tmp = strstr(start, ext);
		if (!tmp) break;
		const char *end = tmp + strlen(ext);
		if (tmp == start || *(tmp - 1) == ' ')
			if (*end == ' ' || *end == '\0') return 1;
		start = end;
	}
	return 0;
}
Beispiel #21
0
void
init(void) {
    initX();

    int major = 0, minor = 0;
    glXQueryVersion(display, &major, &minor);
    glxVersion = (major << 8) | minor;

    extensions = glXQueryExtensionsString(display, screen);

#define CHECK_EXTENSION(name) \
    has_##name = checkExtension(#name, extensions)

    CHECK_EXTENSION(GLX_ARB_create_context);
    CHECK_EXTENSION(GLX_ARB_create_context_profile);
    CHECK_EXTENSION(GLX_EXT_create_context_es_profile);
    CHECK_EXTENSION(GLX_EXT_create_context_es2_profile);

#undef CHECK_EXTENSION
}
Beispiel #22
0
static int GLXExtensionSupported(Display *dpy, const char *extension)
{
	const char *extensionsString, *client_extensions, *pos;

	extensionsString = glXQueryExtensionsString(dpy, DefaultScreen(dpy));
	client_extensions = glXGetClientString(dpy, GLX_EXTENSIONS);

	pos = strstr(extensionsString, extension);

	if (pos != NULL && (pos == extensionsString || pos[-1] == ' ') &&
	    (pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0'))
		return 1;

	pos = strstr(client_extensions, extension);

	if (pos != NULL && (pos == extensionsString || pos[-1] == ' ') &&
	    (pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0'))
		return 1;

	return 0;
}
Beispiel #23
0
bool    isExtensionSupported ( const char * ext )
{
    initExtensions ();                      // since we will need it for platform-specific extensions

    const char * extensions = (const char *) glGetString ( GL_EXTENSIONS );

    if ( isExtensionSupported ( ext, extensions ) )
	    return true;

#ifdef  _WIN32                              // check Windoze extensions
    if ( wglGetExtensionsStringARB == NULL )
    	return false;

    return isExtensionSupported ( ext, wglGetExtensionsStringARB ( wglGetCurrentDC () ) );
#else                                       // check GLX extensions
    Display * display = glXGetCurrentDisplay ();
    int       screen  = DefaultScreen        ( display );

    return isExtensionSupported ( ext, glXQueryExtensionsString ( display, screen ) );
#endif
}
int
__glutIsSupportedByGLX(char *extension)
{
#if defined(GLX_VERSION_1_1)
  static const char *extensions = NULL;
  const char *start;
  char *where, *terminator;
  int major, minor;

  glXQueryVersion(__glutDisplay, &major, &minor);
  /* 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. */
  if ((major == 1 && minor >= 1) || (major > 1)) {
    if (!extensions)
      extensions = glXQueryExtensionsString(__glutDisplay, __glutScreen);
    /* 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)
        return 0;
      terminator = where + strlen(extension);
      if (where == start || *(where - 1) == ' ') {
        if (*terminator == ' ' || *terminator == '\0') {
          return 1;
        }
      }
      start = terminator;
    }
  }
#else
  /* No GLX extensions before GLX 1.1 */
#endif
  return 0;
}
	//-------------------------------------------------------------------------------------------------//
	void GLXGLSupport::initialiseExtensions(void)
	{
		assert (mGLDisplay);
		
		GLSupport::initialiseExtensions();
		
		const char* extensionsString;
		
		// This is more realistic than using glXGetClientString:
		extensionsString = glXQueryExtensionsString(mGLDisplay, DefaultScreen(mGLDisplay));
		
		LogManager::getSingleton().stream() << "Supported GLX extensions: " << extensionsString;
		
		std::stringstream ext;
		String instr;
		
		ext << extensionsString;
		
		while(ext >> instr)
		{
			extensionList.insert(instr);
		}
	}
Beispiel #26
0
EGLint platform_display_initialize (PlatformDisplay *display,
                                    EGLProxyConfig **config_list)
{
    const char *extensions = NULL;
    display->is_modern = ((display->glx_major == 1) && (display->glx_minor > 2))
                         || (display->glx_major > 1);
    /* Check available GLX extensions */
    extensions = glXQueryExtensionsString (display->x11_display,
                                           display->screen);

    if (is_extension_supported (extensions, "GLX_ARB_create_context")) {
        display->glXCreateContextAttribsARB =
            (PFNGLXCREATECONTEXTATTRIBSARBPROC)
            glXGetProcAddressARB ((const GLubyte *)"glXCreateContextAttribsARB");
        display->is_arb_context_profile = is_extension_supported (extensions,
                                          "GLX_ARB_create_context_profile");
    }
    display->is_ext_visual_rating = is_extension_supported (
                                        extensions,
                                        "GLX_EXT_visual_rating");
    display->is_ext_visual_info = is_extension_supported (
                                      extensions,
                                      "GLX_EXT_visual_info");
    display->is_arb_multisample = is_extension_supported (
                                      extensions,
                                      "GLX_ARB_multisample");
    display->is_ext_create_context_es_profile = is_extension_supported (
                extensions,
                "GLX_EXT_create_context_es_profile");
    display->is_ext_create_context_es2_profile = is_extension_supported (
                extensions,
                "GLX_EXT_create_context_es2_profile");
    if (display->is_modern) {
        return glx_populate_from_fbconfigs (display, config_list);
    }
    return glx_populate_from_visualinfos (display, config_list);
}
Beispiel #27
0
static bool create_context_x11_old(struct MPGLContext *ctx)
{
    struct glx_context *glx_ctx = ctx->priv;
    Display *display = ctx->vo->x11->display;
    struct vo *vo = ctx->vo;
    GL *gl = ctx->gl;

    if (glx_ctx->context)
        return true;

    if (!glx_ctx->vinfo) {
        MP_FATAL(vo, "Can't create a legacy GLX context without X visual\n");
        return false;
    }

    GLXContext new_context = glXCreateContext(display, glx_ctx->vinfo, NULL,
                                              True);
    if (!new_context) {
        MP_FATAL(vo, "Could not create GLX context!\n");
        return false;
    }

    if (!glXMakeCurrent(display, ctx->vo->x11->window, new_context)) {
        MP_FATAL(vo, "Could not set GLX context!\n");
        glXDestroyContext(display, new_context);
        return false;
    }

    const char *glxstr = glXQueryExtensionsString(display, ctx->vo->x11->screen);

    mpgl_load_functions(gl, (void *)glXGetProcAddressARB, glxstr, vo->log);

    glx_ctx->context = new_context;

    return true;
}
Beispiel #28
0
StWinGlrc::StWinGlrc(StHandle<StXDisplay>& theDisplay,
                     const bool            theDebugCtx)
: myDisplay(theDisplay->hDisplay),
  myRC(NULL) {
    const char* aGlxExts = glXQueryExtensionsString(theDisplay->hDisplay, DefaultScreen(theDisplay->hDisplay));
    if(StGLContext::stglCheckExtension(aGlxExts, "GLX_ARB_create_context_profile")) {
        glXCreateContextAttribsARB_t aCreateCtxFunc = (glXCreateContextAttribsARB_t )glXGetProcAddress((const GLubyte* )"glXCreateContextAttribsARB");

        int aCtxAttribs[] = {
            //GLX_CONTEXT_MAJOR_VERSION_ARB, 2,
            //GLX_CONTEXT_MINOR_VERSION_ARB, 0,
            GLX_CONTEXT_FLAGS_ARB,        theDebugCtx ? GLX_CONTEXT_DEBUG_BIT_ARB : 0,
            //GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
            None
        };

        myRC = aCreateCtxFunc(theDisplay->hDisplay, theDisplay->FBCfg, 0, True, aCtxAttribs);
    }

    if(myRC == NULL) {
        // fallback compatibility mode
        myRC = glXCreateContext(theDisplay->hDisplay, theDisplay->hVisInfo, None, true);
    }
}
Beispiel #29
0
static bool gfx_ctx_glx_bind_api(void *data, enum gfx_ctx_api api,
      unsigned major, unsigned minor)
{
   (void)data;

   g_major = major;
   g_minor = minor;

#ifdef HAVE_OPENGLES2
   Display *dpy = XOpenDisplay(NULL);
   const char *exts = glXQueryExtensionsString(dpy, DefaultScreen(dpy));
   bool ret = api == GFX_CTX_OPENGL_ES_API &&
      exts && strstr(exts, "GLX_EXT_create_context_es2_profile");
   XCloseDisplay(dpy);
   if (ret && g_major < 3)
   {
      g_major = 2; /* ES 2.0. */
      g_minor = 0;
   }
   return ret;
#else
   return api == GFX_CTX_OPENGL_API;
#endif
}
Beispiel #30
0
static ClutterFeatureFlags
clutter_backend_glx_get_features (ClutterBackend *backend)
{
  ClutterBackendGLX *backend_glx = CLUTTER_BACKEND_GLX (backend);
  const gchar *glx_extensions = NULL;
  const gchar *gl_extensions = NULL;
  ClutterFeatureFlags flags;
  gboolean use_dri = FALSE;

  flags = clutter_backend_x11_get_features (backend);
  flags |= CLUTTER_FEATURE_STAGE_MULTIPLE;

  /* this will make sure that the GL context exists */
  g_assert (backend_glx->gl_context != None);
  g_assert (glXGetCurrentDrawable () != None);

  CLUTTER_NOTE (BACKEND,
                "Checking features\n"
                "  GL_VENDOR: %s\n"
                "  GL_RENDERER: %s\n"
                "  GL_VERSION: %s\n"
                "  GL_EXTENSIONS: %s",
                glGetString (GL_VENDOR),
                glGetString (GL_RENDERER),
                glGetString (GL_VERSION),
                glGetString (GL_EXTENSIONS));

  glx_extensions =
    glXQueryExtensionsString (clutter_x11_get_default_display (),
                              clutter_x11_get_default_screen ());

  CLUTTER_NOTE (BACKEND, "  GLX Extensions: %s", glx_extensions);

  gl_extensions = (const gchar *)glGetString (GL_EXTENSIONS);

  /* When using glBlitFramebuffer or glXCopySubBufferMESA for sub stage
   * redraws, we cannot rely on glXSwapIntervalSGI to throttle the blits
   * so we need to resort to manually synchronizing with the vblank so we
   * always check for the video_sync extension...
   */
  if (_cogl_check_extension ("GLX_SGI_video_sync", glx_extensions) &&
      /* Note: the GLX_SGI_video_sync spec explicitly states this extension
       * only works for direct contexts. */
      glXIsDirect (clutter_x11_get_default_display (),
                   backend_glx->gl_context))
    {
      backend_glx->get_video_sync =
        (GetVideoSyncProc) cogl_get_proc_address ("glXGetVideoSyncSGI");

      backend_glx->wait_video_sync =
        (WaitVideoSyncProc) cogl_get_proc_address ("glXWaitVideoSyncSGI");
    }

  use_dri = check_vblank_env ("dri");

  /* First check for explicit disabling or it set elsewhere (eg NVIDIA) */
  if (check_vblank_env ("none"))
    {
      CLUTTER_NOTE (BACKEND, "vblank sync: disabled at user request");
      goto vblank_setup_done;
    }

  if (g_getenv ("__GL_SYNC_TO_VBLANK") != NULL)
    {
      backend_glx->vblank_type = CLUTTER_VBLANK_GLX_SWAP;
      flags |= CLUTTER_FEATURE_SYNC_TO_VBLANK;

      CLUTTER_NOTE (BACKEND, "Using __GL_SYNC_TO_VBLANK hint");
      goto vblank_setup_done;
    }

  /* We try two GL vblank syncing mechanisms.
   * glXSwapIntervalSGI is tried first, then glXGetVideoSyncSGI.
   *
   * glXSwapIntervalSGI is known to work with Mesa and in particular
   * the Intel drivers. glXGetVideoSyncSGI has serious problems with
   * Intel drivers causing terrible frame rate so it only tried as a
   * fallback.
   *
   * How well glXGetVideoSyncSGI works with other driver (ATI etc) needs
   * to be investigated. glXGetVideoSyncSGI on ATI at least seems to have
   * no effect.
   */
  if (!use_dri &&
      _cogl_check_extension ("GLX_SGI_swap_control", glx_extensions))
    {
      backend_glx->swap_interval =
        (SwapIntervalProc) cogl_get_proc_address ("glXSwapIntervalSGI");

      CLUTTER_NOTE (BACKEND, "attempting glXSwapIntervalSGI vblank setup");

      if (backend_glx->swap_interval != NULL &&
          backend_glx->swap_interval (1) == 0)
        {
          backend_glx->vblank_type = CLUTTER_VBLANK_GLX_SWAP;
          flags |= CLUTTER_FEATURE_SYNC_TO_VBLANK;

          CLUTTER_NOTE (BACKEND, "glXSwapIntervalSGI setup success");

#ifdef GLX_INTEL_swap_event
          /* GLX_INTEL_swap_event allows us to avoid blocking the CPU
           * while we wait for glXSwapBuffers to complete, and instead
           * we get an X event notifying us of completion...
           */
          if (!(clutter_paint_debug_flags & CLUTTER_DEBUG_DISABLE_SWAP_EVENTS) &&
              _cogl_check_extension ("GLX_INTEL_swap_event", glx_extensions))
            {
              flags |= CLUTTER_FEATURE_SWAP_EVENTS;
            }
#endif /* GLX_INTEL_swap_event */

          goto vblank_setup_done;
        }

      CLUTTER_NOTE (BACKEND, "glXSwapIntervalSGI vblank setup failed");
    }

  if (!use_dri &&
      !(flags & CLUTTER_FEATURE_SYNC_TO_VBLANK) &&
      _cogl_check_extension ("GLX_SGI_video_sync", glx_extensions))
    {
      CLUTTER_NOTE (BACKEND, "attempting glXGetVideoSyncSGI vblank setup");

      if ((backend_glx->get_video_sync != NULL) &&
          (backend_glx->wait_video_sync != NULL))
        {
          CLUTTER_NOTE (BACKEND, "glXGetVideoSyncSGI vblank setup success");

          backend_glx->vblank_type = CLUTTER_VBLANK_GLX;
          flags |= CLUTTER_FEATURE_SYNC_TO_VBLANK;

          goto vblank_setup_done;
        }

      CLUTTER_NOTE (BACKEND, "glXGetVideoSyncSGI vblank setup failed");
    }

#ifdef __linux__
  /*
   * DRI is really an extreme fallback -rumoured to work with Via chipsets
   */
  if (!(flags & CLUTTER_FEATURE_SYNC_TO_VBLANK))
    {
      CLUTTER_NOTE (BACKEND, "attempting DRI vblank setup");

      backend_glx->dri_fd = open("/dev/dri/card0", O_RDWR);
      if (backend_glx->dri_fd >= 0)
        {
          CLUTTER_NOTE (BACKEND, "DRI vblank setup success");

          backend_glx->vblank_type = CLUTTER_VBLANK_DRI;
          flags |= CLUTTER_FEATURE_SYNC_TO_VBLANK;

          goto vblank_setup_done;
        }

      CLUTTER_NOTE (BACKEND, "DRI vblank setup failed");
    }
#endif /* __linux__ */

  CLUTTER_NOTE (BACKEND, "no use-able vblank mechanism found");

vblank_setup_done:

  if (_cogl_check_extension ("GLX_MESA_copy_sub_buffer", glx_extensions))
    {
      backend_glx->copy_sub_buffer =
        (CopySubBufferProc) cogl_get_proc_address ("glXCopySubBufferMESA");
      backend_glx->can_blit_sub_buffer = TRUE;
      backend_glx->blit_sub_buffer_is_synchronized = TRUE;
    }
  else if (_cogl_check_extension ("GL_EXT_framebuffer_blit", gl_extensions))
    {
      CLUTTER_NOTE (BACKEND,
                    "Using glBlitFramebuffer fallback for sub_buffer copies");
      backend_glx->blit_framebuffer =
        (BlitFramebufferProc) cogl_get_proc_address ("glBlitFramebuffer");
      backend_glx->can_blit_sub_buffer = TRUE;
      backend_glx->blit_sub_buffer_is_synchronized = FALSE;
    }

  CLUTTER_NOTE (BACKEND, "backend features checked");

  return flags;
}