static void testcooperativelevels_exclusive(void) { HRESULT rc; /* Do some tests with DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN mode */ /* Try to set exclusive mode only */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_EXCLUSIVE); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE) returned: %x\n",rc); /* Full screen mode only */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FULLSCREEN) returned: %x\n",rc); /* Full screen mode + exclusive mode */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE); ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN) returned: %x\n",rc); /* Set the focus window. Should fail */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_SETFOCUSWINDOW); ok(rc==DDERR_HWNDALREADYSET,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %x\n",rc); /* All done */ }
static void testcooperativelevels_exclusive(void) { BOOL sfw, success; HRESULT rc; RECT window_rect; /* Do some tests with DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN mode */ /* First, resize the window so it is not the same size as any screen */ success = SetWindowPos(hwnd, 0, 0, 0, 281, 92, 0); ok(success, "SetWindowPos failed\n"); /* Try to set exclusive mode only */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_EXCLUSIVE); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE) returned: %x\n",rc); /* Full screen mode only */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FULLSCREEN) returned: %x\n",rc); /* Full screen mode + exclusive mode */ rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE); ok(rc==DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, received %x\n", rc); sfw=FALSE; if(hwnd2) sfw=SetForegroundWindow(hwnd2); else skip("Failed to create the second window\n"); rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE); ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN) returned: %x\n",rc); if(sfw) ok(GetForegroundWindow()==hwnd,"Expected the main windows (%p) for foreground, received the second one (%p)\n",hwnd, hwnd2); /* rect_before_create is assumed to hold the screen rect */ GetClientRect(hwnd, &window_rect); rc = EqualRect(&rect_before_create, &window_rect); ok(rc, "Fullscreen window has wrong size.\n"); /* Set the focus window. Should fail */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_SETFOCUSWINDOW); ok(rc==DDERR_HWNDALREADYSET || broken(rc==DDERR_INVALIDPARAMS) /* NT4/Win95 */,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %x\n",rc); /* All done */ }
Err GE2DLibOpen() { DDSURFACEDESC Desc; HRESULT (WINAPI* DirectDrawCreate)( void*, LPDIRECTDRAW*, void* ); Module = LoadLibrary(T("DDRAW.DLL")); *(FARPROC*)&DirectDrawCreate = GetProcAddress(Module,"DirectDrawCreate"); if (!DirectDrawCreate) return 1; if (DirectDrawCreate(NULL,&DD,NULL)!=DD_OK) return 1; IDirectDraw_SetCooperativeLevel(DD, NULL, DDSCL_NORMAL); // get primary surface memset(&Desc,0,sizeof(DDSURFACEDESC)); Desc.dwSize = sizeof(DDSURFACEDESC); Desc.dwFlags = DDSD_CAPS; Desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; if (IDirectDraw_CreateSurface(DD,&Desc,&DDPrimary,NULL) != DD_OK) return 1; return errNone; }
static int DxInitDirectDraw(void) { HRESULT(WINAPI * OurDirectDrawCreateEx)(GUID *, LPVOID *, REFIID, IUnknown FAR *); hddraw_dll = LoadLibrary("DDRAW.DLL"); if (hddraw_dll == NULL) { av_log(NULL, AV_LOG_ERROR, "vo_directx: failed loading ddraw.dll\n"); return FALSE; } OurDirectDrawCreateEx = (void *) GetProcAddress(hddraw_dll, "DirectDrawCreateEx"); if (OurDirectDrawCreateEx == NULL) { FreeLibrary(hddraw_dll); hddraw_dll = NULL; av_log(NULL, AV_LOG_ERROR, "vo_directx: ddraw.dll DirectDrawCreateEx not found\n"); return FALSE; } if (OurDirectDrawCreateEx(NULL, (VOID **) & g_lpdd, &IID_IDirectDraw7, NULL) != DD_OK) { av_log(NULL, AV_LOG_ERROR, "vo_dx: can't create draw object\n"); return FALSE; } if (g_vidmode) { if (IDirectDraw_SetCooperativeLevel(g_lpdd, g_hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN) != DD_OK) { av_log(NULL, AV_LOG_ERROR, "vo_dx: can't set cooperative\n"); return FALSE; } } else { if (IDirectDraw_SetCooperativeLevel(g_lpdd, g_hwnd, DDSCL_NORMAL) != DD_OK) { av_log(NULL, AV_LOG_ERROR, "vo_dx: can't set cooperative\n"); return FALSE; } } av_log(NULL, AV_LOG_INFO, "DirectDraw Object Init OK\n"); return TRUE; }
static void testcooperativelevels_exclusive(void) { BOOL success; HRESULT rc; RECT window_rect; /* Do some tests with DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN mode */ /* First, resize the window so it is not the same size as any screen */ success = SetWindowPos(hwnd, 0, 0, 0, 281, 92, 0); ok(success, "SetWindowPos failed\n"); /* Try to set exclusive mode only */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_EXCLUSIVE); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE) returned: %x\n",rc); /* Full screen mode only */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FULLSCREEN) returned: %x\n",rc); /* Full screen mode + exclusive mode */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE); ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN) returned: %x\n",rc); GetClientRect(hwnd, &window_rect); /* rect_before_create is assumed to hold the screen rect */ rc = EqualRect(&rect_before_create, &window_rect); todo_wine ok(rc!=0, "Fullscreen window has wrong size\n"); /* Set the focus window. Should fail */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_SETFOCUSWINDOW); ok(rc==DDERR_HWNDALREADYSET || broken(rc==DDERR_INVALIDPARAMS) /* NT4/Win95 */,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %x\n",rc); /* All done */ }
HRESULT d3drm_device_create_surfaces_from_clipper(struct d3drm_device *object, IDirectDraw *ddraw, IDirectDrawClipper *clipper, int width, int height, IDirectDrawSurface **surface) { DDSURFACEDESC surface_desc; IDirectDrawSurface *primary_surface, *render_target; HWND window; HRESULT hr; hr = IDirectDrawClipper_GetHWnd(clipper, &window); if (FAILED(hr)) return hr; hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); if (FAILED(hr)) return hr; memset(&surface_desc, 0, sizeof(surface_desc)); surface_desc.dwSize = sizeof(surface_desc); surface_desc.dwFlags = DDSD_CAPS; surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &primary_surface, NULL); if (FAILED(hr)) return hr; hr = IDirectDrawSurface_SetClipper(primary_surface, clipper); if (FAILED(hr)) { IDirectDrawSurface_Release(primary_surface); return hr; } memset(&surface_desc, 0, sizeof(surface_desc)); surface_desc.dwSize = sizeof(surface_desc); surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; surface_desc.dwWidth = width; surface_desc.dwHeight = height; hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &render_target, NULL); if (FAILED(hr)) { IDirectDrawSurface_Release(primary_surface); return hr; } object->primary_surface = primary_surface; object->clipper = clipper; IDirectDrawClipper_AddRef(clipper); *surface = render_target; return D3DRM_OK; }
static BOOL CreateDirectDraw(void) { HRESULT hr; DDSURFACEDESC2 ddsd; IDirectDrawSurface7 *overlay = NULL; HMODULE hmod = GetModuleHandleA("ddraw.dll"); pDirectDrawCreateEx = (void*)GetProcAddress(hmod, "DirectDrawCreateEx"); if (!pDirectDrawCreateEx) { win_skip("DirectDrawCreateEx is not available\n"); return FALSE; } hr = pDirectDrawCreateEx(NULL, (void**)&ddraw, &IID_IDirectDraw7, NULL); ok(hr == DD_OK || hr == DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %x\n", hr); if (!ddraw) { trace("DirectDrawCreateEx() failed with an error %x\n", hr); return FALSE; } hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL); ok(hr == DD_OK, "SetCooperativeLevel returned: %x\n", hr ); memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &primary, NULL); if (FAILED(hr)) { IDirectDraw7_Release(ddraw); trace("IDirectDraw7_CreateSurface() failed with an error %x\n", hr); return FALSE; } overlay = create_overlay(64, 64, MAKEFOURCC('U','Y','V','Y')); if (!overlay) { IDirectDrawSurface7_Release(primary); IDirectDraw7_Release(ddraw); skip("Failed to create an overlay - assuming not supported\n"); return FALSE; } IDirectDraw7_Release(overlay); return TRUE; }
static void RestoreWindow(DDContext *dd) { HWND hWnd = dd->hWnd; if (!dd->NeedRestore) goto exit; if (!dd->owns_hwnd && dd->switch_res) hWnd = GetParent(dd->hWnd); dd->NeedRestore = 0; if (dd->is_3D_out) { ChangeDisplaySettings(NULL,0); SetForegroundWindow(GetDesktopWindow()); SetForegroundWindow(dd->hWnd); } else { #ifdef USE_DX_3 IDirectDraw_SetCooperativeLevel(dd->pDD, hWnd, DDSCL_NORMAL); #else IDirectDraw7_SetCooperativeLevel(dd->pDD, hWnd, DDSCL_NORMAL); #endif dd->NeedRestore = 0; } if (dd->owns_hwnd || dd->is_3D_out) SetWindowLong(dd->hWnd, GWL_STYLE, dd->prev_styles); if (dd->owns_hwnd) SetWindowText(dd->hWnd, "GPAC DirectDraw Output"); if (!dd->switch_res || dd->owns_hwnd) { SetWindowPos(dd->hWnd, NULL, dd->rcWnd.left, dd->rcWnd.top, dd->rcWnd.right - dd->rcWnd.left, dd->rcWnd.bottom - dd->rcWnd.top, SWP_NOZORDER); } else { /*post a message to the parent wnd*/ RECT rc = dd->rcWnd; HWND hWnd = GetParent(dd->hWnd); if (!hWnd) hWnd = dd->hWnd; if (dd->is_3D_out) SetWindowPos(dd->hWnd, NULL, dd->rcChildWnd.left, dd->rcChildWnd.top, dd->rcChildWnd.right - dd->rcChildWnd.left, dd->rcChildWnd.bottom - dd->rcChildWnd.top, SWP_NOZORDER); SetWindowPos(hWnd, NULL, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_NOZORDER); SetForegroundWindow(hWnd); SetFocus(hWnd); } exit: /*store client rect*/ GetWindowRect(dd->hWnd, &dd->rcWnd); }
static void setdisplaymode(int i) { HRESULT rc; rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(rc==DD_OK,"SetCooperativeLevel returned: %x\n",rc); if (modes[i].dwFlags & DDSD_PIXELFORMAT) { if (modes[i].ddpfPixelFormat.dwFlags & DDPF_RGB) { rc = IDirectDraw_SetDisplayMode(lpDD, modes[i].dwWidth, modes[i].dwHeight, U1(modes[i].ddpfPixelFormat).dwRGBBitCount); ok(DD_OK==rc || DDERR_UNSUPPORTED==rc,"SetDisplayMode returned: %x\n",rc); if (rc == DD_OK) { RECT r, scrn, virt; SetRect(&virt, 0, 0, GetSystemMetrics(SM_CXVIRTUALSCREEN), GetSystemMetrics(SM_CYVIRTUALSCREEN)); OffsetRect(&virt, GetSystemMetrics(SM_XVIRTUALSCREEN), GetSystemMetrics(SM_YVIRTUALSCREEN)); SetRect(&scrn, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); trace("Mode (%dx%d) [%dx%d] (%d %d)x(%d %d)\n", modes[i].dwWidth, modes[i].dwHeight, scrn.right, scrn.bottom, virt.left, virt.top, virt.right, virt.bottom); ok(GetClipCursor(&r), "GetClipCursor() failed\n"); /* ddraw sets clip rect here to the screen size, even for multiple monitors */ ok(EqualRect(&r, &scrn), "Invalid clip rect: (%d %d) x (%d %d)\n", r.left, r.top, r.right, r.bottom); ok(ClipCursor(NULL), "ClipCursor() failed\n"); ok(GetClipCursor(&r), "GetClipCursor() failed\n"); ok(EqualRect(&r, &virt), "Invalid clip rect: (%d %d) x (%d %d)\n", r.left, r.top, r.right, r.bottom); rc = IDirectDraw_RestoreDisplayMode(lpDD); ok(DD_OK==rc,"RestoreDisplayMode returned: %x\n",rc); } } } }
static int win32_gui_data_exchange( vo_driver_t * vo_driver, int data_type, void * data ) { win32_driver_t *win32_driver = ( win32_driver_t * ) vo_driver; switch( data_type ) { case GUI_WIN32_MOVED_OR_RESIZED: UpdateRect( win32_driver->win32_visual ); DisplayFrame( win32_driver ); break; case XINE_GUI_SEND_DRAWABLE_CHANGED: { HRESULT result; HWND newWndHnd = (HWND) data; /* set cooperative level */ result = IDirectDraw_SetCooperativeLevel( win32_driver->ddobj, newWndHnd, DDSCL_NORMAL ); if( result != DD_OK ) { Error( 0, "SetCooperativeLevel : error 0x%lx", result ); return 0; } /* associate our clipper with new window */ result = IDirectDrawClipper_SetHWnd( win32_driver->ddclipper, 0, newWndHnd ); if( result != DD_OK ) { Error( 0, "ddclipper->SetHWnd : error 0x%lx", result ); return 0; } /* store our objects in our visual struct */ win32_driver->win32_visual->WndHnd = newWndHnd; /* update video area and redraw current frame */ UpdateRect( win32_driver->win32_visual ); DisplayFrame( win32_driver ); break; } } return 0; }
/******************************************************************************* * IDirectDrawFactoryImpl_CreateDirectDraw *******************************************************************************/ static HRESULT WINAPI IDirectDrawFactoryImpl_CreateDirectDraw(IDirectDrawFactory* iface, GUID * pGUID, HWND hWnd, DWORD dwCoopLevelFlags, DWORD dwReserved, IUnknown *pUnkOuter, IDirectDraw **ppDirectDraw) { HRESULT hr; TRACE("\n"); hr = DirectDrawCreateEx(pGUID, (void**)ppDirectDraw, &IID_IDirectDraw3, pUnkOuter); if (FAILED(hr)) return hr; hr = IDirectDraw_SetCooperativeLevel(*ppDirectDraw, hWnd, dwCoopLevelFlags); if (FAILED(hr)) IDirectDraw_Release(*ppDirectDraw); return hr; }
EXPORT void CALL RomOpen (void) { RECT bigrect, smallrect, statusrect; GetWindowRect(gfx.hWnd,&bigrect); GetClientRect(gfx.hWnd,&smallrect); int rightdiff = screen_width - smallrect.right; int bottomdiff = screen_height - smallrect.bottom; if (gfx.hStatusBar) { GetClientRect(gfx.hStatusBar, &statusrect); bottomdiff += statusrect.bottom; } MoveWindow(gfx.hWnd, bigrect.left, bigrect.top, bigrect.right - bigrect.left + rightdiff, bigrect.bottom - bigrect.top + bottomdiff, TRUE); DDPIXELFORMAT ftpixel; LPDIRECTDRAWCLIPPER lpddcl; res = DirectDrawCreateEx(0, (LPVOID*)&lpdd, IID_IDirectDraw7, 0); if(res != DD_OK) fatalerror("Couldn't create a DirectDraw object"); res = IDirectDraw_SetCooperativeLevel(lpdd, gfx.hWnd, DDSCL_NORMAL); if(res != DD_OK) fatalerror("Couldn't set a cooperative level. Error code %x", res); memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; res = IDirectDraw_CreateSurface(lpdd, &ddsd, &lpddsprimary, 0); if(res != DD_OK) fatalerror("CreateSurface for a primary surface failed. Error code %x", res); ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; ddsd.dwWidth = PRESCALE_WIDTH; ddsd.dwHeight = PRESCALE_HEIGHT; memset(&ftpixel, 0, sizeof(ftpixel)); ftpixel.dwSize = sizeof(ftpixel); ftpixel.dwFlags = DDPF_RGB; ftpixel.dwRGBBitCount = 32; ftpixel.dwRBitMask = 0xff0000; ftpixel.dwGBitMask = 0xff00; ftpixel.dwBBitMask = 0xff; ddsd.ddpfPixelFormat = ftpixel; res = IDirectDraw_CreateSurface(lpdd, &ddsd, &lpddsback, 0); if (res == DDERR_INVALIDPIXELFORMAT) fatalerror("ARGB8888 is not supported. You can try changing desktop color depth to 32-bit, but most likely that won't help."); else if(res != DD_OK) fatalerror("CreateSurface for a secondary surface failed. Error code %x", res); res = IDirectDrawSurface_GetSurfaceDesc(lpddsback, &ddsd); if (res != DD_OK) fatalerror("GetSurfaceDesc failed."); if ((ddsd.lPitch & 3) || ddsd.lPitch < (PRESCALE_WIDTH << 2)) fatalerror("Pitch of a secondary surface is either not 32 bit aligned or two small."); pitchindwords = ddsd.lPitch >> 2; res = IDirectDraw_CreateClipper(lpdd, 0, &lpddcl, 0); if (res != DD_OK) fatalerror("Couldn't create a clipper."); res = IDirectDrawClipper_SetHWnd(lpddcl, 0, gfx.hWnd); if (res != DD_OK) fatalerror("Couldn't register a windows handle as a clipper."); res = IDirectDrawSurface_SetClipper(lpddsprimary, lpddcl); if (res != DD_OK) fatalerror("Couldn't attach a clipper to a surface."); src.top = src.left = 0; src.bottom = 0; src.right = PRESCALE_WIDTH; POINT p; p.x = p.y = 0; GetClientRect(gfx.hWnd, &dst); ClientToScreen(gfx.hWnd, &p); OffsetRect(&dst, p.x, p.y); GetClientRect(gfx.hStatusBar, &statusrect); dst.bottom -= statusrect.bottom; rdp_init(); }
static void testcooperativelevels_normal(void) { HRESULT rc; DDSURFACEDESC surfacedesc; IDirectDrawSurface *surface = (IDirectDrawSurface *) 0xdeadbeef; memset(&surfacedesc, 0, sizeof(surfacedesc)); surfacedesc.dwSize = sizeof(surfacedesc); surfacedesc.ddpfPixelFormat.dwSize = sizeof(surfacedesc.ddpfPixelFormat); surfacedesc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; surfacedesc.dwBackBufferCount = 1; surfacedesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP; /* Do some tests with DDSCL_NORMAL mode */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_NORMAL); ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL) returned: %x\n",rc); /* Try creating a double buffered primary in normal mode */ rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL); ok(rc == DDERR_NOEXCLUSIVEMODE, "IDirectDraw_CreateSurface returned %08x\n", rc); ok(surface == NULL, "Returned surface pointer is %p\n", surface); if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface); /* Set the focus window */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_SETFOCUSWINDOW); ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %x\n",rc); /* Set the focus window a second time*/ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_SETFOCUSWINDOW); ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) the second time returned: %x\n",rc); /* Test DDSCL_SETFOCUSWINDOW with the other flags. They should all fail, except of DDSCL_NOWINDOWCHANGES */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_NORMAL | DDSCL_SETFOCUSWINDOW); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc); rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETFOCUSWINDOW); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc); /* This one succeeds */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_NOWINDOWCHANGES | DDSCL_SETFOCUSWINDOW); ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NOWINDOWCHANGES | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc); rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_MULTITHREADED | DDSCL_SETFOCUSWINDOW); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_MULTITHREADED | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc); rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FPUSETUP | DDSCL_SETFOCUSWINDOW); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FPUSETUP | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc); rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FPUPRESERVE | DDSCL_SETFOCUSWINDOW); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FPUPRESERVE | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc); rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_ALLOWREBOOT | DDSCL_SETFOCUSWINDOW); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_ALLOWREBOOT | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc); rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_ALLOWMODEX | DDSCL_SETFOCUSWINDOW); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_ALLOWMODEX | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc); /* Set the device window without any other flags. Should give an error */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_SETDEVICEWINDOW); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETDEVICEWINDOW) returned: %x\n",rc); /* Set device window with DDSCL_NORMAL */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW); ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW) returned: %x\n",rc); /* Also set the focus window. Should give an error */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETDEVICEWINDOW | DDSCL_SETFOCUSWINDOW); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc); /* All done */ }
void arch_init() { HRESULT ddrval; WNDCLASS wcDescentClass; wcDescentClass.lpszClassName = "WinD1X"; wcDescentClass.hInstance = hInst; wcDescentClass.lpfnWndProc = DescentWndProc; wcDescentClass.hCursor = LoadCursor(NULL, IDC_ARROW); //wcDescentClass.hIcon = LoadIcon(NULL, IDI_WINLOGO); wcDescentClass.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_MAIN_ICON)); wcDescentClass.lpszMenuName = NULL; wcDescentClass.hbrBackground = NULL; wcDescentClass.style = CS_HREDRAW | CS_VREDRAW; wcDescentClass.cbClsExtra = 0; wcDescentClass.cbWndExtra = 0; // Register the class RegisterClass(&wcDescentClass); g_hWnd = CreateWindowEx(0, "WinD1X", "Descent", WS_OVERLAPPED | WS_BORDER, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), NULL, NULL, hInst, NULL ); if (!g_hWnd) return; // CRAP! ShowWindow(g_hWnd,SW_SHOWNORMAL); UpdateWindow(g_hWnd); ddrval=DirectDrawCreate(NULL,&lpDD,NULL); if(ddrval!=DD_OK) { fprintf(stderr,"DirectDrawCreate() failed!\n"); abort(); } if (FindArg("-semiwin")) ddrval=IDirectDraw_SetCooperativeLevel(lpDD,g_hWnd,DDSCL_NORMAL); else { #ifndef NDEBUG ddrval=IDirectDraw_SetCooperativeLevel(lpDD,g_hWnd, DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN|DDSCL_ALLOWREBOOT); #else ddrval=IDirectDraw_SetCooperativeLevel(lpDD,g_hWnd, DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN|DDSCL_ALLOWREBOOT); #endif } if (ddrval!=DD_OK) { fprintf(stderr,"SetCooperativeLevel() failed\n"); abort(); } ShowCursor(FALSE); mouse_hidden = 1; SetPriorityClass(GetCurrentProcess(),HIGH_PRIORITY_CLASS); key_init(); mouse_init(); //added/changed 3/7/99 Owen Evans (next line) joy_init(JOYSTICKID1); printf("arch_init successfully completed\n"); }
static void testcooperativelevels_normal(void) { BOOL sfw; HRESULT rc; DDSURFACEDESC surfacedesc; IDirectDrawSurface *surface = (IDirectDrawSurface *) 0xdeadbeef; memset(&surfacedesc, 0, sizeof(surfacedesc)); surfacedesc.dwSize = sizeof(surfacedesc); surfacedesc.ddpfPixelFormat.dwSize = sizeof(surfacedesc.ddpfPixelFormat); surfacedesc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; surfacedesc.dwBackBufferCount = 1; surfacedesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP; rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW) returned: %x\n",rc); /* Do some tests with DDSCL_NORMAL mode */ /* Fullscreen mode + normal mode + exclusive mode */ rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL); ok(rc==DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, received: %x\n", rc); sfw=FALSE; if(hwnd2) sfw=SetForegroundWindow(hwnd2); else skip("Failed to create the second window\n"); rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL); ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL) returned: %x\n",rc); if(sfw) ok(GetForegroundWindow()==hwnd,"Expected the main windows (%p) for foreground, received the second one (%p)\n",hwnd, hwnd2); /* Try creating a double buffered primary in fullscreen + exclusive + normal mode */ rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL); if (rc == DDERR_UNSUPPORTEDMODE) skip("Unsupported mode\n"); else { ok(rc == DD_OK, "IDirectDraw_CreateSurface returned %08x\n", rc); ok(surface!=NULL, "Returned NULL surface pointer\n"); } if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface); /* Exclusive mode + normal mode */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_EXCLUSIVE | DDSCL_NORMAL); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_NORMAL) returned: %x\n",rc); /* Fullscreen mode + normal mode */ sfw=FALSE; if(hwnd2) sfw=SetForegroundWindow(hwnd2); rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN | DDSCL_NORMAL); ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_FULLSCREEN | DDSCL_NORMAL) returned: %x\n",rc); if(sfw) ok(GetForegroundWindow()==hwnd2,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2, hwnd); rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_FULLSCREEN | DDSCL_NORMAL); ok(rc==DD_OK, "Expected DD_OK, received %x\n", rc); /* Try creating a double buffered primary in fullscreen + normal mode */ rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL); if (rc == DDERR_UNSUPPORTEDMODE) skip("Unsupported mode\n"); else { ok(rc == DDERR_NOEXCLUSIVEMODE, "IDirectDraw_CreateSurface returned %08x\n", rc); ok(surface == NULL, "Returned surface pointer is %p\n", surface); } if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface); /* switching from Fullscreen mode to Normal mode */ sfw=FALSE; if(hwnd2) sfw=SetForegroundWindow(hwnd2); rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_NORMAL); ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL) returned: %x\n",rc); if(sfw) ok(GetForegroundWindow()==hwnd2,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2, hwnd); rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_NORMAL); ok(rc==DD_OK, "Expected DD_OK, received %x\n", rc); /* Try creating a double buffered primary in normal mode */ rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL); if (rc == DDERR_UNSUPPORTEDMODE) skip("Unsupported mode\n"); else { ok(rc == DDERR_NOEXCLUSIVEMODE, "IDirectDraw_CreateSurface returned %08x\n", rc); ok(surface == NULL, "Returned surface pointer is %p\n", surface); } if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface); /* switching from Normal mode to Fullscreen + Normal mode */ sfw=FALSE; if(hwnd2) sfw=SetForegroundWindow(hwnd2); rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_NORMAL | DDSCL_FULLSCREEN); ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL | FULLSCREEN) returned: %x\n",rc); if(sfw) ok(GetForegroundWindow()==hwnd2,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2, hwnd); rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_NORMAL | DDSCL_FULLSCREEN); ok(rc==DD_OK, "Expected DD_OK, received %x\n", rc); /* Set the focus window */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW) returned: %x\n",rc); rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_SETFOCUSWINDOW); if (rc == DDERR_INVALIDPARAMS) { win_skip("NT4/Win95 do not support cooperative levels DDSCL_SETDEVICEWINDOW and DDSCL_SETFOCUSWINDOW\n"); return; } ok(rc==DD_OK, "Expected DD_OK, received %x\n", rc); rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_SETFOCUSWINDOW); if (rc == DDERR_INVALIDPARAMS) { win_skip("NT4/Win95 do not support cooperative levels DDSCL_SETDEVICEWINDOW and DDSCL_SETFOCUSWINDOW\n"); return; } ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %x\n",rc); /* Set the focus window a second time*/ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_SETFOCUSWINDOW); ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) the second time returned: %x\n",rc); /* Test DDSCL_SETFOCUSWINDOW with the other flags. They should all fail, except of DDSCL_NOWINDOWCHANGES */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_NORMAL | DDSCL_SETFOCUSWINDOW); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc); rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETFOCUSWINDOW); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc); /* This one succeeds */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_NOWINDOWCHANGES | DDSCL_SETFOCUSWINDOW); ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NOWINDOWCHANGES | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc); rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_MULTITHREADED | DDSCL_SETFOCUSWINDOW); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_MULTITHREADED | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc); rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FPUSETUP | DDSCL_SETFOCUSWINDOW); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FPUSETUP | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc); rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FPUPRESERVE | DDSCL_SETFOCUSWINDOW); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FPUPRESERVE | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc); rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_ALLOWREBOOT | DDSCL_SETFOCUSWINDOW); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_ALLOWREBOOT | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc); rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_ALLOWMODEX | DDSCL_SETFOCUSWINDOW); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_ALLOWMODEX | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc); /* Set the device window without any other flags. Should give an error */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_SETDEVICEWINDOW); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETDEVICEWINDOW) returned: %x\n",rc); /* Set device window with DDSCL_NORMAL */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW); ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW) returned: %x\n",rc); /* Also set the focus window. Should give an error */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETDEVICEWINDOW | DDSCL_SETFOCUSWINDOW); ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc); /* All done */ }
static void setdisplaymode(int i) { HRESULT rc; RECT orig_rect; SetRect(&orig_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(rc==DD_OK,"SetCooperativeLevel returned: %x\n",rc); if (modes[i].dwFlags & DDSD_PIXELFORMAT) { if (modes[i].ddpfPixelFormat.dwFlags & DDPF_RGB) { rc = IDirectDraw_SetDisplayMode(lpDD, modes[i].dwWidth, modes[i].dwHeight, U1(modes[i].ddpfPixelFormat).dwRGBBitCount); ok(DD_OK==rc || DDERR_UNSUPPORTED==rc,"SetDisplayMode returned: %x\n",rc); if (rc == DD_OK) { RECT r, scrn, test, virt; SetRect(&virt, 0, 0, GetSystemMetrics(SM_CXVIRTUALSCREEN), GetSystemMetrics(SM_CYVIRTUALSCREEN)); OffsetRect(&virt, GetSystemMetrics(SM_XVIRTUALSCREEN), GetSystemMetrics(SM_YVIRTUALSCREEN)); SetRect(&scrn, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); trace("Mode (%dx%d) [%dx%d] (%d %d)x(%d %d)\n", modes[i].dwWidth, modes[i].dwHeight, scrn.right, scrn.bottom, virt.left, virt.top, virt.right, virt.bottom); if (!EqualRect(&scrn, &orig_rect)) { HRESULT rect_result; /* Check that the client rect was resized */ rc = GetClientRect(hwnd, &test); ok(rc!=0, "GetClientRect returned %x\n", rc); rc = EqualRect(&scrn, &test); todo_wine ok(rc!=0, "Fullscreen window has wrong size\n"); /* Check that switching to normal cooperative level does not restore the display mode */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_NORMAL); ok(rc==DD_OK, "SetCooperativeLevel returned %x\n", rc); SetRect(&test, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); rect_result = EqualRect(&scrn, &test); ok(rect_result!=0, "Setting cooperative level to DDSCL_NORMAL changed the display mode\n"); /* Go back to fullscreen */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); ok(rc==DD_OK, "SetCooperativeLevel returned: %x\n",rc); /* If the display mode was changed, set the correct mode to avoid irrelevant failures */ if (rect_result == 0) { rc = IDirectDraw_SetDisplayMode(lpDD, modes[i].dwWidth, modes[i].dwHeight, U1(modes[i].ddpfPixelFormat).dwRGBBitCount); ok(DD_OK==rc, "SetDisplayMode returned: %x\n",rc); } } ok(GetClipCursor(&r), "GetClipCursor() failed\n"); /* ddraw sets clip rect here to the screen size, even for multiple monitors */ ok(EqualRect(&r, &scrn), "Invalid clip rect: (%d %d) x (%d %d)\n", r.left, r.top, r.right, r.bottom); ok(ClipCursor(NULL), "ClipCursor() failed\n"); ok(GetClipCursor(&r), "GetClipCursor() failed\n"); ok(EqualRect(&r, &virt), "Invalid clip rect: (%d %d) x (%d %d)\n", r.left, r.top, r.right, r.bottom); rc = IDirectDraw_RestoreDisplayMode(lpDD); ok(DD_OK==rc,"RestoreDisplayMode returned: %x\n",rc); } } } }
boolean CreatePrimary( win32_driver_t * win32_driver ) { LPDIRECTDRAW ddobj; DDSURFACEDESC2 ddsd; HRESULT result; // create direct draw object result = DirectDrawCreate( 0, &ddobj, 0 ); if( result != DD_OK ) { Error( 0, "DirectDrawCreate : error %i", result ); printf( "vo_out_directx : DirectDrawCreate : error %i\n", result ); return 0; } // set cooperative level result = IDirectDraw_SetCooperativeLevel( ddobj, win32_driver->win32_visual->WndHnd, DDSCL_NORMAL ); if( result != DD_OK ) { Error( 0, "SetCooperativeLevel : error %i", result ); return 0; } // try to get new interface result = IDirectDraw_QueryInterface( ddobj, &IID_IDirectDraw7, (LPVOID *) &win32_driver->ddobj ); if( result != DD_OK ) { Error( 0, "ddobj->QueryInterface : DirectX 7 or higher required" ); return 0; } // release our old interface IDirectDraw_Release( ddobj ); // create primary_surface memset( &ddsd, 0, sizeof( ddsd ) ); ddsd.dwSize = sizeof( ddsd ); ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; result = IDirectDraw7_CreateSurface( win32_driver->ddobj, &ddsd, &win32_driver->primary, 0 ); if( result != DD_OK ) { Error( 0, "CreateSurface ( primary ) : error %i ", result ); return 0; } // create our clipper object result = IDirectDraw7_CreateClipper( win32_driver->ddobj, 0, &win32_driver->ddclipper, 0 ); if( result != DD_OK ) { Error( 0, "CreateClipper : error %i", result ); return 0; } // associate our clipper with our window result = IDirectDrawClipper_SetHWnd( win32_driver->ddclipper, 0, win32_driver->win32_visual->WndHnd ); if( result != DD_OK ) { Error( 0, "ddclipper->SetHWnd : error %i", result ); return 0; } // associate our primary surface with our clipper result = IDirectDrawSurface7_SetClipper( win32_driver->primary, win32_driver->ddclipper ); if( result != DD_OK ) { Error( 0, "ddclipper->SetHWnd : error %i", result ); return 0; } // store our objects in our visual struct UpdateRect( win32_driver->win32_visual ); return 1; }
BOOL DDInit(int mode) { LPDIRECTDRAW lpdd; DDCAPS ddcaps, ddcaps2; HRESULT ddresult; int num; DDWnd = GetLibraryWindow(); // Create Direct Draw Object (Use Emulation if Hardware is off) if (!_lpDD) { ddresult = DirectDrawCreate(NULL, &lpdd, NULL); if (ddresult == DDERR_NODIRECTDRAWHW) { ddresult = DirectDrawCreate( (LPVOID) DDCREATE_EMULATIONONLY, &lpdd, NULL ); if (!CheckDDResult(ddresult, "InitDD:DirectDrawCreate emulation")) return FALSE; DDUseEmulation = TRUE; logentry("DirectDraw: forcing emulation.\n"); } else if (ddresult != DD_OK) return FALSE; logentry("DirectDraw: DirectX API hardware compliant.\n"); } else return FALSE; atexit(DDKill); // Determine hardware caps // Determine capture mode (fullscreen takes exclusive, window is normal) if (mode == DDGR_FULLSCREEN) { DWORD flags; flags = DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN; #ifndef NDEBUG if (!FindArg("-nomodex")) flags |= DDSCL_ALLOWMODEX; #else flags |= DDSCL_ALLOWMODEX; #endif if (!FindArg("-disallowreboot")) flags |= DDSCL_ALLOWREBOOT; ddresult = IDirectDraw_SetCooperativeLevel(lpdd, DDWnd, flags); if (!CheckDDResult(ddresult, "DDInit::SetCooperativeLevel")) { IDirectDraw_Release(lpdd); return FALSE; } _DDExclusive = TRUE; _DDFullScreen = TRUE; } else if (mode == DDGR_EXWINDOW) { ddresult = IDirectDraw_SetCooperativeLevel(lpdd, DDWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); if (!CheckDDResult(ddresult, "DDInit::SetCooperativeLevel")) return FALSE; _DDExclusive = TRUE; _DDFullScreen = FALSE; } else if (mode == DDGR_WINDOW) { ddresult = IDirectDraw_SetCooperativeLevel(lpdd, DDWnd, DDSCL_NORMAL); if (!CheckDDResult(ddresult, "DDInit::SetCooperativeLevel")) return FALSE; _DDExclusive = FALSE; _DDFullScreen = FALSE; } else return FALSE; // Get Display modes/Window Sizes // Force invalidation of all modes for now for (num = 0; num < 16; num++) { _DDModeList[num].rw = _DDModeList[num].w = -1; _DDModeList[num].rh = _DDModeList[num].h = -1; } W95DisplayMode = SM95_640x480x8; num = 0; if (mode == DDGR_FULLSCREEN) { ddresult = IDirectDraw_EnumDisplayModes(lpdd, 0, NULL, 0, EnumDispModesCB); if(!CheckDDResult(ddresult, "DDInit::EnumDisplayModes")) { IDirectDraw_Release(lpdd); return FALSE; } } else if (mode == DDGR_EXWINDOW) { _DDModeList[SM95_320x200x8X].rw = 320; _DDModeList[SM95_320x200x8X].rh = 200; _DDModeList[SM95_320x200x8X].w = 640; _DDModeList[SM95_320x200x8X].h = 480; _DDModeList[SM95_320x200x8X].emul = 1; _DDModeList[SM95_320x200x8X].dbuf = 0; _DDModeList[SM95_320x200x8X].modex = 0; _DDModeList[SM95_320x200x8X].paged = 0; _DDModeList[SM95_640x480x8].rw = 640; _DDModeList[SM95_640x480x8].rh = 480; _DDModeList[SM95_640x480x8].w = 640; _DDModeList[SM95_640x480x8].h = 480; _DDModeList[SM95_640x480x8].emul = 1; _DDModeList[SM95_640x480x8].dbuf = 0; _DDModeList[SM95_640x480x8].modex = 0; _DDModeList[SM95_640x480x8].paged = 0; _DDModeList[SM95_800x600x8].rw = 800; _DDModeList[SM95_800x600x8].rh = 600; _DDModeList[SM95_800x600x8].w = 640; _DDModeList[SM95_800x600x8].h = 480; _DDModeList[SM95_800x600x8].emul = 1; _DDModeList[SM95_800x600x8].dbuf = 0; _DDModeList[SM95_800x600x8].modex = 0; _DDModeList[SM95_800x600x8].paged = 0; _DDNumModes = 3; } else if (mode == DDGR_WINDOW) { _DDModeList[SM95_320x200x8X].rw = 320; _DDModeList[SM95_320x200x8X].rh = 200; _DDModeList[SM95_320x200x8X].w = 640; _DDModeList[SM95_320x200x8X].h = 480; _DDModeList[SM95_320x200x8X].emul = 1; _DDModeList[SM95_320x200x8X].dbuf = 0; _DDModeList[SM95_320x200x8X].modex = 0; _DDModeList[SM95_320x200x8X].paged = 0; _DDModeList[SM95_640x480x8].rw = 640; _DDModeList[SM95_640x480x8].rh = 480; _DDModeList[SM95_640x480x8].w = 640; _DDModeList[SM95_640x480x8].h = 480; _DDModeList[SM95_640x480x8].emul = 1; _DDModeList[SM95_640x480x8].dbuf = 0; _DDModeList[SM95_640x480x8].modex = 0; _DDModeList[SM95_640x480x8].paged = 0; _DDModeList[SM95_800x600x8].rw = 800; _DDModeList[SM95_800x600x8].rh = 600; _DDModeList[SM95_800x600x8].w = 800; _DDModeList[SM95_800x600x8].h = 600; _DDModeList[SM95_800x600x8].emul = 1; _DDModeList[SM95_800x600x8].dbuf = 0; _DDModeList[SM95_800x600x8].modex = 0; _DDModeList[SM95_800x600x8].paged = 0; _DDNumModes = 3; } else return FALSE; // Set appropriate display mode or window mode _lpDD = lpdd; memset(&ddcaps, 0, sizeof(ddcaps)); ddcaps.dwSize = sizeof(ddcaps); ddcaps2.dwSize = sizeof(ddcaps); ddresult = IDirectDraw_GetCaps(_lpDD, &ddcaps, NULL); if (!CheckDDResult(ddresult, "InitDD::GetCaps")) return FALSE; logentry("DirectDraw: VRAM free: %d\n", ddcaps.dwVidMemFree); logentry("DirectDraw: VRAM total: %d\n", ddcaps.dwVidMemTotal); #ifndef NDEBUG if (FindArg("-TsengDebug1")) { IDirectDraw_Release(lpdd); return FALSE; } #endif DDSetDisplayMode(W95DisplayMode, 0); #ifndef NDEBUG if (FindArg("-TsengDebug2")) { IDirectDraw_Release(lpdd); return FALSE; } #endif // If 'windowed' do this. if (!_DDFullScreen) { ddresult = IDirectDraw_CreateClipper(_lpDD, 0, &_lpDDClipper, NULL); if (!CheckDDResult(ddresult, "DDCreateScreen::CreateClipper")) return FALSE; ddresult = IDirectDrawClipper_SetHWnd(_lpDDClipper, 0, DDWnd); if (!CheckDDResult(ddresult, "DDCreateScreen::SetHWnd")) return FALSE; ddresult = IDirectDrawSurface_SetClipper(_lpDDSPrimary, _lpDDClipper); if (!CheckDDResult(ddresult, "DDCreateScreen::SetClipper")) return FALSE; } // Register Optimizations ddcaps.dwSize = sizeof(ddcaps); ddcaps2.dwSize = sizeof(ddcaps); ddresult = IDirectDraw_GetCaps(lpdd, &ddcaps, &ddcaps2); if (!CheckDDResult(ddresult, "DDInit::GetCaps")) return FALSE; #ifndef NDEBUG if (FindArg("-TsengDebug3")) { IDirectDraw_Release(lpdd); return FALSE; } #endif if (FindArg("-vidram")) { logentry("DirectDraw: Forcing VRAM rendering.\n"); _DDSysMemSurfacing = FALSE; } else if (FindArg("-sysram")) { logentry("DirectDraw: Forcing SRAM rendering.\n"); _DDSysMemSurfacing = TRUE; } else if (ddcaps.dwCaps & DDCAPS_BANKSWITCHED) { logentry("DirectDraw: Hardware is bank-switched. Using SRAM rendering.\n"); _DDSysMemSurfacing = TRUE; } else { logentry("DirectDraw: Hardware is not bank-switched. Using VRAM rendering.\n"); _DDSysMemSurfacing = FALSE; } if (ddcaps.dwCaps & DDCAPS_COLORKEYHWASSIST) ddDriverCaps.hwcolorkey = 1; else ddDriverCaps.hwcolorkey = 0; if (ddcaps.dwCaps & DDCAPS_BLTSTRETCH) ddDriverCaps.hwbltstretch = 1; else ddDriverCaps.hwbltstretch = 0; //@@ mprintf((0, "DD::Hardware=")); //@@ if (ddcaps.dwCaps & DDCAPS_NOHARDWARE) mprintf((0, "Off\n")); //@@ else mprintf((0, "On\n")); //@@ //@@ mprintf((0, "DD::VideoMem=%u bytes\n", ddcaps.dwVidMemTotal)); //@@ mprintf((0, "DD::SrcColorKey=")); //@@ if (ddcaps.dwCKeyCaps & DDCKEYCAPS_SRCBLT) mprintf((0, "Hardware\n")); //@@ else mprintf((0, "Emulation\n")); return TRUE; }
/* get_dx_ver: * returns the DirectX dx_version number: * * 0 no DirectX installed * 0x100 DirectX 1 installed * 0x200 DirectX 2 installed * 0x300 DirectX 3 installed * 0x500 at least DirectX 5 installed * 0x600 at least DirectX 6 installed * 0x700 at least DirectX 7 installed */ int get_dx_ver(void) { HRESULT hr; HINSTANCE ddraw_hinst = NULL; HINSTANCE dinput_hinst = NULL; HINSTANCE dsetup_hinst = NULL; LPDIRECTDRAW directdraw = NULL; LPDIRECTDRAW2 directdraw2 = NULL; DIRECTDRAWCREATE DirectDrawCreate = NULL; DIRECTINPUTCREATE DirectInputCreate = NULL; DSETUPCREATE DSetupCreate = NULL; OSVERSIONINFO os_version; LPDIRECTDRAWSURFACE ddraw_surf = NULL; LPDIRECTDRAWSURFACE3 ddraw_surf3 = NULL; DWORD dsetup_revision; DWORD dsetup_version; INT dsetup_result; #if DIRECTX_SDK_VERSION >= 0x600 LPDIRECTDRAWSURFACE4 ddraw_surf4 = NULL; #if DIRECTX_SDK_VERSION >= 0x700 LPDIRECTDRAWSURFACE7 ddraw_surf7 = NULL; #endif #endif DDSURFACEDESC ddraw_surf_desc; LPVOID temp; int dx_version = 0; /* first get the Windows platform */ os_version.dwOSVersionInfoSize = sizeof(os_version); if (!GetVersionEx(&os_version)) return dx_version; if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT) { /* NT is easy... NT 4.0 is DX2, 4.0 SP3 is DX3, 5.0 is DX5 at least * and no DX on earlier versions */ if (os_version.dwMajorVersion < 4) { /* No DX on NT 3.51 or earlier */ return dx_version; } /* First check for DX 8 and 9 */ dsetup_hinst = LoadLibrary( "DSETUP.DLL" ); if ( dsetup_hinst ) { DSetupCreate = (DSETUPCREATE)GetProcAddress(dsetup_hinst, "DirectXSetupGetVersion"); if ( DSetupCreate ) { dsetup_result = DSetupCreate( &dsetup_version, &dsetup_revision ); // returns 0 on failure if ( dsetup_result ) { switch (dsetup_version) { case 0x00040005: dx_version = 0x500; break; case 0x00040006: dx_version = 0x600; break; case 0x00040007: dx_version = 0x700; break; case 0x00040008: /* v8.x */ dx_version = 0x800; switch (dsetup_revision) { case 0x0001032A: case 0x00010371: dx_version = 0x810; /* 8.1 */ dx_version = 0x810; /* 8.1 */ break; case 0x00010385: dx_version = 0x81a; /* 8.1a or b (stupid MS...) */ break; case 0x00020386: dx_version = 0x820; /* 8.2 */ break; default: dx_version = 0x800; /* 8.0 */ } /* switch (dsetup_revision) */ case 0x00040009: switch (dsetup_revision) { case 0x00000384: dx_version = 0x900; /* 9.0 */ break; case 0x00000385: dx_version = 0x90a; /* 9.0a */ break; case 0x00000386: dx_version = 0x90b; /* 9.0b */ break; case 0x00000387: dx_version = 0x90b; /* 9.0(b or c) */ break; case 0x00000388: dx_version = 0x90c; /* 9.0c */ break; default: dx_version = 0x900; } /* switch (dsetup_revision) */ } /* switch (dsetup_version) */ } } FreeLibrary( dsetup_hinst ); if ( dx_version ) return dx_version; } if (os_version.dwMajorVersion == 4) { /* NT4 up to SP2 is DX2, and SP3 onwards is DX3, so we are at least DX2 */ dx_version = 0x200; /* we are not supposed to be able to tell which SP we are on, so check for DInput */ dinput_hinst = LoadLibrary("DINPUT.DLL"); if (!dinput_hinst) { /* no DInput... must be DX2 on NT 4 pre-SP3 */ OutputDebugString("Couldn't LoadLibrary DInput\r\n"); return dx_version; } DirectInputCreate = (DIRECTINPUTCREATE) GetProcAddress(dinput_hinst, "DirectInputCreateA"); FreeLibrary(dinput_hinst); if (!DirectInputCreate) { /* no DInput... must DX2 on NT 4 pre-SP3 */ return dx_version; } /* DX3 on NT4 SP3 or higher */ dx_version = 0x300; return dx_version; } /* it's at least NT 5 and it's DX5a or higher: * drop through to Win9x tests for a test of DDraw */ } /* now we know we are in Windows 9x (or maybe 3.1), so anything's possible; * first see if DDRAW.DLL even exists. */ ddraw_hinst = LoadLibrary("DDRAW.DLL"); if (!ddraw_hinst) { dx_version = 0; goto End; } /* see if we can create the DirectDraw object */ DirectDrawCreate = (DIRECTDRAWCREATE) GetProcAddress(ddraw_hinst, "DirectDrawCreate"); if (!DirectDrawCreate) { dx_version = 0; goto End; } hr = DirectDrawCreate(NULL, &directdraw, NULL); if (FAILED(hr)) { dx_version = 0; goto End; } /* so DirectDraw exists, we are at least DX1 */ dx_version = 0x100; /* let's see if IDirectDraw2 exists */ hr = IDirectDraw_QueryInterface(directdraw, &IID_IDirectDraw2, &temp); if (FAILED(hr)) { /* no IDirectDraw2 exists... must be DX1 */ goto End; } directdraw2 = temp; /* IDirectDraw2 exists... must be at least DX2 */ IDirectDraw2_Release(directdraw2); dx_version = 0x200; /* see if we can create the DirectInput object */ dinput_hinst = LoadLibrary("DINPUT.DLL"); if (!dinput_hinst) { /* no DInput... must be DX2 */ goto End; } DirectInputCreate = (DIRECTINPUTCREATE) GetProcAddress(dinput_hinst, "DirectInputCreateA"); FreeLibrary(dinput_hinst); if (!DirectInputCreate) { /* no DInput... must be DX2 */ goto End; } /* DirectInputCreate exists; that's enough to tell us that we are at least DX3 */ dx_version = 0x300; /* we can tell if DX5 is present by checking for the existence of IDirectDrawSurface3; * first we need a surface to QI off of */ memset(&ddraw_surf_desc, 0, sizeof(ddraw_surf_desc)); ddraw_surf_desc.dwSize = sizeof(ddraw_surf_desc); ddraw_surf_desc.dwFlags = DDSD_CAPS; ddraw_surf_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; hr = IDirectDraw_SetCooperativeLevel(directdraw, NULL, DDSCL_NORMAL); if (FAILED(hr)) { /* failure: this means DDraw isn't properly installed */ dx_version = 0; goto End; } hr = IDirectDraw_CreateSurface(directdraw, &ddraw_surf_desc, &ddraw_surf, NULL); if (FAILED(hr)) { /* failure: this means DDraw isn't properly installed */ dx_version = 0; goto End; } /* try for the IDirectDrawSurface3 interface; if it works, we're on DX5 at least */ hr = IDirectDrawSurface_QueryInterface(ddraw_surf, &IID_IDirectDrawSurface3, &temp); if (FAILED(hr)) goto End; ddraw_surf3 = temp; /* QI for IDirectDrawSurface3 succeeded; we must be at least DX5 */ dx_version = 0x500; #if DIRECTX_SDK_VERSION >= 0x600 /* try for the IDirectDrawSurface4 interface; if it works, we're on DX6 at least */ hr = IDirectDrawSurface_QueryInterface(ddraw_surf, &IID_IDirectDrawSurface4, (LPVOID *) &ddraw_surf4); if (FAILED(hr)) goto End; /* QI for IDirectDrawSurface4 succeeded; we must be at least DX6 */ dx_version = 0x600; #if DIRECTX_SDK_VERSION >= 0x700 /* try for the IDirectDrawSurface7 interface; if it works, we're on DX7 at least */ hr = IDirectDrawSurface_QueryInterface(ddraw_surf, &IID_IDirectDrawSurface7, (LPVOID *) &ddraw_surf7); if (FAILED(hr)) goto End; /* QI for IDirectDrawSurface7 succeeded; we must be at least DX7 */ dx_version = 0x700; #endif #endif End: if (directdraw) IDirectDraw_Release(directdraw); if (ddraw_hinst) FreeLibrary(ddraw_hinst); return dx_version; }
static boolean CreatePrimary( win32_driver_t * win32_driver ) { LPDIRECTDRAW ddobj; DDSURFACEDESC ddsd; HRESULT result; /* create direct draw object */ result = DirectDrawCreate( 0, &ddobj, 0 ); if( result != DD_OK ) { Error( 0, "DirectDrawCreate : error %ld", result ); xprintf(win32_driver->xine, XINE_VERBOSITY_DEBUG, "vo_out_directx : DirectDrawCreate : error %ld\n", result ); return 0; } /* set cooperative level */ result = IDirectDraw_SetCooperativeLevel( ddobj, win32_driver->win32_visual->WndHnd, DDSCL_NORMAL ); if( result != DD_OK ) { Error( 0, "SetCooperativeLevel : error 0x%lx", result ); return 0; } /* try to get new interface */ result = IDirectDraw_QueryInterface( ddobj, &IID_IDirectDraw, (LPVOID *) &win32_driver->ddobj ); if( result != DD_OK ) { Error( 0, "ddobj->QueryInterface : DirectX required" ); return 0; } /* release our old interface */ IDirectDraw_Release( ddobj ); /* create primary_surface */ memset( &ddsd, 0, sizeof( ddsd ) ); ddsd.dwSize = sizeof( ddsd ); ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; result = IDirectDraw_CreateSurface( win32_driver->ddobj, &ddsd, &win32_driver->primary, 0 ); if( result != DD_OK ) { Error( 0, "CreateSurface ( primary ) : error 0x%lx", result ); return 0; } /* create our clipper object */ result = IDirectDraw_CreateClipper( win32_driver->ddobj, 0, &win32_driver->ddclipper, 0 ); if( result != DD_OK ) { Error( 0, "CreateClipper : error 0x%lx", result ); return 0; } /* associate our clipper with our window */ result = IDirectDrawClipper_SetHWnd( win32_driver->ddclipper, 0, win32_driver->win32_visual->WndHnd ); if( result != DD_OK ) { Error( 0, "ddclipper->SetHWnd : error 0x%lx", result ); return 0; } /* associate our primary surface with our clipper */ result = IDirectDrawSurface_SetClipper( win32_driver->primary, win32_driver->ddclipper ); if( result != DD_OK ) { Error( 0, "ddclipper->SetHWnd : error 0x%lx", result ); return 0; } /* store our objects in our visual struct */ UpdateRect( win32_driver->win32_visual ); return 1; }
EXPORT int CALL angrylionRomOpen (void) { #ifndef HAVE_DIRECTDRAW screen_width = SCREEN_WIDTH; screen_height = SCREEN_HEIGHT; blitter_buf = (uint32_t*)calloc(screen_width * screen_height, sizeof(uint32_t)); pitchindwords = screen_width * 4; screen_pitch = PRESCALE_WIDTH << 2; #else DDPIXELFORMAT ftpixel; LPDIRECTDRAWCLIPPER lpddcl; RECT bigrect, smallrect, statusrect; POINT p; int rightdiff; int bottomdiff; GetWindowRect(gfx.hWnd,&bigrect); GetClientRect(gfx.hWnd,&smallrect); rightdiff = screen_width - smallrect.right; bottomdiff = screen_height - smallrect.bottom; if (gfx.hStatusBar) { GetClientRect(gfx.hStatusBar, &statusrect); bottomdiff += statusrect.bottom; } MoveWindow(gfx.hWnd, bigrect.left, bigrect.top, bigrect.right - bigrect.left + rightdiff, bigrect.bottom - bigrect.top + bottomdiff, true); res = DirectDrawCreateEx(0, (LPVOID*)&lpdd, &IID_IDirectDraw7, 0); if (res != DD_OK) { DisplayError("Couldn't create a DirectDraw object."); return; /* to-do: move to InitiateGFX? */ } res = IDirectDraw_SetCooperativeLevel(lpdd, gfx.hWnd, DDSCL_NORMAL); if (res != DD_OK) { DisplayError("Couldn't set a cooperative level."); return; /* to-do: move to InitiateGFX? */ } zerobuf(&ddsd, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; res = IDirectDraw_CreateSurface(lpdd, &ddsd, &lpddsprimary, 0); if (res != DD_OK) { DisplayError("CreateSurface for a primary surface failed."); return; /* to-do: move to InitiateGFX? */ } ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; ddsd.dwWidth = PRESCALE_WIDTH; ddsd.dwHeight = PRESCALE_HEIGHT; zerobuf(&ftpixel, sizeof(ftpixel)); ftpixel.dwSize = sizeof(ftpixel); ftpixel.dwFlags = DDPF_RGB; ftpixel.dwRGBBitCount = 32; ftpixel.dwRBitMask = 0xff0000; ftpixel.dwGBitMask = 0xff00; ftpixel.dwBBitMask = 0xff; ddsd.ddpfPixelFormat = ftpixel; res = IDirectDraw_CreateSurface(lpdd, &ddsd, &lpddsback, 0); if (res == DDERR_INVALIDPIXELFORMAT) { DisplayError( "ARGB8888 is not supported. You can try changing desktop color "\ "depth to 32-bit, but most likely that won't help."); return; /* InitiateGFX fails. */ } else if (res != DD_OK) { DisplayError("CreateSurface for a secondary surface failed."); return; /* InitiateGFX should fail. */ } res = IDirectDrawSurface_GetSurfaceDesc(lpddsback, &ddsd); if (res != DD_OK) { DisplayError("GetSurfaceDesc failed."); return; /* InitiateGFX should fail. */ } if ((ddsd.lPitch & 3) || ddsd.lPitch < (PRESCALE_WIDTH << 2)) { DisplayError( "Pitch of a secondary surface is either not 32 bit aligned or "\ "too small."); return; /* InitiateGFX should fail. */ } pitchindwords = ddsd.lPitch >> 2; res = IDirectDraw_CreateClipper(lpdd, 0, &lpddcl, 0); if (res != DD_OK) { DisplayError("Couldn't create a clipper."); return; /* InitiateGFX should fail. */ } res = IDirectDrawClipper_SetHWnd(lpddcl, 0, gfx.hWnd); if (res != DD_OK) { DisplayError("Couldn't register a windows handle as a clipper."); return; /* InitiateGFX should fail. */ } res = IDirectDrawSurface_SetClipper(lpddsprimary, lpddcl); if (res != DD_OK) { DisplayError("Couldn't attach a clipper to a surface."); return; /* InitiateGFX should fail. */ } src.top = src.left = 0; src.bottom = 0; #if SCREEN_WIDTH < PRESCALE_WIDTH src.right = PRESCALE_WIDTH - 1; /* fix for undefined video card behavior */ #else src.right = PRESCALE_WIDTH; #endif p.x = p.y = 0; GetClientRect(gfx.hWnd, &dst); ClientToScreen(gfx.hWnd, &p); OffsetRect(&dst, p.x, p.y); GetClientRect(gfx.hStatusBar, &statusrect); dst.bottom -= statusrect.bottom; #endif rdp_init(); overlay = 0; return 1; }
static void WINAPI VGA_DoSetMode(ULONG_PTR arg) { LRESULT res; ModeSet *par = (ModeSet *)arg; par->ret=1; if (lpddraw) VGA_DoExit(0); if (!lpddraw) { if (!pDirectDrawCreate) { HMODULE hmod = LoadLibraryA( "ddraw.dll" ); if (hmod) pDirectDrawCreate = (DirectDrawCreateProc)GetProcAddress( hmod, "DirectDrawCreate" ); if (!pDirectDrawCreate) { ERR("Can't lookup DirectDrawCreate from ddraw.dll.\n"); return; } } res = pDirectDrawCreate(NULL,&lpddraw,NULL); if (!lpddraw) { ERR("DirectDraw is not available (res = %lx)\n",res); return; } if (!vga_hwnd) { vga_hwnd = CreateWindowExA(0,"STATIC","WINEDOS VGA", WS_POPUP|WS_VISIBLE|SS_NOTIFY,0,0, par->Xres,par->Yres,0,0,0,NULL); if (!vga_hwnd) { ERR("Failed to create user window.\n"); IDirectDraw_Release(lpddraw); lpddraw=NULL; return; } } else SetWindowPos(vga_hwnd,0,0,0,par->Xres,par->Yres,SWP_NOMOVE|SWP_NOZORDER); if ((res=IDirectDraw_SetCooperativeLevel(lpddraw,vga_hwnd,DDSCL_FULLSCREEN|DDSCL_EXCLUSIVE))) { ERR("Could not set cooperative level to exclusive (%lx)\n",res); } if ((res=IDirectDraw_SetDisplayMode(lpddraw,par->Xres,par->Yres,par->Depth))) { ERR("DirectDraw does not support requested display mode (%dx%dx%d), res = %lx!\n",par->Xres,par->Yres,par->Depth,res); IDirectDraw_Release(lpddraw); lpddraw=NULL; return; } res=IDirectDraw_CreatePalette(lpddraw,DDPCAPS_8BIT,NULL,&lpddpal,NULL); if (res) { ERR("Could not create palette (res = %lx)\n",res); IDirectDraw_Release(lpddraw); lpddraw=NULL; return; } if ((res=IDirectDrawPalette_SetEntries(lpddpal,0,0,256,vga_def_palette))) { ERR("Could not set default palette entries (res = %lx)\n", res); } memset(&sdesc,0,sizeof(sdesc)); sdesc.dwSize=sizeof(sdesc); sdesc.dwFlags = DDSD_CAPS; sdesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; if (IDirectDraw_CreateSurface(lpddraw,&sdesc,&lpddsurf,NULL)||(!lpddsurf)) { ERR("DirectDraw surface is not available\n"); IDirectDraw_Release(lpddraw); lpddraw=NULL; return; } IDirectDrawSurface_SetPalette(lpddsurf,lpddpal); vga_retrace_vertical = vga_retrace_horizontal = FALSE; /* poll every 20ms (50fps should provide adequate responsiveness) */ VGA_InstallTimer(20); } par->ret=0; return; }