Exemplo n.º 1
0
static GLboolean
AllocAndFetchScreenConfigs(Display * dpy, __GLXdisplayPrivate * priv)
{
   __GLXscreenConfigs *psc;
   GLint i, screens;

   /*
    ** First allocate memory for the array of per screen configs.
    */
   screens = ScreenCount(dpy);
   priv->screenConfigs = Xmalloc(screens * sizeof *priv->screenConfigs);
   if (!priv->screenConfigs) {
      return GL_FALSE;
   }

   priv->serverGLXversion =
      __glXQueryServerString(dpy, priv->majorOpcode, 0, GLX_VERSION);
   if (priv->serverGLXversion == NULL) {
      FreeScreenConfigs(priv);
      return GL_FALSE;
   }

   for (i = 0; i < screens; i++) {
      psc = Xcalloc(1, sizeof *psc);
      if (!psc)
         return GL_FALSE;
      getFBConfigs(psc, priv, i);
      priv->screenConfigs[i] = psc;
   }

   SyncHandle();

   return GL_TRUE;
}
Exemplo n.º 2
0
int _glfwCreateContext(_GLFWwindow* window,
                       const _GLFWwndconfig* wndconfig,
                       const _GLFWfbconfig* fbconfig)
{
    _GLFWfbconfig closest;

    // Choose the best available fbconfig
    {
        unsigned int fbcount;
        _GLFWfbconfig* fbconfigs;
        const _GLFWfbconfig* result;

        fbconfigs = getFBConfigs(window, &fbcount);
        if (!fbconfigs)
            return GL_FALSE;

        result = _glfwChooseFBConfig(fbconfig, fbconfigs, fbcount);
        if (!result)
        {
            _glfwSetError(GLFW_PLATFORM_ERROR,
                          "GLX: No GLXFBConfig matched the criteria");

            free(fbconfigs);
            return GL_FALSE;
        }

        closest = *result;
        free(fbconfigs);
    }

    return createContext(window, wndconfig, closest.platformID);
}
Exemplo n.º 3
0
/*
** Allocate the memory for the per screen configs for each screen.
** If that works then fetch the per screen configs data.
*/
static Bool
AllocAndFetchScreenConfigs(Display * dpy, __GLXdisplayPrivate * priv)
{
   __GLXscreenConfigs *psc;
   GLint i, screens;

   /*
    ** First allocate memory for the array of per screen configs.
    */
   screens = ScreenCount(dpy);
   psc = (__GLXscreenConfigs *) Xmalloc(screens * sizeof(__GLXscreenConfigs));
   if (!psc) {
      return GL_FALSE;
   }
   memset(psc, 0, screens * sizeof(__GLXscreenConfigs));
   priv->screenConfigs = psc;

   priv->serverGLXversion =
      __glXQueryServerString(dpy, priv->majorOpcode, 0, GLX_VERSION);
   if (priv->serverGLXversion == NULL) {
      FreeScreenConfigs(priv);
      return GL_FALSE;
   }

   for (i = 0; i < screens; i++, psc++) {
      getVisualConfigs(dpy, priv, i);
      getFBConfigs(dpy, priv, i);

#ifdef GLX_DIRECT_RENDERING
      psc->scr = i;
      psc->dpy = dpy;
      psc->drawHash = __glxHashCreate();
      if (psc->drawHash == NULL)
         continue;

      if (priv->dri2Display)
         psc->driScreen = (*priv->dri2Display->createScreen) (psc, i, priv);

      if (psc->driScreen == NULL && priv->driDisplay)
         psc->driScreen = (*priv->driDisplay->createScreen) (psc, i, priv);

      if (psc->driScreen == NULL && priv->driswDisplay)
         psc->driScreen = (*priv->driswDisplay->createScreen) (psc, i, priv);

      if (psc->driScreen == NULL) {
         __glxHashDestroy(psc->drawHash);
         psc->drawHash = NULL;
      }
#endif
   }
   SyncHandle();
   return GL_TRUE;
}
Exemplo n.º 4
0
_X_HIDDEN Bool
glx_screen_init(struct glx_screen *psc,
		 int screen, struct glx_display * priv)
{
   /* Initialize per screen dynamic client GLX extensions */
   psc->ext_list_first_time = GL_TRUE;
   psc->scr = screen;
   psc->dpy = priv->dpy;
   psc->display = priv;

   getVisualConfigs(psc, priv, screen);
   getFBConfigs(psc, priv, screen);

   return GL_TRUE;
}
Exemplo n.º 5
0
int _glfwCreateContext(_GLFWwindow* window,
                       const _GLFWwndconfig* wndconfig,
                       const _GLFWfbconfig* fbconfig)
{
    _GLFWfbconfig closest;

    window->WGL.DC = GetDC(window->Win32.handle);
    if (!window->WGL.DC)
    {
        _glfwSetError(GLFW_PLATFORM_ERROR,
                      "Win32: Failed to retrieve DC for window");
        return GL_FALSE;
    }

    // Choose the best available fbconfig
    {
        unsigned int fbcount;
        _GLFWfbconfig* fbconfigs;
        const _GLFWfbconfig* result;

        fbconfigs = getFBConfigs(window, &fbcount);
        if (!fbconfigs)
            return GL_FALSE;

        result = _glfwChooseFBConfig(fbconfig, fbconfigs, fbcount);
        if (!result)
        {
            _glfwSetError(GLFW_FORMAT_UNAVAILABLE,
                          "Win32/WGL: No pixel format matched the criteria");

            free(fbconfigs);
            return GL_FALSE;
        }

        closest = *result;
        free(fbconfigs);
    }

    return createContext(window, wndconfig, (int) closest.platformID);
}