bool ALSoftwareGraphicsDriver::Init(int width, int height, int colourDepth, bool windowed, volatile int *loopTimer) { _screenWidth = width; _screenHeight = height; _colorDepth = colourDepth; _windowed = windowed; _loopTimer = loopTimer; int driver = GetAllegroGfxDriverID(windowed); set_color_depth(colourDepth); int actualInitWid = width, actualInitHit = height; _filter->GetRealResolution(&actualInitWid, &actualInitHit); if (_initGfxCallback != NULL) _initGfxCallback(NULL); if ((IsModeSupported(driver, actualInitWid, actualInitHit, colourDepth)) && (set_gfx_mode(driver, actualInitWid, actualInitHit, 0, 0) == 0)) { clear(screen); screen = _filter->ScreenInitialized(screen, width, height); virtualScreen = screen; #ifdef _WIN32 if (!windowed) { memset(&ddrawCaps, 0, sizeof(ddrawCaps)); ddrawCaps.dwSize = sizeof(ddrawCaps); IDirectDraw2_GetCaps(directdraw, &ddrawCaps, NULL); if ((ddrawCaps.dwCaps2 & DDCAPS2_PRIMARYGAMMA) == 0) { } else if (IDirectDrawSurface2_QueryInterface(gfx_directx_primary_surface->id, IID_IDirectDrawGammaControl, (void **)&dxGammaControl) == 0) { dxGammaControl->GetGammaRamp(0, &defaultGammaRamp); } } #endif return true; } return false; }
/** * Probe the capabilities of the hardware * * It is nice to know which features are supported by the hardware so we can * find ways to optimize our rendering. */ static void DirectXGetDDrawCaps(vout_display_t *vd) { vout_display_sys_t *sys = vd->sys; /* This is just an indication of whether or not we'll support overlay, * but with this test we don't know if we support YUV overlay */ DDCAPS ddcaps; ZeroMemory(&ddcaps, sizeof(ddcaps)); ddcaps.dwSize = sizeof(ddcaps); HRESULT hr = IDirectDraw2_GetCaps(sys->ddobject, &ddcaps, NULL); if (hr != DD_OK) { msg_Warn(vd, "cannot get caps"); return; } /* Determine if the hardware supports overlay surfaces */ const bool has_overlay = ddcaps.dwCaps & DDCAPS_OVERLAY; /* Determine if the hardware supports overlay surfaces */ const bool has_overlay_fourcc = ddcaps.dwCaps & DDCAPS_OVERLAYFOURCC; /* Determine if the hardware supports overlay deinterlacing */ const bool can_deinterlace = ddcaps.dwCaps & DDCAPS2_CANFLIPODDEVEN; /* Determine if the hardware supports colorkeying */ const bool has_color_key = ddcaps.dwCaps & DDCAPS_COLORKEY; /* Determine if the hardware supports scaling of the overlay surface */ const bool can_stretch = ddcaps.dwCaps & DDCAPS_OVERLAYSTRETCH; /* Determine if the hardware supports color conversion during a blit */ sys->can_blit_fourcc = ddcaps.dwCaps & DDCAPS_BLTFOURCC; /* Determine overlay source boundary alignment */ const bool align_boundary_src = ddcaps.dwCaps & DDCAPS_ALIGNBOUNDARYSRC; /* Determine overlay destination boundary alignment */ const bool align_boundary_dest = ddcaps.dwCaps & DDCAPS_ALIGNBOUNDARYDEST; /* Determine overlay destination size alignment */ const bool align_size_src = ddcaps.dwCaps & DDCAPS_ALIGNSIZESRC; /* Determine overlay destination size alignment */ const bool align_size_dest = ddcaps.dwCaps & DDCAPS_ALIGNSIZEDEST; msg_Dbg(vd, "DirectDraw Capabilities: overlay=%i yuvoverlay=%i " "can_deinterlace_overlay=%i colorkey=%i stretch=%i " "bltfourcc=%i", has_overlay, has_overlay_fourcc, can_deinterlace, has_color_key, can_stretch, sys->can_blit_fourcc); if (align_boundary_src || align_boundary_dest || align_size_src || align_size_dest) { if (align_boundary_src) vd->sys->i_align_src_boundary = ddcaps.dwAlignBoundarySrc; if (align_boundary_dest) vd->sys->i_align_dest_boundary = ddcaps.dwAlignBoundaryDest; if (align_size_src) vd->sys->i_align_src_size = ddcaps.dwAlignSizeSrc; if (align_size_dest) vd->sys->i_align_dest_size = ddcaps.dwAlignSizeDest; msg_Dbg(vd, "align_boundary_src=%i,%i align_boundary_dest=%i,%i " "align_size_src=%i,%i align_size_dest=%i,%i", align_boundary_src, vd->sys->i_align_src_boundary, align_boundary_dest, vd->sys->i_align_dest_boundary, align_size_src, vd->sys->i_align_src_size, align_size_dest, vd->sys->i_align_dest_size); } }