/// <summary> /// /// </summary> /// <param name="handle"></param> /// <param name="fullScreen"></param> /// <param name="doubleBuffer"></param> /// <returns></returns> public IGraphicsSurface CreatePrimarySurface(IntPtr handle, Boolean fullScreen, Boolean doubleBuffer) { var tempDescr = new DxVBLib.DDSURFACEDESC2 { lFlags = DxVBLib.CONST_DDSURFACEDESCFLAGS.DDSD_CAPS, ddsCaps = { lCaps = DxVBLib.CONST_DDSURFACECAPSFLAGS.DDSCAPS_PRIMARYSURFACE } }; if (doubleBuffer) { tempDescr.lFlags |= DxVBLib.CONST_DDSURFACEDESCFLAGS.DDSD_BACKBUFFERCOUNT; tempDescr.lBackBufferCount = 1; tempDescr.ddsCaps.lCaps |= DxVBLib.CONST_DDSURFACECAPSFLAGS.DDSCAPS_COMPLEX | DxVBLib.CONST_DDSURFACECAPSFLAGS.DDSCAPS_FLIP; } var surface = new DirectDrawSurface(tempDescr); if (fullScreen) { return(surface); } var clipper = DirectDraw.CreateClipper(0); clipper.SetHWnd(handle.ToInt32()); surface.SetClipper(clipper); return(surface); }
/// <summary> /// Creates a new sprite sheet with the given name from an image. /// The sheet is broken into sprites given the number of horizontal /// and vertical frames available on this sheet. /// </summary> /// <param name="spriteName">The name of the sprite sheet</param> /// <param name="spriteImagePath">The path to the image to load.</param> /// <param name="xFrames">The number of horizontal frames on this sheet.</param> /// <param name="yFrames">The number of vertical frames on this sheet.</param> public DirectDrawSpriteSurface(string spriteName, string spriteImagePath, int xFrames, int yFrames) { #if TRACE GraphicsEngine.Profiler.Start("DirectDrawSpriteSurface..ctor()"); #endif _spriteName = spriteName; _ddsurface = new DirectDrawSurface(spriteImagePath); if (_ddsurface == null) { _ddsurface = new DirectDrawSurface(spriteImagePath, DirectDrawSurface.SystemMemorySurfaceDescription); } _ddsurface.TransparencyKey = new ColorKey(DirectDrawSurface.DefaultColorKey); _animationFrames = xFrames; _animationTypes = yFrames; _frameHeight = _ddsurface.Rect.Bottom / _animationTypes; _frameWidth = _ddsurface.Rect.Right / _animationFrames; #if TRACE GraphicsEngine.Profiler.End("DirectDrawSpriteSurface..ctor()"); #endif }