D3DX8.pas 170 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952
  1. {******************************************************************************}
  2. {* *}
  3. {* Copyright (C) Microsoft Corporation. All Rights Reserved. *}
  4. {* *}
  5. {* File: d3dx8.h, d3dx8core.h, d3dx8math.h, d3dx8math.inl, *}
  6. {* d3dx8effect.h, d3dx8mesh.h, d3dx8shape.h, d3dx8tex.h *}
  7. {* Content: Direct3DX 8.1 headers *}
  8. {* *}
  9. {* Direct3DX 8.1 Delphi adaptation by Alexey Barkovoy *}
  10. {* E-Mail: clootie@reactor.ru *}
  11. {* *}
  12. {* Modified: 27-Apr-2003 *}
  13. {* *}
  14. {* Partly based upon : *}
  15. {* Direct3DX 7.0 Delphi adaptation by *}
  16. {* Arne Schäpers, e-Mail: [look at www.delphi-jedi.org/DelphiGraphics/] *}
  17. {* *}
  18. {* Latest version can be downloaded from: *}
  19. {* http://clootie.narod.ru/delphi *}
  20. {* *}
  21. {* This File contains only Direct3DX 8.x Definitions. *}
  22. {* If you want to use D3DX7 version of D3DX use translation by Arne Schäpers *}
  23. {* *}
  24. {******************************************************************************)
  25. { }
  26. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  27. { }
  28. { The contents of this file are used with permission, subject to the Mozilla }
  29. { Public License Version 1.1 (the "License"); you may not use this file except }
  30. { in compliance with the License. You may obtain a copy of the License at }
  31. { http://www.mozilla.org/MPL/MPL-1.1.html }
  32. { }
  33. { Software distributed under the License is distributed on an "AS IS" basis, }
  34. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  35. { the specific language governing rights and limitations under the License. }
  36. { }
  37. { Alternatively, the contents of this file may be used under the terms of the }
  38. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  39. { provisions of the LGPL License are applicable instead of those above. }
  40. { If you wish to allow use of your version of this file only under the terms }
  41. { of the LGPL License and not to allow others to use your version of this file }
  42. { under the MPL, indicate your decision by deleting the provisions above and }
  43. { replace them with the notice and other provisions required by the LGPL }
  44. { License. If you do not delete the provisions above, a recipient may use }
  45. { your version of this file under either the MPL or the LGPL License. }
  46. { }
  47. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  48. { }
  49. {******************************************************************************}
  50. // Original source contained in "D3DX8.par"
  51. {$I DirectX.inc}
  52. unit D3DX8;
  53. interface
  54. // Remove "dot" below to link with debug version of D3DX8
  55. // (only in JEDI or TMT pascal version)
  56. {.$DEFINE DEBUG}
  57. // Remove "dot" below to link with DirectXGraphics and Direct3D
  58. {.$DEFINE DXG_COMPAT}
  59. (*$HPPEMIT '#include "d3dx8.h"' *)
  60. (*$HPPEMIT '#include "dxfile.h"' *)
  61. // Do not emit <DXFile.hpp> to C++Builder
  62. (*$NOINCLUDE DXFile *)
  63. (*$HPPEMIT 'namespace D3dx8' *)
  64. (*$HPPEMIT '{' *)
  65. uses
  66. Windows,
  67. ActiveX,
  68. SysUtils,
  69. {$I UseD3D8.inc},
  70. DXFile;
  71. const
  72. //////////// DLL export definitions ///////////////////////////////////////
  73. d3dx8dll ={$IFDEF DEBUG} 'd3dx8d.dll'{$ELSE} 'D3DX81ab.dll'{$ENDIF};
  74. ///////////////////////////////////////////////////////////////////////////
  75. //
  76. // Copyright (C) Microsoft Corporation. All Rights Reserved.
  77. //
  78. // File: d3dx8.h
  79. // Content: D3DX utility library
  80. //
  81. ///////////////////////////////////////////////////////////////////////////
  82. const
  83. // #define D3DX_DEFAULT ULONG_MAX
  84. D3DX_DEFAULT = $FFFFFFFF;
  85. {$EXTERNALSYM D3DX_DEFAULT}
  86. var
  87. // #define D3DX_DEFAULT_FLOAT FLT_MAX
  88. // Forced to define as 'var' cos pascal compiler treats all consts as Double
  89. D3DX_DEFAULT_FLOAT: Single = 3.402823466e+38; // max single value
  90. {$EXTERNALSYM D3DX_DEFAULT_FLOAT}
  91. //////////////////////////////////////////////////////////////////////////////
  92. //
  93. // Copyright (C) Microsoft Corporation. All Rights Reserved.
  94. //
  95. // File: d3dx8math.h
  96. // Content: D3DX math types and functions
  97. //
  98. //////////////////////////////////////////////////////////////////////////////
  99. //===========================================================================
  100. //
  101. // General purpose utilities
  102. //
  103. //===========================================================================
  104. const
  105. D3DX_PI: Single = 3.141592654;
  106. {$EXTERNALSYM D3DX_PI}
  107. D3DX_1BYPI: Single = 0.318309886;
  108. {$EXTERNALSYM D3DX_1BYPI}
  109. //#define D3DXToRadian( degree ) ((degree) * (D3DX_PI / 180.0f))
  110. function D3DXToRadian(Degree: Single): Single;
  111. {$EXTERNALSYM D3DXToRadian}
  112. //#define D3DXToDegree( radian ) ((radian) * (180.0f / D3DX_PI))
  113. function D3DXToDegree(Radian: Single): Single;
  114. {$EXTERNALSYM D3DXToDegree}
  115. //===========================================================================
  116. //
  117. // Vectors
  118. //
  119. //===========================================================================
  120. //--------------------------
  121. // 2D Vector
  122. //--------------------------
  123. type
  124. {$HPPEMIT 'typedef D3DXVECTOR2 TD3DXVector2;'}
  125. {$HPPEMIT 'typedef D3DXVECTOR2 *PD3DXVector2;'}
  126. PD3DXVector2 = ^TD3DXVector2;
  127. {$NODEFINE PD3DXVector2}
  128. TD3DXVector2 = packed record
  129. x, y: Single;
  130. end;
  131. {$NODEFINE TD3DXVector2}
  132. // Some pascal equalents of C++ class functions & operators
  133. const D3DXVector2Zero: TD3DXVector2 = (x:0; y:0); // (0,0)
  134. function D3DXVector2(_x, _y: Single): TD3DXVector2;
  135. function D3DXVector2Equal(const v1, v2: TD3DXVector2): Boolean;
  136. //--------------------------
  137. // 3D Vector
  138. //--------------------------
  139. type
  140. {$HPPEMIT 'typedef D3DXVECTOR3 TD3DXVector3;'}
  141. {$HPPEMIT 'typedef D3DXVECTOR3 *PD3DXVector3;'}
  142. PD3DXVector3 = ^TD3DXVector3;
  143. {$NODEFINE PD3DXVector3}
  144. TD3DXVector3 = TD3DVector;
  145. {$NODEFINE TD3DXVector3}
  146. // Some pascal equalents of C++ class functions & operators
  147. const D3DXVector3Zero: TD3DXVector3 = (x:0; y:0; z:0); // (0,0,0)
  148. function D3DXVector3(_x, _y, _z: Single): TD3DXVector3;
  149. function D3DXVector3Equal(const v1, v2: TD3DXVector3): Boolean;
  150. //--------------------------
  151. // 4D Vector
  152. //--------------------------
  153. type
  154. {$HPPEMIT 'typedef D3DXVECTOR4 TD3DXVector4;'}
  155. {$HPPEMIT 'typedef D3DXVECTOR4 *PD3DXVector4;'}
  156. PD3DXVector4 = ^TD3DXVector4;
  157. {$NODEFINE PD3DXVector4}
  158. TD3DXVector4 = packed record
  159. x, y, z, w: Single;
  160. end;
  161. {$NODEFINE TD3DXVector4}
  162. // Some pascal equalents of C++ class functions & operators
  163. const D3DXVector4Zero: TD3DXVector4 = (x:0; y:0; z:0; w:0); // (0,0,0,0)
  164. function D3DXVector4(_x, _y, _z, _w: Single): TD3DXVector4;
  165. function D3DXVector4Equal(const v1, v2: TD3DXVector4): Boolean;
  166. //===========================================================================
  167. //
  168. // Matrices
  169. //
  170. //===========================================================================
  171. type
  172. {$HPPEMIT 'typedef D3DXMATRIX TD3DXMatrix;'}
  173. {$HPPEMIT 'typedef D3DXMATRIX *PD3DXMatrix;'}
  174. PD3DXMatrix = ^TD3DXMatrix;
  175. {$NODEFINE PD3DXMatrix}
  176. TD3DXMatrix = TD3DMatrix;
  177. {$NODEFINE TD3DXMatrix}
  178. // Some pascal equalents of C++ class functions & operators
  179. function D3DXMatrix(
  180. _m00, _m01, _m02, _m03,
  181. _m10, _m11, _m12, _m13,
  182. _m20, _m21, _m22, _m23,
  183. _m30, _m31, _m32, _m33: Single): TD3DXMatrix;
  184. function D3DXMatrixAdd(out mOut: TD3DXMatrix; const m1, m2: TD3DXMatrix): PD3DXMatrix;
  185. function D3DXMatrixSubtract(out mOut: TD3DXMatrix; const m1, m2: TD3DXMatrix): PD3DXMatrix;
  186. function D3DXMatrixMul(out mOut: TD3DXMatrix; const m: TD3DXMatrix; MulBy: Single): PD3DXMatrix;
  187. function D3DXMatrixEqual(const m1, m2: TD3DXMatrix): Boolean;
  188. //===========================================================================
  189. //
  190. // Aligned Matrices
  191. //
  192. // This class helps keep matrices 16-byte aligned as preferred by P4 cpus.
  193. // It aligns matrices on the stack and on the heap or in global scope.
  194. // It does this using __declspec(align(16)) which works on VC7 and on VC 6
  195. // with the processor pack. Unfortunately there is no way to detect the
  196. // latter so this is turned on only on VC7. On other compilers this is the
  197. // the same as D3DXMATRIX.
  198. // Using this class on a compiler that does not actually do the alignment
  199. // can be dangerous since it will not expose bugs that ignore alignment.
  200. // E.g if an object of this class in inside a struct or class, and some code
  201. // memcopys data in it assuming tight packing. This could break on a compiler
  202. // that eventually start aligning the matrix.
  203. //
  204. //===========================================================================
  205. // Translator comments: None of current pascal compilers can even align data
  206. // inside records to 16 byte boundary, so we just leave aligned matrix
  207. // declaration equal to standart matrix
  208. type
  209. PD3DXMatrixA16 = ^TD3DXMatrixA16;
  210. TD3DXMatrixA16 = TD3DXMatrix;
  211. //===========================================================================
  212. //
  213. // Quaternions
  214. //
  215. //===========================================================================
  216. type
  217. PD3DXQuaternion = ^TD3DXQuaternion;
  218. TD3DXQuaternion = packed record
  219. x, y, z, w: Single;
  220. end;
  221. {$NODEFINE TD3DXQuaternion}
  222. {$HPPEMIT 'typedef D3DXQUATERNION TD3DXQuaternion;'}
  223. // Some pascal equalents of C++ class functions & operators
  224. function D3DXQuaternion(_x, _y, _z, _w: Single): TD3DXQuaternion;
  225. function D3DXQuaternionAdd(const q1, q2: TD3DXQuaternion): TD3DXQuaternion;
  226. function D3DXQuaternionSubtract(const q1, q2: TD3DXQuaternion): TD3DXQuaternion;
  227. function D3DXQuaternionEqual(const q1, q2: TD3DXQuaternion): Boolean;
  228. function D3DXQuaternionScale(out qOut: TD3DXQuaternion; const q: TD3DXQuaternion;
  229. s: Single): PD3DXQuaternion;
  230. //===========================================================================
  231. //
  232. // Planes
  233. //
  234. //===========================================================================
  235. type
  236. PD3DXPlane = ^TD3DXPlane;
  237. TD3DXPlane = packed record
  238. a, b, c, d: Single;
  239. end;
  240. {$NODEFINE TD3DXPlane}
  241. {$HPPEMIT 'typedef D3DXPLANE TD3DXPlane;'}
  242. // Some pascal equalents of C++ class functions & operators
  243. const D3DXPlaneZero: TD3DXPlane = (a:0; b:0; c:0; d:0); // (0,0,0,0)
  244. function D3DXPlane(_a, _b, _c, _d: Single): TD3DXPlane;
  245. function D3DXPlaneEqual(const p1, p2: TD3DXPlane): Boolean;
  246. //===========================================================================
  247. //
  248. // Colors
  249. //
  250. //===========================================================================
  251. type
  252. {$HPPEMIT 'typedef D3DXCOLOR TD3DXColor;'}
  253. {$HPPEMIT 'typedef D3DXCOLOR *PD3DXColor;'}
  254. PD3DXColor = PD3DColorValue;
  255. {$NODEFINE PD3DXColor}
  256. TD3DXColor = TD3DColorValue;
  257. {$NODEFINE TD3DXColor}
  258. function D3DXColor(_r, _g, _b, _a: Single): TD3DXColor;
  259. function D3DXColorToDWord(c: TD3DXColor): DWord;
  260. function D3DXColorFromDWord(c: DWord): TD3DXColor;
  261. function D3DXColorEqual(const c1, c2: TD3DXColor): Boolean;
  262. //===========================================================================
  263. //
  264. // D3DX math functions:
  265. //
  266. // NOTE:
  267. // * All these functions can take the same object as in and out parameters.
  268. //
  269. // * Out parameters are typically also returned as return values, so that
  270. // the output of one function may be used as a parameter to another.
  271. //
  272. //===========================================================================
  273. //--------------------------
  274. // 2D Vector
  275. //--------------------------
  276. // inline
  277. function D3DXVec2Length(const v: TD3DXVector2): Single;
  278. {$EXTERNALSYM D3DXVec2Length}
  279. function D3DXVec2LengthSq(const v: TD3DXVector2): Single;
  280. {$EXTERNALSYM D3DXVec2LengthSq}
  281. function D3DXVec2Dot(const v1, v2: TD3DXVector2): Single;
  282. {$EXTERNALSYM D3DXVec2Dot}
  283. // Z component of ((x1,y1,0) cross (x2,y2,0))
  284. function D3DXVec2CCW(const v1, v2: TD3DXVector2): Single;
  285. {$EXTERNALSYM D3DXVec2CCW}
  286. function D3DXVec2Add(const v1, v2: TD3DXVector2): TD3DXVector2;
  287. {$EXTERNALSYM D3DXVec2Add}
  288. function D3DXVec2Subtract(const v1, v2: TD3DXVector2): TD3DXVector2;
  289. {$EXTERNALSYM D3DXVec2Subtract}
  290. // Minimize each component. x = min(x1, x2), y = min(y1, y2)
  291. function D3DXVec2Minimize(out vOut: TD3DXVector2; const v1, v2: TD3DXVector2): PD3DXVector2;
  292. {$EXTERNALSYM D3DXVec2Minimize}
  293. // Maximize each component. x = max(x1, x2), y = max(y1, y2)
  294. function D3DXVec2Maximize(out vOut: TD3DXVector2; const v1, v2: TD3DXVector2): PD3DXVector2;
  295. {$EXTERNALSYM D3DXVec2Maximize}
  296. function D3DXVec2Scale(out vOut: TD3DXVector2; const v: TD3DXVector2; s: Single): PD3DXVector2;
  297. {$EXTERNALSYM D3DXVec2Scale}
  298. // Linear interpolation. V1 + s(V2-V1)
  299. function D3DXVec2Lerp(out vOut: TD3DXVector2; const v1, v2: TD3DXVector2; s: Single): PD3DXVector2;
  300. {$EXTERNALSYM D3DXVec2Lerp}
  301. // non-inline
  302. function D3DXVec2Normalize(out vOut: TD3DXVector2; const v: TD3DXVector2): PD3DXVector2; stdcall; external d3dx8dll;
  303. {$EXTERNALSYM D3DXVec2Normalize}
  304. // Hermite interpolation between position V1, tangent T1 (when s == 0)
  305. // and position V2, tangent T2 (when s == 1).
  306. function D3DXVec2Hermite(out vOut: TD3DXVector2;
  307. const v1, t1, v2, t2: TD3DXVector2; s: Single): PD3DXVector2; stdcall; external d3dx8dll;
  308. {$EXTERNALSYM D3DXVec2Hermite}
  309. // CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1)
  310. function D3DXVec2CatmullRom(out vOut: TD3DXVector2;
  311. const v0, v1, v2: TD3DXVector2; s: Single): PD3DXVector2; stdcall; external d3dx8dll;
  312. {$EXTERNALSYM D3DXVec2CatmullRom}
  313. // Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1)
  314. function D3DXVec2BaryCentric(out vOut: TD3DXVector2;
  315. const v1, v2, v3: TD3DXVector2; f, g: Single): PD3DXVector2; stdcall; external d3dx8dll;
  316. {$EXTERNALSYM D3DXVec2BaryCentric}
  317. // Transform (x, y, 0, 1) by matrix.
  318. function D3DXVec2Transform(out vOut: TD3DXVector4;
  319. const v: TD3DXVector2; const m: TD3DXMatrix): PD3DXVector4; stdcall; external d3dx8dll;
  320. {$EXTERNALSYM D3DXVec2Transform}
  321. // Transform (x, y, 0, 1) by matrix, project result back into w=1.
  322. function D3DXVec2TransformCoord(out vOut: TD3DXVector2;
  323. const v: TD3DXVector2; const m: TD3DXMatrix): PD3DXVector2; stdcall; external d3dx8dll;
  324. {$EXTERNALSYM D3DXVec2TransformCoord}
  325. // Transform (x, y, 0, 0) by matrix.
  326. function D3DXVec2TransformNormal(out vOut: TD3DXVector2;
  327. const v: TD3DXVector2; const m: TD3DXMatrix): PD3DXVector2; stdcall; external d3dx8dll;
  328. {$EXTERNALSYM D3DXVec2TransformNormal}
  329. //--------------------------
  330. // 3D Vector
  331. //--------------------------
  332. // inline
  333. function D3DXVec3Length(const v: TD3DXVector3): Single;
  334. {$EXTERNALSYM D3DXVec3Length}
  335. function D3DXVec3LengthSq(const v: TD3DXVector3): Single;
  336. {$EXTERNALSYM D3DXVec3LengthSq}
  337. function D3DXVec3Dot(const v1, v2: TD3DXVector3): Single;
  338. {$EXTERNALSYM D3DXVec3Dot}
  339. function D3DXVec3Cross(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  340. {$EXTERNALSYM D3DXVec3Cross}
  341. function D3DXVec3Add(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  342. {$EXTERNALSYM D3DXVec3Add}
  343. function D3DXVec3Subtract(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  344. {$EXTERNALSYM D3DXVec3Subtract}
  345. // Minimize each component. x = min(x1, x2), y = min(y1, y2), ...
  346. function D3DXVec3Minimize(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  347. {$EXTERNALSYM D3DXVec3Minimize}
  348. // Maximize each component. x = max(x1, x2), y = max(y1, y2), ...
  349. function D3DXVec3Maximize(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  350. {$EXTERNALSYM D3DXVec3Maximize}
  351. function D3DXVec3Scale(out vOut: TD3DXVector3; const v: TD3DXVector3; s: Single): PD3DXVector3;
  352. {$EXTERNALSYM D3DXVec3Scale}
  353. // Linear interpolation. V1 + s(V2-V1)
  354. function D3DXVec3Lerp(out vOut: TD3DXVector3;
  355. const v1, v2: TD3DXVector3; s: Single): PD3DXVector3;
  356. {$EXTERNALSYM D3DXVec3Lerp}
  357. // non-inline
  358. function D3DXVec3Normalize(out vOut: TD3DXVector3;
  359. const v: TD3DXVector3): PD3DXVector3; stdcall; external d3dx8dll;
  360. {$EXTERNALSYM D3DXVec3Normalize}
  361. // Hermite interpolation between position V1, tangent T1 (when s == 0)
  362. // and position V2, tangent T2 (when s == 1).
  363. function D3DXVec3Hermite(out vOut: TD3DXVector3;
  364. const v1, t1, v2, t2: TD3DXVector3; s: Single): PD3DXVector3; stdcall; external d3dx8dll;
  365. {$EXTERNALSYM D3DXVec3Hermite}
  366. // CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1)
  367. function D3DXVec3CatmullRom(out vOut: TD3DXVector3;
  368. const v1, v2, v3: TD3DXVector3; s: Single): PD3DXVector3; stdcall; external d3dx8dll;
  369. {$EXTERNALSYM D3DXVec3CatmullRom}
  370. // Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1)
  371. function D3DXVec3BaryCentric(out vOut: TD3DXVector3;
  372. const v1, v2, v3: TD3DXVector3; f, g: Single): PD3DXVector3; stdcall; external d3dx8dll;
  373. {$EXTERNALSYM D3DXVec3BaryCentric}
  374. // Transform (x, y, z, 1) by matrix.
  375. function D3DXVec3Transform(out vOut: TD3DXVector4;
  376. const v: TD3DXVector3; const m: TD3DXMatrix): PD3DXVector4; stdcall; external d3dx8dll;
  377. {$EXTERNALSYM D3DXVec3Transform}
  378. // Transform (x, y, z, 1) by matrix, project result back into w=1.
  379. function D3DXVec3TransformCoord(out vOut: TD3DXVector3;
  380. const v: TD3DXVector3; const m: TD3DXMatrix): PD3DXVector3; stdcall; external d3dx8dll;
  381. {$EXTERNALSYM D3DXVec3TransformCoord}
  382. // Transform (x, y, z, 0) by matrix. If you transforming a normal by a
  383. // non-affine matrix, the matrix you pass to this function should be the
  384. // transpose of the inverse of the matrix you would use to transform a coord.
  385. function D3DXVec3TransformNormal(out vOut: TD3DXVector3;
  386. const v: TD3DXVector3; const m: TD3DXMatrix): PD3DXVector3; stdcall; external d3dx8dll;
  387. {$EXTERNALSYM D3DXVec3TransformNormal}
  388. // Project vector from object space into screen space
  389. function D3DXVec3Project(out vOut: TD3DXVector3;
  390. const v: TD3DXVector3; const pViewport: TD3DViewport8;
  391. const pProjection, pView, pWorld: TD3DXMatrix): PD3DXVector3; stdcall; external d3dx8dll;
  392. {$EXTERNALSYM D3DXVec3Project}
  393. // Project vector from screen space into object space
  394. function D3DXVec3Unproject(out vOut: TD3DXVector3;
  395. const v: TD3DXVector3; const pViewport: TD3DViewport8;
  396. const pProjection, pView, pWorld: TD3DXMatrix): PD3DXVector3; stdcall; external d3dx8dll;
  397. {$EXTERNALSYM D3DXVec3Unproject}
  398. //--------------------------
  399. // 4D Vector
  400. //--------------------------
  401. // inline
  402. function D3DXVec4Length(const v: TD3DXVector4): Single;
  403. {$EXTERNALSYM D3DXVec4Length}
  404. function D3DXVec4LengthSq(const v: TD3DXVector4): Single;
  405. {$EXTERNALSYM D3DXVec4LengthSq}
  406. function D3DXVec4Dot(const v1, v2: TD3DXVector4): Single;
  407. {$EXTERNALSYM D3DXVec4Dot}
  408. function D3DXVec4Add(out vOut: TD3DXVector4; const v1, v2: TD3DXVector4): PD3DXVector4;
  409. {$EXTERNALSYM D3DXVec4Add}
  410. function D3DXVec4Subtract(out vOut: TD3DXVector4; const v1, v2: TD3DXVector4): PD3DXVector4;
  411. {$EXTERNALSYM D3DXVec4Subtract}
  412. // Minimize each component. x = min(x1, x2), y = min(y1, y2), ...
  413. function D3DXVec4Minimize(out vOut: TD3DXVector4; const v1, v2: TD3DXVector4): PD3DXVector4;
  414. {$EXTERNALSYM D3DXVec4Minimize}
  415. // Maximize each component. x = max(x1, x2), y = max(y1, y2), ...
  416. function D3DXVec4Maximize(out vOut: TD3DXVector4; const v1, v2: TD3DXVector4): PD3DXVector4;
  417. {$EXTERNALSYM D3DXVec4Maximize}
  418. function D3DXVec4Scale(out vOut: TD3DXVector4; const v: TD3DXVector4; s: Single): PD3DXVector4;
  419. {$EXTERNALSYM D3DXVec4Scale}
  420. // Linear interpolation. V1 + s(V2-V1)
  421. function D3DXVec4Lerp(out vOut: TD3DXVector4;
  422. const v1, v2: TD3DXVector4; s: Single): PD3DXVector4;
  423. {$EXTERNALSYM D3DXVec4Lerp}
  424. // non-inline
  425. // Cross-product in 4 dimensions.
  426. function D3DXVec4Cross(out vOut: TD3DXVector4;
  427. const v1, v2, v3: TD3DXVector4): PD3DXVector4; stdcall; external d3dx8dll;
  428. {$EXTERNALSYM D3DXVec4Cross}
  429. function D3DXVec4Normalize(out vOut: TD3DXVector4;
  430. const v: TD3DXVector4): PD3DXVector4; stdcall; external d3dx8dll;
  431. {$EXTERNALSYM D3DXVec4Normalize}
  432. // Hermite interpolation between position V1, tangent T1 (when s == 0)
  433. // and position V2, tangent T2 (when s == 1).
  434. function D3DXVec4Hermite(out vOut: TD3DXVector4;
  435. const v1, t1, v2, t2: TD3DXVector4; s: Single): PD3DXVector4; stdcall; external d3dx8dll;
  436. {$EXTERNALSYM D3DXVec4Hermite}
  437. // CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1)
  438. function D3DXVec4CatmullRom(out vOut: TD3DXVector4;
  439. const v0, v1, v2, v3: TD3DXVector4; s: Single): PD3DXVector4; stdcall; external d3dx8dll;
  440. {$EXTERNALSYM D3DXVec4CatmullRom}
  441. // Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1)
  442. function D3DXVec4BaryCentric(out vOut: TD3DXVector4;
  443. const v1, v2, v3: TD3DXVector4; f, g: Single): PD3DXVector4; stdcall; external d3dx8dll;
  444. {$EXTERNALSYM D3DXVec4BaryCentric}
  445. // Transform vector by matrix.
  446. function D3DXVec4Transform(out vOut: TD3DXVector4;
  447. const v: TD3DXVector4; const m: TD3DXMatrix): PD3DXVector4; stdcall; external d3dx8dll;
  448. {$EXTERNALSYM D3DXVec4Transform}
  449. //--------------------------
  450. // 4D Matrix
  451. //--------------------------
  452. // inline
  453. function D3DXMatrixIdentity(out mOut: TD3DXMatrix): PD3DXMatrix;
  454. {$EXTERNALSYM D3DXMatrixIdentity}
  455. function D3DXMatrixIsIdentity(const m: TD3DXMatrix): BOOL;
  456. {$EXTERNALSYM D3DXMatrixIsIdentity}
  457. // non-inline
  458. function D3DXMatrixfDeterminant(const m: TD3DXMatrix): Single; stdcall; external d3dx8dll;
  459. {$EXTERNALSYM D3DXMatrixfDeterminant}
  460. function D3DXMatrixTranspose(out pOut: TD3DXMatrix; const pM: TD3DXMatrix): PD3DXMatrix; stdcall; external d3dx8dll;
  461. {$EXTERNALSYM D3DXMatrixTranspose}
  462. // Matrix multiplication. The result represents the transformation M2
  463. // followed by the transformation M1. (Out = M1 * M2)
  464. function D3DXMatrixMultiply(out mOut: TD3DXMatrix; const m1, m2: TD3DXMatrix): PD3DXMatrix; stdcall; external d3dx8dll;
  465. {$EXTERNALSYM D3DXMatrixMultiply}
  466. // Matrix multiplication, followed by a transpose. (Out = T(M1 * M2))
  467. function D3DXMatrixMultiplyTranspose(out pOut: TD3DXMatrix; const pM1, pM2: TD3DXMatrix): PD3DXMatrix; stdcall; external d3dx8dll;
  468. {$EXTERNALSYM D3DXMatrixMultiplyTranspose}
  469. // Calculate inverse of matrix. Inversion my fail, in which case NULL will
  470. // be returned. The determinant of pM is also returned it pfDeterminant
  471. // is non-NULL.
  472. function D3DXMatrixInverse(out mOut: TD3DXMatrix; pfDeterminant: PSingle;
  473. const m: TD3DXMatrix): PD3DXMatrix; stdcall; external d3dx8dll;
  474. {$EXTERNALSYM D3DXMatrixInverse}
  475. // Build a matrix which scales by (sx, sy, sz)
  476. function D3DXMatrixScaling(out mOut: TD3DXMatrix; sx, sy, sz: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  477. {$EXTERNALSYM D3DXMatrixScaling}
  478. // Build a matrix which translates by (x, y, z)
  479. function D3DXMatrixTranslation(out mOut: TD3DXMatrix; x, y, z: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  480. {$EXTERNALSYM D3DXMatrixTranslation}
  481. // Build a matrix which rotates around the X axis
  482. function D3DXMatrixRotationX(out mOut: TD3DXMatrix; angle: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  483. {$EXTERNALSYM D3DXMatrixRotationX}
  484. // Build a matrix which rotates around the Y axis
  485. function D3DXMatrixRotationY(out mOut: TD3DXMatrix; angle: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  486. {$EXTERNALSYM D3DXMatrixRotationY}
  487. // Build a matrix which rotates around the Z axis
  488. function D3DXMatrixRotationZ(out mOut: TD3DXMatrix; angle: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  489. {$EXTERNALSYM D3DXMatrixRotationZ}
  490. // Build a matrix which rotates around an arbitrary axis
  491. function D3DXMatrixRotationAxis(out mOut: TD3DXMatrix; const v: TD3DXVector3;
  492. angle: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  493. {$EXTERNALSYM D3DXMatrixRotationAxis}
  494. // Build a matrix from a quaternion
  495. function D3DXMatrixRotationQuaternion(out mOut: TD3DXMatrix; const Q: TD3DXQuaternion): PD3DXMatrix; stdcall; external d3dx8dll;
  496. {$EXTERNALSYM D3DXMatrixRotationQuaternion}
  497. // Yaw around the Y axis, a pitch around the X axis,
  498. // and a roll around the Z axis.
  499. function D3DXMatrixRotationYawPitchRoll(out mOut: TD3DXMatrix; yaw, pitch, roll: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  500. {$EXTERNALSYM D3DXMatrixRotationYawPitchRoll}
  501. // Build transformation matrix. NULL arguments are treated as identity.
  502. // Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt
  503. function D3DXMatrixTransformation(out mOut: TD3DXMatrix;
  504. pScalingCenter: PD3DXVector3;
  505. pScalingRotation: PD3DXQuaternion; pScaling, pRotationCenter: PD3DXVector3;
  506. pRotation: PD3DXQuaternion; pTranslation: PD3DXVector3): PD3DXMatrix; stdcall; external d3dx8dll;
  507. {$EXTERNALSYM D3DXMatrixTransformation}
  508. // Build affine transformation matrix. NULL arguments are treated as identity.
  509. // Mout = Ms * Mrc-1 * Mr * Mrc * Mt
  510. function D3DXMatrixAffineTransformation(out mOut: TD3DXMatrix;
  511. Scaling: Single; pRotationCenter: PD3DXVector3;
  512. pRotation: PD3DXQuaternion; pTranslation: PD3DXVector3): PD3DXMatrix; stdcall; external d3dx8dll;
  513. {$EXTERNALSYM D3DXMatrixAffineTransformation}
  514. // Build a lookat matrix. (right-handed)
  515. function D3DXMatrixLookAtRH(out mOut: TD3DXMatrix; const Eye, At, Up: TD3DXVector3): PD3DXMatrix; stdcall; external d3dx8dll;
  516. {$EXTERNALSYM D3DXMatrixLookAtRH}
  517. // Build a lookat matrix. (left-handed)
  518. function D3DXMatrixLookAtLH(out mOut: TD3DXMatrix; const Eye, At, Up: TD3DXVector3): PD3DXMatrix; stdcall; external d3dx8dll;
  519. {$EXTERNALSYM D3DXMatrixLookAtLH}
  520. // Build a perspective projection matrix. (right-handed)
  521. function D3DXMatrixPerspectiveRH(out mOut: TD3DXMatrix; w, h, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  522. {$EXTERNALSYM D3DXMatrixPerspectiveRH}
  523. // Build a perspective projection matrix. (left-handed)
  524. function D3DXMatrixPerspectiveLH(out mOut: TD3DXMatrix; w, h, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  525. {$EXTERNALSYM D3DXMatrixPerspectiveLH}
  526. // Build a perspective projection matrix. (right-handed)
  527. function D3DXMatrixPerspectiveFovRH(out mOut: TD3DXMatrix; flovy, aspect, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  528. {$EXTERNALSYM D3DXMatrixPerspectiveFovRH}
  529. // Build a perspective projection matrix. (left-handed)
  530. function D3DXMatrixPerspectiveFovLH(out mOut: TD3DXMatrix; flovy, aspect, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  531. {$EXTERNALSYM D3DXMatrixPerspectiveFovLH}
  532. // Build a perspective projection matrix. (right-handed)
  533. function D3DXMatrixPerspectiveOffCenterRH(out mOut: TD3DXMatrix;
  534. l, r, b, t, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  535. {$EXTERNALSYM D3DXMatrixPerspectiveOffCenterRH}
  536. // Build a perspective projection matrix. (left-handed)
  537. function D3DXMatrixPerspectiveOffCenterLH(out mOut: TD3DXMatrix;
  538. l, r, b, t, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  539. {$EXTERNALSYM D3DXMatrixPerspectiveOffCenterLH}
  540. // Build an ortho projection matrix. (right-handed)
  541. function D3DXMatrixOrthoRH(out mOut: TD3DXMatrix; w, h, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  542. {$EXTERNALSYM D3DXMatrixOrthoRH}
  543. // Build an ortho projection matrix. (left-handed)
  544. function D3DXMatrixOrthoLH(out mOut: TD3DXMatrix; w, h, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  545. {$EXTERNALSYM D3DXMatrixOrthoLH}
  546. // Build an ortho projection matrix. (right-handed)
  547. function D3DXMatrixOrthoOffCenterRH(out mOut: TD3DXMatrix;
  548. l, r, b, t, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  549. {$EXTERNALSYM D3DXMatrixOrthoOffCenterRH}
  550. // Build an ortho projection matrix. (left-handed)
  551. function D3DXMatrixOrthoOffCenterLH(out mOut: TD3DXMatrix;
  552. l, r, b, t, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  553. {$EXTERNALSYM D3DXMatrixOrthoOffCenterLH}
  554. // Build a matrix which flattens geometry into a plane, as if casting
  555. // a shadow from a light.
  556. function D3DXMatrixShadow(out mOut: TD3DXMatrix;
  557. const Light: TD3DXVector4; const Plane: TD3DXPlane): PD3DXMatrix; stdcall; external d3dx8dll;
  558. {$EXTERNALSYM D3DXMatrixShadow}
  559. // Build a matrix which reflects the coordinate system about a plane
  560. function D3DXMatrixReflect(out mOut: TD3DXMatrix;
  561. const Plane: TD3DXPlane): PD3DXMatrix; stdcall; external d3dx8dll;
  562. {$EXTERNALSYM D3DXMatrixReflect}
  563. //--------------------------
  564. // Quaternion
  565. //--------------------------
  566. // inline
  567. function D3DXQuaternionLength(const q: TD3DXQuaternion): Single;
  568. {$EXTERNALSYM D3DXQuaternionLength}
  569. // Length squared, or "norm"
  570. function D3DXQuaternionLengthSq(const q: TD3DXQuaternion): Single;
  571. {$EXTERNALSYM D3DXQuaternionLengthSq}
  572. function D3DXQuaternionDot(const q1, q2: TD3DXQuaternion): Single;
  573. {$EXTERNALSYM D3DXQuaternionDot}
  574. // (0, 0, 0, 1)
  575. function D3DXQuaternionIdentity(out qOut: TD3DXQuaternion): PD3DXQuaternion;
  576. {$EXTERNALSYM D3DXQuaternionIdentity}
  577. function D3DXQuaternionIsIdentity (const q: TD3DXQuaternion): BOOL;
  578. {$EXTERNALSYM D3DXQuaternionIsIdentity}
  579. // (-x, -y, -z, w)
  580. function D3DXQuaternionConjugate(out qOut: TD3DXQuaternion;
  581. const q: TD3DXQuaternion): PD3DXQuaternion;
  582. {$EXTERNALSYM D3DXQuaternionConjugate}
  583. // non-inline
  584. // Compute a quaternin's axis and angle of rotation. Expects unit quaternions.
  585. procedure D3DXQuaternionToAxisAngle(const q: TD3DXQuaternion;
  586. out Axis: TD3DXVector3; out Angle: Single); stdcall; external d3dx8dll;
  587. {$EXTERNALSYM D3DXQuaternionToAxisAngle}
  588. // Build a quaternion from a rotation matrix.
  589. function D3DXQuaternionRotationMatrix(out qOut: TD3DXQuaternion;
  590. const m: TD3DXMatrix): PD3DXQuaternion; stdcall; external d3dx8dll;
  591. {$EXTERNALSYM D3DXQuaternionRotationMatrix}
  592. // Rotation about arbitrary axis.
  593. function D3DXQuaternionRotationAxis(out qOut: TD3DXQuaternion;
  594. const v: TD3DXVector3; Angle: Single): PD3DXQuaternion; stdcall; external d3dx8dll;
  595. {$EXTERNALSYM D3DXQuaternionRotationAxis}
  596. // Yaw around the Y axis, a pitch around the X axis,
  597. // and a roll around the Z axis.
  598. function D3DXQuaternionRotationYawPitchRoll(out qOut: TD3DXQuaternion;
  599. yaw, pitch, roll: Single): PD3DXQuaternion; stdcall; external d3dx8dll;
  600. {$EXTERNALSYM D3DXQuaternionRotationYawPitchRoll}
  601. // Quaternion multiplication. The result represents the rotation Q2
  602. // followed by the rotation Q1. (Out = Q2 * Q1)
  603. function D3DXQuaternionMultiply(out qOut: TD3DXQuaternion;
  604. const q1, q2: TD3DXQuaternion): PD3DXQuaternion; stdcall; external d3dx8dll;
  605. {$EXTERNALSYM D3DXQuaternionMultiply}
  606. function D3DXQuaternionNormalize(out qOut: TD3DXQuaternion;
  607. const q: TD3DXQuaternion): PD3DXQuaternion; stdcall; external d3dx8dll;
  608. {$EXTERNALSYM D3DXQuaternionNormalize}
  609. // Conjugate and re-norm
  610. function D3DXQuaternionInverse(out qOut: TD3DXQuaternion;
  611. const q: TD3DXQuaternion): PD3DXQuaternion; stdcall; external d3dx8dll;
  612. {$EXTERNALSYM D3DXQuaternionInverse}
  613. // Expects unit quaternions.
  614. // if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v)
  615. function D3DXQuaternionLn(out qOut: TD3DXQuaternion;
  616. const q: TD3DXQuaternion): PD3DXQuaternion; stdcall; external d3dx8dll;
  617. {$EXTERNALSYM D3DXQuaternionLn}
  618. // Expects pure quaternions. (w == 0) w is ignored in calculation.
  619. // if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v)
  620. function D3DXQuaternionExp(out qOut: TD3DXQuaternion;
  621. const q: TD3DXQuaternion): PD3DXQuaternion; stdcall; external d3dx8dll;
  622. {$EXTERNALSYM D3DXQuaternionExp}
  623. // Spherical linear interpolation between Q1 (s == 0) and Q2 (s == 1).
  624. // Expects unit quaternions.
  625. function D3DXQuaternionSlerp(out qOut: TD3DXQuaternion;
  626. const q1, q2: TD3DXQuaternion; t: Single): PD3DXQuaternion; stdcall; external d3dx8dll;
  627. {$EXTERNALSYM D3DXQuaternionSlerp}
  628. // Spherical quadrangle interpolation.
  629. // Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t))
  630. function D3DXQuaternionSquad(out qOut: TD3DXQuaternion;
  631. const pQ1, pA, pB, pC: TD3DXQuaternion; t: Single): PD3DXQuaternion; stdcall; external d3dx8dll;
  632. {$EXTERNALSYM D3DXQuaternionSquad}
  633. // Setup control points for spherical quadrangle interpolation
  634. // from Q1 to Q2. The control points are chosen in such a way
  635. // to ensure the continuity of tangents with adjacent segments.
  636. procedure D3DXQuaternionSquadSetup(out pAOut, pBOut, pCOut: TD3DXQuaternion;
  637. const pQ0, pQ1, pQ2, pQ3: TD3DXQuaternion); stdcall; external d3dx8dll;
  638. {$EXTERNALSYM D3DXQuaternionSquadSetup}
  639. // Barycentric interpolation.
  640. // Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g))
  641. function D3DXQuaternionBaryCentric(out qOut: TD3DXQuaternion;
  642. const q1, q2, q3: TD3DXQuaternion; f, g: Single): PD3DXQuaternion; stdcall; external d3dx8dll;
  643. {$EXTERNALSYM D3DXQuaternionBaryCentric}
  644. //--------------------------
  645. // Plane
  646. //--------------------------
  647. // inline
  648. // ax + by + cz + dw
  649. function D3DXPlaneDot(const p: TD3DXPlane; const v: TD3DXVector4): Single;
  650. {$EXTERNALSYM D3DXPlaneDot}
  651. // ax + by + cz + d
  652. function D3DXPlaneDotCoord(const p: TD3DXPlane; const v: TD3DXVector3): Single;
  653. {$EXTERNALSYM D3DXPlaneDotCoord}
  654. // ax + by + cz
  655. function D3DXPlaneDotNormal(const p: TD3DXPlane; const v: TD3DXVector3): Single;
  656. {$EXTERNALSYM D3DXPlaneDotNormal}
  657. // non-inline
  658. // Normalize plane (so that |a,b,c| == 1)
  659. function D3DXPlaneNormalize(out pOut: TD3DXPlane; const p: TD3DXPlane): PD3DXPlane; stdcall; external d3dx8dll;
  660. {$EXTERNALSYM D3DXPlaneNormalize}
  661. // Find the intersection between a plane and a line. If the line is
  662. // parallel to the plane, NULL is returned.
  663. function D3DXPlaneIntersectLine(out vOut: TD3DXVector3;
  664. const p: TD3DXPlane; const v1, v2: TD3DXVector3): PD3DXVector3; stdcall; external d3dx8dll;
  665. {$EXTERNALSYM D3DXPlaneIntersectLine}
  666. // Construct a plane from a point and a normal
  667. function D3DXPlaneFromPointNormal(out pOut: TD3DXPlane;
  668. const vPoint, vNormal: TD3DXVector3): PD3DXPlane; stdcall; external d3dx8dll;
  669. {$EXTERNALSYM D3DXPlaneFromPointNormal}
  670. // Construct a plane from 3 points
  671. function D3DXPlaneFromPoints(out pOut: TD3DXPlane;
  672. const v1, v2, v3: TD3DXVector3): PD3DXPlane; stdcall; external d3dx8dll;
  673. {$EXTERNALSYM D3DXPlaneFromPoints}
  674. // Transform a plane by a matrix. The vector (a,b,c) must be normal.
  675. // M should be the inverse transpose of the transformation desired.
  676. function D3DXPlaneTransform(out pOut: TD3DXPlane; const m: TD3DXMatrix): PD3DXPlane; stdcall; external d3dx8dll;
  677. {$EXTERNALSYM D3DXPlaneTransform}
  678. //--------------------------
  679. // Color
  680. //--------------------------
  681. // inline
  682. // (1-r, 1-g, 1-b, a)
  683. function D3DXColorNegative(out cOut: TD3DXColor; const c: TD3DXColor): PD3DXColor;
  684. {$EXTERNALSYM D3DXColorNegative}
  685. function D3DXColorAdd(out cOut: TD3DXColor; const c1, c2: TD3DXColor): PD3DXColor;
  686. {$EXTERNALSYM D3DXColorAdd}
  687. function D3DXColorSubtract(out cOut: TD3DXColor; const c1, c2: TD3DXColor): PD3DXColor;
  688. {$EXTERNALSYM D3DXColorSubtract}
  689. function D3DXColorScale(out cOut: TD3DXColor; const c: TD3DXColor; s: Single): PD3DXColor;
  690. {$EXTERNALSYM D3DXColorScale}
  691. // (r1*r2, g1*g2, b1*b2, a1*a2)
  692. function D3DXColorModulate(out cOut: TD3DXColor; const c1, c2: TD3DXColor): PD3DXColor;
  693. {$EXTERNALSYM D3DXColorModulate}
  694. // Linear interpolation of r,g,b, and a. C1 + s(C2-C1)
  695. function D3DXColorLerp(out cOut: TD3DXColor; const c1, c2: TD3DXColor; s: Single): PD3DXColor;
  696. {$EXTERNALSYM D3DXColorLerp}
  697. // non-inline
  698. // Interpolate r,g,b between desaturated color and color.
  699. // DesaturatedColor + s(Color - DesaturatedColor)
  700. function D3DXColorAdjustSaturation(out cOut: TD3DXColor;
  701. const pC: TD3DXColor; s: Single): PD3DXColor; stdcall; external d3dx8dll;
  702. {$EXTERNALSYM D3DXColorAdjustSaturation}
  703. // Interpolate r,g,b between 50% grey and color. Grey + s(Color - Grey)
  704. function D3DXColorAdjustContrast(out cOut: TD3DXColor;
  705. const pC: TD3DXColor; c: Single): PD3DXColor; stdcall; external d3dx8dll;
  706. {$EXTERNALSYM D3DXColorAdjustContrast}
  707. //--------------------------
  708. // Misc
  709. //--------------------------
  710. // Calculate Fresnel term given the cosine of theta (likely obtained by
  711. // taking the dot of two normals), and the refraction index of the material.
  712. function D3DXFresnelTerm(CosTheta, RefractionIndex: Single): Single; stdcall; external d3dx8dll;
  713. {$EXTERNALSYM D3DXFresnelTerm}
  714. //===========================================================================
  715. //
  716. // Matrix Stack
  717. //
  718. //===========================================================================
  719. type
  720. {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXMatrixStack);'}
  721. {$EXTERNALSYM ID3DXMatrixStack}
  722. ID3DXMatrixStack = interface(IUnknown)
  723. ['{E3357330-CC5E-11d2-A434-00A0C90629A8}']
  724. //
  725. // ID3DXMatrixStack methods
  726. //
  727. // Pops the top of the stack, returns the current top
  728. // *after* popping the top.
  729. function Pop: HResult; stdcall;
  730. // Pushes the stack by one, duplicating the current matrix.
  731. function Push: HResult; stdcall;
  732. // Loads identity in the current matrix.
  733. function LoadIdentity: HResult; stdcall;
  734. // Loads the given matrix into the current matrix
  735. function LoadMatrix(const M: TD3DXMatrix): HResult; stdcall;
  736. // Right-Multiplies the given matrix to the current matrix.
  737. // (transformation is about the current world origin)
  738. function MultMatrix(const M: TD3DXMatrix): HResult; stdcall;
  739. // Left-Multiplies the given matrix to the current matrix
  740. // (transformation is about the local origin of the object)
  741. function MultMatrixLocal(const M: TD3DXMatrix): HResult; stdcall;
  742. // Right multiply the current matrix with the computed rotation
  743. // matrix, counterclockwise about the given axis with the given angle.
  744. // (rotation is about the current world origin)
  745. function RotateAxis(const V: TD3DXVector3; Angle: Single): HResult; stdcall;
  746. // Left multiply the current matrix with the computed rotation
  747. // matrix, counterclockwise about the given axis with the given angle.
  748. // (rotation is about the local origin of the object)
  749. function RotateAxisLocal(const V: TD3DXVector3; Angle: Single): HResult; stdcall;
  750. // Right multiply the current matrix with the computed rotation
  751. // matrix. All angles are counterclockwise. (rotation is about the
  752. // current world origin)
  753. // The rotation is composed of a yaw around the Y axis, a pitch around
  754. // the X axis, and a roll around the Z axis.
  755. function RotateYawPitchRoll(yaw, pitch, roll: Single): HResult; stdcall;
  756. // Left multiply the current matrix with the computed rotation
  757. // matrix. All angles are counterclockwise. (rotation is about the
  758. // local origin of the object)
  759. // The rotation is composed of a yaw around the Y axis, a pitch around
  760. // the X axis, and a roll around the Z axis.
  761. function RotateYawPitchRollLocal(yaw, pitch, roll: Single): HResult; stdcall;
  762. // Right multiply the current matrix with the computed scale
  763. // matrix. (transformation is about the current world origin)
  764. function Scale(x, y, z: Single): HResult; stdcall;
  765. // Left multiply the current matrix with the computed scale
  766. // matrix. (transformation is about the local origin of the object)
  767. function ScaleLocal(x, y, z: Single): HResult; stdcall;
  768. // Right multiply the current matrix with the computed translation
  769. // matrix. (transformation is about the current world origin)
  770. function Translate(x, y, z: Single): HResult; stdcall;
  771. // Left multiply the current matrix with the computed translation
  772. // matrix. (transformation is about the local origin of the object)
  773. function TranslateLocal(x, y, z: Single): HResult; stdcall;
  774. // Obtain the current matrix at the top of the stack
  775. function GetTop: PD3DXMatrix; stdcall;
  776. end;
  777. type
  778. IID_ID3DXMatrixStack = ID3DXMatrixStack;
  779. {$EXTERNALSYM IID_ID3DXMatrixStack}
  780. function D3DXCreateMatrixStack(Flags: DWord; out Stack: ID3DXMatrixStack): HResult; stdcall; external d3dx8dll;
  781. {$EXTERNALSYM D3DXCreateMatrixStack}
  782. ///////////////////////////////////////////////////////////////////////////
  783. //
  784. // Copyright (C) Microsoft Corporation. All Rights Reserved.
  785. //
  786. // File: d3dx8core.h
  787. // Content: D3DX core types and functions
  788. //
  789. ///////////////////////////////////////////////////////////////////////////
  790. type
  791. ///////////////////////////////////////////////////////////////////////////
  792. // ID3DXBuffer:
  793. // ------------
  794. // The buffer object is used by D3DX to return arbitrary size data.
  795. //
  796. // GetBufferPointer -
  797. // Returns a pointer to the beginning of the buffer.
  798. //
  799. // GetBufferSize -
  800. // Returns the size of the buffer, in bytes.
  801. ///////////////////////////////////////////////////////////////////////////
  802. PID3DXBuffer = ^ID3DXBuffer;
  803. {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXBuffer);'}
  804. {$EXTERNALSYM ID3DXBuffer}
  805. ID3DXBuffer = interface(IUnknown)
  806. ['{932E6A7E-C68E-45dd-A7BF-53D19C86DB1F}']
  807. // ID3DXBuffer
  808. function GetBufferPointer: Pointer; stdcall;
  809. function GetBufferSize: DWord; stdcall;
  810. end;
  811. ///////////////////////////////////////////////////////////////////////////
  812. // ID3DXFont:
  813. // ----------
  814. // Font objects contain the textures and resources needed to render
  815. // a specific font on a specific device.
  816. //
  817. // Begin -
  818. // Prepartes device for drawing text. This is optional.. if DrawText
  819. // is called outside of Begin/End, it will call Begin and End for you.
  820. //
  821. // DrawText -
  822. // Draws formatted text on a D3D device. Some parameters are
  823. // surprisingly similar to those of GDI's DrawText function. See GDI
  824. // documentation for a detailed description of these parameters.
  825. //
  826. // End -
  827. // Restores device state to how it was when Begin was called.
  828. //
  829. // OnLostDevice, OnResetDevice -
  830. // Call OnLostDevice() on this object before calling Reset() on the
  831. // device, so that this object can release any stateblocks and video
  832. // memory resources. After Reset(), the call OnResetDevice().
  833. //
  834. ///////////////////////////////////////////////////////////////////////////
  835. {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXFont);'}
  836. {$EXTERNALSYM ID3DXFont}
  837. ID3DXFont = interface(IUnknown)
  838. ['{89FAD6A5-024D-49af-8FE7-F51123B85E25}']
  839. // ID3DXFont
  840. function GetDevice(out ppDevice: IDirect3DDevice8): HResult; stdcall;
  841. function GetLogFont(out pLogFont: TLogFont): HResult; stdcall;
  842. function _Begin: HResult; stdcall;
  843. function DrawTextA(pString: PAnsiChar; Count: Integer; const pRect: TRect; Format: DWord; Color: TD3DColor): Integer; stdcall;
  844. function DrawTextW(pString: PWideChar; Count: Integer; const pRect: TRect; Format: DWord; Color: TD3DColor): Integer; stdcall;
  845. function _End: HResult; stdcall;
  846. function OnLostDevice: HResult; stdcall;
  847. function OnResetDevice: HResult; stdcall;
  848. end;
  849. function D3DXCreateFont(pDevice: IDirect3DDevice8; hFont: HFONT;
  850. out ppFont: ID3DXFont): HResult; stdcall; external d3dx8dll;
  851. {$EXTERNALSYM D3DXCreateFont}
  852. function D3DXCreateFontIndirect(pDevice: IDirect3DDevice8;
  853. const pLogFont: TLogFont; out ppFont: ID3DXFont): HResult; stdcall; external d3dx8dll;
  854. {$EXTERNALSYM D3DXCreateFontIndirect}
  855. ///////////////////////////////////////////////////////////////////////////
  856. // ID3DXSprite:
  857. // ------------
  858. // This object intends to provide an easy way to drawing sprites using D3D.
  859. //
  860. // Begin -
  861. // Prepares device for drawing sprites
  862. //
  863. // Draw, DrawAffine, DrawTransform -
  864. // Draws a sprite in screen-space. Before transformation, the sprite is
  865. // the size of SrcRect, with its top-left corner at the origin (0,0).
  866. // The color and alpha channels are modulated by Color.
  867. //
  868. // End -
  869. // Restores device state to how it was when Begin was called.
  870. //
  871. // OnLostDevice, OnResetDevice -
  872. // Call OnLostDevice() on this object before calling Reset() on the
  873. // device, so that this object can release any stateblocks and video
  874. // memory resources. After Reset(), the call OnResetDevice().
  875. ///////////////////////////////////////////////////////////////////////////
  876. type
  877. {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXSprite);'}
  878. {$EXTERNALSYM ID3DXSprite}
  879. ID3DXSprite = interface(IUnknown)
  880. ['{13D69D15-F9B0-4e0f-B39E-C91EB33F6CE7}']
  881. // ID3DXSprite
  882. function GetDevice(out ppDevice: IDirect3DDevice8): HResult; stdcall;
  883. function _Begin: HResult; stdcall;
  884. function Draw(pSrcTexture: IDirect3DTexture8; pSrcRect: PRect;
  885. pScaling, pRotationCenter: PD3DXVector2; Rotation: Single;
  886. pTranslation: PD3DXVector2; Color: TD3DColor): HResult; stdcall;
  887. function DrawTransform(pSrcTexture: IDirect3DTexture8; pSrcRect: PRect;
  888. const pTransform: TD3DXMatrix; Color: TD3DColor): HResult; stdcall;
  889. function _End: HResult; stdcall;
  890. function OnLostDevice: HResult; stdcall;
  891. function OnResetDevice: HResult; stdcall;
  892. end;
  893. function D3DXCreateSprite(ppDevice: IDirect3DDevice8;
  894. out ppSprite: ID3DXSprite): HResult; stdcall; external d3dx8dll;
  895. {$EXTERNALSYM D3DXCreateSprite}
  896. ///////////////////////////////////////////////////////////////////////////
  897. // ID3DXRenderToSurface:
  898. // ---------------------
  899. // This object abstracts rendering to surfaces. These surfaces do not
  900. // necessarily need to be render targets. If they are not, a compatible
  901. // render target is used, and the result copied into surface at end scene.
  902. //
  903. // BeginScene, EndScene -
  904. // Call BeginScene() and EndScene() at the beginning and ending of your
  905. // scene. These calls will setup and restore render targets, viewports,
  906. // etc..
  907. //
  908. // OnLostDevice, OnResetDevice -
  909. // Call OnLostDevice() on this object before calling Reset() on the
  910. // device, so that this object can release any stateblocks and video
  911. // memory resources. After Reset(), the call OnResetDevice().
  912. ///////////////////////////////////////////////////////////////////////////
  913. type
  914. PD3DXRTSDesc = ^TD3DXRTSDesc;
  915. _D3DXRTS_DESC = packed record
  916. Width: LongWord;
  917. Height: LongWord;
  918. Format: TD3DFormat;
  919. DepthStencil: BOOL;
  920. DepthStencilFormat: TD3DFormat;
  921. end {_D3DXRTS_DESC};
  922. {$EXTERNALSYM _D3DXRTS_DESC}
  923. D3DXRTS_DESC = _D3DXRTS_DESC;
  924. {$EXTERNALSYM D3DXRTS_DESC}
  925. TD3DXRTSDesc = _D3DXRTS_DESC;
  926. {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXRenderToSurface);'}
  927. {$EXTERNALSYM ID3DXRenderToSurface}
  928. ID3DXRenderToSurface = interface(IUnknown)
  929. ['{82DF5B90-E34E-496e-AC1C-62117A6A5913}']
  930. // ID3DXRenderToSurface
  931. function GetDevice(out ppDevice: IDirect3DDevice8): HResult; stdcall;
  932. function GetDesc(out pDesc: TD3DXRTSDesc): HResult; stdcall;
  933. function BeginScene(pSurface: IDirect3DSurface8; pViewport: PD3DViewport8): HResult; stdcall;
  934. function EndScene: HResult; stdcall;
  935. function OnLostDevice: HResult; stdcall;
  936. function OnResetDevice: HResult; stdcall;
  937. end;
  938. function D3DXCreateRenderToSurface(ppDevice: IDirect3DDevice8;
  939. Width: LongWord;
  940. Height: LongWord;
  941. Format: TD3DFormat;
  942. DepthStencil: BOOL;
  943. DepthStencilFormat: TD3DFormat;
  944. out ppRenderToSurface: ID3DXRenderToSurface): HResult; stdcall; external d3dx8dll;
  945. {$EXTERNALSYM D3DXCreateRenderToSurface}
  946. ///////////////////////////////////////////////////////////////////////////
  947. // ID3DXRenderToEnvMap:
  948. // --------------------
  949. // This object abstracts rendering to environment maps. These surfaces
  950. // do not necessarily need to be render targets. If they are not, a
  951. // compatible render target is used, and the result copied into the
  952. // environment map at end scene.
  953. //
  954. // BeginCube, BeginSphere, BeginHemisphere, BeginParabolic -
  955. // This function initiates the rendering of the environment map. As
  956. // parameters, you pass the textures in which will get filled in with
  957. // the resulting environment map.
  958. //
  959. // Face -
  960. // Call this function to initiate the drawing of each face. For each
  961. // environment map, you will call this six times.. once for each face
  962. // in D3DCUBEMAP_FACES.
  963. //
  964. // End -
  965. // This will restore all render targets, and if needed compose all the
  966. // rendered faces into the environment map surfaces.
  967. //
  968. // OnLostDevice, OnResetDevice -
  969. // Call OnLostDevice() on this object before calling Reset() on the
  970. // device, so that this object can release any stateblocks and video
  971. // memory resources. After Reset(), the call OnResetDevice().
  972. ///////////////////////////////////////////////////////////////////////////
  973. type
  974. PD3DXRTEDesc = ^TD3DXRTEDesc;
  975. _D3DXRTE_DESC = record
  976. Size: LongWord;
  977. Format: TD3DFormat;
  978. DepthStencil: Bool;
  979. DepthStencilFormat: TD3DFormat;
  980. end {_D3DXRTE_DESC};
  981. {$EXTERNALSYM _D3DXRTE_DESC}
  982. D3DXRTE_DESC = _D3DXRTE_DESC;
  983. {$EXTERNALSYM D3DXRTE_DESC}
  984. TD3DXRTEDesc = _D3DXRTE_DESC;
  985. {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXRenderToEnvMap);'}
  986. {$EXTERNALSYM ID3DXRenderToEnvMap}
  987. ID3DXRenderToEnvMap = interface(IUnknown)
  988. ['{4E42C623-9451-44b7-8C86-ABCCDE5D52C8}']
  989. // ID3DXRenderToEnvMap
  990. function GetDevice(out ppDevice: IDirect3DDevice8): HResult; stdcall;
  991. function GetDesc(out pDesc: TD3DXRTEDesc): HResult; stdcall;
  992. function BeginCube(pCubeTex: IDirect3DCubeTexture8): HResult; stdcall;
  993. function BeginSphere(pTex: IDirect3DTexture8): HResult; stdcall;
  994. function BeginHemisphere(pTexZPos, pTexZNeg: IDirect3DTexture8): HResult; stdcall;
  995. function BeginParabolic(pTexZPos, pTexZNeg: IDirect3DTexture8): HResult; stdcall;
  996. function Face(Face: TD3DCubemapFaces): HResult; stdcall;
  997. function _End: HResult; stdcall;
  998. function OnLostDevice: HResult; stdcall;
  999. function OnResetDevice: HResult; stdcall;
  1000. end;
  1001. function D3DXCreateRenderToEnvMap(ppDevice: IDirect3DDevice8;
  1002. Size: LongWord;
  1003. Format: TD3DFormat;
  1004. DepthStencil: BOOL;
  1005. DepthStencilFormat: TD3DFormat;
  1006. out ppRenderToEnvMap: ID3DXRenderToEnvMap): HResult; stdcall; external d3dx8dll;
  1007. {$EXTERNALSYM D3DXCreateRenderToEnvMap}
  1008. ///////////////////////////////////////////////////////////////////////////
  1009. // Shader assemblers:
  1010. ///////////////////////////////////////////////////////////////////////////
  1011. //-------------------------------------------------------------------------
  1012. // D3DXASM flags:
  1013. // --------------
  1014. //
  1015. // D3DXASM_DEBUG
  1016. // Generate debug info.
  1017. //
  1018. // D3DXASM_SKIPVALIDATION
  1019. // Do not validate the generated code against known capabilities and
  1020. // constraints. This option is only recommended when assembling shaders
  1021. // you KNOW will work. (ie. have assembled before without this option.)
  1022. //-------------------------------------------------------------------------
  1023. const
  1024. D3DXASM_DEBUG = (1 shl 0);
  1025. {$EXTERNALSYM D3DXASM_DEBUG}
  1026. D3DXASM_SKIPVALIDATION = (1 shl 1);
  1027. {$EXTERNALSYM D3DXASM_SKIPVALIDATION}
  1028. //-------------------------------------------------------------------------
  1029. // D3DXAssembleShader:
  1030. // -------------------
  1031. // Assembles an ascii description of a vertex or pixel shader into
  1032. // binary form.
  1033. //
  1034. // Parameters:
  1035. // pSrcFile
  1036. // Source file name
  1037. // hSrcModule
  1038. // Module handle. if NULL, current module will be used.
  1039. // pSrcResource
  1040. // Resource name in module
  1041. // pSrcData
  1042. // Pointer to source code
  1043. // SrcDataLen
  1044. // Size of source code, in bytes
  1045. // Flags
  1046. // D3DXASM_xxx flags
  1047. // ppConstants
  1048. // Returns an ID3DXBuffer object containing constant declarations.
  1049. // ppCompiledShader
  1050. // Returns an ID3DXBuffer object containing the object code.
  1051. // ppCompilationErrors
  1052. // Returns an ID3DXBuffer object containing ascii error messages
  1053. //-------------------------------------------------------------------------
  1054. function D3DXAssembleShaderFromFileA(
  1055. pSrcFile: PAnsiChar;
  1056. Flags: DWord;
  1057. ppConstants: PID3DXBuffer;
  1058. ppCompiledShader: PID3DXBuffer;
  1059. ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll name 'D3DXAssembleShaderFromFileA';
  1060. {$EXTERNALSYM D3DXAssembleShaderFromFileA}
  1061. function D3DXAssembleShaderFromFileW(
  1062. pSrcFile: PWideChar;
  1063. Flags: DWord;
  1064. ppConstants: PID3DXBuffer;
  1065. ppCompiledShader: PID3DXBuffer;
  1066. ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll name 'D3DXAssembleShaderFromFileW';
  1067. {$EXTERNALSYM D3DXAssembleShaderFromFileW}
  1068. function D3DXAssembleShaderFromFile(
  1069. pSrcFile: PChar;
  1070. Flags: DWord;
  1071. ppConstants: PID3DXBuffer;
  1072. ppCompiledShader: PID3DXBuffer;
  1073. ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll name 'D3DXAssembleShaderFromFileA';
  1074. {$EXTERNALSYM D3DXAssembleShaderFromFile}
  1075. function D3DXAssembleShaderFromResourceA(
  1076. hSrcModule: HModule;
  1077. pSrcResource: PAnsiChar;
  1078. Flags: DWord;
  1079. ppConstants: PID3DXBuffer;
  1080. ppCompiledShader: PID3DXBuffer;
  1081. ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll name 'D3DXAssembleShaderFromResourceA';
  1082. {$EXTERNALSYM D3DXAssembleShaderFromResourceA}
  1083. function D3DXAssembleShaderFromResourceW(
  1084. hSrcModule: HModule;
  1085. pSrcResource: PWideChar;
  1086. Flags: DWord;
  1087. ppConstants: PID3DXBuffer;
  1088. ppCompiledShader: PID3DXBuffer;
  1089. ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll name 'D3DXAssembleShaderFromResourceW';
  1090. {$EXTERNALSYM D3DXAssembleShaderFromResourceW}
  1091. function D3DXAssembleShaderFromResource(
  1092. hSrcModule: HModule;
  1093. pSrcResource: PChar;
  1094. Flags: DWord;
  1095. ppConstants: PID3DXBuffer;
  1096. ppCompiledShader: PID3DXBuffer;
  1097. ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll name 'D3DXAssembleShaderFromResourceA';
  1098. {$EXTERNALSYM D3DXAssembleShaderFromResource}
  1099. function D3DXAssembleShader(
  1100. const pSrcData;
  1101. SrcDataLen: LongWord;
  1102. Flags: DWord;
  1103. ppConstants: PID3DXBuffer;
  1104. ppCompiledShader: PID3DXBuffer;
  1105. ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll;
  1106. {$EXTERNALSYM D3DXAssembleShader}
  1107. ///////////////////////////////////////////////////////////////////////////
  1108. // Misc APIs:
  1109. ///////////////////////////////////////////////////////////////////////////
  1110. //-------------------------------------------------------------------------
  1111. // D3DXGetErrorString:
  1112. // ------------------
  1113. // Returns the error string for given an hresult. Interprets all D3DX and
  1114. // D3D hresults.
  1115. //
  1116. // Parameters:
  1117. // hr
  1118. // The error code to be deciphered.
  1119. // pBuffer
  1120. // Pointer to the buffer to be filled in.
  1121. // BufferLen
  1122. // Count of characters in buffer. Any error message longer than this
  1123. // length will be truncated to fit.
  1124. //-------------------------------------------------------------------------
  1125. function D3DXGetErrorStringA(hr: HResult; pBuffer: PAnsiChar; BufferLen: LongWord): HResult; stdcall; external d3dx8dll name 'D3DXGetErrorStringA'; overload;
  1126. {$EXTERNALSYM D3DXGetErrorStringA}
  1127. function D3DXGetErrorStringW(hr: HResult; pBuffer: PWideChar; BufferLen: LongWord): HResult; stdcall; external d3dx8dll name 'D3DXGetErrorStringW'; overload;
  1128. {$EXTERNALSYM D3DXGetErrorStringW}
  1129. function D3DXGetErrorString(hr: HResult; pBuffer: PChar; BufferLen: LongWord): HResult; stdcall; external d3dx8dll name 'D3DXGetErrorStringA'; overload;
  1130. {$EXTERNALSYM D3DXGetErrorString}
  1131. // Object Pascal support functions for D3DXGetErrorString
  1132. function D3DXGetErrorStringA(hr: HResult): String; overload;
  1133. function D3DXGetErrorStringW(hr: HResult): WideString; overload;
  1134. {$IFNDEF UNICODE}
  1135. function D3DXGetErrorString(hr: HResult): String; overload;
  1136. {$ELSE}
  1137. function D3DXGetErrorString(hr: HResult): WideString; overload;
  1138. {$ENDIF}
  1139. ///////////////////////////////////////////////////////////////////////////
  1140. //
  1141. // Copyright (C) Microsoft Corporation. All Rights Reserved.
  1142. //
  1143. // File: d3dx8effect.h
  1144. // Content: D3DX effect types and functions
  1145. //
  1146. ///////////////////////////////////////////////////////////////////////////
  1147. const
  1148. D3DXFX_DONOTSAVESTATE = (1 shl 0);
  1149. {$EXTERNALSYM D3DXFX_DONOTSAVESTATE}
  1150. type
  1151. _D3DXPARAMETERTYPE = (
  1152. D3DXPT_DWORD {= 0},
  1153. D3DXPT_FLOAT {= 1},
  1154. D3DXPT_VECTOR {= 2},
  1155. D3DXPT_MATRIX {= 3},
  1156. D3DXPT_TEXTURE {= 4},
  1157. D3DXPT_VERTEXSHADER {= 5},
  1158. D3DXPT_PIXELSHADER {= 6},
  1159. D3DXPT_CONSTANT {= 7},
  1160. D3DXPT_STRING {= 8}
  1161. ); {_D3DXPARAMETERTYPE}
  1162. {$EXTERNALSYM _D3DXPARAMETERTYPE}
  1163. D3DXPARAMETERTYPE = _D3DXPARAMETERTYPE;
  1164. {$EXTERNALSYM D3DXPARAMETERTYPE}
  1165. TD3DXParameterType = _D3DXPARAMETERTYPE;
  1166. type
  1167. PD3DXEffectDesc = ^TD3DXEffectDesc;
  1168. _D3DXEFFECT_DESC = packed record
  1169. Parameters: LongWord;
  1170. Techniques: LongWord;
  1171. end;
  1172. {$EXTERNALSYM _D3DXEFFECT_DESC}
  1173. D3DXEFFECT_DESC = _D3DXEFFECT_DESC;
  1174. {$EXTERNALSYM D3DXEFFECT_DESC}
  1175. TD3DXEffectDesc = _D3DXEFFECT_DESC;
  1176. PD3DXParameterDesc = ^TD3DXParameterDesc;
  1177. _D3DXPARAMETER_DESC = packed record
  1178. Name: PAnsiChar;
  1179. Index: PAnsiChar;
  1180. _Type: TD3DXParameterType;
  1181. end;
  1182. {$EXTERNALSYM _D3DXPARAMETER_DESC}
  1183. D3DXPARAMETER_DESC = _D3DXPARAMETER_DESC;
  1184. {$EXTERNALSYM D3DXPARAMETER_DESC}
  1185. TD3DXParameterDesc = _D3DXPARAMETER_DESC;
  1186. PD3DXTechniqueDesc = ^TD3DXTechniqueDesc;
  1187. _D3DXTECHNIQUE_DESC = packed record
  1188. Name: PAnsiChar;
  1189. Index: PAnsiChar;
  1190. Passes: LongWord;
  1191. end;
  1192. {$EXTERNALSYM _D3DXTECHNIQUE_DESC}
  1193. D3DXTECHNIQUE_DESC = _D3DXTECHNIQUE_DESC;
  1194. {$EXTERNALSYM D3DXTECHNIQUE_DESC}
  1195. TD3DXTechniqueDesc = _D3DXTECHNIQUE_DESC;
  1196. PD3DXPassDesc = ^TD3DXPassDesc;
  1197. _D3DXPASS_DESC = packed record
  1198. Name: PAnsiChar;
  1199. Index: PAnsiChar;
  1200. end;
  1201. {$EXTERNALSYM _D3DXPASS_DESC}
  1202. D3DXPASS_DESC = _D3DXPASS_DESC;
  1203. {$EXTERNALSYM D3DXPASS_DESC}
  1204. TD3DXPassDesc = _D3DXPASS_DESC;
  1205. //////////////////////////////////////////////////////////////////////////////
  1206. // ID3DXEffect ///////////////////////////////////////////////////////////////
  1207. //////////////////////////////////////////////////////////////////////////////
  1208. {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXEffect);'}
  1209. {$EXTERNALSYM ID3DXEffect}
  1210. ID3DXEffect = interface(IUnknown)
  1211. ['{648B1CEB-8D4E-4d66-B6FA-E44969E82E89}']
  1212. // ID3DXEffect
  1213. function GetDevice(out ppDevice: IDirect3DDevice8): HResult; stdcall;
  1214. function GetDesc(out pDesc: TD3DXEffectDesc): HResult; stdcall;
  1215. function GetParameterDesc(pParameter: PAnsiChar; out pDesc: TD3DXParameterDesc): HResult; stdcall;
  1216. function GetTechniqueDesc(pTechnique: PAnsiChar; out pDesc: TD3DXTechniqueDesc): HResult; stdcall;
  1217. function GetPassDesc(pTechnique, pPass: PAnsiChar; out pDesc: TD3DXPassDesc): HResult; stdcall;
  1218. function FindNextValidTechnique(pTechnique: PAnsiChar; out pDesc: TD3DXTechniqueDesc): HResult; stdcall;
  1219. function CloneEffect(pDevice: IDirect3DDevice8; out ppEffect: ID3DXEffect): HResult; stdcall;
  1220. function GetCompiledEffect(out ppCompiledEffect: ID3DXBuffer): HResult; stdcall;
  1221. function SetTechnique(pTechnique: PAnsiChar): HResult; stdcall;
  1222. function GetTechnique(out ppTechnique: PAnsiChar): HResult; stdcall;
  1223. function SetDword(pParameter: PAnsiChar; dw: DWord): HResult; stdcall;
  1224. function GetDword(pParameter: PAnsiChar; out pdw: DWord): HResult; stdcall;
  1225. function SetFloat(pParameter: PAnsiChar; f: Single): HResult; stdcall;
  1226. function GetFloat(pParameter: PAnsiChar; out pf: Single): HResult; stdcall;
  1227. function SetVector(pParameter: PAnsiChar; const pVector: TD3DXVector4): HResult; stdcall;
  1228. function GetVector(pParameter: PAnsiChar; out pVector: TD3DXVector4): HResult; stdcall;
  1229. function SetMatrix(pParameter: PAnsiChar; const pMatrix: TD3DXMatrix): HResult; stdcall;
  1230. function GetMatrix(pParameter: PAnsiChar; out pMatrix: TD3DXMatrix): HResult; stdcall;
  1231. function SetTexture(pParameter: PAnsiChar; pTexture: IDirect3DBaseTexture8): HResult; stdcall;
  1232. function GetTexture(pParameter: PAnsiChar; out ppTexture: IDirect3DBaseTexture8): HResult; stdcall;
  1233. function SetVertexShader(pParameter: PAnsiChar; Handle: DWord): HResult; stdcall;
  1234. function GetVertexShader(pParameter: PAnsiChar; out Handle: DWord): HResult; stdcall;
  1235. function SetPixelShader(pParameter: PAnsiChar; Handle: DWord): HResult; stdcall;
  1236. function GetPixelShader(pParameter: PAnsiChar; out Handle: DWord): HResult; stdcall;
  1237. function SetString(pParameter: PAnsiChar; pString: PAnsiChar): HResult; stdcall;
  1238. function GetString(pParameter: PAnsiChar; out ppString: PAnsiChar): HResult; stdcall;
  1239. function IsParameterUsed(pParameter: PAnsiChar): BOOL; stdcall;
  1240. function Validate: HResult; stdcall;
  1241. function _Begin(out pPasses: LongWord; Flags: DWord): HResult; stdcall;
  1242. function Pass(Pass: LongWord): HResult; stdcall;
  1243. function _End: HResult; stdcall;
  1244. function OnLostDevice: HResult; stdcall;
  1245. function OnResetDevice: HResult; stdcall;
  1246. end;
  1247. //////////////////////////////////////////////////////////////////////////////
  1248. // APIs //////////////////////////////////////////////////////////////////////
  1249. //////////////////////////////////////////////////////////////////////////////
  1250. //----------------------------------------------------------------------------
  1251. // D3DXCreateEffect:
  1252. // -----------------
  1253. // Creates an effect from an ascii or binaray effect description.
  1254. //
  1255. // Parameters:
  1256. // pDevice
  1257. // Pointer of the device on which to create the effect
  1258. // pSrcFile
  1259. // Name of the file containing the effect description
  1260. // hSrcModule
  1261. // Module handle. if NULL, current module will be used.
  1262. // pSrcResource
  1263. // Resource name in module
  1264. // pSrcData
  1265. // Pointer to effect description
  1266. // SrcDataSize
  1267. // Size of the effect description in bytes
  1268. // ppEffect
  1269. // Returns a buffer containing created effect.
  1270. // ppCompilationErrors
  1271. // Returns a buffer containing any error messages which occurred during
  1272. // compile. Or NULL if you do not care about the error messages.
  1273. //
  1274. //----------------------------------------------------------------------------
  1275. function D3DXCreateEffectFromFileA(
  1276. pDevice: IDirect3DDevice8;
  1277. pSrcFile: PAnsiChar;
  1278. out ppEffect: ID3DXEffect;
  1279. ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll name 'D3DXCreateEffectFromFileA';
  1280. {$EXTERNALSYM D3DXCreateEffectFromFileA}
  1281. function D3DXCreateEffectFromFileW(
  1282. pDevice: IDirect3DDevice8;
  1283. pSrcFile: PWideChar;
  1284. out ppEffect: ID3DXEffect;
  1285. ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll name 'D3DXCreateEffectFromFileW';
  1286. {$EXTERNALSYM D3DXCreateEffectFromFileW}
  1287. function D3DXCreateEffectFromFile(
  1288. pDevice: IDirect3DDevice8;
  1289. pSrcFile: PChar;
  1290. out ppEffect: ID3DXEffect;
  1291. ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll name 'D3DXCreateEffectFromFileA';
  1292. {$EXTERNALSYM D3DXCreateEffectFromFile}
  1293. function D3DXCreateEffectFromResourceA(
  1294. pDevice: IDirect3DDevice8;
  1295. hSrcModule: HModule;
  1296. pSrcResource: PAnsiChar;
  1297. out ppEffect: ID3DXEffect;
  1298. ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll name 'D3DXCreateEffectFromResourceA';
  1299. {$EXTERNALSYM D3DXCreateEffectFromResourceA}
  1300. function D3DXCreateEffectFromResourceW(
  1301. pDevice: IDirect3DDevice8;
  1302. hSrcModule: HModule;
  1303. pSrcResource: PWideChar;
  1304. out ppEffect: ID3DXEffect;
  1305. ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll name 'D3DXCreateEffectFromResourceW';
  1306. {$EXTERNALSYM D3DXCreateEffectFromResourceW}
  1307. function D3DXCreateEffectFromResource(
  1308. pDevice: IDirect3DDevice8;
  1309. hSrcModule: HModule;
  1310. pSrcResource: PChar;
  1311. out ppEffect: ID3DXEffect;
  1312. ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll name 'D3DXCreateEffectFromResourceA';
  1313. {$EXTERNALSYM D3DXCreateEffectFromResource}
  1314. function D3DXCreateEffect(
  1315. pDevice: IDirect3DDevice8;
  1316. const pSrcData;
  1317. SrcDataSize: LongWord;
  1318. out ppEffect: ID3DXEffect;
  1319. ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll;
  1320. {$EXTERNALSYM D3DXCreateEffect}
  1321. //////////////////////////////////////////////////////////////////////////////
  1322. //
  1323. // Copyright (C) Microsoft Corporation. All Rights Reserved.
  1324. //
  1325. // File: d3dx8mesh.h
  1326. // Content: D3DX mesh types and functions
  1327. //
  1328. //////////////////////////////////////////////////////////////////////////////
  1329. type
  1330. _D3DXMESH = {$IFDEF TYPE_IDENTITY}type {$ENDIF}DWord;
  1331. {$EXTERNALSYM _D3DXMESH}
  1332. TD3DXMesh = _D3DXMESH;
  1333. // Mesh options - lower 3 bytes only, upper byte used by _D3DXMESHOPT option flags
  1334. const
  1335. D3DXMESH_32BIT = $001; // If set, then use 32 bit indices, if not set use 16 bit indices.
  1336. {$EXTERNALSYM D3DXMESH_32BIT}
  1337. D3DXMESH_DONOTCLIP = $002; // Use D3DUSAGE_DONOTCLIP for VB & IB.
  1338. {$EXTERNALSYM D3DXMESH_DONOTCLIP}
  1339. D3DXMESH_POINTS = $004; // Use D3DUSAGE_POINTS for VB & IB.
  1340. {$EXTERNALSYM D3DXMESH_POINTS}
  1341. D3DXMESH_RTPATCHES = $008; // Use D3DUSAGE_RTPATCHES for VB & IB.
  1342. {$EXTERNALSYM D3DXMESH_RTPATCHES}
  1343. D3DXMESH_NPATCHES = $4000;// Use D3DUSAGE_NPATCHES for VB & IB.
  1344. {$EXTERNALSYM D3DXMESH_NPATCHES}
  1345. D3DXMESH_VB_SYSTEMMEM = $010; // Use D3DPOOL_SYSTEMMEM for VB. Overrides D3DXMESH_MANAGEDVERTEXBUFFER
  1346. {$EXTERNALSYM D3DXMESH_VB_SYSTEMMEM}
  1347. D3DXMESH_VB_MANAGED = $020; // Use D3DPOOL_MANAGED for VB.
  1348. {$EXTERNALSYM D3DXMESH_VB_MANAGED}
  1349. D3DXMESH_VB_WRITEONLY = $040; // Use D3DUSAGE_WRITEONLY for VB.
  1350. {$EXTERNALSYM D3DXMESH_VB_WRITEONLY}
  1351. D3DXMESH_VB_DYNAMIC = $080; // Use D3DUSAGE_DYNAMIC for VB.
  1352. {$EXTERNALSYM D3DXMESH_VB_DYNAMIC}
  1353. D3DXMESH_VB_SOFTWAREPROCESSING = $8000; // Use D3DUSAGE_SOFTWAREPROCESSING for VB.
  1354. {$EXTERNALSYM D3DXMESH_VB_SOFTWAREPROCESSING}
  1355. D3DXMESH_IB_SYSTEMMEM = $100; // Use D3DPOOL_SYSTEMMEM for IB. Overrides D3DXMESH_MANAGEDINDEXBUFFER
  1356. {$EXTERNALSYM D3DXMESH_IB_SYSTEMMEM}
  1357. D3DXMESH_IB_MANAGED = $200; // Use D3DPOOL_MANAGED for IB.
  1358. {$EXTERNALSYM D3DXMESH_IB_MANAGED}
  1359. D3DXMESH_IB_WRITEONLY = $400; // Use D3DUSAGE_WRITEONLY for IB.
  1360. {$EXTERNALSYM D3DXMESH_IB_WRITEONLY}
  1361. D3DXMESH_IB_DYNAMIC = $800; // Use D3DUSAGE_DYNAMIC for IB.
  1362. {$EXTERNALSYM D3DXMESH_IB_DYNAMIC}
  1363. D3DXMESH_IB_SOFTWAREPROCESSING= $10000; // Use D3DUSAGE_SOFTWAREPROCESSING for IB.
  1364. {$EXTERNALSYM D3DXMESH_IB_SOFTWAREPROCESSING}
  1365. D3DXMESH_VB_SHARE = $1000; // Valid for Clone* calls only, forces cloned mesh/pmesh to share vertex buffer
  1366. {$EXTERNALSYM D3DXMESH_VB_SHARE}
  1367. D3DXMESH_USEHWONLY = $2000; // Valid for ID3DXSkinMesh::ConvertToBlendedMesh
  1368. {$EXTERNALSYM D3DXMESH_USEHWONLY}
  1369. // Helper options
  1370. D3DXMESH_SYSTEMMEM = $110; // D3DXMESH_VB_SYSTEMMEM | D3DXMESH_IB_SYSTEMMEM
  1371. {$EXTERNALSYM D3DXMESH_SYSTEMMEM}
  1372. D3DXMESH_MANAGED = $220; // D3DXMESH_VB_MANAGED | D3DXMESH_IB_MANAGED
  1373. {$EXTERNALSYM D3DXMESH_MANAGED}
  1374. D3DXMESH_WRITEONLY = $440; // D3DXMESH_VB_WRITEONLY | D3DXMESH_IB_WRITEONLY
  1375. {$EXTERNALSYM D3DXMESH_WRITEONLY}
  1376. D3DXMESH_DYNAMIC = $880; // D3DXMESH_VB_DYNAMIC | D3DXMESH_IB_DYNAMIC
  1377. {$EXTERNALSYM D3DXMESH_DYNAMIC}
  1378. D3DXMESH_SOFTWAREPROCESSING = $18000; // D3DXMESH_VB_SOFTWAREPROCESSING | D3DXMESH_IB_SOFTWAREPROCESSING
  1379. {$EXTERNALSYM D3DXMESH_SOFTWAREPROCESSING}
  1380. type
  1381. // option field values for specifying min value in D3DXGeneratePMesh and D3DXSimplifyMesh
  1382. _D3DXMESHSIMP = (
  1383. {$IFNDEF COMPILER6_UP}
  1384. D3DXMESHSIMP_INVALID_0{= 0x0},
  1385. D3DXMESHSIMP_VERTEX {= 0x1},
  1386. D3DXMESHSIMP_FACE {= 0x2}
  1387. {$ELSE}
  1388. D3DXMESHSIMP_VERTEX = $1,
  1389. D3DXMESHSIMP_FACE = $2
  1390. {$ENDIF}
  1391. );
  1392. {$EXTERNALSYM _D3DXMESHSIMP}
  1393. TD3DMeshSimp = _D3DXMESHSIMP;
  1394. _MAX_FVF_DECL_SIZE = DWord;
  1395. {$EXTERNALSYM _MAX_FVF_DECL_SIZE}
  1396. const
  1397. MAX_FVF_DECL_SIZE = 20;
  1398. {$EXTERNALSYM MAX_FVF_DECL_SIZE}
  1399. type
  1400. TFVFDeclaration = array [0..MAX_FVF_DECL_SIZE-1] of DWord;
  1401. PD3DXAttributeRange = ^TD3DXAttributeRange;
  1402. _D3DXATTRIBUTERANGE = packed record
  1403. AttribId: DWord;
  1404. FaceStart: DWord;
  1405. FaceCount: DWord;
  1406. VertexStart: DWord;
  1407. VertexCount: DWord;
  1408. end;
  1409. {$EXTERNALSYM _D3DXATTRIBUTERANGE}
  1410. D3DXATTRIBUTERANGE = _D3DXATTRIBUTERANGE;
  1411. {$EXTERNALSYM D3DXATTRIBUTERANGE}
  1412. TD3DXAttributeRange = _D3DXATTRIBUTERANGE;
  1413. PD3DXMaterial = ^TD3DXMaterial;
  1414. D3DXMATERIAL = packed record
  1415. MatD3D: TD3Dmaterial8;
  1416. pTextureFilename: PAnsiChar;
  1417. end;
  1418. {$EXTERNALSYM D3DXMATERIAL}
  1419. TD3DXMaterial = D3DXMATERIAL;
  1420. PD3DXAttributeWeights = ^TD3DXAttributeWeights;
  1421. _D3DXATTRIBUTEWEIGHTS = packed record
  1422. Position: Single;
  1423. Boundary: Single;
  1424. Normal: Single;
  1425. Diffuse: Single;
  1426. Specular: Single;
  1427. Tex: array[0..7] of Single;
  1428. end;
  1429. {$EXTERNALSYM _D3DXATTRIBUTEWEIGHTS}
  1430. D3DXATTRIBUTEWEIGHTS = _D3DXATTRIBUTEWEIGHTS;
  1431. {$EXTERNALSYM D3DXATTRIBUTEWEIGHTS}
  1432. TD3DXAttributeWeights = _D3DXATTRIBUTEWEIGHTS;
  1433. _D3DXWELDEPSILONSFLAGS = {$IFDEF TYPE_IDENTITY}type {$ENDIF}DWord;
  1434. {$EXTERNALSYM _D3DXWELDEPSILONSFLAGS}
  1435. TD3DXWeldEpsilonsFlags = _D3DXWELDEPSILONSFLAGS;
  1436. const
  1437. D3DXWELDEPSILONS_WELDALL = $1; // weld all vertices marked by adjacency as being overlapping
  1438. {$EXTERNALSYM D3DXWELDEPSILONS_WELDALL}
  1439. D3DXWELDEPSILONS_WELDPARTIALMATCHES = $2; // if a given vertex component is within epsilon, modify partial matched
  1440. // vertices so that both components identical AND if all components "equal"
  1441. // remove one of the vertices
  1442. {$EXTERNALSYM D3DXWELDEPSILONS_WELDPARTIALMATCHES}
  1443. D3DXWELDEPSILONS_DONOTREMOVEVERTICES = $4; // instructs weld to only allow modifications to vertices and not removal
  1444. // ONLY valid if D3DXWELDEPSILONS_WELDPARTIALMATCHES is set
  1445. // useful to modify vertices to be equal, but not allow vertices to be removed
  1446. {$EXTERNALSYM D3DXWELDEPSILONS_DONOTREMOVEVERTICES}
  1447. type
  1448. PD3DXWeldEpsilons = ^TD3DXWeldEpsilons;
  1449. _D3DXWELDEPSILONS = packed record
  1450. SkinWeights: Single;
  1451. Normal: Single;
  1452. Tex: array[0..7] of Single;
  1453. Flags: DWord;
  1454. end;
  1455. {$EXTERNALSYM _D3DXWELDEPSILONS}
  1456. D3DXWELDEPSILONS = _D3DXWELDEPSILONS;
  1457. {$EXTERNALSYM D3DXWELDEPSILONS}
  1458. TD3DXWeldEpsilons = _D3DXWELDEPSILONS;
  1459. ID3DXMesh = interface;
  1460. {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXBaseMesh);'}
  1461. {$EXTERNALSYM ID3DXBaseMesh}
  1462. ID3DXBaseMesh = interface(IUnknown)
  1463. ['{2A835771-BF4D-43f4-8E14-82A809F17D8A}']
  1464. // ID3DXBaseMesh
  1465. function DrawSubset(AttribId: DWord): HResult; stdcall;
  1466. function GetNumFaces: DWord; stdcall;
  1467. function GetNumVertices: DWord; stdcall;
  1468. function GetFVF: DWord; stdcall;
  1469. function GetDeclaration(out Declaration: TFVFDeclaration): HResult; stdcall;
  1470. function GetOptions: DWord; stdcall;
  1471. function GetDevice(out ppDevice: IDirect3DDevice8): HResult; stdcall;
  1472. function CloneMeshFVF(Options, FVF: DWord; ppDevice: IDirect3DDevice8;
  1473. out ppCloneMesh: ID3DXMesh): HResult; stdcall;
  1474. function CloneMesh(Options: DWord; pDeclaration: PDWord;
  1475. ppDevice: IDirect3DDevice8; out ppCloneMesh: ID3DXMesh): HResult; stdcall;
  1476. function GetVertexBuffer(out ppVB: IDirect3DVertexBuffer8): HResult; stdcall;
  1477. function GetIndexBuffer(out ppIB: IDirect3DIndexBuffer8): HResult; stdcall;
  1478. function LockVertexBuffer(Flags: DWord; out ppData: PByte): HResult; stdcall;
  1479. function UnlockVertexBuffer: HResult; stdcall;
  1480. function LockIndexBuffer(Flags: DWord; out ppData: PByte): HResult; stdcall;
  1481. function UnlockIndexBuffer: HResult; stdcall;
  1482. function GetAttributeTable(pAttribTable: PD3DXAttributeRange;
  1483. pAttribTableSize: PDWord): HResult; stdcall;
  1484. function ConvertPointRepsToAdjacency(pPRep: PDWord; pAdjacency: PDWord): HResult; stdcall;
  1485. function ConvertAdjacencyToPointReps(pAdjacency: PDWord; pPRep: PDWord): HResult; stdcall;
  1486. function GenerateAdjacency(Epsilon: Single; pAdjacency: PDWord): HResult; stdcall;
  1487. end;
  1488. {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXMesh);'}
  1489. {$EXTERNALSYM ID3DXMesh}
  1490. ID3DXMesh = interface(ID3DXBaseMesh)
  1491. ['{CCAE5C3B-4DD1-4d0f-997E-4684CA64557F}']
  1492. // ID3DXMesh
  1493. function LockAttributeBuffer(Flags: DWord; out ppData: PByte): HResult; stdcall;
  1494. function UnlockAttributeBuffer: HResult; stdcall;
  1495. function Optimize(Flags: DWord; pAdjacencyIn, pAdjacencyOut: PDWord;
  1496. pFaceRemap: PDWord; ppVertexRemap: PID3DXBuffer;
  1497. out ppOptMesh: ID3DXMesh): HResult; stdcall;
  1498. function OptimizeInplace(Flags: DWord; pAdjacencyIn, pAdjacencyOut: PDWord;
  1499. pFaceRemap: PDWord; ppVertexRemap: PID3DXBuffer): HResult; stdcall;
  1500. end;
  1501. {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXPMesh);'}
  1502. {$EXTERNALSYM ID3DXPMesh}
  1503. ID3DXPMesh = interface(ID3DXBaseMesh)
  1504. ['{19FBE386-C282-4659-97BD-CB869B084A6C}']
  1505. // ID3DXPMesh
  1506. function ClonePMeshFVF(Options, FVF: DWord; ppDevice: IDirect3DDevice8;
  1507. out ppCloneMesh: ID3DXPMesh): HResult; stdcall;
  1508. function ClonePMesh(Options: DWord; pDeclaration: PDWord;
  1509. ppDevice: IDirect3DDevice8; out ppCloneMesh: ID3DXPMesh): HResult; stdcall;
  1510. function SetNumFaces(Faces: DWord): HResult; stdcall;
  1511. function SetNumVertices(Vertices: DWord): HResult; stdcall;
  1512. function GetMaxFaces: DWord; stdcall;
  1513. function GetMinFaces: DWord; stdcall;
  1514. function GetMaxVertices: DWord; stdcall;
  1515. function GetMinVertices: DWord; stdcall;
  1516. function Save(pStream: IStream; pMaterials: PD3DXMaterial;
  1517. NumMaterials: DWord): HResult; stdcall;
  1518. function Optimize(Flags: DWord; pAdjacencyOut: PDWord;
  1519. pFaceRemap: PDWord; ppVertexRemap: PID3DXBuffer;
  1520. out ppOptMesh: ID3DXMesh): HResult; stdcall;
  1521. function OptimizeBaseLOD(Flags: DWord; pFaceRemap: PDWord): HResult; stdcall;
  1522. function TrimByFaces(NewFacesMin, NewFacesMax: DWord; rgiFaceRemap, rgiVertRemap: PDWord): HResult; stdcall;
  1523. function TrimByVertices(NewVerticesMin, NewVerticesMax: DWord; rgiFaceRemap, rgiVertRemap: PDWord): HResult; stdcall;
  1524. function GetAdjacency(pAdjacency: PDWord): HResult; stdcall;
  1525. end;
  1526. {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXSPMesh);'}
  1527. {$EXTERNALSYM ID3DXSPMesh}
  1528. ID3DXSPMesh = interface(IUnknown)
  1529. ['{4E3CA05C-D4FF-4d11-8A02-16459E08F6F4}']
  1530. // ID3DXSPMesh
  1531. function GetNumFaces: DWord; stdcall;
  1532. function GetNumVertices: DWord; stdcall;
  1533. function GetFVF: DWord; stdcall;
  1534. function GetDeclaration(out Declaration: TFVFDeclaration): HResult; stdcall;
  1535. function GetOptions: DWord; stdcall;
  1536. function GetDevice(out ppDevice: IDirect3DDevice8): HResult; stdcall;
  1537. function CloneMeshFVF(Options, FVF: DWord; ppDevice: IDirect3DDevice8;
  1538. pAdjacencyOut, pVertexRemapOut: PDWord;
  1539. out ppCloneMesh: ID3DXMesh): HResult; stdcall;
  1540. function CloneMesh(Options: DWord; pDeclaration: PDWord;
  1541. ppDevice: IDirect3DDevice8; pAdjacencyOut, pVertexRemapOut: PDWord;
  1542. out ppCloneMesh: ID3DXMesh): HResult; stdcall;
  1543. function ClonePMeshFVF(Options, FVF: DWord; ppDevice: IDirect3DDevice8;
  1544. pVertexRemapOut: PDWord; out ppCloneMesh: ID3DXPMesh): HResult; stdcall;
  1545. function ClonePMesh(Options: DWord; pDeclaration: PDWord;
  1546. ppDevice: IDirect3DDevice8; pVertexRemapOut: PDWord;
  1547. out ppCloneMesh: ID3DXPMesh): HResult; stdcall;
  1548. function ReduceFaces(Faces: DWord): HResult; stdcall;
  1549. function ReduceVertices(Vertices: DWord): HResult; stdcall;
  1550. function GetMaxFaces: DWord; stdcall;
  1551. function GetMaxVertices: DWord; stdcall;
  1552. function GetVertexAttributeWeights(pVertexAttributeWeights: PD3DXAttributeWeights): HResult; stdcall;
  1553. function GetVertexWeights(pVertexWeights: PSingle): HResult; stdcall;
  1554. end;
  1555. const
  1556. UNUSED16 = $ffff;
  1557. {$EXTERNALSYM UNUSED16}
  1558. UNUSED32 = $ffffffff;
  1559. {$EXTERNALSYM UNUSED32}
  1560. // ID3DXMesh::Optimize options - upper byte only, lower 3 bytes used from _D3DXMESH option flags
  1561. type
  1562. _D3DXMESHOPT = {$IFDEF TYPE_IDENTITY}type {$ENDIF}DWord;
  1563. {$EXTERNALSYM _D3DXMESHOPT}
  1564. TD3DXMeshOpt = _D3DXMESHOPT;
  1565. const
  1566. D3DXMESHOPT_COMPACT = $01000000;
  1567. {$EXTERNALSYM D3DXMESHOPT_COMPACT}
  1568. D3DXMESHOPT_ATTRSORT = $02000000;
  1569. {$EXTERNALSYM D3DXMESHOPT_ATTRSORT}
  1570. D3DXMESHOPT_VERTEXCACHE = $04000000;
  1571. {$EXTERNALSYM D3DXMESHOPT_VERTEXCACHE}
  1572. D3DXMESHOPT_STRIPREORDER = $08000000;
  1573. {$EXTERNALSYM D3DXMESHOPT_STRIPREORDER}
  1574. D3DXMESHOPT_IGNOREVERTS = $10000000; // optimize faces only; don't touch vertices
  1575. {$EXTERNALSYM D3DXMESHOPT_IGNOREVERTS}
  1576. D3DXMESHOPT_SHAREVB = $1000; // same as D3DXMESH_VB_SHARE
  1577. {$EXTERNALSYM D3DXMESHOPT_SHAREVB}
  1578. // Subset of the mesh that has the same attribute and bone combination.
  1579. // This subset can be rendered in a single draw call
  1580. type
  1581. PDWordArray = ^TDWordArray;
  1582. {$NODEFINE PDWordArray}
  1583. TDWordArray = array[0..8181] of DWord;
  1584. {$NODEFINE TDWordArray}
  1585. PD3DXBoneCombination = ^TD3DXBoneCombination;
  1586. _D3DXBONECOMBINATION = packed record
  1587. AttribId: DWord;
  1588. FaceStart: DWord;
  1589. FaceCount: DWord;
  1590. VertexStart: DWord;
  1591. VertexCount: DWord;
  1592. BoneId: PDWordArray; // [ DWORD* ] in original d3dx8mesh.h
  1593. end;
  1594. {$EXTERNALSYM _D3DXBONECOMBINATION}
  1595. D3DXBONECOMBINATION = _D3DXBONECOMBINATION;
  1596. {$EXTERNALSYM D3DXBONECOMBINATION}
  1597. TD3DXBoneCombination = _D3DXBONECOMBINATION;
  1598. {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXSkinMesh);'}
  1599. {$EXTERNALSYM ID3DXSkinMesh}
  1600. ID3DXSkinMesh = interface(IUnknown)
  1601. ['{8DB06ECC-EBFC-408a-9404-3074B4773515}']
  1602. // close to ID3DXMesh
  1603. function GetNumFaces: DWord; stdcall;
  1604. function GetNumVertices: DWord; stdcall;
  1605. function GetFVF: DWord; stdcall;
  1606. function GetDeclaration(out Declaration: TFVFDeclaration): HResult; stdcall;
  1607. function GetOptions: DWord; stdcall;
  1608. function GetDevice(out ppDevice: IDirect3DDevice8): HResult; stdcall;
  1609. function GetVertexBuffer(out ppVB: IDirect3DVertexBuffer8): HResult; stdcall;
  1610. function GetIndexBuffer(out ppIB: IDirect3DIndexBuffer8): HResult; stdcall;
  1611. function LockVertexBuffer(Flags: DWord; out ppData: PByte): HResult; stdcall;
  1612. function UnlockVertexBuffer: HResult; stdcall;
  1613. function LockIndexBuffer(Flags: DWord; out ppData: PByte): HResult; stdcall;
  1614. function UnlockIndexBuffer: HResult; stdcall;
  1615. function LockAttributeBuffer(Flags: DWord; out ppData: PByte): HResult; stdcall;
  1616. function UnlockAttributeBuffer: HResult; stdcall;
  1617. // ID3DXSkinMesh
  1618. function GetNumBones: DWord; stdcall;
  1619. function GetOriginalMesh(out ppMesh: ID3DXMesh): HResult; stdcall;
  1620. function SetBoneInfluence(bone, numInfluences: DWord; vertices: PDWord;
  1621. weights: PSingle): HResult; stdcall;
  1622. function GetNumBoneInfluences(bone: DWord): DWord; stdcall;
  1623. function GetBoneInfluence(bone: DWord; vertices: PDWord;
  1624. weights: PSingle): HResult; stdcall;
  1625. function GetMaxVertexInfluences(out maxVertexInfluences: DWord): HResult; stdcall;
  1626. function GetMaxFaceInfluences(out maxFaceInfluences: DWord): HResult; stdcall;
  1627. function ConvertToBlendedMesh(Options: DWord;
  1628. pAdjacencyIn, pAdjacencyOut: PDWord;
  1629. out pNumBoneCombinations: DWord; out ppBoneCombinationTable: ID3DXBuffer;
  1630. pFaceRemap: PDWord; ppVertexRemap: PID3DXBuffer;
  1631. out ppMesh: ID3DXMesh): HResult; stdcall;
  1632. function ConvertToIndexedBlendedMesh(Options: DWord;
  1633. pAdjacencyIn: PDWord; paletteSize: DWord; pAdjacencyOut: PDWord;
  1634. out pNumBoneCombinations: DWord; out ppBoneCombinationTable: ID3DXBuffer;
  1635. pFaceRemap: PDWord; ppVertexRemap: PID3DXBuffer;
  1636. out ppMesh: ID3DXMesh): HResult; stdcall;
  1637. function GenerateSkinnedMesh(Options: DWord; minWeight: Single;
  1638. pAdjacencyIn, pAdjacencyOut: PDWord;
  1639. pFaceRemap: PDWord; ppVertexRemap: PID3DXBuffer;
  1640. out ppMesh: ID3DXMesh): HResult; stdcall;
  1641. function UpdateSkinnedMesh(
  1642. const pBoneTransforms: TD3DXmatrix; pBoneInvTransforms: PD3DXmatrix;
  1643. ppMesh: ID3DXMesh): HResult; stdcall;
  1644. end;
  1645. type
  1646. IID_ID3DXBaseMesh = ID3DXBaseMesh;
  1647. {$EXTERNALSYM IID_ID3DXBaseMesh}
  1648. IID_ID3DXMesh = ID3DXMesh;
  1649. {$EXTERNALSYM IID_ID3DXMesh}
  1650. IID_ID3DXPMesh = ID3DXPMesh;
  1651. {$EXTERNALSYM IID_ID3DXPMesh}
  1652. IID_ID3DXSPMesh = ID3DXSPMesh;
  1653. {$EXTERNALSYM IID_ID3DXSPMesh}
  1654. IID_ID3DXSkinMesh = ID3DXSkinMesh;
  1655. {$EXTERNALSYM IID_ID3DXSkinMesh}
  1656. function D3DXCreateMesh(NumFaces, NumVertices: DWord; Options: DWord;
  1657. pDeclaration: PDWord; pD3D: IDirect3DDevice8; out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx8dll;
  1658. {$EXTERNALSYM D3DXCreateMesh}
  1659. function D3DXCreateMeshFVF(NumFaces, NumVertices: DWord; Options: DWord;
  1660. FVF: DWord; pD3D: IDirect3DDevice8; out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx8dll;
  1661. {$EXTERNALSYM D3DXCreateMeshFVF}
  1662. function D3DXCreateSPMesh(pMesh: ID3DXMesh; pAdjacency: PDWord;
  1663. pVertexAttributeWeights: PD3DXAttributeWeights; pVertexWeights: PSingle;
  1664. out ppSMesh: ID3DXSPMesh): HResult; stdcall; external d3dx8dll;
  1665. {$EXTERNALSYM D3DXCreateSPMesh}
  1666. // clean a mesh up for simplification, try to make manifold
  1667. function D3DXCleanMesh(pMeshIn: ID3DXMesh; pAdjacencyIn: PDWord;
  1668. out ppMeshOut: ID3DXMesh; pAdjacencyOut: PDWord;
  1669. ppErrorsAndWarnings: PID3DXBuffer): HResult; stdcall; external d3dx8dll;
  1670. {$EXTERNALSYM D3DXCleanMesh}
  1671. function D3DXValidMesh(pMeshIn: ID3DXMesh; pAdjacency: PDWord;
  1672. ppErrorsAndWarnings: PID3DXBuffer): HResult; stdcall; external d3dx8dll;
  1673. {$EXTERNALSYM D3DXValidMesh}
  1674. function D3DXGeneratePMesh(pMesh: ID3DXMesh; pAdjacency: PDWord;
  1675. pVertexAttributeWeights: PD3DXAttributeWeights; pVertexWeights: PSingle;
  1676. MinValue: DWord; Options: TD3DMeshSimp; out ppPMesh: ID3DXPMesh): HResult; stdcall; external d3dx8dll;
  1677. {$EXTERNALSYM D3DXGeneratePMesh}
  1678. function D3DXSimplifyMesh(pMesh: ID3DXMesh; pAdjacency: PDWord;
  1679. pVertexAttributeWeights: PD3DXAttributeWeights; pVertexWeights: PSingle;
  1680. MinValue: DWord; Options: TD3DMeshSimp; out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx8dll;
  1681. {$EXTERNALSYM D3DXSimplifyMesh}
  1682. function D3DXComputeBoundingSphere(const pPointsFVF; NumVertices: DWord;
  1683. FVF: DWord; out pCenter: TD3DXVector3; out pRadius: Single): HResult; stdcall; external d3dx8dll;
  1684. {$EXTERNALSYM D3DXComputeBoundingSphere}
  1685. function D3DXComputeBoundingBox(const pPointsFVF; NumVertices: DWord;
  1686. FVF: DWord; out pMin, pMax: TD3DXVector3): HResult; stdcall; external d3dx8dll;
  1687. {$EXTERNALSYM D3DXComputeBoundingBox}
  1688. function D3DXComputeNormals(pMesh: ID3DXBaseMesh; pAdjacency: PDWord): HResult; stdcall; external d3dx8dll;
  1689. {$EXTERNALSYM D3DXComputeNormals}
  1690. function D3DXCreateBuffer(NumBytes: DWord; out ppBuffer: ID3DXBuffer): HResult; stdcall; external d3dx8dll;
  1691. {$EXTERNALSYM D3DXCreateBuffer}
  1692. function D3DXLoadMeshFromX(pFilename: PAnsiChar; Options: DWord;
  1693. pD3D: IDirect3DDevice8; ppAdjacency, ppMaterials: PID3DXBuffer;
  1694. pNumMaterials: PDWord; out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx8dll;
  1695. {$EXTERNALSYM D3DXLoadMeshFromX}
  1696. function D3DXLoadMeshFromXInMemory(Memory: PByte; SizeOfMemory: DWord;
  1697. Options: DWord; pD3D: IDirect3DDevice8;
  1698. ppAdjacency, ppMaterials: PID3DXBuffer;
  1699. pNumMaterials: PDWord; out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx8dll;
  1700. {$EXTERNALSYM D3DXLoadMeshFromXInMemory}
  1701. function D3DXLoadMeshFromXResource(Module: HModule; Name: PAnsiChar; _Type: PAnsiChar;
  1702. Options: DWord; pD3D: IDirect3DDevice8;
  1703. ppAdjacency, ppMaterials: PID3DXBuffer;
  1704. pNumMaterials: PDWord; out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx8dll;
  1705. {$EXTERNALSYM D3DXLoadMeshFromXResource}
  1706. function D3DXSaveMeshToX(pFilename: PAnsiChar; ppMesh: ID3DXMesh;
  1707. pAdjacency: PDWord; pMaterials: PD3DXMaterial; NumMaterials: DWord;
  1708. Format: DWord): HResult; stdcall; external d3dx8dll;
  1709. {$EXTERNALSYM D3DXSaveMeshToX}
  1710. function D3DXCreatePMeshFromStream(pStream: IStream; Options: DWord;
  1711. pD3D: IDirect3DDevice8; ppMaterials: PID3DXBuffer;
  1712. pNumMaterials: PDWord; out ppPMesh: ID3DXPMesh): HResult; stdcall; external d3dx8dll;
  1713. {$EXTERNALSYM D3DXCreatePMeshFromStream}
  1714. function D3DXCreateSkinMesh(NumFaces, NumVertices, NumBones, Options: DWord;
  1715. pDeclaration: PDWord; pD3D: IDirect3DDevice8;
  1716. out ppSkinMesh: ID3DXSkinMesh): HResult; stdcall; external d3dx8dll;
  1717. {$EXTERNALSYM D3DXCreateSkinMesh}
  1718. function D3DXCreateSkinMeshFVF(NumFaces, NumVertices, NumBones, Options: DWord;
  1719. FVF: DWord; pD3D: IDirect3DDevice8;
  1720. out ppSkinMesh: ID3DXSkinMesh): HResult; stdcall; external d3dx8dll;
  1721. {$EXTERNALSYM D3DXCreateSkinMeshFVF}
  1722. function D3DXCreateSkinMeshFromMesh(pMesh: ID3DXMesh; numBones: DWord;
  1723. out ppSkinMesh: ID3DXSkinMesh): HResult; stdcall; external d3dx8dll;
  1724. {$EXTERNALSYM D3DXCreateSkinMeshFromMesh}
  1725. function D3DXLoadMeshFromXof(pXofObjMesh: IDirectXFileData;
  1726. Options: DWord; pD3D: IDirect3DDevice8;
  1727. ppAdjacency, ppMaterials: PID3DXBuffer;
  1728. pNumMaterials: PDWord; out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx8dll;
  1729. {$EXTERNALSYM D3DXLoadMeshFromXof}
  1730. function D3DXLoadSkinMeshFromXof(pXofObjMesh: IDirectXFileData;
  1731. Options: DWord; pD3D: IDirect3DDevice8;
  1732. ppAdjacency, ppMaterials: PID3DXBuffer;
  1733. pmMatOut: PDWord; ppBoneNames, ppBoneTransforms: PID3DXBuffer;
  1734. out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx8dll;
  1735. {$EXTERNALSYM D3DXLoadSkinMeshFromXof}
  1736. function D3DXTessellateNPatches(pMeshIn: ID3DXMesh;
  1737. pAdjacencyIn: PDWord; NumSegs: Single;
  1738. QuadraticInterpNormals: BOOL; // if false use linear intrep for normals, if true use quadratic
  1739. out ppMeshOut: ID3DXMesh; ppAdjacencyOut: PDWord): HResult; stdcall; external d3dx8dll;
  1740. {$EXTERNALSYM D3DXTessellateNPatches}
  1741. function D3DXGetFVFVertexSize(FVF: DWord): LongWord; stdcall; external d3dx8dll;
  1742. {$EXTERNALSYM D3DXGetFVFVertexSize}
  1743. function D3DXDeclaratorFromFVF(FVF: DWord; out Declaration: TFVFDeclaration): HResult; stdcall; external d3dx8dll;
  1744. {$EXTERNALSYM D3DXDeclaratorFromFVF}
  1745. function D3DXFVFFromDeclarator(pDeclarator: PDWord; out pFVF: DWord): HResult; stdcall; external d3dx8dll;
  1746. {$EXTERNALSYM D3DXFVFFromDeclarator}
  1747. function D3DXWeldVertices(pMesh: ID3DXMesh; pEpsilons: PD3DXWeldEpsilons;
  1748. rgdwAdjacencyIn, rgdwAdjacencyOut, pFaceRemap: PDWord;
  1749. ppVertexRemap: PID3DXBuffer): HResult; stdcall; external d3dx8dll;
  1750. {$EXTERNALSYM D3DXWeldVertices}
  1751. type
  1752. PD3DXIntersectInfo = ^TD3DXIntersectInfo;
  1753. _D3DXINTERSECTINFO = packed record
  1754. FaceIndex: DWord; // index of face intersected
  1755. U: Single; // Barycentric Hit Coordinates
  1756. V: Single; // Barycentric Hit Coordinates
  1757. Dist: Single; // Ray-Intersection Parameter Distance
  1758. end;
  1759. {$EXTERNALSYM _D3DXINTERSECTINFO}
  1760. D3DXINTERSECTINFO = _D3DXINTERSECTINFO;
  1761. {$EXTERNALSYM D3DXINTERSECTINFO}
  1762. TD3DXIntersectInfo = _D3DXINTERSECTINFO;
  1763. function D3DXIntersect(pMesh: ID3DXBaseMesh;
  1764. const pRayPos, pRayDir: TD3DXVector3;
  1765. out pHit: BOOL; // True if any faces were intersected
  1766. pFaceIndex: PDWord; // index of closest face intersected
  1767. pU: PSingle; // Barycentric Hit Coordinates
  1768. pV: PSingle; // Barycentric Hit Coordinates
  1769. pDist: PSingle; // Ray-Intersection Parameter Distance
  1770. ppAllHits: PID3DXBuffer; // Array of D3DXINTERSECTINFOs for all hits (not just closest)
  1771. pCountOfHits: PDWord // Number of entries in AllHits array
  1772. ): HResult; stdcall; external d3dx8dll;
  1773. {$EXTERNALSYM D3DXIntersect}
  1774. function D3DXIntersectSubset(pMesh: ID3DXBaseMesh; AttribId: DWord;
  1775. const pRayPos, pRayDir: TD3DXVector3;
  1776. out pHit: BOOL; // True if any faces were intersected
  1777. pFaceIndex: PDWord; // index of closest face intersected
  1778. pU: PSingle; // Barycentric Hit Coordinates
  1779. pV: PSingle; // Barycentric Hit Coordinates
  1780. pDist: PSingle; // Ray-Intersection Parameter Distance
  1781. ppAllHits: PID3DXBuffer; // Array of D3DXINTERSECTINFOs for all hits (not just closest)
  1782. pCountOfHits: PDWord // Number of entries in AllHits array
  1783. ): HResult; stdcall; external d3dx8dll;
  1784. {$EXTERNALSYM D3DXIntersectSubset}
  1785. function D3DXSplitMesh(pMeshIn: ID3DXMesh; pAdjacencyIn: PDWord;
  1786. MaxSize, Options: DWord;
  1787. out pMeshesOut: DWord; out ppMeshArrayOut: ID3DXBuffer;
  1788. ppAdjacencyArrayOut, ppFaceRemapArrayOut, ppVertRemapArrayOut: PID3DXBuffer
  1789. ): HResult; stdcall; external d3dx8dll;
  1790. {$EXTERNALSYM D3DXSplitMesh}
  1791. function D3DXIntersectTri(
  1792. const p0: TD3DXVector3; // Triangle vertex 0 position
  1793. const p1: TD3DXVector3; // Triangle vertex 1 position
  1794. const p2: TD3DXVector3; // Triangle vertex 2 position
  1795. const pRayPos: TD3DXVector3; // Ray origin
  1796. const pRayDir: TD3DXVector3; // Ray direction
  1797. out pU: Single; // Barycentric Hit Coordinates
  1798. out pV: Single; // Barycentric Hit Coordinates
  1799. out pDist: Single // Ray-Intersection Parameter Distance
  1800. ): HResult; stdcall; external d3dx8dll;
  1801. {$EXTERNALSYM D3DXIntersectTri}
  1802. function D3DXSphereBoundProbe(const pCenter: TD3DXVector3; Radius: Single;
  1803. out pRayPosition, pRayDirection: TD3DXVector3): BOOL; stdcall; external d3dx8dll;
  1804. {$EXTERNALSYM D3DXSphereBoundProbe}
  1805. function D3DXBoxBoundProbe(const pMin, pMax: TD3DXVector3;
  1806. out pRayPosition, pRayDirection: TD3DXVector3): BOOL; stdcall; external d3dx8dll;
  1807. {$EXTERNALSYM D3DXBoxBoundProbe}
  1808. type
  1809. _D3DXERR = HResult;
  1810. {$EXTERNALSYM _D3DXERR}
  1811. {$IFDEF DXG_COMPAT}
  1812. const
  1813. MAKE_D3DHRESULT_R = MAKE_D3DHRESULT;
  1814. {$ENDIF}
  1815. const
  1816. D3DXERR_CANNOTMODIFYINDEXBUFFER = HResult(MAKE_D3DHRESULT_R or 2900);
  1817. {$EXTERNALSYM D3DXERR_CANNOTMODIFYINDEXBUFFER}
  1818. D3DXERR_INVALIDMESH = HResult(MAKE_D3DHRESULT_R or 2901);
  1819. {$EXTERNALSYM D3DXERR_INVALIDMESH}
  1820. D3DXERR_CANNOTATTRSORT = HResult(MAKE_D3DHRESULT_R or 2902);
  1821. {$EXTERNALSYM D3DXERR_CANNOTATTRSORT}
  1822. D3DXERR_SKINNINGNOTSUPPORTED = HResult(MAKE_D3DHRESULT_R or 2903);
  1823. {$EXTERNALSYM D3DXERR_SKINNINGNOTSUPPORTED}
  1824. D3DXERR_TOOMANYINFLUENCES = HResult(MAKE_D3DHRESULT_R or 2904);
  1825. {$EXTERNALSYM D3DXERR_TOOMANYINFLUENCES}
  1826. D3DXERR_INVALIDDATA = HResult(MAKE_D3DHRESULT_R or 2905);
  1827. {$EXTERNALSYM D3DXERR_INVALIDDATA}
  1828. D3DXERR_LOADEDMESHASNODATA = HResult(MAKE_D3DHRESULT_R or 2906);
  1829. {$EXTERNALSYM D3DXERR_LOADEDMESHASNODATA}
  1830. const
  1831. D3DX_COMP_TANGENT_NONE = $FFFFFFFF;
  1832. {$EXTERNALSYM D3DX_COMP_TANGENT_NONE}
  1833. function D3DXComputeTangent(InMesh: ID3DXMesh; TexStage: DWord;
  1834. OutMesh: ID3DXMesh; TexStageUVec, TexStageVVec: DWord;
  1835. Wrap: DWord; Adjacency: PDWord): HResult; stdcall; external d3dx8dll;
  1836. {$EXTERNALSYM D3DXComputeTangent}
  1837. function D3DXConvertMeshSubsetToSingleStrip(MeshIn: ID3DXBaseMesh;
  1838. AttribId: DWord; IBOptions: DWord;
  1839. out ppIndexBuffer: IDirect3DIndexBuffer8; pNumIndices: PDWord
  1840. ): HResult; stdcall; external d3dx8dll;
  1841. {$EXTERNALSYM D3DXConvertMeshSubsetToSingleStrip}
  1842. function D3DXConvertMeshSubsetToStrips(MeshIn: ID3DXBaseMesh;
  1843. AttribId: DWord; IBOptions: DWord;
  1844. out ppIndexBuffer: IDirect3DIndexBuffer8; pNumIndices: PDWord;
  1845. ppStripLengths: PID3DXBuffer; pNumStrips: PDWord): HResult; stdcall; external d3dx8dll;
  1846. {$EXTERNALSYM D3DXConvertMeshSubsetToStrips}
  1847. ///////////////////////////////////////////////////////////////////////////
  1848. //
  1849. // Copyright (C) Microsoft Corporation. All Rights Reserved.
  1850. //
  1851. // File: d3dx8shapes.h
  1852. // Content: D3DX simple shapes
  1853. //
  1854. ///////////////////////////////////////////////////////////////////////////
  1855. ///////////////////////////////////////////////////////////////////////////
  1856. // Functions:
  1857. ///////////////////////////////////////////////////////////////////////////
  1858. //-------------------------------------------------------------------------
  1859. // D3DXCreatePolygon:
  1860. // ------------------
  1861. // Creates a mesh containing an n-sided polygon. The polygon is centered
  1862. // at the origin.
  1863. //
  1864. // Parameters:
  1865. //
  1866. // pDevice The D3D device with which the mesh is going to be used.
  1867. // Length Length of each side.
  1868. // Sides Number of sides the polygon has. (Must be >= 3)
  1869. // ppMesh The mesh object which will be created
  1870. // ppAdjacency Returns a buffer containing adjacency info. Can be NULL.
  1871. //-------------------------------------------------------------------------
  1872. function D3DXCreatePolygon(ppDevice: IDirect3DDevice8;
  1873. Length: Single;
  1874. Sides: LongWord;
  1875. out ppMesh: ID3DXMesh;
  1876. ppAdjacency: PID3DXBuffer): HResult; stdcall; external d3dx8dll;
  1877. {$EXTERNALSYM D3DXCreatePolygon}
  1878. //-------------------------------------------------------------------------
  1879. // D3DXCreateBox:
  1880. // --------------
  1881. // Creates a mesh containing an axis-aligned box. The box is centered at
  1882. // the origin.
  1883. //
  1884. // Parameters:
  1885. //
  1886. // pDevice The D3D device with which the mesh is going to be used.
  1887. // Width Width of box (along X-axis)
  1888. // Height Height of box (along Y-axis)
  1889. // Depth Depth of box (along Z-axis)
  1890. // ppMesh The mesh object which will be created
  1891. // ppAdjacency Returns a buffer containing adjacency info. Can be NULL.
  1892. //-------------------------------------------------------------------------
  1893. function D3DXCreateBox(ppDevice: IDirect3DDevice8;
  1894. Width,
  1895. Height,
  1896. Depth: Single;
  1897. out ppMesh: ID3DXMesh;
  1898. ppAdjacency: PID3DXBuffer): HResult; stdcall; external d3dx8dll;
  1899. {$EXTERNALSYM D3DXCreateBox}
  1900. //-------------------------------------------------------------------------
  1901. // D3DXCreateCylinder:
  1902. // -------------------
  1903. // Creates a mesh containing a cylinder. The generated cylinder is
  1904. // centered at the origin, and its axis is aligned with the Z-axis.
  1905. //
  1906. // Parameters:
  1907. //
  1908. // pDevice The D3D device with which the mesh is going to be used.
  1909. // Radius1 Radius at -Z end (should be >= 0.0f)
  1910. // Radius2 Radius at +Z end (should be >= 0.0f)
  1911. // Length Length of cylinder (along Z-axis)
  1912. // Slices Number of slices about the main axis
  1913. // Stacks Number of stacks along the main axis
  1914. // ppMesh The mesh object which will be created
  1915. // ppAdjacency Returns a buffer containing adjacency info. Can be NULL.
  1916. //-------------------------------------------------------------------------
  1917. function D3DXCreateCylinder(ppDevice: IDirect3DDevice8;
  1918. Radius1,
  1919. Radius2,
  1920. Length: Single;
  1921. Slices,
  1922. Stacks: LongWord;
  1923. out ppMesh: ID3DXMesh;
  1924. ppAdjacency: PID3DXBuffer): HResult; stdcall; external d3dx8dll;
  1925. {$EXTERNALSYM D3DXCreateCylinder}
  1926. //-------------------------------------------------------------------------
  1927. // D3DXCreateSphere:
  1928. // -----------------
  1929. // Creates a mesh containing a sphere. The sphere is centered at the
  1930. // origin.
  1931. //
  1932. // Parameters:
  1933. //
  1934. // pDevice The D3D device with which the mesh is going to be used.
  1935. // Radius Radius of the sphere (should be >= 0.0f)
  1936. // Slices Number of slices about the main axis
  1937. // Stacks Number of stacks along the main axis
  1938. // ppMesh The mesh object which will be created
  1939. // ppAdjacency Returns a buffer containing adjacency info. Can be NULL.
  1940. //-------------------------------------------------------------------------
  1941. function D3DXCreateSphere(ppDevice: IDirect3DDevice8;
  1942. Radius: Single;
  1943. Slices,
  1944. Stacks: LongWord;
  1945. out ppMesh: ID3DXMesh;
  1946. ppAdjacency: PID3DXBuffer): HResult; stdcall; external d3dx8dll;
  1947. {$EXTERNALSYM D3DXCreateSphere}
  1948. //-------------------------------------------------------------------------
  1949. // D3DXCreateTorus:
  1950. // ----------------
  1951. // Creates a mesh containing a torus. The generated torus is centered at
  1952. // the origin, and its axis is aligned with the Z-axis.
  1953. //
  1954. // Parameters:
  1955. //
  1956. // pDevice The D3D device with which the mesh is going to be used.
  1957. // InnerRadius Inner radius of the torus (should be >= 0.0f)
  1958. // OuterRadius Outer radius of the torue (should be >= 0.0f)
  1959. // Sides Number of sides in a cross-section (must be >= 3)
  1960. // Rings Number of rings making up the torus (must be >= 3)
  1961. // ppMesh The mesh object which will be created
  1962. // ppAdjacency Returns a buffer containing adjacency info. Can be NULL.
  1963. //-------------------------------------------------------------------------
  1964. function D3DXCreateTorus(ppDevice: IDirect3DDevice8;
  1965. InnerRadius,
  1966. OuterRadius: Single;
  1967. Sides,
  1968. Rings: LongWord;
  1969. out ppMesh: ID3DXMesh;
  1970. ppAdjacency: PID3DXBuffer): HResult; stdcall; external d3dx8dll;
  1971. {$EXTERNALSYM D3DXCreateTorus}
  1972. //-------------------------------------------------------------------------
  1973. // D3DXCreateTeapot:
  1974. // -----------------
  1975. // Creates a mesh containing a teapot.
  1976. //
  1977. // Parameters:
  1978. //
  1979. // pDevice The D3D device with which the mesh is going to be used.
  1980. // ppMesh The mesh object which will be created
  1981. // ppAdjacency Returns a buffer containing adjacency info. Can be NULL.
  1982. //-------------------------------------------------------------------------
  1983. function D3DXCreateTeapot(ppDevice: IDirect3DDevice8;
  1984. out ppMesh: ID3DXMesh;
  1985. ppAdjacency: PID3DXBuffer): HResult; stdcall; external d3dx8dll;
  1986. {$EXTERNALSYM D3DXCreateTeapot}
  1987. //-------------------------------------------------------------------------
  1988. // D3DXCreateText:
  1989. // ---------------
  1990. // Creates a mesh containing the specified text using the font associated
  1991. // with the device context.
  1992. //
  1993. // Parameters:
  1994. //
  1995. // pDevice The D3D device with which the mesh is going to be used.
  1996. // hDC Device context, with desired font selected
  1997. // pText Text to generate
  1998. // Deviation Maximum chordal deviation from true font outlines
  1999. // Extrusion Amount to extrude text in -Z direction
  2000. // ppMesh The mesh object which will be created
  2001. // pGlyphMetrics Address of buffer to receive glyph metric data (or NULL)
  2002. //-------------------------------------------------------------------------
  2003. function D3DXCreateTextA(ppDevice: IDirect3DDevice8;
  2004. hDC: HDC;
  2005. pText: PAnsiChar;
  2006. Deviation: Single;
  2007. Extrusion: Single;
  2008. out ppMesh: ID3DXMesh;
  2009. ppAdjacency: PID3DXBuffer;
  2010. pGlyphMetrics: PGlyphMetricsFloat): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextA';
  2011. {$EXTERNALSYM D3DXCreateTextA}
  2012. function D3DXCreateTextW(ppDevice: IDirect3DDevice8;
  2013. hDC: HDC;
  2014. pText: PWideChar;
  2015. Deviation: Single;
  2016. Extrusion: Single;
  2017. out ppMesh: ID3DXMesh;
  2018. ppAdjacency: PID3DXBuffer;
  2019. pGlyphMetrics: PGlyphMetricsFloat): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextW';
  2020. {$EXTERNALSYM D3DXCreateTextW}
  2021. function D3DXCreateText(ppDevice: IDirect3DDevice8;
  2022. hDC: HDC;
  2023. pText: PChar;
  2024. Deviation: Single;
  2025. Extrusion: Single;
  2026. out ppMesh: ID3DXMesh;
  2027. ppAdjacency: PID3DXBuffer;
  2028. pGlyphMetrics: PGlyphMetricsFloat): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextA';
  2029. {$EXTERNALSYM D3DXCreateText}
  2030. //////////////////////////////////////////////////////////////////////////////
  2031. //
  2032. // Copyright (C) Microsoft Corporation. All Rights Reserved.
  2033. //
  2034. // File: d3dx8tex.h
  2035. // Content: D3DX texturing APIs
  2036. //
  2037. //////////////////////////////////////////////////////////////////////////////
  2038. //----------------------------------------------------------------------------
  2039. // D3DX_FILTER flags:
  2040. // ------------------
  2041. //
  2042. // A valid filter must contain one of these values:
  2043. //
  2044. // D3DX_FILTER_NONE
  2045. // No scaling or filtering will take place. Pixels outside the bounds
  2046. // of the source image are assumed to be transparent black.
  2047. // D3DX_FILTER_POINT
  2048. // Each destination pixel is computed by sampling the nearest pixel
  2049. // from the source image.
  2050. // D3DX_FILTER_LINEAR
  2051. // Each destination pixel is computed by linearly interpolating between
  2052. // the nearest pixels in the source image. This filter works best
  2053. // when the scale on each axis is less than 2.
  2054. // D3DX_FILTER_TRIANGLE
  2055. // Every pixel in the source image contributes equally to the
  2056. // destination image. This is the slowest of all the filters.
  2057. // D3DX_FILTER_BOX
  2058. // Each pixel is computed by averaging a 2x2(x2) box pixels from
  2059. // the source image. Only works when the dimensions of the
  2060. // destination are half those of the source. (as with mip maps)
  2061. //
  2062. // And can be OR'd with any of these optional flags:
  2063. //
  2064. // D3DX_FILTER_MIRROR_U
  2065. // Indicates that pixels off the edge of the texture on the U-axis
  2066. // should be mirrored, not wraped.
  2067. // D3DX_FILTER_MIRROR_V
  2068. // Indicates that pixels off the edge of the texture on the V-axis
  2069. // should be mirrored, not wraped.
  2070. // D3DX_FILTER_MIRROR_W
  2071. // Indicates that pixels off the edge of the texture on the W-axis
  2072. // should be mirrored, not wraped.
  2073. // D3DX_FILTER_MIRROR
  2074. // Same as specifying D3DX_FILTER_MIRROR_U | D3DX_FILTER_MIRROR_V |
  2075. // D3DX_FILTER_MIRROR_V
  2076. // D3DX_FILTER_DITHER
  2077. // Dithers the resulting image.
  2078. //
  2079. //----------------------------------------------------------------------------
  2080. const
  2081. D3DX_FILTER_NONE = (1 shl 0);
  2082. {$EXTERNALSYM D3DX_FILTER_NONE}
  2083. D3DX_FILTER_POINT = (2 shl 0);
  2084. {$EXTERNALSYM D3DX_FILTER_POINT}
  2085. D3DX_FILTER_LINEAR = (3 shl 0);
  2086. {$EXTERNALSYM D3DX_FILTER_LINEAR}
  2087. D3DX_FILTER_TRIANGLE = (4 shl 0);
  2088. {$EXTERNALSYM D3DX_FILTER_TRIANGLE}
  2089. D3DX_FILTER_BOX = (5 shl 0);
  2090. {$EXTERNALSYM D3DX_FILTER_BOX}
  2091. D3DX_FILTER_MIRROR_U = (1 shl 16);
  2092. {$EXTERNALSYM D3DX_FILTER_MIRROR_U}
  2093. D3DX_FILTER_MIRROR_V = (2 shl 16);
  2094. {$EXTERNALSYM D3DX_FILTER_MIRROR_V}
  2095. D3DX_FILTER_MIRROR_W = (4 shl 16);
  2096. {$EXTERNALSYM D3DX_FILTER_MIRROR_W}
  2097. D3DX_FILTER_MIRROR = (7 shl 16);
  2098. {$EXTERNALSYM D3DX_FILTER_MIRROR}
  2099. D3DX_FILTER_DITHER = (8 shl 16);
  2100. {$EXTERNALSYM D3DX_FILTER_DITHER}
  2101. //----------------------------------------------------------------------------
  2102. // D3DX_NORMALMAP flags:
  2103. // ---------------------
  2104. // These flags are used to control how D3DXComputeNormalMap generates normal
  2105. // maps. Any number of these flags may be OR'd together in any combination.
  2106. //
  2107. // D3DX_NORMALMAP_MIRROR_U
  2108. // Indicates that pixels off the edge of the texture on the U-axis
  2109. // should be mirrored, not wraped.
  2110. // D3DX_NORMALMAP_MIRROR_V
  2111. // Indicates that pixels off the edge of the texture on the V-axis
  2112. // should be mirrored, not wraped.
  2113. // D3DX_NORMALMAP_MIRROR
  2114. // Same as specifying D3DX_NORMALMAP_MIRROR_U | D3DX_NORMALMAP_MIRROR_V
  2115. // D3DX_NORMALMAP_INVERTSIGN
  2116. // Inverts the direction of each normal
  2117. // D3DX_NORMALMAP_COMPUTE_OCCLUSION
  2118. // Compute the per pixel Occlusion term and encodes it into the alpha.
  2119. // An Alpha of 1 means that the pixel is not obscured in anyway, and
  2120. // an alpha of 0 would mean that the pixel is completly obscured.
  2121. //
  2122. //----------------------------------------------------------------------------
  2123. //----------------------------------------------------------------------------
  2124. const
  2125. D3DX_NORMALMAP_MIRROR_U = (1 shl 16);
  2126. {$EXTERNALSYM D3DX_NORMALMAP_MIRROR_U}
  2127. D3DX_NORMALMAP_MIRROR_V = (2 shl 16);
  2128. {$EXTERNALSYM D3DX_NORMALMAP_MIRROR_V}
  2129. D3DX_NORMALMAP_MIRROR = (3 shl 16);
  2130. {$EXTERNALSYM D3DX_NORMALMAP_MIRROR}
  2131. D3DX_NORMALMAP_INVERTSIGN = (8 shl 16);
  2132. {$EXTERNALSYM D3DX_NORMALMAP_INVERTSIGN}
  2133. D3DX_NORMALMAP_COMPUTE_OCCLUSION = (16 shl 16);
  2134. {$EXTERNALSYM D3DX_NORMALMAP_COMPUTE_OCCLUSION}
  2135. //----------------------------------------------------------------------------
  2136. // D3DX_CHANNEL flags:
  2137. // -------------------
  2138. // These flags are used by functions which operate on or more channels
  2139. // in a texture.
  2140. //
  2141. // D3DX_CHANNEL_RED
  2142. // Indicates the red channel should be used
  2143. // D3DX_CHANNEL_BLUE
  2144. // Indicates the blue channel should be used
  2145. // D3DX_CHANNEL_GREEN
  2146. // Indicates the green channel should be used
  2147. // D3DX_CHANNEL_ALPHA
  2148. // Indicates the alpha channel should be used
  2149. // D3DX_CHANNEL_LUMINANCE
  2150. // Indicates the luminaces of the red green and blue channels should be
  2151. // used.
  2152. //
  2153. //----------------------------------------------------------------------------
  2154. const
  2155. D3DX_CHANNEL_RED = (1 shl 0);
  2156. {$EXTERNALSYM D3DX_CHANNEL_RED}
  2157. D3DX_CHANNEL_BLUE = (1 shl 1);
  2158. {$EXTERNALSYM D3DX_CHANNEL_BLUE}
  2159. D3DX_CHANNEL_GREEN = (1 shl 2);
  2160. {$EXTERNALSYM D3DX_CHANNEL_GREEN}
  2161. D3DX_CHANNEL_ALPHA = (1 shl 3);
  2162. {$EXTERNALSYM D3DX_CHANNEL_ALPHA}
  2163. D3DX_CHANNEL_LUMINANCE = (1 shl 4);
  2164. {$EXTERNALSYM D3DX_CHANNEL_LUMINANCE}
  2165. //----------------------------------------------------------------------------
  2166. // D3DXIMAGE_FILEFORMAT:
  2167. // ---------------------
  2168. // This enum is used to describe supported image file formats.
  2169. //
  2170. //----------------------------------------------------------------------------
  2171. type
  2172. PD3DXImageFileFormat = ^TD3DXImageFileFormat;
  2173. _D3DXIMAGE_FILEFORMAT = (
  2174. D3DXIFF_BMP {= 0},
  2175. D3DXIFF_JPG {= 1},
  2176. D3DXIFF_TGA {= 2},
  2177. D3DXIFF_PNG {= 3},
  2178. D3DXIFF_DDS {= 4},
  2179. D3DXIFF_PPM {= 5},
  2180. D3DXIFF_DIB {= 6}
  2181. );
  2182. {$EXTERNALSYM _D3DXIMAGE_FILEFORMAT}
  2183. D3DXIMAGE_FILEFORMAT = _D3DXIMAGE_FILEFORMAT;
  2184. {$EXTERNALSYM D3DXIMAGE_FILEFORMAT}
  2185. TD3DXImageFileFormat = _D3DXIMAGE_FILEFORMAT;
  2186. //----------------------------------------------------------------------------
  2187. // LPD3DXFILL2D and LPD3DXFILL3D:
  2188. // ------------------------------
  2189. // Function types used by the texture fill functions.
  2190. //
  2191. // Parameters:
  2192. // pOut
  2193. // Pointer to a vector which the function uses to return its result.
  2194. // X,Y,Z,W will be mapped to R,G,B,A respectivly.
  2195. // pTexCoord
  2196. // Pointer to a vector containing the coordinates of the texel currently
  2197. // being evaluated. Textures and VolumeTexture texcoord components
  2198. // range from 0 to 1. CubeTexture texcoord component range from -1 to 1.
  2199. // pTexelSize
  2200. // Pointer to a vector containing the dimensions of the current texel.
  2201. // pData
  2202. // Pointer to user data.
  2203. //
  2204. //----------------------------------------------------------------------------
  2205. type
  2206. // typedef VOID (*LPD3DXFILL2D)(D3DXVECTOR4 *pOut, D3DXVECTOR2 *pTexCoord, D3DXVECTOR2 *pTexelSize, LPVOID pData);
  2207. LPD3DXFILL2D = procedure (out pOut: TD3DXVector4; const pTexCoord, pTexelSize: TD3DXVector2; var pData);
  2208. {$EXTERNALSYM LPD3DXFILL2D}
  2209. TD3DXFill2D = LPD3DXFILL2D;
  2210. // typedef VOID (*LPD3DXFILL3D)(D3DXVECTOR4 *pOut, D3DXVECTOR3 *pTexCoord, D3DXVECTOR3 *pTexelSize, LPVOID pData);
  2211. LPD3DXFILL3D = procedure (out pOut: TD3DXVector4; const pTexCoord, pTexelSize: TD3DXVector3; var pData);
  2212. {$EXTERNALSYM LPD3DXFILL3D}
  2213. TD3DXFill3D = LPD3DXFILL3D;
  2214. //----------------------------------------------------------------------------
  2215. // D3DXIMAGE_INFO:
  2216. // ---------------
  2217. // This structure is used to return a rough description of what the
  2218. // the original contents of an image file looked like.
  2219. //
  2220. // Width
  2221. // Width of original image in pixels
  2222. // Height
  2223. // Height of original image in pixels
  2224. // Depth
  2225. // Depth of original image in pixels
  2226. // MipLevels
  2227. // Number of mip levels in original image
  2228. // Format
  2229. // D3D format which most closely describes the data in original image
  2230. // ResourceType
  2231. // D3DRESOURCETYPE representing the type of texture stored in the file.
  2232. // D3DRTYPE_TEXTURE, D3DRTYPE_VOLUMETEXTURE, or D3DRTYPE_CUBETEXTURE.
  2233. // ImageFileFormat
  2234. // D3DXIMAGE_FILEFORMAT representing the format of the image file.
  2235. //
  2236. //----------------------------------------------------------------------------
  2237. type
  2238. PD3DXImageInfo = ^TD3DXImageInfo;
  2239. _D3DXIMAGE_INFO = packed record
  2240. Width: LongWord;
  2241. Height: LongWord;
  2242. Depth: LongWord;
  2243. MipLevels: LongWord;
  2244. Format: TD3DFormat;
  2245. ResourceType: TD3DResourceType;
  2246. ImageFileFormat: TD3DXImageFileFormat;
  2247. end;
  2248. {$EXTERNALSYM _D3DXIMAGE_INFO}
  2249. D3DXIMAGE_INFO = _D3DXIMAGE_INFO;
  2250. {$EXTERNALSYM D3DXIMAGE_INFO}
  2251. TD3DXImageInfo = _D3DXIMAGE_INFO;
  2252. //////////////////////////////////////////////////////////////////////////////
  2253. // Image File APIs ///////////////////////////////////////////////////////////
  2254. //////////////////////////////////////////////////////////////////////////////
  2255. //----------------------------------------------------------------------------
  2256. // GetImageInfoFromFile/Resource:
  2257. // ------------------------------
  2258. // Fills in a D3DXIMAGE_INFO struct with information about an image file.
  2259. //
  2260. // Parameters:
  2261. // pSrcFile
  2262. // File name of the source image.
  2263. // pSrcModule
  2264. // Module where resource is located, or NULL for module associated
  2265. // with image the os used to create the current process.
  2266. // pSrcResource
  2267. // Resource name
  2268. // pSrcData
  2269. // Pointer to file in memory.
  2270. // SrcDataSize
  2271. // Size in bytes of file in memory.
  2272. // pSrcInfo
  2273. // Pointer to a D3DXIMAGE_INFO structure to be filled in with the
  2274. // description of the data in the source image file.
  2275. //
  2276. //----------------------------------------------------------------------------
  2277. function D3DXGetImageInfoFromFileA(
  2278. pSrcFile: PAnsiChar;
  2279. out pSrcInfo: TD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXGetImageInfoFromFileA';
  2280. {$EXTERNALSYM D3DXGetImageInfoFromFileA}
  2281. function D3DXGetImageInfoFromFileW(
  2282. pSrcFile: PWideChar;
  2283. out pSrcInfo: TD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXGetImageInfoFromFileW';
  2284. {$EXTERNALSYM D3DXGetImageInfoFromFileW}
  2285. function D3DXGetImageInfoFromFile(
  2286. pSrcFile: PChar;
  2287. out pSrcInfo: TD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXGetImageInfoFromFileA';
  2288. {$EXTERNALSYM D3DXGetImageInfoFromFile}
  2289. function D3DXGetImageInfoFromResourceA(
  2290. hSrcModule: HModule;
  2291. pSrcResource: PAnsiChar;
  2292. out pSrcInfo: TD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXGetImageInfoFromResourceA';
  2293. {$EXTERNALSYM D3DXGetImageInfoFromResourceA}
  2294. function D3DXGetImageInfoFromResourceW(
  2295. hSrcModule: HModule;
  2296. pSrcResource: PWideChar;
  2297. out pSrcInfo: TD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXGetImageInfoFromResourceW';
  2298. {$EXTERNALSYM D3DXGetImageInfoFromResourceW}
  2299. function D3DXGetImageInfoFromResource(
  2300. hSrcModule: HModule;
  2301. pSrcResource: PChar;
  2302. out pSrcInfo: TD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXGetImageInfoFromResourceA';
  2303. {$EXTERNALSYM D3DXGetImageInfoFromResource}
  2304. function D3DXGetImageInfoFromFileInMemory(
  2305. const pSrcData;
  2306. SrcDataSize: LongWord;
  2307. out pSrcInfo: TD3DXImageInfo): HResult; stdcall; external d3dx8dll;
  2308. {$EXTERNALSYM D3DXGetImageInfoFromFileInMemory}
  2309. //////////////////////////////////////////////////////////////////////////////
  2310. // Load/Save Surface APIs ////////////////////////////////////////////////////
  2311. //////////////////////////////////////////////////////////////////////////////
  2312. //----------------------------------------------------------------------------
  2313. // D3DXLoadSurfaceFromFile/Resource:
  2314. // ---------------------------------
  2315. // Load surface from a file or resource
  2316. //
  2317. // Parameters:
  2318. // pDestSurface
  2319. // Destination surface, which will receive the image.
  2320. // pDestPalette
  2321. // Destination palette of 256 colors, or NULL
  2322. // pDestRect
  2323. // Destination rectangle, or NULL for entire surface
  2324. // pSrcFile
  2325. // File name of the source image.
  2326. // pSrcModule
  2327. // Module where resource is located, or NULL for module associated
  2328. // with image the os used to create the current process.
  2329. // pSrcResource
  2330. // Resource name
  2331. // pSrcData
  2332. // Pointer to file in memory.
  2333. // SrcDataSize
  2334. // Size in bytes of file in memory.
  2335. // pSrcRect
  2336. // Source rectangle, or NULL for entire image
  2337. // Filter
  2338. // D3DX_FILTER flags controlling how the image is filtered.
  2339. // Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
  2340. // ColorKey
  2341. // Color to replace with transparent black, or 0 to disable colorkey.
  2342. // This is always a 32-bit ARGB color, independent of the source image
  2343. // format. Alpha is significant, and should usually be set to FF for
  2344. // opaque colorkeys. (ex. Opaque black == 0xff000000)
  2345. // pSrcInfo
  2346. // Pointer to a D3DXIMAGE_INFO structure to be filled in with the
  2347. // description of the data in the source image file, or NULL.
  2348. //
  2349. //----------------------------------------------------------------------------
  2350. function D3DXLoadSurfaceFromFileA(
  2351. pDestSurface: IDirect3DSurface8;
  2352. pDestPalette: PPaletteEntry;
  2353. pDestRect: PRect;
  2354. pSrcFile: PAnsiChar;
  2355. pSrcRect: PRect;
  2356. Filter: DWord;
  2357. ColorKey: TD3DColor;
  2358. pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXLoadSurfaceFromFileA';
  2359. {$EXTERNALSYM D3DXLoadSurfaceFromFileA}
  2360. function D3DXLoadSurfaceFromFileW(
  2361. pDestSurface: IDirect3DSurface8;
  2362. pDestPalette: PPaletteEntry;
  2363. pDestRect: PRect;
  2364. pSrcFile: PWideChar;
  2365. pSrcRect: PRect;
  2366. Filter: DWord;
  2367. ColorKey: TD3DColor;
  2368. pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXLoadSurfaceFromFileW';
  2369. {$EXTERNALSYM D3DXLoadSurfaceFromFileW}
  2370. function D3DXLoadSurfaceFromFile(
  2371. pDestSurface: IDirect3DSurface8;
  2372. pDestPalette: PPaletteEntry;
  2373. pDestRect: PRect;
  2374. pSrcFile: PChar;
  2375. pSrcRect: PRect;
  2376. Filter: DWord;
  2377. ColorKey: TD3DColor;
  2378. pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXLoadSurfaceFromFileA';
  2379. {$EXTERNALSYM D3DXLoadSurfaceFromFile}
  2380. function D3DXLoadSurfaceFromResourceA(
  2381. pDestSurface: IDirect3DSurface8;
  2382. pDestPalette: PPaletteEntry;
  2383. pDestRect: PRect;
  2384. hSrcModule: HModule;
  2385. pSrcResource: PAnsiChar;
  2386. pSrcRect: PRect;
  2387. Filter: DWord;
  2388. ColorKey: TD3DColor;
  2389. pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXLoadSurfaceFromResourceA';
  2390. {$EXTERNALSYM D3DXLoadSurfaceFromResourceA}
  2391. function D3DXLoadSurfaceFromResourceW(
  2392. pDestSurface: IDirect3DSurface8;
  2393. pDestPalette: PPaletteEntry;
  2394. pDestRect: PRect;
  2395. hSrcModule: HModule;
  2396. pSrcResource: PWideChar;
  2397. pSrcRect: PRect;
  2398. Filter: DWord;
  2399. ColorKey: TD3DColor;
  2400. pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXLoadSurfaceFromResourceW';
  2401. {$EXTERNALSYM D3DXLoadSurfaceFromResourceW}
  2402. function D3DXLoadSurfaceFromResource(
  2403. pDestSurface: IDirect3DSurface8;
  2404. pDestPalette: PPaletteEntry;
  2405. pDestRect: PRect;
  2406. hSrcModule: HModule;
  2407. pSrcResource: PChar;
  2408. pSrcRect: PRect;
  2409. Filter: DWord;
  2410. ColorKey: TD3DColor;
  2411. pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXLoadSurfaceFromResourceA';
  2412. {$EXTERNALSYM D3DXLoadSurfaceFromResource}
  2413. function D3DXLoadSurfaceFromFileInMemory(
  2414. pDestSurface: IDirect3DSurface8;
  2415. pDestPalette: PPaletteEntry;
  2416. pDestRect: PRect;
  2417. const pSrcData;
  2418. SrcDataSize: LongWord;
  2419. pSrcRect: PRect;
  2420. Filter: DWord;
  2421. ColorKey: TD3DColor;
  2422. pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll;
  2423. {$EXTERNALSYM D3DXLoadSurfaceFromFileInMemory}
  2424. //----------------------------------------------------------------------------
  2425. // D3DXLoadSurfaceFromSurface:
  2426. // ---------------------------
  2427. // Load surface from another surface (with color conversion)
  2428. //
  2429. // Parameters:
  2430. // pDestSurface
  2431. // Destination surface, which will receive the image.
  2432. // pDestPalette
  2433. // Destination palette of 256 colors, or NULL
  2434. // pDestRect
  2435. // Destination rectangle, or NULL for entire surface
  2436. // pSrcSurface
  2437. // Source surface
  2438. // pSrcPalette
  2439. // Source palette of 256 colors, or NULL
  2440. // pSrcRect
  2441. // Source rectangle, or NULL for entire surface
  2442. // Filter
  2443. // D3DX_FILTER flags controlling how the image is filtered.
  2444. // Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
  2445. // ColorKey
  2446. // Color to replace with transparent black, or 0 to disable colorkey.
  2447. // This is always a 32-bit ARGB color, independent of the source image
  2448. // format. Alpha is significant, and should usually be set to FF for
  2449. // opaque colorkeys. (ex. Opaque black == 0xff000000)
  2450. //
  2451. //----------------------------------------------------------------------------
  2452. function D3DXLoadSurfaceFromSurface(
  2453. pDestSurface: IDirect3DSurface8;
  2454. pDestPalette: PPaletteEntry;
  2455. pDestRect: PRect;
  2456. pSrcSurface: IDirect3DSurface8;
  2457. pSrcPalette: PPaletteEntry;
  2458. pSrcRect: PRect;
  2459. Filter: DWord;
  2460. ColorKey: TD3DColor): HResult; stdcall; external d3dx8dll;
  2461. {$EXTERNALSYM D3DXLoadSurfaceFromSurface}
  2462. //----------------------------------------------------------------------------
  2463. // D3DXLoadSurfaceFromMemory:
  2464. // ---------------------------
  2465. // Load surface from memory.
  2466. //
  2467. // Parameters:
  2468. // pDestSurface
  2469. // Destination surface, which will receive the image.
  2470. // pDestPalette
  2471. // Destination palette of 256 colors, or NULL
  2472. // pDestRect
  2473. // Destination rectangle, or NULL for entire surface
  2474. // pSrcMemory
  2475. // Pointer to the top-left corner of the source image in memory
  2476. // SrcFormat
  2477. // Pixel format of the source image.
  2478. // SrcPitch
  2479. // Pitch of source image, in bytes. For DXT formats, this number
  2480. // should represent the width of one row of cells, in bytes.
  2481. // pSrcPalette
  2482. // Source palette of 256 colors, or NULL
  2483. // pSrcRect
  2484. // Source rectangle.
  2485. // Filter
  2486. // D3DX_FILTER flags controlling how the image is filtered.
  2487. // Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
  2488. // ColorKey
  2489. // Color to replace with transparent black, or 0 to disable colorkey.
  2490. // This is always a 32-bit ARGB color, independent of the source image
  2491. // format. Alpha is significant, and should usually be set to FF for
  2492. // opaque colorkeys. (ex. Opaque black == 0xff000000)
  2493. //
  2494. //----------------------------------------------------------------------------
  2495. function D3DXLoadSurfaceFromMemory(
  2496. pDestSurface: IDirect3DSurface8;
  2497. pDestPalette: PPaletteEntry;
  2498. pDestRect: PRect;
  2499. const pSrcMemory;
  2500. SrcFormat: TD3DFormat;
  2501. SrcPitch: LongWord;
  2502. pSrcPalette: PPaletteEntry;
  2503. pSrcRect: PRect;
  2504. Filter: DWord;
  2505. ColorKey: TD3DColor): HResult; stdcall; external d3dx8dll;
  2506. {$EXTERNALSYM D3DXLoadSurfaceFromMemory}
  2507. //----------------------------------------------------------------------------
  2508. // D3DXSaveSurfaceToFile:
  2509. // ----------------------
  2510. // Save a surface to a image file.
  2511. //
  2512. // Parameters:
  2513. // pDestFile
  2514. // File name of the destination file
  2515. // DestFormat
  2516. // D3DXIMAGE_FILEFORMAT specifying file format to use when saving.
  2517. // pSrcSurface
  2518. // Source surface, containing the image to be saved
  2519. // pSrcPalette
  2520. // Source palette of 256 colors, or NULL
  2521. // pSrcRect
  2522. // Source rectangle, or NULL for the entire image
  2523. //
  2524. //----------------------------------------------------------------------------
  2525. function D3DXSaveSurfaceToFileA(
  2526. pDestFile: PAnsiChar;
  2527. DestFormat: TD3DXImageFileFormat;
  2528. pSrcSurface: IDirect3DSurface8;
  2529. pSrcPalette: PPaletteEntry;
  2530. pSrcRect: PRect): HResult; stdcall; external d3dx8dll name 'D3DXSaveSurfaceToFileA';
  2531. {$EXTERNALSYM D3DXSaveSurfaceToFileA}
  2532. function D3DXSaveSurfaceToFileW(
  2533. pDestFile: PWideChar;
  2534. DestFormat: TD3DXImageFileFormat;
  2535. pSrcSurface: IDirect3DSurface8;
  2536. pSrcPalette: PPaletteEntry;
  2537. pSrcRect: PRect): HResult; stdcall; external d3dx8dll name 'D3DXSaveSurfaceToFileW';
  2538. {$EXTERNALSYM D3DXSaveSurfaceToFileW}
  2539. function D3DXSaveSurfaceToFile(
  2540. pDestFile: PChar;
  2541. DestFormat: TD3DXImageFileFormat;
  2542. pSrcSurface: IDirect3DSurface8;
  2543. pSrcPalette: PPaletteEntry;
  2544. pSrcRect: PRect): HResult; stdcall; external d3dx8dll name 'D3DXSaveSurfaceToFileA';
  2545. {$EXTERNALSYM D3DXSaveSurfaceToFile}
  2546. //////////////////////////////////////////////////////////////////////////////
  2547. // Load/Save Volume APIs /////////////////////////////////////////////////////
  2548. //////////////////////////////////////////////////////////////////////////////
  2549. //----------------------------------------------------------------------------
  2550. // D3DXLoadVolumeFromFile/Resource:
  2551. // --------------------------------
  2552. // Load volume from a file or resource
  2553. //
  2554. // Parameters:
  2555. // pDestVolume
  2556. // Destination volume, which will receive the image.
  2557. // pDestPalette
  2558. // Destination palette of 256 colors, or NULL
  2559. // pDestBox
  2560. // Destination box, or NULL for entire volume
  2561. // pSrcFile
  2562. // File name of the source image.
  2563. // pSrcModule
  2564. // Module where resource is located, or NULL for module associated
  2565. // with image the os used to create the current process.
  2566. // pSrcResource
  2567. // Resource name
  2568. // pSrcData
  2569. // Pointer to file in memory.
  2570. // SrcDataSize
  2571. // Size in bytes of file in memory.
  2572. // pSrcBox
  2573. // Source box, or NULL for entire image
  2574. // Filter
  2575. // D3DX_FILTER flags controlling how the image is filtered.
  2576. // Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
  2577. // ColorKey
  2578. // Color to replace with transparent black, or 0 to disable colorkey.
  2579. // This is always a 32-bit ARGB color, independent of the source image
  2580. // format. Alpha is significant, and should usually be set to FF for
  2581. // opaque colorkeys. (ex. Opaque black == 0xff000000)
  2582. // pSrcInfo
  2583. // Pointer to a D3DXIMAGE_INFO structure to be filled in with the
  2584. // description of the data in the source image file, or NULL.
  2585. //
  2586. //----------------------------------------------------------------------------
  2587. function D3DXLoadVolumeFromFileA(
  2588. pDestVolume: IDirect3DVolume8;
  2589. pDestPalette: PPaletteEntry;
  2590. pDestBox: TD3DBox;
  2591. pSrcFile: PAnsiChar;
  2592. pSrcBox: TD3DBox;
  2593. Filter: DWord;
  2594. ColorKey: TD3DColor;
  2595. pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXLoadVolumeFromFileA';
  2596. {$EXTERNALSYM D3DXLoadVolumeFromFileA}
  2597. function D3DXLoadVolumeFromFileW(
  2598. pDestVolume: IDirect3DVolume8;
  2599. pDestPalette: PPaletteEntry;
  2600. pDestBox: TD3DBox;
  2601. pSrcFile: PWideChar;
  2602. pSrcBox: TD3DBox;
  2603. Filter: DWord;
  2604. ColorKey: TD3DColor;
  2605. pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXLoadVolumeFromFileW';
  2606. {$EXTERNALSYM D3DXLoadVolumeFromFileW}
  2607. function D3DXLoadVolumeFromFile(
  2608. pDestVolume: IDirect3DVolume8;
  2609. pDestPalette: PPaletteEntry;
  2610. pDestBox: TD3DBox;
  2611. pSrcFile: PChar;
  2612. pSrcBox: TD3DBox;
  2613. Filter: DWord;
  2614. ColorKey: TD3DColor;
  2615. pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXLoadVolumeFromFileA';
  2616. {$EXTERNALSYM D3DXLoadVolumeFromFile}
  2617. function D3DXLoadVolumeFromResourceA(
  2618. pDestVolume: IDirect3DVolume8;
  2619. pDestPalette: PPaletteEntry;
  2620. pDestBox: TD3DBox;
  2621. hSrcModule: HModule;
  2622. pSrcResource: PAnsiChar;
  2623. pSrcBox: TD3DBox;
  2624. Filter: DWord;
  2625. ColorKey: TD3DColor;
  2626. pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXLoadVolumeFromResourceA';
  2627. {$EXTERNALSYM D3DXLoadVolumeFromResourceA}
  2628. function D3DXLoadVolumeFromResourceW(
  2629. pDestVolume: IDirect3DVolume8;
  2630. pDestPalette: PPaletteEntry;
  2631. pDestBox: TD3DBox;
  2632. hSrcModule: HModule;
  2633. pSrcResource: PWideChar;
  2634. pSrcBox: TD3DBox;
  2635. Filter: DWord;
  2636. ColorKey: TD3DColor;
  2637. pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXLoadVolumeFromResourceW';
  2638. {$EXTERNALSYM D3DXLoadVolumeFromResourceW}
  2639. function D3DXLoadVolumeFromResource(
  2640. pDestVolume: IDirect3DVolume8;
  2641. pDestPalette: PPaletteEntry;
  2642. pDestBox: TD3DBox;
  2643. hSrcModule: HModule;
  2644. pSrcResource: PChar;
  2645. pSrcBox: TD3DBox;
  2646. Filter: DWord;
  2647. ColorKey: TD3DColor;
  2648. pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXLoadVolumeFromResourceA';
  2649. {$EXTERNALSYM D3DXLoadVolumeFromResource}
  2650. function D3DXLoadVolumeFromFileInMemory(
  2651. pDestVolume: IDirect3DVolume8;
  2652. pDestPalette: PPaletteEntry;
  2653. pDestBox: TD3DBox;
  2654. const pSrcData;
  2655. SrcDataSize: LongWord;
  2656. pSrcBox: TD3DBox;
  2657. Filter: DWord;
  2658. ColorKey: TD3DColor;
  2659. pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll;
  2660. {$EXTERNALSYM D3DXLoadVolumeFromFileInMemory}
  2661. //----------------------------------------------------------------------------
  2662. // D3DXLoadVolumeFromVolume:
  2663. // ---------------------------
  2664. // Load volume from another volume (with color conversion)
  2665. //
  2666. // Parameters:
  2667. // pDestVolume
  2668. // Destination volume, which will receive the image.
  2669. // pDestPalette
  2670. // Destination palette of 256 colors, or NULL
  2671. // pDestBox
  2672. // Destination box, or NULL for entire volume
  2673. // pSrcVolume
  2674. // Source volume
  2675. // pSrcPalette
  2676. // Source palette of 256 colors, or NULL
  2677. // pSrcBox
  2678. // Source box, or NULL for entire volume
  2679. // Filter
  2680. // D3DX_FILTER flags controlling how the image is filtered.
  2681. // Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
  2682. // ColorKey
  2683. // Color to replace with transparent black, or 0 to disable colorkey.
  2684. // This is always a 32-bit ARGB color, independent of the source image
  2685. // format. Alpha is significant, and should usually be set to FF for
  2686. // opaque colorkeys. (ex. Opaque black == 0xff000000)
  2687. //
  2688. //----------------------------------------------------------------------------
  2689. function D3DXLoadVolumeFromVolume(
  2690. pDestVolume: IDirect3DVolume8;
  2691. pDestPalette: PPaletteEntry;
  2692. pDestBox: TD3DBox;
  2693. pSrcVolume: IDirect3DVolume8;
  2694. pSrcPalette: PPaletteEntry;
  2695. pSrcBox: TD3DBox;
  2696. Filter: DWord;
  2697. ColorKey: TD3DColor): HResult; stdcall; external d3dx8dll;
  2698. {$EXTERNALSYM D3DXLoadVolumeFromVolume}
  2699. //----------------------------------------------------------------------------
  2700. // D3DXLoadVolumeFromMemory:
  2701. // ---------------------------
  2702. // Load volume from memory.
  2703. //
  2704. // Parameters:
  2705. // pDestVolume
  2706. // Destination volume, which will receive the image.
  2707. // pDestPalette
  2708. // Destination palette of 256 colors, or NULL
  2709. // pDestBox
  2710. // Destination box, or NULL for entire volume
  2711. // pSrcMemory
  2712. // Pointer to the top-left corner of the source volume in memory
  2713. // SrcFormat
  2714. // Pixel format of the source volume.
  2715. // SrcRowPitch
  2716. // Pitch of source image, in bytes. For DXT formats, this number
  2717. // should represent the size of one row of cells, in bytes.
  2718. // SrcSlicePitch
  2719. // Pitch of source image, in bytes. For DXT formats, this number
  2720. // should represent the size of one slice of cells, in bytes.
  2721. // pSrcPalette
  2722. // Source palette of 256 colors, or NULL
  2723. // pSrcBox
  2724. // Source box.
  2725. // Filter
  2726. // D3DX_FILTER flags controlling how the image is filtered.
  2727. // Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
  2728. // ColorKey
  2729. // Color to replace with transparent black, or 0 to disable colorkey.
  2730. // This is always a 32-bit ARGB color, independent of the source image
  2731. // format. Alpha is significant, and should usually be set to FF for
  2732. // opaque colorkeys. (ex. Opaque black == 0xff000000)
  2733. //
  2734. //----------------------------------------------------------------------------
  2735. function D3DXLoadVolumeFromMemory(
  2736. pDestVolume: IDirect3DVolume8;
  2737. pDestPalette: PPaletteEntry;
  2738. pDestBox: TD3DBox;
  2739. const pSrcMemory;
  2740. SrcFormat: TD3DFormat;
  2741. SrcRowPitch: LongWord;
  2742. SrcSlicePitch: LongWord;
  2743. pSrcPalette: PPaletteEntry;
  2744. pSrcBox: TD3DBox;
  2745. Filter: DWord;
  2746. ColorKey: TD3DColor): HResult; stdcall; external d3dx8dll;
  2747. {$EXTERNALSYM D3DXLoadVolumeFromMemory}
  2748. //----------------------------------------------------------------------------
  2749. // D3DXSaveVolumeToFile:
  2750. // ---------------------
  2751. // Save a volume to a image file.
  2752. //
  2753. // Parameters:
  2754. // pDestFile
  2755. // File name of the destination file
  2756. // DestFormat
  2757. // D3DXIMAGE_FILEFORMAT specifying file format to use when saving.
  2758. // pSrcVolume
  2759. // Source volume, containing the image to be saved
  2760. // pSrcPalette
  2761. // Source palette of 256 colors, or NULL
  2762. // pSrcBox
  2763. // Source box, or NULL for the entire volume
  2764. //
  2765. //----------------------------------------------------------------------------
  2766. function D3DXSaveVolumeToFileA(
  2767. pDestFile: PAnsiChar;
  2768. DestFormat: TD3DXImageFileFormat;
  2769. pSrcVolume: IDirect3DVolume8;
  2770. pSrcPalette: PPaletteEntry;
  2771. pSrcBox: TD3DBox): HResult; stdcall; external d3dx8dll name 'D3DXSaveVolumeToFileA';
  2772. {$EXTERNALSYM D3DXSaveVolumeToFileA}
  2773. function D3DXSaveVolumeToFileW(
  2774. pDestFile: PWideChar;
  2775. DestFormat: TD3DXImageFileFormat;
  2776. pSrcVolume: IDirect3DVolume8;
  2777. pSrcPalette: PPaletteEntry;
  2778. pSrcBox: TD3DBox): HResult; stdcall; external d3dx8dll name 'D3DXSaveVolumeToFileW';
  2779. {$EXTERNALSYM D3DXSaveVolumeToFileW}
  2780. function D3DXSaveVolumeToFile(
  2781. pDestFile: PChar;
  2782. DestFormat: TD3DXImageFileFormat;
  2783. pSrcVolume: IDirect3DVolume8;
  2784. pSrcPalette: PPaletteEntry;
  2785. pSrcBox: TD3DBox): HResult; stdcall; external d3dx8dll name 'D3DXSaveVolumeToFileA';
  2786. {$EXTERNALSYM D3DXSaveVolumeToFile}
  2787. //////////////////////////////////////////////////////////////////////////////
  2788. // Create/Save Texture APIs //////////////////////////////////////////////////
  2789. //////////////////////////////////////////////////////////////////////////////
  2790. //----------------------------------------------------------------------------
  2791. // D3DXCheckTextureRequirements:
  2792. // -----------------------------
  2793. // Checks texture creation parameters. If parameters are invalid, this
  2794. // function returns corrected parameters.
  2795. //
  2796. // Parameters:
  2797. //
  2798. // pDevice
  2799. // The D3D device to be used
  2800. // pWidth, pHeight, pDepth, pSize
  2801. // Desired size in pixels, or NULL. Returns corrected size.
  2802. // pNumMipLevels
  2803. // Number of desired mipmap levels, or NULL. Returns corrected number.
  2804. // Usage
  2805. // Texture usage flags
  2806. // pFormat
  2807. // Desired pixel format, or NULL. Returns corrected format.
  2808. // Pool
  2809. // Memory pool to be used to create texture
  2810. //
  2811. //----------------------------------------------------------------------------
  2812. function D3DXCheckTextureRequirements(
  2813. pDevice: IDirect3DDevice8;
  2814. pWidth: PLongWord;
  2815. pHeight: PLongWord;
  2816. pNumMipLevels: PLongWord;
  2817. Usage: DWord;
  2818. pFormat: PD3DFormat;
  2819. Pool: TD3DPool): HResult; stdcall; external d3dx8dll;
  2820. {$EXTERNALSYM D3DXCheckTextureRequirements}
  2821. function D3DXCheckCubeTextureRequirements(
  2822. pDevice: IDirect3DDevice8;
  2823. pSize: PLongWord;
  2824. pNumMipLevels: PLongWord;
  2825. Usage: DWord;
  2826. pFormat: PD3DFormat;
  2827. Pool: TD3DPool): HResult; stdcall; external d3dx8dll;
  2828. {$EXTERNALSYM D3DXCheckCubeTextureRequirements}
  2829. function D3DXCheckVolumeTextureRequirements(
  2830. pDevice: IDirect3DDevice8;
  2831. pWidth: PLongWord;
  2832. pHeight: PLongWord;
  2833. pDepth: PLongWord;
  2834. pNumMipLevels: PLongWord;
  2835. Usage: DWord;
  2836. pFormat: PD3DFormat;
  2837. Pool: TD3DPool): HResult; stdcall; external d3dx8dll;
  2838. {$EXTERNALSYM D3DXCheckVolumeTextureRequirements}
  2839. //----------------------------------------------------------------------------
  2840. // D3DXCreateTexture:
  2841. // ------------------
  2842. // Create an empty texture
  2843. //
  2844. // Parameters:
  2845. //
  2846. // pDevice
  2847. // The D3D device with which the texture is going to be used.
  2848. // Width, Height, Depth, Size
  2849. // size in pixels; these must be non-zero
  2850. // MipLevels
  2851. // number of mip levels desired; if zero or D3DX_DEFAULT, a complete
  2852. // mipmap chain will be created.
  2853. // Usage
  2854. // Texture usage flags
  2855. // Format
  2856. // Pixel format.
  2857. // Pool
  2858. // Memory pool to be used to create texture
  2859. // ppTexture, ppCubeTexture, ppVolumeTexture
  2860. // The texture object that will be created
  2861. //
  2862. //----------------------------------------------------------------------------
  2863. function D3DXCreateTexture(
  2864. Device: IDirect3DDevice8;
  2865. Width: LongWord;
  2866. Height: LongWord;
  2867. MipLevels: LongWord;
  2868. Usage: DWord;
  2869. Format: TD3DFormat;
  2870. Pool: TD3DPool;
  2871. out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll;
  2872. {$EXTERNALSYM D3DXCreateTexture}
  2873. function D3DXCreateCubeTexture(
  2874. Device: IDirect3DDevice8;
  2875. Size: LongWord;
  2876. MipLevels: LongWord;
  2877. Usage: DWord;
  2878. Format: TD3DFormat;
  2879. Pool: TD3DPool;
  2880. out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll;
  2881. {$EXTERNALSYM D3DXCreateCubeTexture}
  2882. function D3DXCreateVolumeTexture(
  2883. Device: IDirect3DDevice8;
  2884. Width: LongWord;
  2885. Height: LongWord;
  2886. Depth: LongWord;
  2887. MipLevels: LongWord;
  2888. Usage: DWord;
  2889. Format: TD3DFormat;
  2890. Pool: TD3DPool;
  2891. out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll;
  2892. {$EXTERNALSYM D3DXCreateVolumeTexture}
  2893. //----------------------------------------------------------------------------
  2894. // D3DXCreateTextureFromFile/Resource:
  2895. // -----------------------------------
  2896. // Create a texture object from a file or resource.
  2897. //
  2898. // Parameters:
  2899. //
  2900. // pDevice
  2901. // The D3D device with which the texture is going to be used.
  2902. // pSrcFile
  2903. // File name.
  2904. // hSrcModule
  2905. // Module handle. if NULL, current module will be used.
  2906. // pSrcResource
  2907. // Resource name in module
  2908. // pvSrcData
  2909. // Pointer to file in memory.
  2910. // SrcDataSize
  2911. // Size in bytes of file in memory.
  2912. // Width, Height, Depth, Size
  2913. // Size in pixels; if zero or D3DX_DEFAULT, the size will be taken
  2914. // from the file.
  2915. // MipLevels
  2916. // Number of mip levels; if zero or D3DX_DEFAULT, a complete mipmap
  2917. // chain will be created.
  2918. // Usage
  2919. // Texture usage flags
  2920. // Format
  2921. // Desired pixel format. If D3DFMT_UNKNOWN, the format will be
  2922. // taken from the file.
  2923. // Pool
  2924. // Memory pool to be used to create texture
  2925. // Filter
  2926. // D3DX_FILTER flags controlling how the image is filtered.
  2927. // Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
  2928. // MipFilter
  2929. // D3DX_FILTER flags controlling how each miplevel is filtered.
  2930. // Or D3DX_DEFAULT for D3DX_FILTER_BOX,
  2931. // ColorKey
  2932. // Color to replace with transparent black, or 0 to disable colorkey.
  2933. // This is always a 32-bit ARGB color, independent of the source image
  2934. // format. Alpha is significant, and should usually be set to FF for
  2935. // opaque colorkeys. (ex. Opaque black == 0xff000000)
  2936. // pSrcInfo
  2937. // Pointer to a D3DXIMAGE_INFO structure to be filled in with the
  2938. // description of the data in the source image file, or NULL.
  2939. // pPalette
  2940. // 256 color palette to be filled in, or NULL
  2941. // ppTexture, ppCubeTexture, ppVolumeTexture
  2942. // The texture object that will be created
  2943. //
  2944. //----------------------------------------------------------------------------
  2945. // FromFile
  2946. function D3DXCreateTextureFromFileA(
  2947. Device: IDirect3DDevice8;
  2948. pSrcFile: PAnsiChar;
  2949. out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextureFromFileA';
  2950. {$EXTERNALSYM D3DXCreateTextureFromFileA}
  2951. function D3DXCreateTextureFromFileW(
  2952. Device: IDirect3DDevice8;
  2953. pSrcFile: PWideChar;
  2954. out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextureFromFileW';
  2955. {$EXTERNALSYM D3DXCreateTextureFromFileW}
  2956. function D3DXCreateTextureFromFile(
  2957. Device: IDirect3DDevice8;
  2958. pSrcFile: PChar;
  2959. out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextureFromFileA';
  2960. {$EXTERNALSYM D3DXCreateTextureFromFile}
  2961. function D3DXCreateCubeTextureFromFileA(
  2962. Device: IDirect3DDevice8;
  2963. pSrcFile: PAnsiChar;
  2964. out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateCubeTextureFromFileA';
  2965. {$EXTERNALSYM D3DXCreateCubeTextureFromFileA}
  2966. function D3DXCreateCubeTextureFromFileW(
  2967. Device: IDirect3DDevice8;
  2968. pSrcFile: PWideChar;
  2969. out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateCubeTextureFromFileW';
  2970. {$EXTERNALSYM D3DXCreateCubeTextureFromFileW}
  2971. function D3DXCreateCubeTextureFromFile(
  2972. Device: IDirect3DDevice8;
  2973. pSrcFile: PChar;
  2974. out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateCubeTextureFromFileA';
  2975. {$EXTERNALSYM D3DXCreateCubeTextureFromFile}
  2976. function D3DXCreateVolumeTextureFromFileA(
  2977. Device: IDirect3DDevice8;
  2978. pSrcFile: PAnsiChar;
  2979. out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateVolumeTextureFromFileA';
  2980. {$EXTERNALSYM D3DXCreateVolumeTextureFromFileA}
  2981. function D3DXCreateVolumeTextureFromFileW(
  2982. Device: IDirect3DDevice8;
  2983. pSrcFile: PWideChar;
  2984. out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateVolumeTextureFromFileW';
  2985. {$EXTERNALSYM D3DXCreateVolumeTextureFromFileW}
  2986. function D3DXCreateVolumeTextureFromFile(
  2987. Device: IDirect3DDevice8;
  2988. pSrcFile: PChar;
  2989. out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateVolumeTextureFromFileA';
  2990. {$EXTERNALSYM D3DXCreateVolumeTextureFromFile}
  2991. // FromResource
  2992. function D3DXCreateTextureFromResourceA(
  2993. Device: IDirect3DDevice8;
  2994. hSrcModule: HModule;
  2995. pSrcResource: PAnsiChar;
  2996. out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextureFromResourceA';
  2997. {$EXTERNALSYM D3DXCreateTextureFromResourceA}
  2998. function D3DXCreateTextureFromResourceW(
  2999. Device: IDirect3DDevice8;
  3000. hSrcModule: HModule;
  3001. pSrcResource: PWideChar;
  3002. out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextureFromResourceW';
  3003. {$EXTERNALSYM D3DXCreateTextureFromResourceW}
  3004. function D3DXCreateTextureFromResource(
  3005. Device: IDirect3DDevice8;
  3006. hSrcModule: HModule;
  3007. pSrcResource: PChar;
  3008. out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextureFromResourceA';
  3009. {$EXTERNALSYM D3DXCreateTextureFromResource}
  3010. function D3DXCreateCubeTextureFromResourceA(
  3011. Device: IDirect3DDevice8;
  3012. hSrcModule: HModule;
  3013. pSrcResource: PAnsiChar;
  3014. out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateCubeTextureFromResourceA';
  3015. {$EXTERNALSYM D3DXCreateCubeTextureFromResourceA}
  3016. function D3DXCreateCubeTextureFromResourceW(
  3017. Device: IDirect3DDevice8;
  3018. hSrcModule: HModule;
  3019. pSrcResource: PWideChar;
  3020. out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateCubeTextureFromResourceW';
  3021. {$EXTERNALSYM D3DXCreateCubeTextureFromResourceW}
  3022. function D3DXCreateCubeTextureFromResource(
  3023. Device: IDirect3DDevice8;
  3024. hSrcModule: HModule;
  3025. pSrcResource: PChar;
  3026. out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateCubeTextureFromResourceA';
  3027. {$EXTERNALSYM D3DXCreateCubeTextureFromResource}
  3028. function D3DXCreateVolumeTextureFromResourceA(
  3029. Device: IDirect3DDevice8;
  3030. hSrcModule: HModule;
  3031. pSrcResource: PAnsiChar;
  3032. out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateVolumeTextureFromResourceA';
  3033. {$EXTERNALSYM D3DXCreateVolumeTextureFromResourceA}
  3034. function D3DXCreateVolumeTextureFromResourceW(
  3035. Device: IDirect3DDevice8;
  3036. hSrcModule: HModule;
  3037. pSrcResource: PWideChar;
  3038. out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateVolumeTextureFromResourceW';
  3039. {$EXTERNALSYM D3DXCreateVolumeTextureFromResourceW}
  3040. function D3DXCreateVolumeTextureFromResource(
  3041. Device: IDirect3DDevice8;
  3042. hSrcModule: HModule;
  3043. pSrcResource: PChar;
  3044. out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateVolumeTextureFromResourceA';
  3045. {$EXTERNALSYM D3DXCreateVolumeTextureFromResource}
  3046. // FromFileEx
  3047. function D3DXCreateTextureFromFileExA(
  3048. Device: IDirect3DDevice8;
  3049. pSrcFile: PAnsiChar;
  3050. Width: LongWord;
  3051. Height: LongWord;
  3052. MipLevels: LongWord;
  3053. Usage: DWord;
  3054. Format: TD3DFormat;
  3055. Pool: TD3DPool;
  3056. Filter: DWord;
  3057. MipFilter: DWord;
  3058. ColorKey: TD3DColor;
  3059. pSrcInfo: PD3DXImageInfo;
  3060. pPalette: PPaletteEntry;
  3061. out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextureFromFileExA';
  3062. {$EXTERNALSYM D3DXCreateTextureFromFileExA}
  3063. function D3DXCreateTextureFromFileExW(
  3064. Device: IDirect3DDevice8;
  3065. pSrcFile: PWideChar;
  3066. Width: LongWord;
  3067. Height: LongWord;
  3068. MipLevels: LongWord;
  3069. Usage: DWord;
  3070. Format: TD3DFormat;
  3071. Pool: TD3DPool;
  3072. Filter: DWord;
  3073. MipFilter: DWord;
  3074. ColorKey: TD3DColor;
  3075. pSrcInfo: PD3DXImageInfo;
  3076. pPalette: PPaletteEntry;
  3077. out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextureFromFileExW';
  3078. {$EXTERNALSYM D3DXCreateTextureFromFileExW}
  3079. function D3DXCreateTextureFromFileEx(
  3080. Device: IDirect3DDevice8;
  3081. pSrcFile: PChar;
  3082. Width: LongWord;
  3083. Height: LongWord;
  3084. MipLevels: LongWord;
  3085. Usage: DWord;
  3086. Format: TD3DFormat;
  3087. Pool: TD3DPool;
  3088. Filter: DWord;
  3089. MipFilter: DWord;
  3090. ColorKey: TD3DColor;
  3091. pSrcInfo: PD3DXImageInfo;
  3092. pPalette: PPaletteEntry;
  3093. out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextureFromFileExA';
  3094. {$EXTERNALSYM D3DXCreateTextureFromFileEx}
  3095. function D3DXCreateCubeTextureFromFileExA(
  3096. Device: IDirect3DDevice8;
  3097. pSrcFile: PAnsiChar;
  3098. Size: LongWord;
  3099. MipLevels: LongWord;
  3100. Usage: DWord;
  3101. Format: TD3DFormat;
  3102. Pool: TD3DPool;
  3103. Filter: DWord;
  3104. MipFilter: DWord;
  3105. ColorKey: TD3DColor;
  3106. pSrcInfo: PD3DXImageInfo;
  3107. pPalette: PPaletteEntry;
  3108. out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateCubeTextureFromFileExA';
  3109. {$EXTERNALSYM D3DXCreateCubeTextureFromFileExA}
  3110. function D3DXCreateCubeTextureFromFileExW(
  3111. Device: IDirect3DDevice8;
  3112. pSrcFile: PWideChar;
  3113. Size: LongWord;
  3114. MipLevels: LongWord;
  3115. Usage: DWord;
  3116. Format: TD3DFormat;
  3117. Pool: TD3DPool;
  3118. Filter: DWord;
  3119. MipFilter: DWord;
  3120. ColorKey: TD3DColor;
  3121. pSrcInfo: PD3DXImageInfo;
  3122. pPalette: PPaletteEntry;
  3123. out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateCubeTextureFromFileExW';
  3124. {$EXTERNALSYM D3DXCreateCubeTextureFromFileExW}
  3125. function D3DXCreateCubeTextureFromFileEx(
  3126. Device: IDirect3DDevice8;
  3127. pSrcFile: PChar;
  3128. Size: LongWord;
  3129. MipLevels: LongWord;
  3130. Usage: DWord;
  3131. Format: TD3DFormat;
  3132. Pool: TD3DPool;
  3133. Filter: DWord;
  3134. MipFilter: DWord;
  3135. ColorKey: TD3DColor;
  3136. pSrcInfo: PD3DXImageInfo;
  3137. pPalette: PPaletteEntry;
  3138. out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateCubeTextureFromFileExA';
  3139. {$EXTERNALSYM D3DXCreateCubeTextureFromFileEx}
  3140. function D3DXCreateVolumeTextureFromFileExA(
  3141. Device: IDirect3DDevice8;
  3142. pSrcFile: PAnsiChar;
  3143. Width: LongWord;
  3144. Height: LongWord;
  3145. Depth: LongWord;
  3146. MipLevels: LongWord;
  3147. Usage: DWord;
  3148. Format: TD3DFormat;
  3149. Pool: TD3DPool;
  3150. Filter: DWord;
  3151. MipFilter: DWord;
  3152. ColorKey: TD3DColor;
  3153. pSrcInfo: PD3DXImageInfo;
  3154. pPalette: PPaletteEntry;
  3155. out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateVolumeTextureFromFileExA';
  3156. {$EXTERNALSYM D3DXCreateVolumeTextureFromFileExA}
  3157. function D3DXCreateVolumeTextureFromFileExW(
  3158. Device: IDirect3DDevice8;
  3159. pSrcFile: PWideChar;
  3160. Width: LongWord;
  3161. Height: LongWord;
  3162. Depth: LongWord;
  3163. MipLevels: LongWord;
  3164. Usage: DWord;
  3165. Format: TD3DFormat;
  3166. Pool: TD3DPool;
  3167. Filter: DWord;
  3168. MipFilter: DWord;
  3169. ColorKey: TD3DColor;
  3170. pSrcInfo: PD3DXImageInfo;
  3171. pPalette: PPaletteEntry;
  3172. out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateVolumeTextureFromFileExW';
  3173. {$EXTERNALSYM D3DXCreateVolumeTextureFromFileExW}
  3174. function D3DXCreateVolumeTextureFromFileEx(
  3175. Device: IDirect3DDevice8;
  3176. pSrcFile: PChar;
  3177. Width: LongWord;
  3178. Height: LongWord;
  3179. Depth: LongWord;
  3180. MipLevels: LongWord;
  3181. Usage: DWord;
  3182. Format: TD3DFormat;
  3183. Pool: TD3DPool;
  3184. Filter: DWord;
  3185. MipFilter: DWord;
  3186. ColorKey: TD3DColor;
  3187. pSrcInfo: PD3DXImageInfo;
  3188. pPalette: PPaletteEntry;
  3189. out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateVolumeTextureFromFileExA';
  3190. {$EXTERNALSYM D3DXCreateVolumeTextureFromFileEx}
  3191. // FromResourceEx
  3192. function D3DXCreateTextureFromResourceExA(
  3193. Device: IDirect3DDevice8;
  3194. hSrcModule: HModule;
  3195. pSrcResource: PAnsiChar;
  3196. Width: LongWord;
  3197. Height: LongWord;
  3198. MipLevels: LongWord;
  3199. Usage: DWord;
  3200. Format: TD3DFormat;
  3201. Pool: TD3DPool;
  3202. Filter: DWord;
  3203. MipFilter: DWord;
  3204. ColorKey: TD3DColor;
  3205. pSrcInfo: PD3DXImageInfo;
  3206. pPalette: PPaletteEntry;
  3207. out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextureFromResourceExA';
  3208. {$EXTERNALSYM D3DXCreateTextureFromResourceExA}
  3209. function D3DXCreateTextureFromResourceExW(
  3210. Device: IDirect3DDevice8;
  3211. hSrcModule: HModule;
  3212. pSrcResource: PWideChar;
  3213. Width: LongWord;
  3214. Height: LongWord;
  3215. MipLevels: LongWord;
  3216. Usage: DWord;
  3217. Format: TD3DFormat;
  3218. Pool: TD3DPool;
  3219. Filter: DWord;
  3220. MipFilter: DWord;
  3221. ColorKey: TD3DColor;
  3222. pSrcInfo: PD3DXImageInfo;
  3223. pPalette: PPaletteEntry;
  3224. out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextureFromResourceExW';
  3225. {$EXTERNALSYM D3DXCreateTextureFromResourceExW}
  3226. function D3DXCreateTextureFromResourceEx(
  3227. Device: IDirect3DDevice8;
  3228. hSrcModule: HModule;
  3229. pSrcResource: PChar;
  3230. Width: LongWord;
  3231. Height: LongWord;
  3232. MipLevels: LongWord;
  3233. Usage: DWord;
  3234. Format: TD3DFormat;
  3235. Pool: TD3DPool;
  3236. Filter: DWord;
  3237. MipFilter: DWord;
  3238. ColorKey: TD3DColor;
  3239. pSrcInfo: PD3DXImageInfo;
  3240. pPalette: PPaletteEntry;
  3241. out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextureFromResourceExA';
  3242. {$EXTERNALSYM D3DXCreateTextureFromResourceEx}
  3243. function D3DXCreateCubeTextureFromResourceExA(
  3244. Device: IDirect3DDevice8;
  3245. hSrcModule: HModule;
  3246. pSrcResource: PAnsiChar;
  3247. Size: LongWord;
  3248. MipLevels: LongWord;
  3249. Usage: DWord;
  3250. Format: TD3DFormat;
  3251. Pool: TD3DPool;
  3252. Filter: DWord;
  3253. MipFilter: DWord;
  3254. ColorKey: TD3DColor;
  3255. pSrcInfo: PD3DXImageInfo;
  3256. pPalette: PPaletteEntry;
  3257. out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateCubeTextureFromResourceExA';
  3258. {$EXTERNALSYM D3DXCreateCubeTextureFromResourceExA}
  3259. function D3DXCreateCubeTextureFromResourceExW(
  3260. Device: IDirect3DDevice8;
  3261. hSrcModule: HModule;
  3262. pSrcResource: PWideChar;
  3263. Size: LongWord;
  3264. MipLevels: LongWord;
  3265. Usage: DWord;
  3266. Format: TD3DFormat;
  3267. Pool: TD3DPool;
  3268. Filter: DWord;
  3269. MipFilter: DWord;
  3270. ColorKey: TD3DColor;
  3271. pSrcInfo: PD3DXImageInfo;
  3272. pPalette: PPaletteEntry;
  3273. out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateCubeTextureFromResourceExW';
  3274. {$EXTERNALSYM D3DXCreateCubeTextureFromResourceExW}
  3275. function D3DXCreateCubeTextureFromResourceEx(
  3276. Device: IDirect3DDevice8;
  3277. hSrcModule: HModule;
  3278. pSrcResource: PChar;
  3279. Size: LongWord;
  3280. MipLevels: LongWord;
  3281. Usage: DWord;
  3282. Format: TD3DFormat;
  3283. Pool: TD3DPool;
  3284. Filter: DWord;
  3285. MipFilter: DWord;
  3286. ColorKey: TD3DColor;
  3287. pSrcInfo: PD3DXImageInfo;
  3288. pPalette: PPaletteEntry;
  3289. out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateCubeTextureFromResourceExA';
  3290. {$EXTERNALSYM D3DXCreateCubeTextureFromResourceEx}
  3291. function D3DXCreateVolumeTextureFromResourceExA(
  3292. Device: IDirect3DDevice8;
  3293. hSrcModule: HModule;
  3294. pSrcResource: PAnsiChar;
  3295. Width: LongWord;
  3296. Height: LongWord;
  3297. Depth: LongWord;
  3298. MipLevels: LongWord;
  3299. Usage: DWord;
  3300. Format: TD3DFormat;
  3301. Pool: TD3DPool;
  3302. Filter: DWord;
  3303. MipFilter: DWord;
  3304. ColorKey: TD3DColor;
  3305. pSrcInfo: PD3DXImageInfo;
  3306. pPalette: PPaletteEntry;
  3307. out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateVolumeTextureFromResourceExA';
  3308. {$EXTERNALSYM D3DXCreateVolumeTextureFromResourceExA}
  3309. function D3DXCreateVolumeTextureFromResourceExW(
  3310. Device: IDirect3DDevice8;
  3311. hSrcModule: HModule;
  3312. pSrcResource: PWideChar;
  3313. Width: LongWord;
  3314. Height: LongWord;
  3315. Depth: LongWord;
  3316. MipLevels: LongWord;
  3317. Usage: DWord;
  3318. Format: TD3DFormat;
  3319. Pool: TD3DPool;
  3320. Filter: DWord;
  3321. MipFilter: DWord;
  3322. ColorKey: TD3DColor;
  3323. pSrcInfo: PD3DXImageInfo;
  3324. pPalette: PPaletteEntry;
  3325. out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateVolumeTextureFromResourceExW';
  3326. {$EXTERNALSYM D3DXCreateVolumeTextureFromResourceExW}
  3327. function D3DXCreateVolumeTextureFromResourceEx(
  3328. Device: IDirect3DDevice8;
  3329. hSrcModule: HModule;
  3330. pSrcResource: PChar;
  3331. Width: LongWord;
  3332. Height: LongWord;
  3333. Depth: LongWord;
  3334. MipLevels: LongWord;
  3335. Usage: DWord;
  3336. Format: TD3DFormat;
  3337. Pool: TD3DPool;
  3338. Filter: DWord;
  3339. MipFilter: DWord;
  3340. ColorKey: TD3DColor;
  3341. pSrcInfo: PD3DXImageInfo;
  3342. pPalette: PPaletteEntry;
  3343. out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateVolumeTextureFromResourceExA';
  3344. {$EXTERNALSYM D3DXCreateVolumeTextureFromResourceEx}
  3345. // FromFileInMemory
  3346. function D3DXCreateTextureFromFileInMemory(
  3347. Device: IDirect3DDevice8;
  3348. const pSrcData;
  3349. SrcDataSize: LongWord;
  3350. out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll;
  3351. {$EXTERNALSYM D3DXCreateTextureFromFileInMemory}
  3352. function D3DXCreateCubeTextureFromFileInMemory(
  3353. Device: IDirect3DDevice8;
  3354. const pSrcData;
  3355. SrcDataSize: LongWord;
  3356. out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll;
  3357. {$EXTERNALSYM D3DXCreateCubeTextureFromFileInMemory}
  3358. function D3DXCreateVolumeTextureFromFileInMemory(
  3359. Device: IDirect3DDevice8;
  3360. const pSrcData;
  3361. SrcDataSize: LongWord;
  3362. out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll;
  3363. {$EXTERNALSYM D3DXCreateVolumeTextureFromFileInMemory}
  3364. // FromFileInMemoryEx
  3365. function D3DXCreateTextureFromFileInMemoryEx(
  3366. Device: IDirect3DDevice8;
  3367. const pSrcData;
  3368. SrcDataSize: LongWord;
  3369. Width: LongWord;
  3370. Height: LongWord;
  3371. MipLevels: LongWord;
  3372. Usage: DWord;
  3373. Format: TD3DFormat;
  3374. Pool: TD3DPool;
  3375. Filter: DWord;
  3376. MipFilter: DWord;
  3377. ColorKey: TD3DColor;
  3378. pSrcInfo: PD3DXImageInfo;
  3379. pPalette: PPaletteEntry;
  3380. out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll;
  3381. {$EXTERNALSYM D3DXCreateTextureFromFileInMemoryEx}
  3382. function D3DXCreateCubeTextureFromFileInMemoryEx(
  3383. Device: IDirect3DDevice8;
  3384. const pSrcData;
  3385. SrcDataSize: LongWord;
  3386. Size: LongWord;
  3387. MipLevels: LongWord;
  3388. Usage: DWord;
  3389. Format: TD3DFormat;
  3390. Pool: TD3DPool;
  3391. Filter: DWord;
  3392. MipFilter: DWord;
  3393. ColorKey: TD3DColor;
  3394. pSrcInfo: PD3DXImageInfo;
  3395. pPalette: PPaletteEntry;
  3396. out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll;
  3397. {$EXTERNALSYM D3DXCreateCubeTextureFromFileInMemoryEx}
  3398. function D3DXCreateVolumeTextureFromFileInMemoryEx(
  3399. Device: IDirect3DDevice8;
  3400. const pSrcData;
  3401. SrcDataSize: LongWord;
  3402. Width: LongWord;
  3403. Height: LongWord;
  3404. Depth: LongWord;
  3405. MipLevels: LongWord;
  3406. Usage: DWord;
  3407. Format: TD3DFormat;
  3408. Pool: TD3DPool;
  3409. Filter: DWord;
  3410. MipFilter: DWord;
  3411. ColorKey: TD3DColor;
  3412. pSrcInfo: PD3DXImageInfo;
  3413. pPalette: PPaletteEntry;
  3414. out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll;
  3415. {$EXTERNALSYM D3DXCreateVolumeTextureFromFileInMemoryEx}
  3416. //----------------------------------------------------------------------------
  3417. // D3DXSaveTextureToFile:
  3418. // ----------------------
  3419. // Save a texture to a file.
  3420. //
  3421. // Parameters:
  3422. // pDestFile
  3423. // File name of the destination file
  3424. // DestFormat
  3425. // D3DXIMAGE_FILEFORMAT specifying file format to use when saving.
  3426. // pSrcTexture
  3427. // Source texture, containing the image to be saved
  3428. // pSrcPalette
  3429. // Source palette of 256 colors, or NULL
  3430. //
  3431. //----------------------------------------------------------------------------
  3432. function D3DXSaveTextureToFileA(
  3433. pDestFile: PAnsiChar;
  3434. DestFormat: TD3DXImageFileFormat;
  3435. pSrcTexture: IDirect3DBaseTexture8;
  3436. pSrcPalette: PPaletteEntry): HResult; stdcall; external d3dx8dll name 'D3DXSaveTextureToFileA';
  3437. {$EXTERNALSYM D3DXSaveTextureToFileA}
  3438. function D3DXSaveTextureToFileW(
  3439. pDestFile: PWideChar;
  3440. DestFormat: TD3DXImageFileFormat;
  3441. pSrcTexture: IDirect3DBaseTexture8;
  3442. pSrcPalette: PPaletteEntry): HResult; stdcall; external d3dx8dll name 'D3DXSaveTextureToFileW';
  3443. {$EXTERNALSYM D3DXSaveTextureToFileW}
  3444. function D3DXSaveTextureToFile(
  3445. pDestFile: PChar;
  3446. DestFormat: TD3DXImageFileFormat;
  3447. pSrcTexture: IDirect3DBaseTexture8;
  3448. pSrcPalette: PPaletteEntry): HResult; stdcall; external d3dx8dll name 'D3DXSaveTextureToFileA';
  3449. {$EXTERNALSYM D3DXSaveTextureToFile}
  3450. //////////////////////////////////////////////////////////////////////////////
  3451. // Misc Texture APIs /////////////////////////////////////////////////////////
  3452. //////////////////////////////////////////////////////////////////////////////
  3453. //----------------------------------------------------------------------------
  3454. // D3DXFilterTexture:
  3455. // ------------------
  3456. // Filters mipmaps levels of a texture.
  3457. //
  3458. // Parameters:
  3459. // pBaseTexture
  3460. // The texture object to be filtered
  3461. // pPalette
  3462. // 256 color palette to be used, or NULL for non-palettized formats
  3463. // SrcLevel
  3464. // The level whose image is used to generate the subsequent levels.
  3465. // Filter
  3466. // D3DX_FILTER flags controlling how each miplevel is filtered.
  3467. // Or D3DX_DEFAULT for D3DX_FILTER_BOX,
  3468. //
  3469. //-------------------------------------------------------------------------
  3470. function D3DXFilterTexture(
  3471. pTexture: IDirect3DTexture8;
  3472. pPalette: PPaletteEntry;
  3473. SrcLevel: LongWord;
  3474. Filter: DWord): HResult; stdcall; external d3dx8dll;
  3475. {$EXTERNALSYM D3DXFilterTexture}
  3476. // #define D3DXFilterCubeTexture D3DXFilterTexture
  3477. // In Pascal this mapped to DLL-exported "D3DXFilterTexture" function
  3478. function D3DXFilterCubeTexture(
  3479. pTexture: IDirect3DCubeTexture8;
  3480. pPalette: PPaletteEntry;
  3481. SrcLevel: LongWord;
  3482. Filter: DWord): HResult; stdcall; external d3dx8dll name 'D3DXFilterTexture';
  3483. {$EXTERNALSYM D3DXFilterCubeTexture}
  3484. // #define D3DXFilterVolumeTexture D3DXFilterTexture
  3485. // In Pascal this mapped to DLL-exported "D3DXFilterTexture" function
  3486. function D3DXFilterVolumeTexture(
  3487. pTexture: IDirect3DVolumeTexture8;
  3488. pPalette: PPaletteEntry;
  3489. SrcLevel: LongWord;
  3490. Filter: DWord): HResult; stdcall; external d3dx8dll name 'D3DXFilterTexture';
  3491. {$EXTERNALSYM D3DXFilterVolumeTexture}
  3492. //----------------------------------------------------------------------------
  3493. // D3DXFillTexture:
  3494. // ----------------
  3495. // Uses a user provided function to fill each texel of each mip level of a
  3496. // given texture.
  3497. //
  3498. // Paramters:
  3499. // pTexture, pCubeTexture, pVolumeTexture
  3500. // Pointer to the texture to be filled.
  3501. // pFunction
  3502. // Pointer to user provided evalutor function which will be used to
  3503. // compute the value of each texel.
  3504. // pData
  3505. // Pointer to an arbitrary block of user defined data. This pointer
  3506. // will be passed to the function provided in pFunction
  3507. //-----------------------------------------------------------------------------
  3508. function D3DXFillTexture(
  3509. pTexture: IDirect3DTexture8;
  3510. pFunction: TD3DXFill2D;
  3511. const pData): HResult; stdcall; external d3dx8dll;
  3512. {$EXTERNALSYM D3DXFillTexture}
  3513. function D3DXFillCubeTexture(
  3514. pCubeTexture: IDirect3DCubeTexture8;
  3515. pFunction: TD3DXFill2D;
  3516. const pData): HResult; stdcall; external d3dx8dll;
  3517. {$EXTERNALSYM D3DXFillCubeTexture}
  3518. function D3DXFillVolumeTexture(
  3519. pVolumeTexture: IDirect3DVolumeTexture8;
  3520. pFunction: TD3DXFill3D;
  3521. const pData): HResult; stdcall; external d3dx8dll;
  3522. {$EXTERNALSYM D3DXFillVolumeTexture}
  3523. //----------------------------------------------------------------------------
  3524. // D3DXComputeNormalMap:
  3525. // ---------------------
  3526. // Converts a height map into a normal map. The (x,y,z) components of each
  3527. // normal are mapped to the (r,g,b) channels of the output texture.
  3528. //
  3529. // Parameters
  3530. // pTexture
  3531. // Pointer to the destination texture
  3532. // pSrcTexture
  3533. // Pointer to the source heightmap texture
  3534. // pSrcPalette
  3535. // Source palette of 256 colors, or NULL
  3536. // Flags
  3537. // D3DX_NORMALMAP flags
  3538. // Channel
  3539. // D3DX_CHANNEL specifying source of height information
  3540. // Amplitude
  3541. // The constant value which the height information is multiplied by.
  3542. //---------------------------------------------------------------------------
  3543. function D3DXComputeNormalMap(
  3544. pTexture: IDirect3DTexture8;
  3545. pSrcTexture: IDirect3DTexture8;
  3546. pSrcPalette: PPaletteEntry;
  3547. Flags: DWord;
  3548. Channel: DWord;
  3549. Amplitude: Single): HResult; stdcall; external d3dx8dll;
  3550. {$EXTERNALSYM D3DXComputeNormalMap}
  3551. //********************************************************************
  3552. // Introduced types for compatibility with "REVISED" D3DX8.pas translation
  3553. // by Ampaze (Tim Baumgarten) from www.Delphi-Jedi.org/DelphiGraphics
  3554. type
  3555. PD3DXEffect_Desc = PD3DXEffectDesc;
  3556. PD3DXImage_Info = PD3DXImageInfo;
  3557. PD3DXParameter_Desc = PD3DXParameterDesc;
  3558. PD3DXPass_Desc = PD3DXPassDesc;
  3559. PD3DXRTE_Desc = PD3DXRTEDesc;
  3560. PD3DXRTS_Desc = PD3DXRTSDesc;
  3561. PD3DXTechnique_Desc = PD3DXTechniqueDesc;
  3562. TD3DXEffect_Desc = TD3DXEffectDesc;
  3563. TD3DXImage_Info = TD3DXImageInfo;
  3564. TD3DXParameter_Desc = TD3DXParameterDesc;
  3565. TD3DXPass_Desc = TD3DXPassDesc;
  3566. TD3DXRTE_Desc = TD3DXRTEDesc;
  3567. TD3DXRTS_Desc = TD3DXRTSDesc;
  3568. TD3DXTechnique_Desc = TD3DXTechniqueDesc;
  3569. PD3DXImage_FileFormat = PD3DXImageFileFormat;
  3570. TD3DXImage_FileFormat = TD3DXImageFileFormat;
  3571. (*$HPPEMIT '} /* namespace D3dx8 */' *)
  3572. //***************************************************************************//
  3573. //***************************************************************************//
  3574. //***************************************************************************//
  3575. implementation
  3576. //***************************************************************************//
  3577. //***************************************************************************//
  3578. //***************************************************************************//
  3579. //////////////////////////////////////////////////////////////////////////////
  3580. //
  3581. // Copyright (C) Microsoft Corporation. All Rights Reserved.
  3582. //
  3583. // File: d3dx8math.h
  3584. // Content: D3DX math types and functions
  3585. //
  3586. //////////////////////////////////////////////////////////////////////////////
  3587. //===========================================================================
  3588. //
  3589. // General purpose utilities
  3590. //
  3591. //===========================================================================
  3592. function D3DXToRadian(Degree: Single): Single;
  3593. begin
  3594. Result:= Degree * (D3DX_PI / 180.0);
  3595. end;
  3596. function D3DXToDegree(Radian: Single): Single;
  3597. begin
  3598. Result:= Radian * (180.0 / D3DX_PI);
  3599. end;
  3600. //--------------------------
  3601. // 2D Vector
  3602. //--------------------------
  3603. function D3DXVector2(_x, _y: Single): TD3DXVector2;
  3604. begin
  3605. Result.x:= _x; Result.y:= _y;
  3606. end;
  3607. function D3DXVector2Equal(const v1, v2: TD3DXVector2): Boolean;
  3608. begin
  3609. Result:= (v1.x = v2.x) and (v1.y = v2.y);
  3610. end;
  3611. //--------------------------
  3612. // 3D Vector
  3613. //--------------------------
  3614. function D3DXVector3(_x, _y, _z: Single): TD3DXVector3;
  3615. begin
  3616. Result.x:= _x; Result.y:= _y; Result.z:=_z;
  3617. end;
  3618. function D3DXVector3Equal(const v1, v2: TD3DXVector3): Boolean;
  3619. begin
  3620. Result:= (v1.x = v2.x) and (v1.y = v2.y) and (v1.z = v2.z);
  3621. end;
  3622. //--------------------------
  3623. // 4D Vector
  3624. //--------------------------
  3625. function D3DXVector4(_x, _y, _z, _w: Single): TD3DXVector4;
  3626. begin
  3627. with Result do
  3628. begin
  3629. x:= _x; y:= _y; z:= _z; w:= _w;
  3630. end;
  3631. end;
  3632. function D3DXVector4Equal(const v1, v2: TD3DXVector4): Boolean;
  3633. begin
  3634. Result:= (v1.x = v2.x) and (v1.y = v2.y) and
  3635. (v1.z = v2.z) and (v1.w = v2.w);
  3636. end;
  3637. //--------------------------
  3638. // 4D Matrix
  3639. //--------------------------
  3640. function D3DXMatrix(
  3641. _m00, _m01, _m02, _m03,
  3642. _m10, _m11, _m12, _m13,
  3643. _m20, _m21, _m22, _m23,
  3644. _m30, _m31, _m32, _m33: Single): TD3DXMatrix;
  3645. begin
  3646. with Result do
  3647. begin
  3648. m[0,0]:= _m00; m[0,1]:= _m01; m[0,2]:= _m02; m[0,3]:= _m03;
  3649. m[1,0]:= _m10; m[1,1]:= _m11; m[1,2]:= _m12; m[1,3]:= _m13;
  3650. m[2,0]:= _m20; m[2,1]:= _m21; m[2,2]:= _m22; m[2,3]:= _m23;
  3651. m[3,0]:= _m30; m[3,1]:= _m31; m[3,2]:= _m32; m[3,3]:= _m33;
  3652. end;
  3653. end;
  3654. function D3DXMatrixAdd(out mOut: TD3DXMatrix; const m1, m2: TD3DXMatrix): PD3DXMatrix;
  3655. var
  3656. pOut, p1, p2: PSingle; x: Integer;
  3657. begin
  3658. pOut:= @mOut._11; p1:= @m1._11; p2:= @m2._11;
  3659. for x:= 0 to 15 do
  3660. begin
  3661. pOut^:= p1^+p2^;
  3662. Inc(pOut); Inc(p1); Inc(p2);
  3663. end;
  3664. Result:= @mOut;
  3665. end;
  3666. function D3DXMatrixSubtract(out mOut: TD3DXMatrix; const m1, m2: TD3DXMatrix): PD3DXMatrix;
  3667. var
  3668. pOut, p1, p2: PSingle; x: Integer;
  3669. begin
  3670. pOut:= @mOut._11; p1:= @m1._11; p2:= @m2._11;
  3671. for x:= 0 to 15 do
  3672. begin
  3673. pOut^:= p1^-p2^;
  3674. Inc(pOut); Inc(p1); Inc(p2);
  3675. end;
  3676. Result:= @mOut;
  3677. end;
  3678. function D3DXMatrixMul(out mOut: TD3DXMatrix; const m: TD3DXMatrix; MulBy: Single): PD3DXMatrix;
  3679. var
  3680. pOut, p: PSingle; x: Integer;
  3681. begin
  3682. pOut:= @mOut._11; p:= @m._11;
  3683. for x:= 0 to 15 do
  3684. begin
  3685. pOut^:= p^* MulBy;
  3686. Inc(pOut); Inc(p);
  3687. end;
  3688. Result:= @mOut;
  3689. end;
  3690. function D3DXMatrixEqual(const m1, m2: TD3DXMatrix): Boolean;
  3691. begin
  3692. Result:= CompareMem(@m1, @m2, SizeOf(TD3DXMatrix));
  3693. end;
  3694. //--------------------------
  3695. // Quaternion
  3696. //--------------------------
  3697. function D3DXQuaternion(_x, _y, _z, _w: Single): TD3DXQuaternion;
  3698. begin
  3699. with Result do
  3700. begin
  3701. x:= _x; y:= _y; z:= _z; w:= _w;
  3702. end;
  3703. end;
  3704. function D3DXQuaternionAdd(const q1, q2: TD3DXQuaternion): TD3DXQuaternion;
  3705. begin
  3706. with Result do
  3707. begin
  3708. x:= q1.x+q2.x; y:= q1.y+q2.y; z:= q1.z+q2.z; w:= q1.w+q2.w;
  3709. end;
  3710. end;
  3711. function D3DXQuaternionSubtract(const q1, q2: TD3DXQuaternion): TD3DXQuaternion;
  3712. begin
  3713. with Result do
  3714. begin
  3715. x:= q1.x-q2.x; y:= q1.y-q2.y; z:= q1.z-q2.z; w:= q1.w-q2.w;
  3716. end;
  3717. end;
  3718. function D3DXQuaternionEqual(const q1, q2: TD3DXQuaternion): Boolean;
  3719. begin
  3720. Result:= (q1.x = q2.x) and (q1.y = q2.y) and
  3721. (q1.z = q2.z) and (q1.w = q2.w);
  3722. end;
  3723. function D3DXQuaternionScale(out qOut: TD3DXQuaternion; const q: TD3DXQuaternion;
  3724. s: Single): PD3DXQuaternion;
  3725. begin
  3726. with qOut do
  3727. begin
  3728. x:= q.x*s; y:= q.y*s; z:= q.z*s; w:= q.w*s;
  3729. end;
  3730. Result:= @qOut;
  3731. end;
  3732. //--------------------------
  3733. // Plane
  3734. //--------------------------
  3735. function D3DXPlane(_a, _b, _c, _d: Single): TD3DXPlane;
  3736. begin
  3737. with Result do
  3738. begin
  3739. a:= _a; b:= _b; c:= _c; d:= _d;
  3740. end;
  3741. end;
  3742. function D3DXPlaneEqual(const p1, p2: TD3DXPlane): Boolean;
  3743. begin
  3744. Result:=
  3745. (p1.a = p2.a) and (p1.b = p2.b) and
  3746. (p1.c = p2.c) and (p1.d = p2.d);
  3747. end;
  3748. //--------------------------
  3749. // Color
  3750. //--------------------------
  3751. function D3DXColor(_r, _g, _b, _a: Single): TD3DXColor;
  3752. begin
  3753. with Result do
  3754. begin
  3755. r:= _r; g:= _g; b:= _b; a:= _a;
  3756. end;
  3757. end;
  3758. function D3DXColorToDWord(c: TD3DXColor): DWord;
  3759. function ColorLimit(const x: Single): DWord;
  3760. begin
  3761. if x > 1.0 then Result:= 255
  3762. else if x < 0 then Result:= 0
  3763. else Result:= Trunc(x * 255.0 + 0.5);
  3764. end;
  3765. begin
  3766. Result:= ColorLimit(c.a) shl 24 or ColorLimit(c.r) shl 16
  3767. or ColorLimit(c.g) shl 8 or ColorLimit(c.b);
  3768. end;
  3769. function D3DXColorFromDWord(c: DWord): TD3DXColor;
  3770. const
  3771. f: Single = 1/255;
  3772. begin
  3773. with Result do
  3774. begin
  3775. r:= f * Byte(c shr 16);
  3776. g:= f * Byte(c shr 8);
  3777. b:= f * Byte(c shr 0);
  3778. a:= f * Byte(c shr 24);
  3779. end;
  3780. end;
  3781. function D3DXColorEqual(const c1, c2: TD3DXColor): Boolean;
  3782. begin
  3783. Result:= (c1.r = c2.r) and (c1.g = c2.g) and (c1.b = c2.b) and (c1.a = c2.a);
  3784. end;
  3785. //===========================================================================
  3786. //
  3787. // D3DX math functions:
  3788. //
  3789. // NOTE:
  3790. // * All these functions can take the same object as in and out parameters.
  3791. //
  3792. // * Out parameters are typically also returned as return values, so that
  3793. // the output of one function may be used as a parameter to another.
  3794. //
  3795. //===========================================================================
  3796. //--------------------------
  3797. // 2D Vector
  3798. //--------------------------
  3799. // "inline"
  3800. function D3DXVec2Length(const v: TD3DXVector2): Single;
  3801. begin
  3802. with v do Result:= Sqrt(x*x + y*y);
  3803. end;
  3804. function D3DXVec2LengthSq(const v: TD3DXVector2): Single;
  3805. begin
  3806. with v do Result:= x*x + y*y;
  3807. end;
  3808. function D3DXVec2Dot(const v1, v2: TD3DXVector2): Single;
  3809. begin
  3810. Result:= v1.x*v2.x + v1.y*v2.y;
  3811. end;
  3812. // Z component of ((x1,y1,0) cross (x2,y2,0))
  3813. function D3DXVec2CCW(const v1, v2: TD3DXVector2): Single;
  3814. begin
  3815. Result:= v1.x*v2.y - v1.y*v2.x;
  3816. end;
  3817. function D3DXVec2Add(const v1, v2: TD3DXVector2): TD3DXVector2;
  3818. begin
  3819. Result.x:= v1.x + v2.x;
  3820. Result.y:= v1.y + v2.y;
  3821. end;
  3822. function D3DXVec2Subtract(const v1, v2: TD3DXVector2): TD3DXVector2;
  3823. begin
  3824. Result.x:= v1.x - v2.x;
  3825. Result.y:= v1.y - v2.y;
  3826. end;
  3827. // Minimize each component. x = min(x1, x2), y = min(y1, y2)
  3828. function D3DXVec2Minimize(out vOut: TD3DXVector2; const v1, v2: TD3DXVEctor2): PD3DXVector2;
  3829. begin
  3830. if v1.x < v2.x then vOut.x:= v1.x else vOut.y:= v2.x;
  3831. if v1.y < v2.y then vOut.y:= v1.y else vOut.y:= v2.y;
  3832. Result:= @vOut;
  3833. end;
  3834. // Maximize each component. x = max(x1, x2), y = max(y1, y2)
  3835. function D3DXVec2Maximize(out vOut: TD3DXVector2; const v1, v2: TD3DXVector2): PD3DXVector2;
  3836. begin
  3837. if v1.x > v2.x then vOut.x:= v1.x else vOut.y:= v2.x;
  3838. if v1.y > v2.y then vOut.y:= v1.y else vOut.y:= v2.y;
  3839. Result:= @vOut;
  3840. end;
  3841. function D3DXVec2Scale(out vOut: TD3DXVector2; const v: TD3DXVector2; s: Single): PD3DXVector2;
  3842. begin
  3843. vOut.x:= v.x*s; vOut.y:= v.y*s;
  3844. Result:= @vOut;
  3845. end;
  3846. // Linear interpolation. V1 + s(V2-V1)
  3847. function D3DXVec2Lerp(out vOut: TD3DXVector2; const v1, v2: TD3DXVector2; s: Single): PD3DXVector2;
  3848. begin
  3849. vOut.x:= v1.x + s * (v2.x-v1.x);
  3850. vOut.y:= v1.y + s * (v2.y-v1.y);
  3851. Result:= @vOut;
  3852. end;
  3853. //--------------------------
  3854. // 3D Vector
  3855. //--------------------------
  3856. function D3DXVec3Length(const v: TD3DXVector3): Single;
  3857. begin
  3858. with v do Result:= Sqrt(x*x + y*y + z*z);
  3859. end;
  3860. function D3DXVec3LengthSq(const v: TD3DXVector3): Single;
  3861. begin
  3862. with v do Result:= x*x + y*y + z*z;
  3863. end;
  3864. function D3DXVec3Dot(const v1, v2: TD3DXVector3): Single;
  3865. begin
  3866. Result:= v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
  3867. end;
  3868. function D3DXVec3Cross(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  3869. begin
  3870. vOut.x:= v1.y * v2.z - v1.z * v2.y;
  3871. vOut.y:= v1.z * v2.x - v1.x * v2.z;
  3872. vOut.z:= v1.x * v2.y - v1.y * v2.x;
  3873. Result:= @vOut;
  3874. end;
  3875. function D3DXVec3Add(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  3876. begin
  3877. with vOut do
  3878. begin
  3879. x:= v1.x + v2.x;
  3880. y:= v1.y + v2.y;
  3881. z:= v1.z + v2.z;
  3882. end;
  3883. Result:= @vOut;
  3884. end;
  3885. function D3DXVec3Subtract(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  3886. begin
  3887. with vOut do
  3888. begin
  3889. x:= v1.x - v2.x;
  3890. y:= v1.y - v2.y;
  3891. z:= v1.z - v2.z;
  3892. end;
  3893. Result:= @vOut;
  3894. end;
  3895. // Minimize each component. x = min(x1, x2), y = min(y1, y2)
  3896. function D3DXVec3Minimize(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  3897. begin
  3898. if v1.x < v2.x then vOut.x:= v1.x else vOut.x:= v2.x;
  3899. if v1.y < v2.y then vOut.y:= v1.y else vOut.y:= v2.y;
  3900. if v1.z < v2.z then vOut.z:= v1.z else vOut.z:= v2.z;
  3901. Result:= @vOut;
  3902. end;
  3903. // Maximize each component. x = max(x1, x2), y = max(y1, y2)
  3904. function D3DXVec3Maximize(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  3905. begin
  3906. if v1.x > v2.x then vOut.x:= v1.x else vOut.x:= v2.x;
  3907. if v1.y > v2.y then vOut.y:= v1.y else vOut.y:= v2.y;
  3908. if v1.z > v2.z then vOut.z:= v1.z else vOut.z:= v2.z;
  3909. Result:= @vOut;
  3910. end;
  3911. function D3DXVec3Scale(out vOut: TD3DXVector3; const v: TD3DXVector3; s: Single): PD3DXVector3;
  3912. begin
  3913. with vOut do
  3914. begin
  3915. x:= v.x * s; y:= v.y * s; z:= v.z * s;
  3916. end;
  3917. Result:= @vOut;
  3918. end;
  3919. // Linear interpolation. V1 + s(V2-V1)
  3920. function D3DXVec3Lerp(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3; s: Single): PD3DXVector3;
  3921. begin
  3922. vOut.x:= v1.x + s * (v2.x-v1.x);
  3923. vOut.y:= v1.y + s * (v2.y-v1.y);
  3924. vOut.z:= v1.z + s * (v2.z-v1.z);
  3925. Result:= @vOut;
  3926. end;
  3927. //--------------------------
  3928. // 4D Vector
  3929. //--------------------------
  3930. function D3DXVec4Length(const v: TD3DXVector4): Single;
  3931. begin
  3932. with v do Result:= Sqrt(x*x + y*y + z*z + w*w);
  3933. end;
  3934. function D3DXVec4LengthSq(const v: TD3DXVector4): Single;
  3935. begin
  3936. with v do Result:= x*x + y*y + z*z + w*w
  3937. end;
  3938. function D3DXVec4Dot(const v1, v2: TD3DXVector4): Single;
  3939. begin
  3940. Result:= v1.x * v2.x + v1.y * v2.y + v1.z * v2.z + v1.w * v2.w;
  3941. end;
  3942. function D3DXVec4Add(out vOut: TD3DXVector4; const v1, v2: TD3DXVector4): PD3DXVector4;
  3943. begin
  3944. with vOut do
  3945. begin
  3946. x:= v1.x + v2.x;
  3947. y:= v1.y + v2.y;
  3948. z:= v1.z + v2.z;
  3949. w:= v1.w + v2.w;
  3950. end;
  3951. Result:= @vOut;
  3952. end;
  3953. function D3DXVec4Subtract(out vOut: TD3DXVector4; const v1, v2: TD3DXVector4): PD3DXVector4;
  3954. begin
  3955. with vOut do
  3956. begin
  3957. x:= v1.x - v2.x;
  3958. y:= v1.y - v2.y;
  3959. z:= v1.z - v2.z;
  3960. w:= v1.w - v2.w;
  3961. end;
  3962. Result:= @vOut;
  3963. end;
  3964. // Minimize each component. x = min(x1, x2), y = min(y1, y2)
  3965. function D3DXVec4Minimize(out vOut: TD3DXVector4; const v1, v2: TD3DXVector4): PD3DXVector4;
  3966. begin
  3967. if v1.x < v2.x then vOut.x:= v1.x else vOut.x:= v2.x;
  3968. if v1.y < v2.y then vOut.y:= v1.y else vOut.y:= v2.y;
  3969. if v1.z < v2.z then vOut.z:= v1.z else vOut.z:= v2.z;
  3970. if v1.w < v2.w then vOut.w:= v1.w else vOut.w:= v2.w;
  3971. Result:= @vOut;
  3972. end;
  3973. // Maximize each component. x = max(x1, x2), y = max(y1, y2)
  3974. function D3DXVec4Maximize(out vOut: TD3DXVector4; const v1, v2: TD3DXVector4): PD3DXVector4;
  3975. begin
  3976. if v1.x > v2.x then vOut.x:= v1.x else vOut.x:= v2.x;
  3977. if v1.y > v2.y then vOut.y:= v1.y else vOut.y:= v2.y;
  3978. if v1.z > v2.z then vOut.z:= v1.z else vOut.z:= v2.z;
  3979. if v1.w > v2.w then vOut.w:= v1.w else vOut.w:= v2.w;
  3980. Result:= @vOut;
  3981. end;
  3982. function D3DXVec4Scale(out vOut: TD3DXVector4; const v: TD3DXVector4; s: Single): PD3DXVector4;
  3983. begin
  3984. with vOut do
  3985. begin
  3986. x:= v.x * s; y:= v.y * s; z:= v.z * s; w:= v.w * s;
  3987. end;
  3988. Result:= @vOut;
  3989. end;
  3990. // Linear interpolation. V1 + s(V2-V1)
  3991. function D3DXVec4Lerp(out vOut: TD3DXVector4;
  3992. const v1, v2: TD3DXVector4; s: Single): PD3DXVector4;
  3993. begin
  3994. with vOut do
  3995. begin
  3996. x:= v1.x + s * (v2.x - v1.x);
  3997. y:= v1.y + s * (v2.y - v1.y);
  3998. z:= v1.z + s * (v2.z - v1.z);
  3999. w:= v1.w + s * (v2.w - v1.w);
  4000. end;
  4001. Result:= @vOut;
  4002. end;
  4003. //--------------------------
  4004. // 4D Matrix
  4005. //--------------------------
  4006. // inline
  4007. function D3DXMatrixIdentity(out mOut: TD3DXMatrix): PD3DXMatrix;
  4008. begin
  4009. FillChar(mOut, SizeOf(mOut), 0);
  4010. mOut._11:= 1; mOut._22:= 1; mOut._33:= 1; mOut._44:= 1;
  4011. Result:= @mOut;
  4012. end;
  4013. function D3DXMatrixIsIdentity(const m: TD3DXMatrix): BOOL;
  4014. begin
  4015. with m do Result:=
  4016. (_11 = 1) and (_12 = 0) and (_13 = 0) and (_14 = 0) and
  4017. (_21 = 0) and (_22 = 1) and (_23 = 0) and (_24 = 0) and
  4018. (_31 = 0) and (_32 = 0) and (_33 = 1) and (_34 = 0) and
  4019. (_41 = 0) and (_42 = 0) and (_43 = 0) and (_44 = 1);
  4020. end;
  4021. //--------------------------
  4022. // Quaternion
  4023. //--------------------------
  4024. // inline
  4025. function D3DXQuaternionLength(const q: TD3DXQuaternion): Single;
  4026. begin
  4027. with q do Result:= Sqrt(x*x + y*y + z*z + w*w);
  4028. end;
  4029. // Length squared, or "norm"
  4030. function D3DXQuaternionLengthSq(const q: TD3DXQuaternion): Single;
  4031. begin
  4032. with q do Result:= x*x + y*y + z*z + w*w;
  4033. end;
  4034. function D3DXQuaternionDot(const q1, q2: TD3DXQuaternion): Single;
  4035. begin
  4036. Result:= q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w;
  4037. end;
  4038. function D3DXQuaternionIdentity(out qOut: TD3DXQuaternion): PD3DXQuaternion;
  4039. begin
  4040. with qOut do
  4041. begin
  4042. x:= 0; y:= 0; z:= 0; w:= 1.0;
  4043. end;
  4044. Result:= @qOut;
  4045. end;
  4046. function D3DXQuaternionIsIdentity(const q: TD3DXQuaternion): BOOL;
  4047. begin
  4048. with q do Result:= (x = 0) and (y = 0) and (z = 0) and (w = 1);
  4049. end;
  4050. // (-x, -y, -z, w)
  4051. function D3DXQuaternionConjugate(out qOut: TD3DXQuaternion;
  4052. const q: TD3DXQuaternion): PD3DXQuaternion;
  4053. begin
  4054. with qOut do
  4055. begin
  4056. x:= -q.x; y:= -q.y; z:= -q.z; w:= q.w;
  4057. end;
  4058. Result:= @qOut;
  4059. end;
  4060. //--------------------------
  4061. // Plane
  4062. //--------------------------
  4063. // ax + by + cz + dw
  4064. function D3DXPlaneDot(const p: TD3DXPlane; const v: TD3DXVector4): Single;
  4065. begin
  4066. with p,v do Result:= a*x + b*y + c*z + d*w;
  4067. end;
  4068. // ax + by + cz + d
  4069. function D3DXPlaneDotCoord(const p: TD3DXPlane; const v: TD3DXVector3): Single;
  4070. begin
  4071. with p,v do Result:= a*x + b*y + c*z + d;
  4072. end;
  4073. // ax + by + cz
  4074. function D3DXPlaneDotNormal(const p: TD3DXPlane; const v: TD3DXVector3): Single;
  4075. begin
  4076. with p,v do Result:= a*x + b*y + c*z;
  4077. end;
  4078. //--------------------------
  4079. // Color
  4080. //--------------------------
  4081. // inline
  4082. function D3DXColorNegative(out cOut: TD3DXColor; const c: TD3DXColor): PD3DXColor;
  4083. begin
  4084. with cOut do
  4085. begin
  4086. r:= 1.0 - c.r; g:= 1.0 - c.g; b:= 1.0 - c.b;
  4087. a:= c.a;
  4088. end;
  4089. Result:= @cOut;
  4090. end;
  4091. function D3DXColorAdd(out cOut: TD3DXColor; const c1,c2: TD3DXColor): PD3DXColor;
  4092. begin
  4093. with cOut do
  4094. begin
  4095. r:= c1.r + c2.r; g:= c1.g + c2.g; b:= c1.b + c2.b;
  4096. a:= c1.a + c2.a;
  4097. end;
  4098. Result:= @cOut;
  4099. end;
  4100. function D3DXColorSubtract(out cOut: TD3DXColor; const c1,c2: TD3DXColor): PD3DXColor;
  4101. begin
  4102. with cOut do
  4103. begin
  4104. r:= c1.r - c2.r; g:= c1.g - c2.g; b:= c1.b - c2.b;
  4105. a:= c1.a - c2.a;
  4106. end;
  4107. Result:= @cOut;
  4108. end;
  4109. function D3DXColorScale(out cOut: TD3DXColor; const c: TD3DXColor; s: Single): PD3DXColor;
  4110. begin
  4111. with cOut do
  4112. begin
  4113. r:= c.r * s; g:= c.g * s;
  4114. b:= c.b * s; a:= c.a * s;
  4115. end;
  4116. Result:= @cOut;
  4117. end;
  4118. // (r1*r2, g1*g2, b1*b2, a1*a2)
  4119. function D3DXColorModulate(out cOut: TD3DXColor; const c1,c2: TD3DXColor): PD3DXColor;
  4120. begin
  4121. with cOut do
  4122. begin
  4123. r:= c1.r * c2.r; g:= c1.g * c2.g;
  4124. b:= c1.b * c2.b; a:= c1.a * c2.a;
  4125. end;
  4126. Result:= @cOut;
  4127. end;
  4128. // Linear interpolation of r,g,b, and a. C1 + s(C2-C1)
  4129. function D3DXColorLerp(out cOut: TD3DXColor; const c1,c2: TD3DXColor; s: Single): PD3DXColor;
  4130. begin
  4131. with cOut do
  4132. begin
  4133. r:= c1.r + s * (c2.r - c1.r);
  4134. g:= c1.g + s * (c2.g - c1.g);
  4135. b:= c1.b + s * (c2.b - c1.b);
  4136. a:= c1.a + s * (c2.a - c1.a);
  4137. end;
  4138. Result:= @cOut;
  4139. end;
  4140. ///////////////////////////////////////////////////////////////////////////
  4141. //
  4142. // Copyright (C) Microsoft Corporation. All Rights Reserved.
  4143. //
  4144. // File: d3dx8core.h
  4145. // Content: D3DX core types and functions
  4146. //
  4147. ///////////////////////////////////////////////////////////////////////////
  4148. // Object Pascal support functions for D3DXGetErrorString
  4149. function D3DXGetErrorStringA(hr: HResult): String;
  4150. var
  4151. Buffer: array [0..254] of Char;
  4152. begin
  4153. D3DXGetErrorString(hr, PAnsiChar(@Buffer), 255);
  4154. SetLength(Result, StrLen(PAnsiChar(@Buffer)));
  4155. Move(Buffer, Result[1], Length(Result));
  4156. end;
  4157. function D3DXGetErrorStringW(hr: HResult): WideString;
  4158. function WStrLen(Str: PWideChar): Integer;
  4159. begin
  4160. Result := 0;
  4161. while Str[Result] <> #0 do Inc(Result);
  4162. end;
  4163. begin
  4164. SetLength(Result, 255);
  4165. D3DXGetErrorStringW(hr, PWideChar(Result), Length(Result));
  4166. SetLength(Result, WStrLen(PWideChar(Result)));
  4167. end;
  4168. {$IFNDEF UNICODE}
  4169. function D3DXGetErrorString(hr: HResult): String;
  4170. var
  4171. Buffer: array [0..254] of Char;
  4172. begin
  4173. D3DXGetErrorString(hr, PAnsiChar(@Buffer), 255);
  4174. SetLength(Result, StrLen(PAnsiChar(@Buffer)));
  4175. Move(Buffer, Result[1], Length(Result));
  4176. end;
  4177. {$ELSE}
  4178. function D3DXGetErrorString(hr: HResult): WideString;
  4179. function WStrLen(Str: PWideChar): Integer;
  4180. begin
  4181. Result := 0;
  4182. while Str[Result] <> #0 do Inc(Result);
  4183. end;
  4184. begin
  4185. SetLength(Result, 255);
  4186. D3DXGetErrorStringW(hr, PWideChar(Result), Length(Result));
  4187. SetLength(Result, WStrLen(PWideChar(Result)));
  4188. end;
  4189. {$ENDIF}
  4190. end.