/** * Given an HDC, return the corresponding stw_framebuffer. * The returned stw_framebuffer will have its mutex locked. */ struct stw_framebuffer * stw_framebuffer_from_hdc(HDC hdc) { struct stw_framebuffer *fb; if (!stw_dev) return NULL; stw_lock_framebuffers(stw_dev); fb = stw_framebuffer_from_hdc_locked(hdc); stw_unlock_framebuffers(stw_dev); return fb; }
/** * Given an hdc, return the corresponding stw_framebuffer. */ struct stw_framebuffer * stw_framebuffer_from_hdc( HDC hdc ) { struct stw_framebuffer *fb; if (!stw_dev) return NULL; pipe_mutex_lock( stw_dev->fb_mutex ); fb = stw_framebuffer_from_hdc_locked(hdc); pipe_mutex_unlock( stw_dev->fb_mutex ); return fb; }
BOOL APIENTRY DrvSetPixelFormat(HDC hdc, LONG iPixelFormat) { uint count; uint index; struct stw_framebuffer *fb; if (!stw_dev) return FALSE; index = (uint) iPixelFormat - 1; count = stw_pixelformat_get_count(); if (index >= count) return FALSE; fb = stw_framebuffer_from_hdc_locked(hdc); if (fb) { /* * SetPixelFormat must be called only once. However ignore * pbuffers, for which the framebuffer object is created first. */ boolean bPbuffer = fb->bPbuffer; stw_framebuffer_unlock( fb ); return bPbuffer; } fb = stw_framebuffer_create(hdc, iPixelFormat); if (!fb) { return FALSE; } stw_framebuffer_unlock( fb ); /* Some applications mistakenly use the undocumented wglSetPixelFormat * function instead of SetPixelFormat, so we call SetPixelFormat here to * avoid opengl32.dll's wglCreateContext to fail */ if (GetPixelFormat(hdc) == 0) { BOOL bRet = SetPixelFormat(hdc, iPixelFormat, NULL); if (!bRet) { debug_printf("SetPixelFormat failed\n"); } } return TRUE; }
BOOL APIENTRY DrvSetPixelFormat( HDC hdc, LONG iPixelFormat ) { uint count; uint index; struct stw_framebuffer *fb; if (!stw_dev) return FALSE; index = (uint) iPixelFormat - 1; count = stw_pixelformat_get_extended_count(); if (index >= count) return FALSE; fb = stw_framebuffer_from_hdc_locked(hdc); if(fb) { /* SetPixelFormat must be called only once */ stw_framebuffer_release( fb ); return FALSE; } fb = stw_framebuffer_create(hdc, iPixelFormat); if(!fb) { return FALSE; } stw_framebuffer_release( fb ); /* Some applications mistakenly use the undocumented wglSetPixelFormat * function instead of SetPixelFormat, so we call SetPixelFormat here to * avoid opengl32.dll's wglCreateContext to fail */ if (GetPixelFormat(hdc) == 0) { SetPixelFormat(hdc, iPixelFormat, NULL); } return TRUE; }