Advertisement
Guest User

setpixelformat159

a guest
Jul 19th, 2012
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. /***********************************************************************
  2. * glxdrv_SetPixelFormat
  3. */
  4. static BOOL glxdrv_SetPixelFormat(PHYSDEV dev, int iPixelFormat, const PIXELFORMATDESCRIPTOR *ppfd)
  5. {
  6. struct glx_physdev *physdev = get_glxdrv_dev( dev );
  7. WineGLPixelFormat *fmt;
  8. int value;
  9. HWND hwnd;
  10.  
  11. TRACE("(%p,%d,%p)\n", dev->hdc, iPixelFormat, ppfd);
  12.  
  13. if (!has_opengl()) return FALSE;
  14.  
  15. if(physdev->pixel_format) /* cannot change it if already set */
  16. return (physdev->pixel_format == iPixelFormat);
  17.  
  18. /* SetPixelFormat is not allowed on the X root_window e.g. GetDC(0) */
  19. if(physdev->x11dev->drawable == root_window)
  20. {
  21. ERR("Invalid operation on root_window\n");
  22. return FALSE;
  23. }
  24.  
  25. /* Check if iPixelFormat is in our list of supported formats to see if it is supported. */
  26. fmt = ConvertPixelFormatWGLtoGLX(gdi_display, iPixelFormat, FALSE /* Offscreen */, &value);
  27. if(!fmt) {
  28. ERR("Invalid iPixelFormat: %d\n", iPixelFormat);
  29. return FALSE;
  30. }
  31.  
  32. wine_tsx11_lock();
  33. pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &value);
  34. wine_tsx11_unlock();
  35.  
  36. hwnd = WindowFromDC(physdev->dev.hdc);
  37. if(hwnd) {
  38. if(!(value&GLX_WINDOW_BIT)) {
  39. WARN("Pixel format %d is not compatible for window rendering\n", iPixelFormat);
  40. return FALSE;
  41. }
  42.  
  43. if(!SendMessageW(hwnd, WM_X11DRV_SET_WIN_FORMAT, fmt->fmt_id, 0)) {
  44. ERR("Couldn't set format of the window, returning failure\n");
  45. return FALSE;
  46. }
  47. /* physDev->current_pf will be set by the DCE update */
  48. }
  49. else if (GetObjectType( physdev->dev.hdc ) == OBJ_MEMDC) {
  50. if(!(value&GLX_PIXMAP_BIT)) {
  51. WARN("Pixel format %d is not compatible for bitmap rendering\n", iPixelFormat);
  52. return FALSE;
  53. }
  54.  
  55. physdev->pixel_format = iPixelFormat;
  56. physdev->type = DC_GL_BITMAP;
  57. }
  58. else {
  59. FIXME("called on a non-window, non-bitmap object?\n");
  60. }
  61.  
  62. if (TRACE_ON(wgl)) {
  63. int gl_test = 0;
  64.  
  65. wine_tsx11_lock();
  66. gl_test = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_FBCONFIG_ID, &value);
  67. if (gl_test) {
  68. ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
  69. } else {
  70. TRACE(" FBConfig have :\n");
  71. TRACE(" - FBCONFIG_ID 0x%x\n", value);
  72. pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_VISUAL_ID, &value);
  73. TRACE(" - VISUAL_ID 0x%x\n", value);
  74. pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &value);
  75. TRACE(" - DRAWABLE_TYPE 0x%x\n", value);
  76. }
  77. wine_tsx11_unlock();
  78. }
  79. return TRUE;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement