changeset 30466:cd3f6962fcfd

Set the PixelFormat right after creating the window and set it only once.
author reimar
date Thu, 04 Feb 2010 22:46:01 +0000
parents 3422423f2e20
children 9b7b4eeea093
files libvo/w32_common.c
diffstat 1 files changed, 23 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/w32_common.c	Thu Feb 04 22:08:23 2010 +0000
+++ b/libvo/w32_common.c	Thu Feb 04 22:46:01 2010 +0000
@@ -329,10 +329,7 @@
 
 static int createRenderingContext(void) {
     HWND layer = HWND_NOTOPMOST;
-    PIXELFORMATDESCRIPTOR pfd;
-    HDC vo_hdc = vo_w32_get_dc(vo_window);
     RECT r;
-    int pf;
   if (WinID < 0) {
     int style = (vo_border && !vo_fs) ?
                 (WS_OVERLAPPEDWINDOW | WS_SIZEBOX) : WS_POPUP;
@@ -378,26 +375,6 @@
     AdjustWindowRect(&r, style, 0);
     SetWindowPos(vo_window, layer, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_SHOWWINDOW);
   }
-
-    memset(&pfd, 0, sizeof pfd);
-    pfd.nSize = sizeof pfd;
-    pfd.nVersion = 1;
-    pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
-    pfd.iPixelType = PFD_TYPE_RGBA;
-    pfd.cColorBits = 24;
-    pfd.iLayerType = PFD_MAIN_PLANE;
-    pf = ChoosePixelFormat(vo_hdc, &pfd);
-    if (!pf) {
-            mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to select a valid pixel format!\n");
-        ReleaseDC(vo_window, vo_hdc);
-        return 0;
-    }
-
-    SetPixelFormat(vo_hdc, pf, &pfd);
-
-    mp_msg(MSGT_VO, MSGL_V, "vo: win32: running at %dx%d with depth %d\n", vo_screenwidth, vo_screenheight, vo_depthonscreen);
-
-    vo_w32_release_dc(vo_window, vo_hdc);
     return 1;
 }
 
@@ -461,6 +438,9 @@
  * \return 1 = Success, 0 = Failure
  */
 int vo_w32_init(void) {
+    PIXELFORMATDESCRIPTOR pfd;
+    HDC vo_hdc;
+    int pf;
     HICON mplayerIcon = 0;
     char exedir[MAX_PATH];
     HINSTANCE user32;
@@ -517,6 +497,26 @@
     if (dev) dev_hdc = CreateDC(dev, NULL, NULL, NULL);
     updateScreenProperties();
 
+    vo_hdc = vo_w32_get_dc(vo_window);
+    memset(&pfd, 0, sizeof pfd);
+    pfd.nSize = sizeof pfd;
+    pfd.nVersion = 1;
+    pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
+    pfd.iPixelType = PFD_TYPE_RGBA;
+    pfd.cColorBits = 24;
+    pfd.iLayerType = PFD_MAIN_PLANE;
+    pf = ChoosePixelFormat(vo_hdc, &pfd);
+    if (!pf) {
+            mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to select a valid pixel format!\n");
+        vo_w32_release_dc(vo_window, vo_hdc);
+        return 0;
+    }
+
+    SetPixelFormat(vo_hdc, pf, &pfd);
+    vo_w32_release_dc(vo_window, vo_hdc);
+
+    mp_msg(MSGT_VO, MSGL_V, "vo: win32: running at %dx%d with depth %d\n", vo_screenwidth, vo_screenheight, vo_depthonscreen);
+
     return 1;
 }