[ Pobierz całość w formacie PDF ]
.Then we call CoUninitialize(); to unload COM libraries and we re finished.Easy, huh?SummaryIn this hour, you learned about DirectShow, and how to use it to render a video stream toany DirectDraw surface.You also learned a bit about the inner workings of DirectShowand about filters and filter graphs.So to wrap it up, you re now ready to add video toyour DirectX based games.Q&AQ Can I render DirectShow video streams onto ANY DirectDraw surface?A Yes.You can render to any DirectDraw surface you want, including Direct3D tex-tures.Q Will the Media Player ActiveX control work with browsers other thanInternet Explorer?A The Media Player ActiveX control will work in all browsers that support ActiveXcontrols.That means Internet Explorer, but it s also possible to make it work withNetscape.See your Direct Media SDK documentation on how to do this.Q If I want to make an animated logo using an AVI video clip, can I use colorkeying?A Yes.Simply set the color key of the DirectX Surface of your sample stream object.Q I noticed you used DirectDrawSurface4 rather than DirectDrawSurface7.Why?A DirectX Media is a separate SDK that ships with DirectX but lags behind theDirectX SDK itself.In fact, DirectX 7 includes DirectX Media SDK version 6.0,which is as yet unaware of DirectX 7 interfaces.Q Oh.Is that a problem?31 1634xCH22 11/13/99 11:18 AM Page 463Adding Video with DirectShow 463A It depends on what you re doing.For Web pages, it s no problem, but for gameapplications dedicated to DirectX 7 interfaces (remember, COM ensures you can22use the older interfaces) it could cause problems.If you use DirectDraw7 andDirectDrawSurface7, it will compile, link, and run, but you ll get error reports inthe debug window, and this could lead to compatibility problems with some hard-ware or drivers.Some developers choose to avoid this risk by excluding all formsof movie play and using engine cinematics instead.WorkshopThe workshop will enable you to test yourself on what you have learned in this hour andget you thinking about how to apply this knowledge in a real life application.Theanswers to the quiz are in Appendix A, Answers.Quiz1.What is a DirectShow filter?2.What is a DirectShow pin?3.What happens if the destination rectangle of a DirectShow stream is larger thanthat of the stream itself?4.Mention a few streaming and nonstreaming DirectShow supported media formats.5.What would happen if you put a 20MB nonstreaming video on your homepage?Exercises1.Modify the cityscape from Hour 17, Introducing DirectInput Getting UserInput, to display a video billboard on one of the buildings.(Hint: Give one housedifferent textures on each side and let one of them be a video stream.)2.Make a cool menu for your own game, and let the logo be a color keyed videostream.(Hint: Use any animation program that can save to AVI or MPEG.)31 1634xCH22 11/13/99 11:18 AM Page 46432 1634xCH23 11/13/99 11:19 AM Page 465HOUR 23Bring Surfaces to Lifewith DirectX Transformby Sam Christiansen and Sylvia MollerstromDirectX Transform is the part of the DirectX Media SDK that lets you ani-mate, blend, and distort two-dimensional images and three-dimensionalmesh objects.DirectX Transform helps you write transforms, which are a setof instructions that take zero (or more) graphical or 3D mesh inputs andresult in one graphical or 3D mesh output.For example, in this hour, youwill learn how to write a Wipe Transform that creates an animated transitionbetween two images.This transform takes two different images as inputsand results in one single output image that is, by varying degrees, a compos-ite of the two input images.DirectX Transform is a powerful tool that can help you create things likeAdobe PhotoShop filters and animated content for Web pages.You can taketransforms that you write with DirectX Transform and create the abovethings without modifying the transforms in any way part of the beauty of32 1634xCH23 11/13/99 11:19 AM Page 466466 Hour 23DirectX Transform is that it does everything for you automatically! To get you startedwith using and writing transforms, this hour will help you work with DirectX Transforminside of your DirectX application.In this hour, you will" Learn about the power of DirectX Transforms" Learn about the DXSurface object" Learn how to create special effects using DirectX Transforms" Learn how to use DirectX Transforms in your applicationThe Power of DirectX TransformDirectX Transform is so powerful because it combines two concepts that are normally atopposite ends of the computer experience.Because it comes with many pre-built trans-forms, it is easy to use if you want to just dabble in it; however, it is also easily extensi-ble so that you can quickly move beyond the basics and into some powerful issues bywriting your own transforms.Normally when you want to create smooth transitionsbetween graphics, you have to worry about many details.With DirectX Transform, allthese details are taken care of so that you only have to worry about doing exactly whatyou want!The following are some of the highlights of DirectX Transform:" With DirectX Transform, you can use many different file formats (such as.GIF,.JPEG, and.BMP).DirectX Transform automatically converts the images to a ver-sion that it can read." DirectX Transform is easy to use, yet extensible: it comes with many pre-builttransforms, or you can write your own." DirectX Transform allows you to easily create transition type transforms.Normally,artists would have to draw every frame of the transition; even if the artist uses acomputer, the computer will use up a lot of memory in order to draw each frame ofthe animation.But, with DirectX Transform, you only need two input surfaces.Thissaves you both time and space when transitioning." DirectX Transform helps you write procedural surfaces.These are surfaces thatstore functions instead of an array describing each pixel of an image.Because pro-cedural surfaces do not have to store information for each pixel, they let you createnaturalistic patterns (like marble or wood), and they use even less space!" DirectX Transform lets you scale your transforms to hardware.So, you can takeadvantage of fast hardware to make your transforms look even better.32 1634xCH23 11/13/99 11:19 AM Page 467Bring Surfaces to Life with DirectX Transform 467A Versatile DirectDraw Surface: IDXSurfaceThe DXSurface is at the heart of DirectX Transform.The DXSurface is an object thatusually wraps a DirectDrawSurface object.In other words, at the core of eachDXSurface, there is a DirectDrawSurface
[ Pobierz całość w formacie PDF ]