Download DirectX 8 and Visual Basic Development Keith Sink ebook All Chapters PDF
Download DirectX 8 and Visual Basic Development Keith Sink ebook All Chapters PDF
com
https://ebookname.com/product/directx-8-and-visual-basic-
development-keith-sink/
OR CLICK BUTTON
DOWLOAD EBOOK
https://ebookname.com/product/visual-basic-game-programming-with-
directx-1st-edition-jonathan-s-harbour/
ebookname.com
https://ebookname.com/product/ableton-live-8-and-suite-8-keith-
robinson/
ebookname.com
https://ebookname.com/product/clearly-visual-basic-programming-with-
microsoft-visual-basic-2012-3rd-edition-diane-zak/
ebookname.com
https://ebookname.com/product/python-programming-for-biology-
bioinformatics-and-beyond-1st-edition-tim-j-stevens/
ebookname.com
https://ebookname.com/product/mahdis-and-millenarians-shi-ite-
extremists-in-early-muslim-iraq-1st-edition-william-frederick-tucker/
ebookname.com
https://ebookname.com/product/prepositions-in-their-syntactic-
semantic-and-pragmatic-context-1st-edition-susanne-feigenbaum-ed/
ebookname.com
https://ebookname.com/product/truth-in-nonfiction-essays-1st-edition-
david-lazar/
ebookname.com
Symmetry 1st Edition Gracia Arredondo
https://ebookname.com/product/symmetry-1st-edition-gracia-arredondo/
ebookname.com
DirectX 8 and Visual Basic
Development
Keith Sink
TECHNICAL EDITORS
Trademarks Andrew Indovina
All terms mentioned in this book that are known to be trademarks or service Joe Johnston
marks have been appropriately capitalized. Sams Publishing cannot attest to William McLoughlin
the accuracy of this information. Use of a term in this book should not be
TEAM COORDINATOR
regarded as affecting the validity of any trademark or service mark.
Lynne Williams
DirectX, DirectDraw, DirectShow, DirectSound, DirectMusic, DirectPlay,
DirectInput, Direct3D, DirectGraphics, Microsoft, Microsoft Visual Basic, and MEDIA DEVELOPER
Windows are registered trademarks of Microsoft Corporation. Dan Scherf
INTERIOR DESIGNER
Warning and Disclaimer Anne Jones
Every effort has been made to make this book as complete and as accurate as COVER DESIGNER
possible, but no warranty or fitness is implied. The information provided is on Gary Adair
an “as is” basis. The author and the publisher shall have neither liability nor
responsibility to any person or entity with respect to any loss or damages aris- PAGE LAYOUT
ing from the information contained in this book or programs accompanying it. Octal Publishing, Inc.
Contents at a Glance
Introduction
Index
Table of Contents
Introduction 1
Who This Book Is For? ..........................................................................1
What You Need to Know ........................................................................1
What Hardware and Software You Need ................................................1
How This Book Is Organized ................................................................2
Conventions Used in This Book ............................................................3
3 Animation Techniques 39
The Basics ............................................................................................40
The Model Sheet ............................................................................40
The Frame ........................................................................................40
The Cycle ........................................................................................41
Storyboards ......................................................................................41
Keyframes ........................................................................................42
Backgrounds ....................................................................................42
DirectX Objects ....................................................................................43
Frame Rates ....................................................................................43
Blits ..................................................................................................43
Sprites ..............................................................................................44
Drawing Surfaces ............................................................................45
Palettes ............................................................................................45
Rectangles ........................................................................................46
Clippers ............................................................................................46
Billboards ........................................................................................47
Techniques ............................................................................................48
Blitting ............................................................................................48
Page Flipping and Back Buffering ..................................................48
Palette Cycling ................................................................................49
Summary ..............................................................................................50
vii
CONTENTS
7 3D Geometry 103
3D Space Coordinate System ............................................................104
3D Objects ..........................................................................................105
Vertices ..........................................................................................106
Polygons ........................................................................................106
Faces ..............................................................................................107
Mesh ..............................................................................................107
Texture ..........................................................................................109
viii
DIRECTX 8 AND VISUAL BASIC DEVELOPMENT
Lights ............................................................................................109
Materials ........................................................................................109
Matrices ..............................................................................................111
Projection Matrix ..........................................................................112
View Matrix ..................................................................................112
World Matrix (World Transformation) ..........................................112
Summary ............................................................................................112
8 Direct3D 115
Direct3D Objects ................................................................................116
The Direct3D8 Class ....................................................................116
The Direct3DBaseTexture8 Class ................................................117
The Direct3DCubeTexture8 Class ................................................118
The Direct3DDevice8 Class ..........................................................119
The Direct3DIndexBuffer8 Class ..................................................123
The Direct3DResource8 Class ......................................................124
The Direct3DSurface8 Class ........................................................125
The Direct3DSwapChain8 Class ..................................................126
The Direct3DTexture8 Class ........................................................126
The Direct3DVertexBuffer8 Class ................................................127
The Direct3DVolume8 Class ........................................................127
The Direct3DVolumeTexture8 Class ............................................128
Creating 3D Applications ..................................................................129
Creating a Direct3D Application ..................................................129
Working with Vertices ..................................................................133
Working with Matrices ..................................................................137
Working with Lights ......................................................................142
Working with Textures ..................................................................146
Working with Meshes ....................................................................149
Summary ............................................................................................153
Lobby ............................................................................................343
GUID ............................................................................................343
Communication Models ......................................................................344
Peer-to-Peer ..................................................................................344
Client/Server ..................................................................................344
DirectPlay Events ..............................................................................346
A DirectPlay Peer-to-Peer Client ......................................................346
Assigning a GUID ........................................................................346
Initializing the DirectPlay Peer-to-Peer Client ............................346
Finding the Available Service Providers ......................................347
Finding the Game Host ................................................................347
Connecting to the Session ............................................................347
Managing the Session ....................................................................348
Sending Messages ........................................................................348
Closing the Session ......................................................................348
A DirectPlay Client/Server Connection ............................................349
Assigning a GUID ........................................................................349
Initializing the DirectPlay Client/Server Client ............................349
Finding the Available Service Providers ......................................349
Finding the Game Host ................................................................350
Connecting to the Session ............................................................350
Managing the Session ....................................................................350
Sending Messages ........................................................................351
Closing the Session ......................................................................351
Summary ............................................................................................351
Index 405
About the Author
Keith Sink is a Senior Technical Engineer for Capital Stream, a financial software company in
Seattle, WA, where he has been involved in the design, development, and architecture of a
number of successful applications. Keith has been a professional software developer for six
years and an MCP since 1994, has taught numerous VB training courses, and has beta-tested
Microsoft’s DirectX since version 2.0. Keith has been animating and writing video games
since the TRS-80 programming days in the early 1980s, and enjoys restoring classic video
games. While working with Microsoft, Keith contributed to Office 97 Help content as well as
content for the Word and PowerPoint Answer Wizards.
About the Technical Editors
Andrew J. Indovina is currently a software developer living in Rochester, NY. With a degree
in computer science, he has a wide programming background. Andy has co-authored two
books based on Visual Basic 6 and Visual C++, respectively.
Joseph Johnston is currently a technical specialist for Cendant Corporation. He uses VB,
VFP5 and 6, SQL Server, MTS/COM+, and VC++ on a daily basis. Joe also creates solutions
or utilities for acute issues with data and software systems using the tool that makes the most
sense.
William McLoughlin is currently a software developer for a major pharmaceutical company.
Bill has a degree in computer information systems technologies. He lives in Long Valley, NJ
with his wife Jennifer and their sons Liam and Owen.
Dedication
In memory of my parents: Wade and Janet.
E-mail: feedback@samspublishing.com
Mail:
Sams Publishing
800 East 96th Street
Indianapolis, IN 46240 USA
Introduction
DirectX and the graphics SDKs, which were its foundation, have been around since the early
days of Windows in one form or another. However, most of us have not been exposed to their
fantastic capabilities. Under the shroud of secrecy, Windows game programmers have carefully
guarded their secrets to protect their investments. This shroud has become transparent in recent
years, though, and now the advanced libraries that used to belong to a select few are available
in a universal library called DirectX. For some years, DirectX was accessible only to C pro-
grammers, but not anymore. DirectX is now available to Visual Basic programmers, and more
and more of them are creating games and multimedia applications.
This world can be quite complex, but also quite exciting. With the ease of use of Visual Basic
and the powerful libraries in DirectX, this combination is a natural marriage of technologies.
This book will take you through understanding DirectX concepts and show you how to create
applications that can make use of this technology. This book will introduce you to what you
need to know, but as with all languages and libraries, practice makes perfect.
Most of the standard hardware on the market will run the programs in this book. The only
exception is Direct3D applications. If you are going to develop Direct3D applications, you will
need a 3D graphics card.
NOTE
TIP
CAUTION
Cautions advise you about potential problems and help you steer clear of disaster.
PART
I
VB and DirectX Development
IN THIS PART
1 Introduction to DirectX Programming 7
3 Animation Techniques 39
Discovering Diverse Content Through
Random Scribd Documents
—De nada servirá nuestro valor —dijo Santorcaz—, si antes no
acabamos con todos los traidores que hay en Madrid.
—Lo mismo digo —afirmó Mortero.
—Por todas partes no se ven sino espías de los franceses, y ahora
es ocasión de que este señor Regidor que aquí tenemos se luzca.
—Así es la verdad —dije yo—. Sé de muchos que se fingen muy
patriotas, y están vendidos a los franceses. Los que hacen más
aspavientos y dan más gritos, y más gallardean de patriotas, son los
peores. ¿No es verdad, Santorcaz?
—Pues acabar con ellos.
—Para eso nos bastamos y nos sobramos —añadió Majoma—. Y
vengan malos patriotas y gabachones, para dar cuenta de ellos.
—Personajes conozco yo —dijo Mañara— que han de mori
arrastrados, si Dios no lo remedia; y si llego a ser Regidor, ya nos
veremos las caras, señores afrancesados.
—Esa es la gente más mala —afirmó Santorcaz con mucho
desparpajo—, más desvergonzada y más traidora que hay; y si no
ponemos mano en ellos, no saldremos bien de esta guerra. Porque yo
sé que hay quien está tramando abrir las puertas de Madrid si nos
ponen asedio.
—Pues despacharlos, y se acabó la junción —dijo Pujitos—. En m
compañía están tan rabiosos, que solo con decir «ese es gabacho», se
le van encima y le quieren despedazar.
—Los peores —repetí yo, teniendo el gusto de que el tío Mano
apoyara enérgicamente mi opinión— son los que chillan y enredan, y
están a todas horas hablando de traidores; y si no, aquí está
Santorcaz, que conoce a la gente y lo puede decir.
—Así es, en efecto —repuso el francmasón algo contrariado—; pero
que hay traidores, no tiene duda.
XI
É
—Él les escribe cartas de lo que aquí pasa, y con el dinero que le
dan paga gente alborotadora, que arme querellas entre la tropa. Como
este hay muchos, y se dice que señores muy alcurniados están
vendidos a los franceses. Pero, Gabriel, que se nos amostacen las
narices, y veremos a dónde van a parar. Hay otros que, aunque no son
traidores, son melindrosos, y no quieren lo que llaman Constitución, la
cual se va a poner ahora pa acabar con el espotismo. ¿Sabes tú lo que
es el espotismo? Pues el espotismo es una cosa muy mala, muy mala
A bien que desde que acabamos con Godoy y los lairones que con é
vivían, se acabaron todas las picardías, y ahora, luego que demos fin a
esto del córcego, los reinos de España se van a gobernar de otra
manera, y estaremos tan bien, que no nos cambiaremos por los
ángeles del cielo.
Y diciendo esto, dio media vuelta y marchose lejos de mí a toda
prisa. No tardé yo en acudir pronto a la formación de mi compañía.
Ante las evidentes muestras de alarma que a todas horas se
observaban en Madrid, mal podía el optimismo del Gran Capitán
sostenerse en las ideales regiones donde le hemos visto cernerse
como el águila de la patria a quien ni el peligro ni el miedo pueden
obligar a abatir su majestuoso vuelo. Ya no era posible negar la derrota
de Espinosa, ni tampoco la de Gamonal, y solo los locos podrían
suponer a Napoleón dispuesto a detenerse en su victorioso camino
Muchos días resistiose el fuerte espíritu de mi amigo a la evidencia de
tantos descalabros; por muchos días sostuvo que nuestras armas
victoriosas echarían a los franceses con su malhadado Emperador de
otro lado del Bidasoa; por muchos días continuó atribuyendo a los
papeles públicos la pérfida invención de aquellos absurdos
acontecimientos que no cabían en su homérica cabeza; pero al fin la
muchedumbre de las noticias malas, la agitación pública, el pánico de
todos, la general zozobra, y el tumulto y laberinto de los preparativos
de defensa rindieron golpe tras golpe el formidable castillo de su
terquedad, dando en tierra con tantas ilusiones. El héroe no aparentó
desmayar con esto, antes bien se reía tomando la cosa como una
fiesta. Lleno de confianza en la capital, siempre negaba que Napoleón
se atreviese a ponerse delante de los madrileños, y esta fue una
tenacidad que le duró contra viento y marea hasta el 25 de noviembre
en cuya noche, al retirarse a su casa, preguntole Doña Gregoria, como
siempre, las noticias de la tarde:
—Nada, mujer —repuso frotándose las manos, y promulgando con
desdeñosas sonrisas la categórica confianza que llenaba su espíritu—
Nada, mujer: emperadorcito tenemos.
XIII
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookname.com