Graphics.cpp 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721
  1. // Copyright (c) 2008-2022 the Urho3D project
  2. // License: MIT
  3. #include "../Precompiled.h"
  4. #include "../Core/Profiler.h"
  5. #include "../Graphics/AnimatedModel.h"
  6. #include "../Graphics/Animation.h"
  7. #include "../Graphics/AnimationController.h"
  8. #include "../Graphics/Camera.h"
  9. #include "../Graphics/CustomGeometry.h"
  10. #include "../Graphics/DebugRenderer.h"
  11. #include "../Graphics/DecalSet.h"
  12. #include "../Graphics/Graphics.h"
  13. #include "../Graphics/GraphicsEvents.h"
  14. #include "../Graphics/Material.h"
  15. #include "../Graphics/Octree.h"
  16. #include "../Graphics/ParticleEffect.h"
  17. #include "../Graphics/ParticleEmitter.h"
  18. #include "../Graphics/RibbonTrail.h"
  19. #include "../Graphics/Skybox.h"
  20. #include "../Graphics/StaticModelGroup.h"
  21. #include "../Graphics/Technique.h"
  22. #include "../Graphics/Terrain.h"
  23. #include "../Graphics/TerrainPatch.h"
  24. #include "../Graphics/Zone.h"
  25. #include "../GraphicsAPI/GraphicsImpl.h"
  26. #include "../GraphicsAPI/Shader.h"
  27. #include "../GraphicsAPI/ShaderPrecache.h"
  28. #include "../GraphicsAPI/Texture2D.h"
  29. #include "../GraphicsAPI/Texture2DArray.h"
  30. #include "../GraphicsAPI/Texture3D.h"
  31. #include "../GraphicsAPI/TextureCube.h"
  32. #include "../IO/FileSystem.h"
  33. #include "../IO/Log.h"
  34. #include <SDL/SDL.h>
  35. #include "../DebugNew.h"
  36. namespace Urho3D
  37. {
  38. void Graphics::SetExternalWindow(void* window)
  39. {
  40. if (!window_)
  41. externalWindow_ = window;
  42. else
  43. URHO3D_LOGERROR("Window already opened, can not set external window");
  44. }
  45. void Graphics::SetWindowTitle(const String& windowTitle)
  46. {
  47. windowTitle_ = windowTitle;
  48. if (window_)
  49. SDL_SetWindowTitle(window_, windowTitle_.CString());
  50. }
  51. void Graphics::SetWindowIcon(Image* windowIcon)
  52. {
  53. windowIcon_ = windowIcon;
  54. if (window_)
  55. CreateWindowIcon();
  56. }
  57. void Graphics::SetWindowPosition(const IntVector2& position)
  58. {
  59. if (window_)
  60. SDL_SetWindowPosition(window_, position.x_, position.y_);
  61. else
  62. position_ = position; // Sets as initial position for SDL_CreateWindow()
  63. }
  64. void Graphics::SetWindowPosition(int x, int y)
  65. {
  66. SetWindowPosition(IntVector2(x, y));
  67. }
  68. void Graphics::SetOrientations(const String& orientations)
  69. {
  70. orientations_ = orientations.Trimmed();
  71. SDL_SetHint(SDL_HINT_ORIENTATIONS, orientations_.CString());
  72. }
  73. bool Graphics::SetScreenMode(int width, int height)
  74. {
  75. return SetScreenMode(width, height, screenParams_);
  76. }
  77. bool Graphics::SetWindowModes(const WindowModeParams& windowMode, const WindowModeParams& secondaryWindowMode, bool maximize)
  78. {
  79. primaryWindowMode_ = windowMode;
  80. secondaryWindowMode_ = secondaryWindowMode;
  81. return SetScreenMode(primaryWindowMode_.width_, primaryWindowMode_.height_, primaryWindowMode_.screenParams_, maximize);
  82. }
  83. bool Graphics::SetDefaultWindowModes(int width, int height, const ScreenModeParams& params)
  84. {
  85. // Fill window mode to be applied now
  86. WindowModeParams primaryWindowMode;
  87. primaryWindowMode.width_ = width;
  88. primaryWindowMode.height_ = height;
  89. primaryWindowMode.screenParams_ = params;
  90. // Fill window mode to be applied on Graphics::ToggleFullscreen
  91. WindowModeParams secondaryWindowMode = primaryWindowMode;
  92. // Pick resolution automatically
  93. secondaryWindowMode.width_ = 0;
  94. secondaryWindowMode.height_ = 0;
  95. if (params.fullscreen_ || params.borderless_)
  96. {
  97. secondaryWindowMode.screenParams_.fullscreen_ = false;
  98. secondaryWindowMode.screenParams_.borderless_ = false;
  99. }
  100. else
  101. {
  102. secondaryWindowMode.screenParams_.borderless_ = true;
  103. }
  104. const bool maximize = (!width || !height) && !params.fullscreen_ && !params.borderless_ && params.resizable_;
  105. return SetWindowModes(primaryWindowMode, secondaryWindowMode, maximize);
  106. }
  107. bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless, bool resizable,
  108. bool highDPI, bool vsync, bool tripleBuffer, int multiSample, int monitor, int refreshRate)
  109. {
  110. ScreenModeParams params;
  111. params.fullscreen_ = fullscreen;
  112. params.borderless_ = borderless;
  113. params.resizable_ = resizable;
  114. params.highDPI_ = highDPI;
  115. params.vsync_ = vsync;
  116. params.tripleBuffer_ = tripleBuffer;
  117. params.multiSample_ = multiSample;
  118. params.monitor_ = monitor;
  119. params.refreshRate_ = refreshRate;
  120. return SetDefaultWindowModes(width, height, params);
  121. }
  122. bool Graphics::SetMode(int width, int height)
  123. {
  124. return SetDefaultWindowModes(width, height, screenParams_);
  125. }
  126. bool Graphics::ToggleFullscreen()
  127. {
  128. Swap(primaryWindowMode_, secondaryWindowMode_);
  129. return SetScreenMode(primaryWindowMode_.width_, primaryWindowMode_.height_, primaryWindowMode_.screenParams_);
  130. }
  131. void Graphics::SetShaderParameter(StringHash param, const Variant& value)
  132. {
  133. switch (value.GetType())
  134. {
  135. case VAR_BOOL:
  136. SetShaderParameter(param, value.GetBool());
  137. break;
  138. case VAR_INT:
  139. SetShaderParameter(param, value.GetInt());
  140. break;
  141. case VAR_FLOAT:
  142. case VAR_DOUBLE:
  143. SetShaderParameter(param, value.GetFloat());
  144. break;
  145. case VAR_VECTOR2:
  146. SetShaderParameter(param, value.GetVector2());
  147. break;
  148. case VAR_VECTOR3:
  149. SetShaderParameter(param, value.GetVector3());
  150. break;
  151. case VAR_VECTOR4:
  152. SetShaderParameter(param, value.GetVector4());
  153. break;
  154. case VAR_COLOR:
  155. SetShaderParameter(param, value.GetColor());
  156. break;
  157. case VAR_MATRIX3:
  158. SetShaderParameter(param, value.GetMatrix3());
  159. break;
  160. case VAR_MATRIX3X4:
  161. SetShaderParameter(param, value.GetMatrix3x4());
  162. break;
  163. case VAR_MATRIX4:
  164. SetShaderParameter(param, value.GetMatrix4());
  165. break;
  166. case VAR_BUFFER:
  167. {
  168. const Vector<u8>& buffer = value.GetBuffer();
  169. if (buffer.Size() >= sizeof(float))
  170. SetShaderParameter(param, reinterpret_cast<const float*>(&buffer[0]), buffer.Size() / sizeof(float));
  171. }
  172. break;
  173. default:
  174. // Unsupported parameter type, do nothing
  175. break;
  176. }
  177. }
  178. IntVector2 Graphics::GetWindowPosition() const
  179. {
  180. if (window_)
  181. {
  182. IntVector2 position;
  183. SDL_GetWindowPosition(window_, &position.x_, &position.y_);
  184. return position;
  185. }
  186. return position_;
  187. }
  188. Vector<IntVector3> Graphics::GetResolutions(int monitor) const
  189. {
  190. Vector<IntVector3> ret;
  191. // Emscripten is not able to return a valid list
  192. #ifndef __EMSCRIPTEN__
  193. auto numModes = (unsigned)SDL_GetNumDisplayModes(monitor);
  194. for (unsigned i = 0; i < numModes; ++i)
  195. {
  196. SDL_DisplayMode mode;
  197. SDL_GetDisplayMode(monitor, i, &mode);
  198. int width = mode.w;
  199. int height = mode.h;
  200. int rate = mode.refresh_rate;
  201. // Store mode if unique
  202. bool unique = true;
  203. for (unsigned j = 0; j < ret.Size(); ++j)
  204. {
  205. if (ret[j].x_ == width && ret[j].y_ == height && ret[j].z_ == rate)
  206. {
  207. unique = false;
  208. break;
  209. }
  210. }
  211. if (unique)
  212. ret.Push(IntVector3(width, height, rate));
  213. }
  214. #endif
  215. return ret;
  216. }
  217. i32 Graphics::FindBestResolutionIndex(int monitor, int width, int height, int refreshRate) const
  218. {
  219. const Vector<IntVector3> resolutions = GetResolutions(monitor);
  220. if (resolutions.Empty())
  221. return NINDEX;
  222. i32 best = 0;
  223. i32 bestError = M_MAX_INT;
  224. for (i32 i = 0; i < resolutions.Size(); ++i)
  225. {
  226. i32 error = Abs(resolutions[i].x_ - width) + Abs(resolutions[i].y_ - height);
  227. if (refreshRate != 0)
  228. error += Abs(resolutions[i].z_ - refreshRate);
  229. if (error < bestError)
  230. {
  231. best = i;
  232. bestError = error;
  233. }
  234. }
  235. return best;
  236. }
  237. IntVector2 Graphics::GetDesktopResolution(int monitor) const
  238. {
  239. #if !defined(__ANDROID__) && !defined(IOS) && !defined(TVOS)
  240. SDL_DisplayMode mode;
  241. SDL_GetDesktopDisplayMode(monitor, &mode);
  242. return IntVector2(mode.w, mode.h);
  243. #else
  244. // SDL_GetDesktopDisplayMode() may not work correctly on mobile platforms. Rather return the window size
  245. return IntVector2(width_, height_);
  246. #endif
  247. }
  248. int Graphics::GetMonitorCount() const
  249. {
  250. return SDL_GetNumVideoDisplays();
  251. }
  252. int Graphics::GetCurrentMonitor() const
  253. {
  254. return window_ ? SDL_GetWindowDisplayIndex(window_) : 0;
  255. }
  256. bool Graphics::GetMaximized() const
  257. {
  258. return window_? static_cast<bool>(SDL_GetWindowFlags(window_) & SDL_WINDOW_MAXIMIZED) : false;
  259. }
  260. Vector3 Graphics::GetDisplayDPI(int monitor) const
  261. {
  262. Vector3 result;
  263. SDL_GetDisplayDPI(monitor, &result.z_, &result.x_, &result.y_);
  264. return result;
  265. }
  266. void Graphics::Maximize()
  267. {
  268. if (!window_)
  269. return;
  270. SDL_MaximizeWindow(window_);
  271. }
  272. void Graphics::Minimize()
  273. {
  274. if (!window_)
  275. return;
  276. SDL_MinimizeWindow(window_);
  277. }
  278. void Graphics::Raise() const
  279. {
  280. if (!window_)
  281. return;
  282. SDL_RaiseWindow(window_);
  283. }
  284. void Graphics::BeginDumpShaders(const String& fileName)
  285. {
  286. shaderPrecache_ = new ShaderPrecache(context_, fileName);
  287. }
  288. void Graphics::EndDumpShaders()
  289. {
  290. shaderPrecache_.Reset();
  291. }
  292. void Graphics::PrecacheShaders(Deserializer& source)
  293. {
  294. URHO3D_PROFILE(PrecacheShaders);
  295. ShaderPrecache::LoadShaders(this, source);
  296. }
  297. void Graphics::SetShaderCacheDir(const String& path)
  298. {
  299. String trimmedPath = path.Trimmed();
  300. if (trimmedPath.Length())
  301. shaderCacheDir_ = AddTrailingSlash(trimmedPath);
  302. }
  303. void Graphics::AddGPUObject(GPUObject* object)
  304. {
  305. MutexLock lock(gpuObjectMutex_);
  306. gpuObjects_.Push(object);
  307. }
  308. void Graphics::RemoveGPUObject(GPUObject* object)
  309. {
  310. MutexLock lock(gpuObjectMutex_);
  311. gpuObjects_.Remove(object);
  312. }
  313. void* Graphics::ReserveScratchBuffer(i32 size)
  314. {
  315. assert(size >= 0);
  316. if (!size)
  317. return nullptr;
  318. if (size > maxScratchBufferRequest_)
  319. maxScratchBufferRequest_ = size;
  320. // First check for a free buffer that is large enough
  321. for (ScratchBuffer& scratchBuffer : scratchBuffers_)
  322. {
  323. if (!scratchBuffer.reserved_ && scratchBuffer.size_ >= size)
  324. {
  325. scratchBuffer.reserved_ = true;
  326. return scratchBuffer.data_.Get();
  327. }
  328. }
  329. // Then check if a free buffer can be resized
  330. for (ScratchBuffer& scratchBuffer : scratchBuffers_)
  331. {
  332. if (!scratchBuffer.reserved_)
  333. {
  334. scratchBuffer.data_ = new u8[size];
  335. scratchBuffer.size_ = size;
  336. scratchBuffer.reserved_ = true;
  337. URHO3D_LOGDEBUG("Resized scratch buffer to size " + String(size));
  338. return scratchBuffer.data_.Get();
  339. }
  340. }
  341. // Finally allocate a new buffer
  342. ScratchBuffer newBuffer;
  343. newBuffer.data_ = new u8[size];
  344. newBuffer.size_ = size;
  345. newBuffer.reserved_ = true;
  346. scratchBuffers_.Push(newBuffer);
  347. URHO3D_LOGDEBUG("Allocated scratch buffer with size " + String(size));
  348. return newBuffer.data_.Get();
  349. }
  350. void Graphics::FreeScratchBuffer(void* buffer)
  351. {
  352. if (!buffer)
  353. return;
  354. for (ScratchBuffer& scratchBuffer : scratchBuffers_)
  355. {
  356. if (scratchBuffer.reserved_ && scratchBuffer.data_.Get() == buffer)
  357. {
  358. scratchBuffer.reserved_ = false;
  359. return;
  360. }
  361. }
  362. URHO3D_LOGWARNING("Reserved scratch buffer " + ToStringHex((unsigned)(size_t)buffer) + " not found");
  363. }
  364. void Graphics::CleanupScratchBuffers()
  365. {
  366. for (ScratchBuffer& scratchBuffer : scratchBuffers_)
  367. {
  368. if (!scratchBuffer.reserved_ && scratchBuffer.size_ > maxScratchBufferRequest_ * 2 && scratchBuffer.size_ >= 1024 * 1024)
  369. {
  370. scratchBuffer.data_ = maxScratchBufferRequest_ > 0 ? (new u8[maxScratchBufferRequest_]) : nullptr;
  371. scratchBuffer.size_ = maxScratchBufferRequest_;
  372. URHO3D_LOGDEBUG("Resized scratch buffer to size " + String(maxScratchBufferRequest_));
  373. }
  374. }
  375. maxScratchBufferRequest_ = 0;
  376. }
  377. void Graphics::CreateWindowIcon()
  378. {
  379. if (windowIcon_)
  380. {
  381. SDL_Surface* surface = windowIcon_->GetSDLSurface();
  382. if (surface)
  383. {
  384. SDL_SetWindowIcon(window_, surface);
  385. SDL_FreeSurface(surface);
  386. }
  387. }
  388. }
  389. void Graphics::AdjustScreenMode(int& newWidth, int& newHeight, ScreenModeParams& params, bool& maximize) const
  390. {
  391. // High DPI is supported only for OpenGL backend
  392. if (Graphics::GetGAPI() != GAPI_OPENGL)
  393. params.highDPI_ = false;
  394. #if defined(IOS) || defined(TVOS)
  395. // iOS and tvOS app always take the fullscreen (and with status bar hidden)
  396. params.fullscreen_ = true;
  397. #endif
  398. // Make sure monitor index is not bigger than the currently detected monitors
  399. const int numMonitors = SDL_GetNumVideoDisplays();
  400. if (params.monitor_ >= numMonitors || params.monitor_ < 0)
  401. params.monitor_ = 0; // this monitor is not present, use first monitor
  402. // Fullscreen or Borderless can not be resizable and cannot be maximized
  403. if (params.fullscreen_ || params.borderless_)
  404. {
  405. params.resizable_ = false;
  406. maximize = false;
  407. }
  408. // Borderless cannot be fullscreen, they are mutually exclusive
  409. if (params.borderless_)
  410. params.fullscreen_ = false;
  411. // On iOS window needs to be resizable to handle orientation changes properly
  412. #ifdef IOS
  413. if (!externalWindow_)
  414. params.resizable_ = true;
  415. #endif
  416. // Ensure that multisample factor is in valid range
  417. params.multiSample_ = NextPowerOfTwo(Clamp(params.multiSample_, 1, 16));
  418. // If zero dimensions in windowed mode, set windowed mode to maximize and set a predefined default restored window size.
  419. // If zero in fullscreen, use desktop mode
  420. if (!newWidth || !newHeight)
  421. {
  422. if (params.fullscreen_ || params.borderless_)
  423. {
  424. SDL_DisplayMode mode;
  425. SDL_GetDesktopDisplayMode(params.monitor_, &mode);
  426. newWidth = mode.w;
  427. newHeight = mode.h;
  428. }
  429. else
  430. {
  431. newWidth = 1024;
  432. newHeight = 768;
  433. }
  434. }
  435. // Check fullscreen mode validity (desktop only). Use a closest match if not found
  436. #ifdef DESKTOP_GRAPHICS
  437. if (params.fullscreen_)
  438. {
  439. const Vector<IntVector3> resolutions = GetResolutions(params.monitor_);
  440. if (!resolutions.Empty())
  441. {
  442. const i32 bestResolution = FindBestResolutionIndex(params.monitor_,
  443. newWidth, newHeight, params.refreshRate_);
  444. newWidth = resolutions[bestResolution].x_;
  445. newHeight = resolutions[bestResolution].y_;
  446. params.refreshRate_ = resolutions[bestResolution].z_;
  447. }
  448. }
  449. else
  450. {
  451. // If windowed, use the same refresh rate as desktop
  452. SDL_DisplayMode mode;
  453. SDL_GetDesktopDisplayMode(params.monitor_, &mode);
  454. params.refreshRate_ = mode.refresh_rate;
  455. }
  456. #endif
  457. }
  458. void Graphics::OnScreenModeChanged()
  459. {
  460. #ifdef URHO3D_LOGGING
  461. String msg;
  462. msg.AppendWithFormat("Set screen mode %dx%d rate %d Hz %s monitor %d", width_, height_, screenParams_.refreshRate_,
  463. (screenParams_.fullscreen_ ? "fullscreen" : "windowed"), screenParams_.monitor_);
  464. if (screenParams_.borderless_)
  465. msg.Append(" borderless");
  466. if (screenParams_.resizable_)
  467. msg.Append(" resizable");
  468. if (screenParams_.highDPI_)
  469. msg.Append(" highDPI");
  470. if (screenParams_.multiSample_ > 1)
  471. msg.AppendWithFormat(" multisample %d", screenParams_.multiSample_);
  472. URHO3D_LOGINFO(msg);
  473. #endif
  474. using namespace ScreenMode;
  475. VariantMap& eventData = GetEventDataMap();
  476. eventData[P_WIDTH] = width_;
  477. eventData[P_HEIGHT] = height_;
  478. eventData[P_FULLSCREEN] = screenParams_.fullscreen_;
  479. eventData[P_BORDERLESS] = screenParams_.borderless_;
  480. eventData[P_RESIZABLE] = screenParams_.resizable_;
  481. eventData[P_HIGHDPI] = screenParams_.highDPI_;
  482. eventData[P_MONITOR] = screenParams_.monitor_;
  483. eventData[P_REFRESHRATE] = screenParams_.refreshRate_;
  484. SendEvent(E_SCREENMODE, eventData);
  485. }
  486. Graphics::Graphics(Context* context, GAPI gapi)
  487. : Object(context)
  488. {
  489. Graphics::gapi = gapi;
  490. #ifdef URHO3D_OPENGL
  491. if (gapi == GAPI_OPENGL)
  492. {
  493. Constructor_OGL();
  494. return;
  495. }
  496. #endif
  497. #ifdef URHO3D_D3D9
  498. if (gapi == GAPI_D3D9)
  499. {
  500. Constructor_D3D9();
  501. return;
  502. }
  503. #endif
  504. #ifdef URHO3D_D3D11
  505. if (gapi == GAPI_D3D11)
  506. {
  507. Constructor_D3D11();
  508. return;
  509. }
  510. #endif
  511. }
  512. Graphics::~Graphics()
  513. {
  514. GAPI gapi = Graphics::GetGAPI();
  515. #ifdef URHO3D_OPENGL
  516. if (gapi == GAPI_OPENGL)
  517. {
  518. Destructor_OGL();
  519. return;
  520. }
  521. #endif
  522. #ifdef URHO3D_D3D9
  523. if (gapi == GAPI_D3D9)
  524. {
  525. Destructor_D3D9();
  526. return;
  527. }
  528. #endif
  529. #ifdef URHO3D_D3D11
  530. if (gapi == GAPI_D3D11)
  531. {
  532. Destructor_D3D11();
  533. return;
  534. }
  535. #endif
  536. }
  537. bool Graphics::SetScreenMode(int width, int height, const ScreenModeParams& params, bool maximize)
  538. {
  539. GAPI gapi = Graphics::GetGAPI();
  540. #ifdef URHO3D_OPENGL
  541. if (gapi == GAPI_OPENGL)
  542. return SetScreenMode_OGL(width, height, params, maximize);
  543. #endif
  544. #ifdef URHO3D_D3D9
  545. if (gapi == GAPI_D3D9)
  546. return SetScreenMode_D3D9(width, height, params, maximize);;
  547. #endif
  548. #ifdef URHO3D_D3D11
  549. if (gapi == GAPI_D3D11)
  550. return SetScreenMode_D3D11(width, height, params, maximize);;
  551. #endif
  552. return {}; // Prevent warning
  553. }
  554. void Graphics::SetSRGB(bool enable)
  555. {
  556. GAPI gapi = Graphics::GetGAPI();
  557. #ifdef URHO3D_OPENGL
  558. if (gapi == GAPI_OPENGL)
  559. return SetSRGB_OGL(enable);
  560. #endif
  561. #ifdef URHO3D_D3D9
  562. if (gapi == GAPI_D3D9)
  563. return SetSRGB_D3D9(enable);
  564. #endif
  565. #ifdef URHO3D_D3D11
  566. if (gapi == GAPI_D3D11)
  567. return SetSRGB_D3D11(enable);
  568. #endif
  569. }
  570. void Graphics::SetDither(bool enable)
  571. {
  572. GAPI gapi = Graphics::GetGAPI();
  573. #ifdef URHO3D_OPENGL
  574. if (gapi == GAPI_OPENGL)
  575. return SetDither_OGL(enable);
  576. #endif
  577. #ifdef URHO3D_D3D9
  578. if (gapi == GAPI_D3D9)
  579. return SetDither_D3D9(enable);
  580. #endif
  581. #ifdef URHO3D_D3D11
  582. if (gapi == GAPI_D3D11)
  583. return SetDither_D3D11(enable);
  584. #endif
  585. }
  586. void Graphics::SetFlushGPU(bool enable)
  587. {
  588. GAPI gapi = Graphics::GetGAPI();
  589. #ifdef URHO3D_OPENGL
  590. if (gapi == GAPI_OPENGL)
  591. return SetFlushGPU_OGL(enable);
  592. #endif
  593. #ifdef URHO3D_D3D9
  594. if (gapi == GAPI_D3D9)
  595. return SetFlushGPU_D3D9(enable);;
  596. #endif
  597. #ifdef URHO3D_D3D11
  598. if (gapi == GAPI_D3D11)
  599. return SetFlushGPU_D3D11(enable);;
  600. #endif
  601. }
  602. void Graphics::SetForceGL2(bool enable)
  603. {
  604. GAPI gapi = Graphics::GetGAPI();
  605. #ifdef URHO3D_OPENGL
  606. if (gapi == GAPI_OPENGL)
  607. return SetForceGL2_OGL(enable);
  608. #endif
  609. #ifdef URHO3D_D3D9
  610. if (gapi == GAPI_D3D9)
  611. return SetForceGL2_D3D9(enable);
  612. #endif
  613. #ifdef URHO3D_D3D11
  614. if (gapi == GAPI_D3D11)
  615. return SetForceGL2_D3D11(enable);
  616. #endif
  617. }
  618. void Graphics::Close()
  619. {
  620. GAPI gapi = Graphics::GetGAPI();
  621. #ifdef URHO3D_OPENGL
  622. if (gapi == GAPI_OPENGL)
  623. return Close_OGL();
  624. #endif
  625. #ifdef URHO3D_D3D9
  626. if (gapi == GAPI_D3D9)
  627. return Close_D3D9();
  628. #endif
  629. #ifdef URHO3D_D3D11
  630. if (gapi == GAPI_D3D11)
  631. return Close_D3D11();
  632. #endif
  633. }
  634. bool Graphics::TakeScreenShot(Image& destImage)
  635. {
  636. GAPI gapi = Graphics::GetGAPI();
  637. #ifdef URHO3D_OPENGL
  638. if (gapi == GAPI_OPENGL)
  639. return TakeScreenShot_OGL(destImage);
  640. #endif
  641. #ifdef URHO3D_D3D9
  642. if (gapi == GAPI_D3D9)
  643. return TakeScreenShot_D3D9(destImage);
  644. #endif
  645. #ifdef URHO3D_D3D11
  646. if (gapi == GAPI_D3D11)
  647. return TakeScreenShot_D3D11(destImage);
  648. #endif
  649. return {}; // Prevent warning
  650. }
  651. bool Graphics::BeginFrame()
  652. {
  653. GAPI gapi = Graphics::GetGAPI();
  654. #ifdef URHO3D_OPENGL
  655. if (gapi == GAPI_OPENGL)
  656. return BeginFrame_OGL();
  657. #endif
  658. #ifdef URHO3D_D3D9
  659. if (gapi == GAPI_D3D9)
  660. return BeginFrame_D3D9();
  661. #endif
  662. #ifdef URHO3D_D3D11
  663. if (gapi == GAPI_D3D11)
  664. return BeginFrame_D3D11();
  665. #endif
  666. return {}; // Prevent warning
  667. }
  668. void Graphics::EndFrame()
  669. {
  670. GAPI gapi = Graphics::GetGAPI();
  671. #ifdef URHO3D_OPENGL
  672. if (gapi == GAPI_OPENGL)
  673. return EndFrame_OGL();
  674. #endif
  675. #ifdef URHO3D_D3D9
  676. if (gapi == GAPI_D3D9)
  677. return EndFrame_D3D9();
  678. #endif
  679. #ifdef URHO3D_D3D11
  680. if (gapi == GAPI_D3D11)
  681. return EndFrame_D3D11();
  682. #endif
  683. }
  684. void Graphics::Clear(ClearTargetFlags flags, const Color& color, float depth, unsigned stencil)
  685. {
  686. GAPI gapi = Graphics::GetGAPI();
  687. #ifdef URHO3D_OPENGL
  688. if (gapi == GAPI_OPENGL)
  689. return Clear_OGL(flags, color, depth, stencil);
  690. #endif
  691. #ifdef URHO3D_D3D9
  692. if (gapi == GAPI_D3D9)
  693. return Clear_D3D9(flags, color, depth, stencil);
  694. #endif
  695. #ifdef URHO3D_D3D11
  696. if (gapi == GAPI_D3D11)
  697. return Clear_D3D11(flags, color, depth, stencil);
  698. #endif
  699. }
  700. bool Graphics::ResolveToTexture(Texture2D* destination, const IntRect& viewport)
  701. {
  702. GAPI gapi = Graphics::GetGAPI();
  703. #ifdef URHO3D_OPENGL
  704. if (gapi == GAPI_OPENGL)
  705. return ResolveToTexture_OGL(destination, viewport);
  706. #endif
  707. #ifdef URHO3D_D3D9
  708. if (gapi == GAPI_D3D9)
  709. return ResolveToTexture_D3D9(destination, viewport);
  710. #endif
  711. #ifdef URHO3D_D3D11
  712. if (gapi == GAPI_D3D11)
  713. return ResolveToTexture_D3D11(destination, viewport);
  714. #endif
  715. return {}; // Prevent warning
  716. }
  717. bool Graphics::ResolveToTexture(Texture2D* texture)
  718. {
  719. GAPI gapi = Graphics::GetGAPI();
  720. #ifdef URHO3D_OPENGL
  721. if (gapi == GAPI_OPENGL)
  722. return ResolveToTexture_OGL(texture);
  723. #endif
  724. #ifdef URHO3D_D3D9
  725. if (gapi == GAPI_D3D9)
  726. return ResolveToTexture_D3D9(texture);
  727. #endif
  728. #ifdef URHO3D_D3D11
  729. if (gapi == GAPI_D3D11)
  730. return ResolveToTexture_D3D11(texture);
  731. #endif
  732. return {}; // Prevent warning
  733. }
  734. bool Graphics::ResolveToTexture(TextureCube* texture)
  735. {
  736. GAPI gapi = Graphics::GetGAPI();
  737. #ifdef URHO3D_OPENGL
  738. if (gapi == GAPI_OPENGL)
  739. return ResolveToTexture_OGL(texture);
  740. #endif
  741. #ifdef URHO3D_D3D9
  742. if (gapi == GAPI_D3D9)
  743. return ResolveToTexture_D3D9(texture);
  744. #endif
  745. #ifdef URHO3D_D3D11
  746. if (gapi == GAPI_D3D11)
  747. return ResolveToTexture_D3D11(texture);
  748. #endif
  749. return {}; // Prevent warning
  750. }
  751. void Graphics::Draw(PrimitiveType type, unsigned vertexStart, unsigned vertexCount)
  752. {
  753. GAPI gapi = Graphics::GetGAPI();
  754. #ifdef URHO3D_OPENGL
  755. if (gapi == GAPI_OPENGL)
  756. return Draw_OGL(type, vertexStart, vertexCount);
  757. #endif
  758. #ifdef URHO3D_D3D9
  759. if (gapi == GAPI_D3D9)
  760. return Draw_D3D9(type, vertexStart, vertexCount);;
  761. #endif
  762. #ifdef URHO3D_D3D11
  763. if (gapi == GAPI_D3D11)
  764. return Draw_D3D11(type, vertexStart, vertexCount);;
  765. #endif
  766. }
  767. void Graphics::Draw(PrimitiveType type, unsigned indexStart, unsigned indexCount, unsigned minVertex, unsigned vertexCount)
  768. {
  769. GAPI gapi = Graphics::GetGAPI();
  770. #ifdef URHO3D_OPENGL
  771. if (gapi == GAPI_OPENGL)
  772. return Draw_OGL(type, indexStart, indexCount, minVertex, vertexCount);
  773. #endif
  774. #ifdef URHO3D_D3D9
  775. if (gapi == GAPI_D3D9)
  776. return Draw_D3D9(type, indexStart, indexCount, minVertex, vertexCount);
  777. #endif
  778. #ifdef URHO3D_D3D11
  779. if (gapi == GAPI_D3D11)
  780. return Draw_D3D11(type, indexStart, indexCount, minVertex, vertexCount);
  781. #endif
  782. }
  783. void Graphics::Draw(PrimitiveType type, unsigned indexStart, unsigned indexCount, unsigned baseVertexIndex, unsigned minVertex, unsigned vertexCount)
  784. {
  785. GAPI gapi = Graphics::GetGAPI();
  786. #ifdef URHO3D_OPENGL
  787. if (gapi == GAPI_OPENGL)
  788. return Draw_OGL(type, indexStart, indexCount, baseVertexIndex, minVertex, vertexCount);
  789. #endif
  790. #ifdef URHO3D_D3D9
  791. if (gapi == GAPI_D3D9)
  792. return Draw_D3D9(type, indexStart, indexCount, baseVertexIndex, minVertex, vertexCount);
  793. #endif
  794. #ifdef URHO3D_D3D11
  795. if (gapi == GAPI_D3D11)
  796. return Draw_D3D11(type, indexStart, indexCount, baseVertexIndex, minVertex, vertexCount);
  797. #endif
  798. }
  799. void Graphics::DrawInstanced(PrimitiveType type, unsigned indexStart, unsigned indexCount, unsigned minVertex, unsigned vertexCount, unsigned instanceCount)
  800. {
  801. GAPI gapi = Graphics::GetGAPI();
  802. #ifdef URHO3D_OPENGL
  803. if (gapi == GAPI_OPENGL)
  804. return DrawInstanced_OGL(type, indexStart, indexCount, minVertex, vertexCount, instanceCount);
  805. #endif
  806. #ifdef URHO3D_D3D9
  807. if (gapi == GAPI_D3D9)
  808. return DrawInstanced_D3D9(type, indexStart, indexCount, minVertex, vertexCount, instanceCount);
  809. #endif
  810. #ifdef URHO3D_D3D11
  811. if (gapi == GAPI_D3D11)
  812. return DrawInstanced_D3D11(type, indexStart, indexCount, minVertex, vertexCount, instanceCount);
  813. #endif
  814. }
  815. void Graphics::DrawInstanced(PrimitiveType type, unsigned indexStart, unsigned indexCount, unsigned baseVertexIndex, unsigned minVertex,
  816. unsigned vertexCount, unsigned instanceCount)
  817. {
  818. GAPI gapi = Graphics::GetGAPI();
  819. #ifdef URHO3D_OPENGL
  820. if (gapi == GAPI_OPENGL)
  821. return DrawInstanced_OGL(type, indexStart, indexCount, baseVertexIndex, minVertex, vertexCount, instanceCount);
  822. #endif
  823. #ifdef URHO3D_D3D9
  824. if (gapi == GAPI_D3D9)
  825. return DrawInstanced_D3D9(type, indexStart, indexCount, baseVertexIndex, minVertex, vertexCount, instanceCount);
  826. #endif
  827. #ifdef URHO3D_D3D11
  828. if (gapi == GAPI_D3D11)
  829. return DrawInstanced_D3D11(type, indexStart, indexCount, baseVertexIndex, minVertex, vertexCount, instanceCount);
  830. #endif
  831. }
  832. void Graphics::SetVertexBuffer(VertexBuffer* buffer)
  833. {
  834. GAPI gapi = Graphics::GetGAPI();
  835. #ifdef URHO3D_OPENGL
  836. if (gapi == GAPI_OPENGL)
  837. return SetVertexBuffer_OGL(buffer);
  838. #endif
  839. #ifdef URHO3D_D3D9
  840. if (gapi == GAPI_D3D9)
  841. return SetVertexBuffer_D3D9(buffer);
  842. #endif
  843. #ifdef URHO3D_D3D11
  844. if (gapi == GAPI_D3D11)
  845. return SetVertexBuffer_D3D11(buffer);
  846. #endif
  847. }
  848. bool Graphics::SetVertexBuffers(const Vector<VertexBuffer*>& buffers, unsigned instanceOffset)
  849. {
  850. GAPI gapi = Graphics::GetGAPI();
  851. #ifdef URHO3D_OPENGL
  852. if (gapi == GAPI_OPENGL)
  853. return SetVertexBuffers_OGL(buffers, instanceOffset);
  854. #endif
  855. #ifdef URHO3D_D3D9
  856. if (gapi == GAPI_D3D9)
  857. return SetVertexBuffers_D3D9(buffers, instanceOffset);
  858. #endif
  859. #ifdef URHO3D_D3D11
  860. if (gapi == GAPI_D3D11)
  861. return SetVertexBuffers_D3D11(buffers, instanceOffset);
  862. #endif
  863. return {}; // Prevent warning
  864. }
  865. bool Graphics::SetVertexBuffers(const Vector<SharedPtr<VertexBuffer>>& buffers, unsigned instanceOffset)
  866. {
  867. GAPI gapi = Graphics::GetGAPI();
  868. #ifdef URHO3D_OPENGL
  869. if (gapi == GAPI_OPENGL)
  870. return SetVertexBuffers_OGL(buffers, instanceOffset);
  871. #endif
  872. #ifdef URHO3D_D3D9
  873. if (gapi == GAPI_D3D9)
  874. return SetVertexBuffers_D3D9(buffers, instanceOffset);
  875. #endif
  876. #ifdef URHO3D_D3D11
  877. if (gapi == GAPI_D3D11)
  878. return SetVertexBuffers_D3D11(buffers, instanceOffset);
  879. #endif
  880. return {}; // Prevent warning
  881. }
  882. void Graphics::SetIndexBuffer(IndexBuffer* buffer)
  883. {
  884. GAPI gapi = Graphics::GetGAPI();
  885. #ifdef URHO3D_OPENGL
  886. if (gapi == GAPI_OPENGL)
  887. return SetIndexBuffer_OGL(buffer);
  888. #endif
  889. #ifdef URHO3D_D3D9
  890. if (gapi == GAPI_D3D9)
  891. return SetIndexBuffer_D3D9(buffer);
  892. #endif
  893. #ifdef URHO3D_D3D11
  894. if (gapi == GAPI_D3D11)
  895. return SetIndexBuffer_D3D11(buffer);
  896. #endif
  897. }
  898. void Graphics::SetShaders(ShaderVariation* vs, ShaderVariation* ps)
  899. {
  900. GAPI gapi = Graphics::GetGAPI();
  901. #ifdef URHO3D_OPENGL
  902. if (gapi == GAPI_OPENGL)
  903. return SetShaders_OGL(vs, ps);
  904. #endif
  905. #ifdef URHO3D_D3D9
  906. if (gapi == GAPI_D3D9)
  907. return SetShaders_D3D9(vs, ps);
  908. #endif
  909. #ifdef URHO3D_D3D11
  910. if (gapi == GAPI_D3D11)
  911. return SetShaders_D3D11(vs, ps);
  912. #endif
  913. }
  914. void Graphics::SetShaderParameter(StringHash param, const float* data, unsigned count)
  915. {
  916. GAPI gapi = Graphics::GetGAPI();
  917. #ifdef URHO3D_OPENGL
  918. if (gapi == GAPI_OPENGL)
  919. return SetShaderParameter_OGL(param, data, count);
  920. #endif
  921. #ifdef URHO3D_D3D9
  922. if (gapi == GAPI_D3D9)
  923. return SetShaderParameter_D3D9(param, data, count);
  924. #endif
  925. #ifdef URHO3D_D3D11
  926. if (gapi == GAPI_D3D11)
  927. return SetShaderParameter_D3D11(param, data, count);
  928. #endif
  929. }
  930. void Graphics::SetShaderParameter(StringHash param, float value)
  931. {
  932. GAPI gapi = Graphics::GetGAPI();
  933. #ifdef URHO3D_OPENGL
  934. if (gapi == GAPI_OPENGL)
  935. return SetShaderParameter_OGL(param, value);
  936. #endif
  937. #ifdef URHO3D_D3D9
  938. if (gapi == GAPI_D3D9)
  939. return SetShaderParameter_D3D9(param, value);
  940. #endif
  941. #ifdef URHO3D_D3D11
  942. if (gapi == GAPI_D3D11)
  943. return SetShaderParameter_D3D11(param, value);
  944. #endif
  945. }
  946. void Graphics::SetShaderParameter(StringHash param, int value)
  947. {
  948. GAPI gapi = Graphics::GetGAPI();
  949. #ifdef URHO3D_OPENGL
  950. if (gapi == GAPI_OPENGL)
  951. return SetShaderParameter_OGL(param, value);
  952. #endif
  953. #ifdef URHO3D_D3D9
  954. if (gapi == GAPI_D3D9)
  955. return SetShaderParameter_D3D9(param, value);
  956. #endif
  957. #ifdef URHO3D_D3D11
  958. if (gapi == GAPI_D3D11)
  959. return SetShaderParameter_D3D11(param, value);
  960. #endif
  961. }
  962. void Graphics::SetShaderParameter(StringHash param, bool value)
  963. {
  964. GAPI gapi = Graphics::GetGAPI();
  965. #ifdef URHO3D_OPENGL
  966. if (gapi == GAPI_OPENGL)
  967. return SetShaderParameter_OGL(param, value);
  968. #endif
  969. #ifdef URHO3D_D3D9
  970. if (gapi == GAPI_D3D9)
  971. return SetShaderParameter_D3D9(param, value);
  972. #endif
  973. #ifdef URHO3D_D3D11
  974. if (gapi == GAPI_D3D11)
  975. return SetShaderParameter_D3D11(param, value);
  976. #endif
  977. }
  978. void Graphics::SetShaderParameter(StringHash param, const Color& color)
  979. {
  980. GAPI gapi = Graphics::GetGAPI();
  981. #ifdef URHO3D_OPENGL
  982. if (gapi == GAPI_OPENGL)
  983. return SetShaderParameter_OGL(param, color);
  984. #endif
  985. #ifdef URHO3D_D3D9
  986. if (gapi == GAPI_D3D9)
  987. return SetShaderParameter_D3D9(param, color);
  988. #endif
  989. #ifdef URHO3D_D3D11
  990. if (gapi == GAPI_D3D11)
  991. return SetShaderParameter_D3D11(param, color);
  992. #endif
  993. }
  994. void Graphics::SetShaderParameter(StringHash param, const Vector2& vector)
  995. {
  996. GAPI gapi = Graphics::GetGAPI();
  997. #ifdef URHO3D_OPENGL
  998. if (gapi == GAPI_OPENGL)
  999. return SetShaderParameter_OGL(param, vector);
  1000. #endif
  1001. #ifdef URHO3D_D3D9
  1002. if (gapi == GAPI_D3D9)
  1003. return SetShaderParameter_D3D9(param, vector);
  1004. #endif
  1005. #ifdef URHO3D_D3D11
  1006. if (gapi == GAPI_D3D11)
  1007. return SetShaderParameter_D3D11(param, vector);
  1008. #endif
  1009. }
  1010. void Graphics::SetShaderParameter(StringHash param, const Matrix3& matrix)
  1011. {
  1012. GAPI gapi = Graphics::GetGAPI();
  1013. #ifdef URHO3D_OPENGL
  1014. if (gapi == GAPI_OPENGL)
  1015. return SetShaderParameter_OGL(param, matrix);
  1016. #endif
  1017. #ifdef URHO3D_D3D9
  1018. if (gapi == GAPI_D3D9)
  1019. return SetShaderParameter_D3D9(param, matrix);
  1020. #endif
  1021. #ifdef URHO3D_D3D11
  1022. if (gapi == GAPI_D3D11)
  1023. return SetShaderParameter_D3D11(param, matrix);
  1024. #endif
  1025. }
  1026. void Graphics::SetShaderParameter(StringHash param, const Vector3& vector)
  1027. {
  1028. GAPI gapi = Graphics::GetGAPI();
  1029. #ifdef URHO3D_OPENGL
  1030. if (gapi == GAPI_OPENGL)
  1031. return SetShaderParameter_OGL(param, vector);
  1032. #endif
  1033. #ifdef URHO3D_D3D9
  1034. if (gapi == GAPI_D3D9)
  1035. return SetShaderParameter_D3D9(param, vector);
  1036. #endif
  1037. #ifdef URHO3D_D3D11
  1038. if (gapi == GAPI_D3D11)
  1039. return SetShaderParameter_D3D11(param, vector);
  1040. #endif
  1041. }
  1042. void Graphics::SetShaderParameter(StringHash param, const Matrix4& matrix)
  1043. {
  1044. GAPI gapi = Graphics::GetGAPI();
  1045. #ifdef URHO3D_OPENGL
  1046. if (gapi == GAPI_OPENGL)
  1047. return SetShaderParameter_OGL(param, matrix);
  1048. #endif
  1049. #ifdef URHO3D_D3D9
  1050. if (gapi == GAPI_D3D9)
  1051. return SetShaderParameter_D3D9(param, matrix);
  1052. #endif
  1053. #ifdef URHO3D_D3D11
  1054. if (gapi == GAPI_D3D11)
  1055. return SetShaderParameter_D3D11(param, matrix);
  1056. #endif
  1057. }
  1058. void Graphics::SetShaderParameter(StringHash param, const Vector4& vector)
  1059. {
  1060. GAPI gapi = Graphics::GetGAPI();
  1061. #ifdef URHO3D_OPENGL
  1062. if (gapi == GAPI_OPENGL)
  1063. return SetShaderParameter_OGL(param, vector);
  1064. #endif
  1065. #ifdef URHO3D_D3D9
  1066. if (gapi == GAPI_D3D9)
  1067. return SetShaderParameter_D3D9(param, vector);
  1068. #endif
  1069. #ifdef URHO3D_D3D11
  1070. if (gapi == GAPI_D3D11)
  1071. return SetShaderParameter_D3D11(param, vector);
  1072. #endif
  1073. }
  1074. void Graphics::SetShaderParameter(StringHash param, const Matrix3x4& matrix)
  1075. {
  1076. GAPI gapi = Graphics::GetGAPI();
  1077. #ifdef URHO3D_OPENGL
  1078. if (gapi == GAPI_OPENGL)
  1079. return SetShaderParameter_OGL(param, matrix);
  1080. #endif
  1081. #ifdef URHO3D_D3D9
  1082. if (gapi == GAPI_D3D9)
  1083. return SetShaderParameter_D3D9(param, matrix);
  1084. #endif
  1085. #ifdef URHO3D_D3D11
  1086. if (gapi == GAPI_D3D11)
  1087. return SetShaderParameter_D3D11(param, matrix);
  1088. #endif
  1089. }
  1090. bool Graphics::NeedParameterUpdate(ShaderParameterGroup group, const void* source)
  1091. {
  1092. GAPI gapi = Graphics::GetGAPI();
  1093. #ifdef URHO3D_OPENGL
  1094. if (gapi == GAPI_OPENGL)
  1095. return NeedParameterUpdate_OGL(group, source);
  1096. #endif
  1097. #ifdef URHO3D_D3D9
  1098. if (gapi == GAPI_D3D9)
  1099. return NeedParameterUpdate_D3D9(group, source);
  1100. #endif
  1101. #ifdef URHO3D_D3D11
  1102. if (gapi == GAPI_D3D11)
  1103. return NeedParameterUpdate_D3D11(group, source);
  1104. #endif
  1105. return {}; // Prevent warning
  1106. }
  1107. bool Graphics::HasShaderParameter(StringHash param)
  1108. {
  1109. GAPI gapi = Graphics::GetGAPI();
  1110. #ifdef URHO3D_OPENGL
  1111. if (gapi == GAPI_OPENGL)
  1112. return HasShaderParameter_OGL(param);
  1113. #endif
  1114. #ifdef URHO3D_D3D9
  1115. if (gapi == GAPI_D3D9)
  1116. return HasShaderParameter_D3D9(param);
  1117. #endif
  1118. #ifdef URHO3D_D3D11
  1119. if (gapi == GAPI_D3D11)
  1120. return HasShaderParameter_D3D11(param);
  1121. #endif
  1122. return {}; // Prevent warning
  1123. }
  1124. bool Graphics::HasTextureUnit(TextureUnit unit)
  1125. {
  1126. GAPI gapi = Graphics::GetGAPI();
  1127. #ifdef URHO3D_OPENGL
  1128. if (gapi == GAPI_OPENGL)
  1129. return HasTextureUnit_OGL(unit);
  1130. #endif
  1131. #ifdef URHO3D_D3D9
  1132. if (gapi == GAPI_D3D9)
  1133. return HasTextureUnit_D3D9(unit);
  1134. #endif
  1135. #ifdef URHO3D_D3D11
  1136. if (gapi == GAPI_D3D11)
  1137. return HasTextureUnit_D3D11(unit);
  1138. #endif
  1139. return {}; // Prevent warning
  1140. }
  1141. void Graphics::ClearParameterSource(ShaderParameterGroup group)
  1142. {
  1143. GAPI gapi = Graphics::GetGAPI();
  1144. #ifdef URHO3D_OPENGL
  1145. if (gapi == GAPI_OPENGL)
  1146. return ClearParameterSource_OGL(group);
  1147. #endif
  1148. #ifdef URHO3D_D3D9
  1149. if (gapi == GAPI_D3D9)
  1150. return ClearParameterSource_D3D9(group);
  1151. #endif
  1152. #ifdef URHO3D_D3D11
  1153. if (gapi == GAPI_D3D11)
  1154. return ClearParameterSource_D3D11(group);
  1155. #endif
  1156. }
  1157. void Graphics::ClearParameterSources()
  1158. {
  1159. GAPI gapi = Graphics::GetGAPI();
  1160. #ifdef URHO3D_OPENGL
  1161. if (gapi == GAPI_OPENGL)
  1162. return ClearParameterSources_OGL();
  1163. #endif
  1164. #ifdef URHO3D_D3D9
  1165. if (gapi == GAPI_D3D9)
  1166. return ClearParameterSources_D3D9();
  1167. #endif
  1168. #ifdef URHO3D_D3D11
  1169. if (gapi == GAPI_D3D11)
  1170. return ClearParameterSources_D3D11();
  1171. #endif
  1172. }
  1173. void Graphics::ClearTransformSources()
  1174. {
  1175. GAPI gapi = Graphics::GetGAPI();
  1176. #ifdef URHO3D_OPENGL
  1177. if (gapi == GAPI_OPENGL)
  1178. return ClearTransformSources_OGL();
  1179. #endif
  1180. #ifdef URHO3D_D3D9
  1181. if (gapi == GAPI_D3D9)
  1182. return ClearTransformSources_D3D9();
  1183. #endif
  1184. #ifdef URHO3D_D3D11
  1185. if (gapi == GAPI_D3D11)
  1186. return ClearTransformSources_D3D11();
  1187. #endif
  1188. }
  1189. void Graphics::SetTexture(unsigned index, Texture* texture)
  1190. {
  1191. GAPI gapi = Graphics::GetGAPI();
  1192. #ifdef URHO3D_OPENGL
  1193. if (gapi == GAPI_OPENGL)
  1194. return SetTexture_OGL(index, texture);
  1195. #endif
  1196. #ifdef URHO3D_D3D9
  1197. if (gapi == GAPI_D3D9)
  1198. return SetTexture_D3D9(index, texture);
  1199. #endif
  1200. #ifdef URHO3D_D3D11
  1201. if (gapi == GAPI_D3D11)
  1202. return SetTexture_D3D11(index, texture);
  1203. #endif
  1204. }
  1205. void Graphics::SetDefaultTextureFilterMode(TextureFilterMode mode)
  1206. {
  1207. GAPI gapi = Graphics::GetGAPI();
  1208. #ifdef URHO3D_OPENGL
  1209. if (gapi == GAPI_OPENGL)
  1210. return SetDefaultTextureFilterMode_OGL(mode);
  1211. #endif
  1212. #ifdef URHO3D_D3D9
  1213. if (gapi == GAPI_D3D9)
  1214. return SetDefaultTextureFilterMode_D3D9(mode);
  1215. #endif
  1216. #ifdef URHO3D_D3D11
  1217. if (gapi == GAPI_D3D11)
  1218. return SetDefaultTextureFilterMode_D3D11(mode);
  1219. #endif
  1220. }
  1221. void Graphics::SetDefaultTextureAnisotropy(unsigned level)
  1222. {
  1223. GAPI gapi = Graphics::GetGAPI();
  1224. #ifdef URHO3D_OPENGL
  1225. if (gapi == GAPI_OPENGL)
  1226. return SetDefaultTextureAnisotropy_OGL(level);
  1227. #endif
  1228. #ifdef URHO3D_D3D9
  1229. if (gapi == GAPI_D3D9)
  1230. return SetDefaultTextureAnisotropy_D3D9(level);
  1231. #endif
  1232. #ifdef URHO3D_D3D11
  1233. if (gapi == GAPI_D3D11)
  1234. return SetDefaultTextureAnisotropy_D3D11(level);
  1235. #endif
  1236. }
  1237. void Graphics::ResetRenderTargets()
  1238. {
  1239. GAPI gapi = Graphics::GetGAPI();
  1240. #ifdef URHO3D_OPENGL
  1241. if (gapi == GAPI_OPENGL)
  1242. return ResetRenderTargets_OGL();
  1243. #endif
  1244. #ifdef URHO3D_D3D9
  1245. if (gapi == GAPI_D3D9)
  1246. return ResetRenderTargets_D3D9();
  1247. #endif
  1248. #ifdef URHO3D_D3D11
  1249. if (gapi == GAPI_D3D11)
  1250. return ResetRenderTargets_D3D11();
  1251. #endif
  1252. }
  1253. void Graphics::ResetRenderTarget(unsigned index)
  1254. {
  1255. GAPI gapi = Graphics::GetGAPI();
  1256. #ifdef URHO3D_OPENGL
  1257. if (gapi == GAPI_OPENGL)
  1258. return ResetRenderTarget_OGL(index);
  1259. #endif
  1260. #ifdef URHO3D_D3D9
  1261. if (gapi == GAPI_D3D9)
  1262. return ResetRenderTarget_D3D9(index);
  1263. #endif
  1264. #ifdef URHO3D_D3D11
  1265. if (gapi == GAPI_D3D11)
  1266. return ResetRenderTarget_D3D11(index);
  1267. #endif
  1268. }
  1269. void Graphics::ResetDepthStencil()
  1270. {
  1271. GAPI gapi = Graphics::GetGAPI();
  1272. #ifdef URHO3D_OPENGL
  1273. if (gapi == GAPI_OPENGL)
  1274. return ResetDepthStencil_OGL();
  1275. #endif
  1276. #ifdef URHO3D_D3D9
  1277. if (gapi == GAPI_D3D9)
  1278. return ResetDepthStencil_D3D9();
  1279. #endif
  1280. #ifdef URHO3D_D3D11
  1281. if (gapi == GAPI_D3D11)
  1282. return ResetDepthStencil_D3D11();
  1283. #endif
  1284. }
  1285. void Graphics::SetRenderTarget(unsigned index, RenderSurface* renderTarget)
  1286. {
  1287. GAPI gapi = Graphics::GetGAPI();
  1288. #ifdef URHO3D_OPENGL
  1289. if (gapi == GAPI_OPENGL)
  1290. return SetRenderTarget_OGL(index, renderTarget);
  1291. #endif
  1292. #ifdef URHO3D_D3D9
  1293. if (gapi == GAPI_D3D9)
  1294. return SetRenderTarget_D3D9(index, renderTarget);
  1295. #endif
  1296. #ifdef URHO3D_D3D11
  1297. if (gapi == GAPI_D3D11)
  1298. return SetRenderTarget_D3D11(index, renderTarget);
  1299. #endif
  1300. }
  1301. void Graphics::SetRenderTarget(unsigned index, Texture2D* texture)
  1302. {
  1303. GAPI gapi = Graphics::GetGAPI();
  1304. #ifdef URHO3D_OPENGL
  1305. if (gapi == GAPI_OPENGL)
  1306. return SetRenderTarget_OGL(index, texture);
  1307. #endif
  1308. #ifdef URHO3D_D3D9
  1309. if (gapi == GAPI_D3D9)
  1310. return SetRenderTarget_D3D9(index, texture);
  1311. #endif
  1312. #ifdef URHO3D_D3D11
  1313. if (gapi == GAPI_D3D11)
  1314. return SetRenderTarget_D3D11(index, texture);
  1315. #endif
  1316. }
  1317. void Graphics::SetDepthStencil(RenderSurface* depthStencil)
  1318. {
  1319. GAPI gapi = Graphics::GetGAPI();
  1320. #ifdef URHO3D_OPENGL
  1321. if (gapi == GAPI_OPENGL)
  1322. return SetDepthStencil_OGL(depthStencil);
  1323. #endif
  1324. #ifdef URHO3D_D3D9
  1325. if (gapi == GAPI_D3D9)
  1326. return SetDepthStencil_D3D9(depthStencil);
  1327. #endif
  1328. #ifdef URHO3D_D3D11
  1329. if (gapi == GAPI_D3D11)
  1330. return SetDepthStencil_D3D11(depthStencil);
  1331. #endif
  1332. }
  1333. void Graphics::SetDepthStencil(Texture2D* texture)
  1334. {
  1335. GAPI gapi = Graphics::GetGAPI();
  1336. #ifdef URHO3D_OPENGL
  1337. if (gapi == GAPI_OPENGL)
  1338. return SetDepthStencil_OGL(texture);
  1339. #endif
  1340. #ifdef URHO3D_D3D9
  1341. if (gapi == GAPI_D3D9)
  1342. return SetDepthStencil_D3D9(texture);
  1343. #endif
  1344. #ifdef URHO3D_D3D11
  1345. if (gapi == GAPI_D3D11)
  1346. return SetDepthStencil_D3D11(texture);
  1347. #endif
  1348. }
  1349. void Graphics::SetViewport(const IntRect& rect)
  1350. {
  1351. GAPI gapi = Graphics::GetGAPI();
  1352. #ifdef URHO3D_OPENGL
  1353. if (gapi == GAPI_OPENGL)
  1354. return SetViewport_OGL(rect);
  1355. #endif
  1356. #ifdef URHO3D_D3D9
  1357. if (gapi == GAPI_D3D9)
  1358. return SetViewport_D3D9(rect);
  1359. #endif
  1360. #ifdef URHO3D_D3D11
  1361. if (gapi == GAPI_D3D11)
  1362. return SetViewport_D3D11(rect);
  1363. #endif
  1364. }
  1365. void Graphics::SetBlendMode(BlendMode mode, bool alphaToCoverage)
  1366. {
  1367. GAPI gapi = Graphics::GetGAPI();
  1368. #ifdef URHO3D_OPENGL
  1369. if (gapi == GAPI_OPENGL)
  1370. return SetBlendMode_OGL(mode, alphaToCoverage);
  1371. #endif
  1372. #ifdef URHO3D_D3D9
  1373. if (gapi == GAPI_D3D9)
  1374. return SetBlendMode_D3D9(mode, alphaToCoverage);
  1375. #endif
  1376. #ifdef URHO3D_D3D11
  1377. if (gapi == GAPI_D3D11)
  1378. return SetBlendMode_D3D11(mode, alphaToCoverage);
  1379. #endif
  1380. }
  1381. void Graphics::SetColorWrite(bool enable)
  1382. {
  1383. GAPI gapi = Graphics::GetGAPI();
  1384. #ifdef URHO3D_OPENGL
  1385. if (gapi == GAPI_OPENGL)
  1386. return SetColorWrite_OGL(enable);
  1387. #endif
  1388. #ifdef URHO3D_D3D9
  1389. if (gapi == GAPI_D3D9)
  1390. return SetColorWrite_D3D9(enable);
  1391. #endif
  1392. #ifdef URHO3D_D3D11
  1393. if (gapi == GAPI_D3D11)
  1394. return SetColorWrite_D3D11(enable);
  1395. #endif
  1396. }
  1397. void Graphics::SetCullMode(CullMode mode)
  1398. {
  1399. GAPI gapi = Graphics::GetGAPI();
  1400. #ifdef URHO3D_OPENGL
  1401. if (gapi == GAPI_OPENGL)
  1402. return SetCullMode_OGL(mode);
  1403. #endif
  1404. #ifdef URHO3D_D3D9
  1405. if (gapi == GAPI_D3D9)
  1406. return SetCullMode_D3D9(mode);
  1407. #endif
  1408. #ifdef URHO3D_D3D11
  1409. if (gapi == GAPI_D3D11)
  1410. return SetCullMode_D3D11(mode);
  1411. #endif
  1412. }
  1413. void Graphics::SetDepthBias(float constantBias, float slopeScaledBias)
  1414. {
  1415. GAPI gapi = Graphics::GetGAPI();
  1416. #ifdef URHO3D_OPENGL
  1417. if (gapi == GAPI_OPENGL)
  1418. return SetDepthBias_OGL(constantBias, slopeScaledBias);
  1419. #endif
  1420. #ifdef URHO3D_D3D9
  1421. if (gapi == GAPI_D3D9)
  1422. return SetDepthBias_D3D9(constantBias, slopeScaledBias);
  1423. #endif
  1424. #ifdef URHO3D_D3D11
  1425. if (gapi == GAPI_D3D11)
  1426. return SetDepthBias_D3D11(constantBias, slopeScaledBias);
  1427. #endif
  1428. }
  1429. void Graphics::SetDepthTest(CompareMode mode)
  1430. {
  1431. GAPI gapi = Graphics::GetGAPI();
  1432. #ifdef URHO3D_OPENGL
  1433. if (gapi == GAPI_OPENGL)
  1434. return SetDepthTest_OGL(mode);
  1435. #endif
  1436. #ifdef URHO3D_D3D9
  1437. if (gapi == GAPI_D3D9)
  1438. return SetDepthTest_D3D9(mode);
  1439. #endif
  1440. #ifdef URHO3D_D3D11
  1441. if (gapi == GAPI_D3D11)
  1442. return SetDepthTest_D3D11(mode);
  1443. #endif
  1444. }
  1445. void Graphics::SetDepthWrite(bool enable)
  1446. {
  1447. GAPI gapi = Graphics::GetGAPI();
  1448. #ifdef URHO3D_OPENGL
  1449. if (gapi == GAPI_OPENGL)
  1450. return SetDepthWrite_OGL(enable);
  1451. #endif
  1452. #ifdef URHO3D_D3D9
  1453. if (gapi == GAPI_D3D9)
  1454. return SetDepthWrite_D3D9(enable);
  1455. #endif
  1456. #ifdef URHO3D_D3D11
  1457. if (gapi == GAPI_D3D11)
  1458. return SetDepthWrite_D3D11(enable);
  1459. #endif
  1460. }
  1461. void Graphics::SetFillMode(FillMode mode)
  1462. {
  1463. GAPI gapi = Graphics::GetGAPI();
  1464. #ifdef URHO3D_OPENGL
  1465. if (gapi == GAPI_OPENGL)
  1466. return SetFillMode_OGL(mode);
  1467. #endif
  1468. #ifdef URHO3D_D3D9
  1469. if (gapi == GAPI_D3D9)
  1470. return SetFillMode_D3D9(mode);
  1471. #endif
  1472. #ifdef URHO3D_D3D11
  1473. if (gapi == GAPI_D3D11)
  1474. return SetFillMode_D3D11(mode);
  1475. #endif
  1476. }
  1477. void Graphics::SetLineAntiAlias(bool enable)
  1478. {
  1479. GAPI gapi = Graphics::GetGAPI();
  1480. #ifdef URHO3D_OPENGL
  1481. if (gapi == GAPI_OPENGL)
  1482. return SetLineAntiAlias_OGL(enable);
  1483. #endif
  1484. #ifdef URHO3D_D3D9
  1485. if (gapi == GAPI_D3D9)
  1486. return SetLineAntiAlias_D3D9(enable);
  1487. #endif
  1488. #ifdef URHO3D_D3D11
  1489. if (gapi == GAPI_D3D11)
  1490. return SetLineAntiAlias_D3D11(enable);
  1491. #endif
  1492. }
  1493. void Graphics::SetScissorTest(bool enable, const Rect& rect, bool borderInclusive)
  1494. {
  1495. GAPI gapi = Graphics::GetGAPI();
  1496. #ifdef URHO3D_OPENGL
  1497. if (gapi == GAPI_OPENGL)
  1498. return SetScissorTest_OGL(enable, rect, borderInclusive);
  1499. #endif
  1500. #ifdef URHO3D_D3D9
  1501. if (gapi == GAPI_D3D9)
  1502. return SetScissorTest_D3D9(enable, rect, borderInclusive);
  1503. #endif
  1504. #ifdef URHO3D_D3D11
  1505. if (gapi == GAPI_D3D11)
  1506. return SetScissorTest_D3D11(enable, rect, borderInclusive);
  1507. #endif
  1508. }
  1509. void Graphics::SetScissorTest(bool enable, const IntRect& rect)
  1510. {
  1511. GAPI gapi = Graphics::GetGAPI();
  1512. #ifdef URHO3D_OPENGL
  1513. if (gapi == GAPI_OPENGL)
  1514. return SetScissorTest_OGL(enable, rect);
  1515. #endif
  1516. #ifdef URHO3D_D3D9
  1517. if (gapi == GAPI_D3D9)
  1518. return SetScissorTest_D3D9(enable, rect);
  1519. #endif
  1520. #ifdef URHO3D_D3D11
  1521. if (gapi == GAPI_D3D11)
  1522. return SetScissorTest_D3D11(enable, rect);
  1523. #endif
  1524. }
  1525. void Graphics::SetClipPlane(bool enable, const Plane& clipPlane, const Matrix3x4& view, const Matrix4& projection)
  1526. {
  1527. GAPI gapi = Graphics::GetGAPI();
  1528. #ifdef URHO3D_OPENGL
  1529. if (gapi == GAPI_OPENGL)
  1530. return SetClipPlane_OGL(enable, clipPlane, view, projection);
  1531. #endif
  1532. #ifdef URHO3D_D3D9
  1533. if (gapi == GAPI_D3D9)
  1534. return SetClipPlane_D3D9(enable, clipPlane, view, projection);
  1535. #endif
  1536. #ifdef URHO3D_D3D11
  1537. if (gapi == GAPI_D3D11)
  1538. return SetClipPlane_D3D11(enable, clipPlane, view, projection);
  1539. #endif
  1540. }
  1541. void Graphics::SetStencilTest(bool enable, CompareMode mode, StencilOp pass, StencilOp fail, StencilOp zFail, unsigned stencilRef,
  1542. unsigned compareMask, unsigned writeMask)
  1543. {
  1544. GAPI gapi = Graphics::GetGAPI();
  1545. #ifdef URHO3D_OPENGL
  1546. if (gapi == GAPI_OPENGL)
  1547. return SetStencilTest_OGL(enable, mode, pass, fail, zFail, stencilRef, compareMask, writeMask);
  1548. #endif
  1549. #ifdef URHO3D_D3D9
  1550. if (gapi == GAPI_D3D9)
  1551. return SetStencilTest_D3D9(enable, mode, pass, fail, zFail, stencilRef, compareMask, writeMask);
  1552. #endif
  1553. #ifdef URHO3D_D3D11
  1554. if (gapi == GAPI_D3D11)
  1555. return SetStencilTest_D3D11(enable, mode, pass, fail, zFail, stencilRef, compareMask, writeMask);
  1556. #endif
  1557. }
  1558. bool Graphics::IsInitialized() const
  1559. {
  1560. GAPI gapi = Graphics::GetGAPI();
  1561. #ifdef URHO3D_OPENGL
  1562. if (gapi == GAPI_OPENGL)
  1563. return IsInitialized_OGL();
  1564. #endif
  1565. #ifdef URHO3D_D3D9
  1566. if (gapi == GAPI_D3D9)
  1567. return IsInitialized_D3D9();
  1568. #endif
  1569. #ifdef URHO3D_D3D11
  1570. if (gapi == GAPI_D3D11)
  1571. return IsInitialized_D3D11();
  1572. #endif
  1573. return {}; // Prevent warning
  1574. }
  1575. bool Graphics::GetDither() const
  1576. {
  1577. GAPI gapi = Graphics::GetGAPI();
  1578. #ifdef URHO3D_OPENGL
  1579. if (gapi == GAPI_OPENGL)
  1580. return GetDither_OGL();
  1581. #endif
  1582. #ifdef URHO3D_D3D9
  1583. if (gapi == GAPI_D3D9)
  1584. return GetDither_D3D9();
  1585. #endif
  1586. #ifdef URHO3D_D3D11
  1587. if (gapi == GAPI_D3D11)
  1588. return GetDither_D3D11();
  1589. #endif
  1590. return {}; // Prevent warning
  1591. }
  1592. bool Graphics::IsDeviceLost() const
  1593. {
  1594. GAPI gapi = Graphics::GetGAPI();
  1595. #ifdef URHO3D_OPENGL
  1596. if (gapi == GAPI_OPENGL)
  1597. return IsDeviceLost_OGL();
  1598. #endif
  1599. #ifdef URHO3D_D3D9
  1600. if (gapi == GAPI_D3D9)
  1601. return IsDeviceLost_D3D9();
  1602. #endif
  1603. #ifdef URHO3D_D3D11
  1604. if (gapi == GAPI_D3D11)
  1605. return IsDeviceLost_D3D11();
  1606. #endif
  1607. return {}; // Prevent warning
  1608. }
  1609. Vector<int> Graphics::GetMultiSampleLevels() const
  1610. {
  1611. GAPI gapi = Graphics::GetGAPI();
  1612. #ifdef URHO3D_OPENGL
  1613. if (gapi == GAPI_OPENGL)
  1614. return GetMultiSampleLevels_OGL();
  1615. #endif
  1616. #ifdef URHO3D_D3D9
  1617. if (gapi == GAPI_D3D9)
  1618. return GetMultiSampleLevels_D3D9();
  1619. #endif
  1620. #ifdef URHO3D_D3D11
  1621. if (gapi == GAPI_D3D11)
  1622. return GetMultiSampleLevels_D3D11();
  1623. #endif
  1624. return {}; // Prevent warning
  1625. }
  1626. unsigned Graphics::GetFormat(CompressedFormat format) const
  1627. {
  1628. GAPI gapi = Graphics::GetGAPI();
  1629. #ifdef URHO3D_OPENGL
  1630. if (gapi == GAPI_OPENGL)
  1631. return GetFormat_OGL(format);
  1632. #endif
  1633. #ifdef URHO3D_D3D9
  1634. if (gapi == GAPI_D3D9)
  1635. return GetFormat_D3D9(format);
  1636. #endif
  1637. #ifdef URHO3D_D3D11
  1638. if (gapi == GAPI_D3D11)
  1639. return GetFormat_D3D11(format);
  1640. #endif
  1641. return {}; // Prevent warning
  1642. }
  1643. ShaderVariation* Graphics::GetShader(ShaderType type, const String& name, const String& defines) const
  1644. {
  1645. GAPI gapi = Graphics::GetGAPI();
  1646. #ifdef URHO3D_OPENGL
  1647. if (gapi == GAPI_OPENGL)
  1648. return GetShader_OGL(type, name, defines);
  1649. #endif
  1650. #ifdef URHO3D_D3D9
  1651. if (gapi == GAPI_D3D9)
  1652. return GetShader_D3D9(type, name, defines);
  1653. #endif
  1654. #ifdef URHO3D_D3D11
  1655. if (gapi == GAPI_D3D11)
  1656. return GetShader_D3D11(type, name, defines);
  1657. #endif
  1658. return {}; // Prevent warning
  1659. }
  1660. ShaderVariation* Graphics::GetShader(ShaderType type, const char* name, const char* defines) const
  1661. {
  1662. GAPI gapi = Graphics::GetGAPI();
  1663. #ifdef URHO3D_OPENGL
  1664. if (gapi == GAPI_OPENGL)
  1665. return GetShader_OGL(type, name, defines);
  1666. #endif
  1667. #ifdef URHO3D_D3D9
  1668. if (gapi == GAPI_D3D9)
  1669. return GetShader_D3D9(type, name, defines);
  1670. #endif
  1671. #ifdef URHO3D_D3D11
  1672. if (gapi == GAPI_D3D11)
  1673. return GetShader_D3D11(type, name, defines);
  1674. #endif
  1675. return {}; // Prevent warning
  1676. }
  1677. VertexBuffer* Graphics::GetVertexBuffer(unsigned index) const
  1678. {
  1679. GAPI gapi = Graphics::GetGAPI();
  1680. #ifdef URHO3D_OPENGL
  1681. if (gapi == GAPI_OPENGL)
  1682. return GetVertexBuffer_OGL(index);
  1683. #endif
  1684. #ifdef URHO3D_D3D9
  1685. if (gapi == GAPI_D3D9)
  1686. return GetVertexBuffer_D3D9(index);
  1687. #endif
  1688. #ifdef URHO3D_D3D11
  1689. if (gapi == GAPI_D3D11)
  1690. return GetVertexBuffer_D3D11(index);
  1691. #endif
  1692. return {}; // Prevent warning
  1693. }
  1694. TextureUnit Graphics::GetTextureUnit(const String& name)
  1695. {
  1696. GAPI gapi = Graphics::GetGAPI();
  1697. #ifdef URHO3D_OPENGL
  1698. if (gapi == GAPI_OPENGL)
  1699. return GetTextureUnit_OGL(name);
  1700. #endif
  1701. #ifdef URHO3D_D3D9
  1702. if (gapi == GAPI_D3D9)
  1703. return GetTextureUnit_D3D9(name);
  1704. #endif
  1705. #ifdef URHO3D_D3D11
  1706. if (gapi == GAPI_D3D11)
  1707. return GetTextureUnit_D3D11(name);
  1708. #endif
  1709. return {}; // Prevent warning
  1710. }
  1711. const String& Graphics::GetTextureUnitName(TextureUnit unit)
  1712. {
  1713. GAPI gapi = Graphics::GetGAPI();
  1714. #ifdef URHO3D_OPENGL
  1715. if (gapi == GAPI_OPENGL)
  1716. return GetTextureUnitName_OGL(unit);
  1717. #endif
  1718. #ifdef URHO3D_D3D9
  1719. if (gapi == GAPI_D3D9)
  1720. return GetTextureUnitName_D3D9(unit);
  1721. #endif
  1722. #ifdef URHO3D_D3D11
  1723. if (gapi == GAPI_D3D11)
  1724. return GetTextureUnitName_D3D11(unit);
  1725. #endif
  1726. return String::EMPTY; // Prevent warning
  1727. }
  1728. Texture* Graphics::GetTexture(unsigned index) const
  1729. {
  1730. GAPI gapi = Graphics::GetGAPI();
  1731. #ifdef URHO3D_OPENGL
  1732. if (gapi == GAPI_OPENGL)
  1733. return GetTexture_OGL(index);
  1734. #endif
  1735. #ifdef URHO3D_D3D9
  1736. if (gapi == GAPI_D3D9)
  1737. return GetTexture_D3D9(index);
  1738. #endif
  1739. #ifdef URHO3D_D3D11
  1740. if (gapi == GAPI_D3D11)
  1741. return GetTexture_D3D11(index);
  1742. #endif
  1743. return {}; // Prevent warning
  1744. }
  1745. RenderSurface* Graphics::GetRenderTarget(unsigned index) const
  1746. {
  1747. GAPI gapi = Graphics::GetGAPI();
  1748. #ifdef URHO3D_OPENGL
  1749. if (gapi == GAPI_OPENGL)
  1750. return GetRenderTarget_OGL(index);
  1751. #endif
  1752. #ifdef URHO3D_D3D9
  1753. if (gapi == GAPI_D3D9)
  1754. return GetRenderTarget_D3D9(index);
  1755. #endif
  1756. #ifdef URHO3D_D3D11
  1757. if (gapi == GAPI_D3D11)
  1758. return GetRenderTarget_D3D11(index);
  1759. #endif
  1760. return {}; // Prevent warning
  1761. }
  1762. IntVector2 Graphics::GetRenderTargetDimensions() const
  1763. {
  1764. GAPI gapi = Graphics::GetGAPI();
  1765. #ifdef URHO3D_OPENGL
  1766. if (gapi == GAPI_OPENGL)
  1767. return GetRenderTargetDimensions_OGL();
  1768. #endif
  1769. #ifdef URHO3D_D3D9
  1770. if (gapi == GAPI_D3D9)
  1771. return GetRenderTargetDimensions_D3D9();
  1772. #endif
  1773. #ifdef URHO3D_D3D11
  1774. if (gapi == GAPI_D3D11)
  1775. return GetRenderTargetDimensions_D3D11();
  1776. #endif
  1777. return {}; // Prevent warning
  1778. }
  1779. void Graphics::OnWindowResized()
  1780. {
  1781. GAPI gapi = Graphics::GetGAPI();
  1782. #ifdef URHO3D_OPENGL
  1783. if (gapi == GAPI_OPENGL)
  1784. return OnWindowResized_OGL();
  1785. #endif
  1786. #ifdef URHO3D_D3D9
  1787. if (gapi == GAPI_D3D9)
  1788. return OnWindowResized_D3D9();
  1789. #endif
  1790. #ifdef URHO3D_D3D11
  1791. if (gapi == GAPI_D3D11)
  1792. return OnWindowResized_D3D11();
  1793. #endif
  1794. }
  1795. void Graphics::OnWindowMoved()
  1796. {
  1797. GAPI gapi = Graphics::GetGAPI();
  1798. #ifdef URHO3D_OPENGL
  1799. if (gapi == GAPI_OPENGL)
  1800. return OnWindowMoved_OGL();
  1801. #endif
  1802. #ifdef URHO3D_D3D9
  1803. if (gapi == GAPI_D3D9)
  1804. return OnWindowMoved_D3D9();
  1805. #endif
  1806. #ifdef URHO3D_D3D11
  1807. if (gapi == GAPI_D3D11)
  1808. return OnWindowMoved_D3D11();
  1809. #endif
  1810. }
  1811. ConstantBuffer* Graphics::GetOrCreateConstantBuffer(ShaderType type, unsigned index, unsigned size)
  1812. {
  1813. GAPI gapi = Graphics::GetGAPI();
  1814. #ifdef URHO3D_OPENGL
  1815. if (gapi == GAPI_OPENGL)
  1816. return GetOrCreateConstantBuffer_OGL(type, index, size);
  1817. #endif
  1818. #ifdef URHO3D_D3D9
  1819. if (gapi == GAPI_D3D9)
  1820. return GetOrCreateConstantBuffer_D3D9(type, index, size);
  1821. #endif
  1822. #ifdef URHO3D_D3D11
  1823. if (gapi == GAPI_D3D11)
  1824. return GetOrCreateConstantBuffer_D3D11(type, index, size);
  1825. #endif
  1826. return {}; // Prevent warning
  1827. }
  1828. unsigned Graphics::GetMaxBones()
  1829. {
  1830. GAPI gapi = Graphics::GetGAPI();
  1831. #ifdef URHO3D_OPENGL
  1832. if (gapi == GAPI_OPENGL)
  1833. return GetMaxBones_OGL();
  1834. #endif
  1835. #ifdef URHO3D_D3D9
  1836. if (gapi == GAPI_D3D9)
  1837. return GetMaxBones_D3D9();
  1838. #endif
  1839. #ifdef URHO3D_D3D11
  1840. if (gapi == GAPI_D3D11)
  1841. return GetMaxBones_D3D11();
  1842. #endif
  1843. return {}; // Prevent warning
  1844. }
  1845. bool Graphics::GetGL3Support()
  1846. {
  1847. GAPI gapi = Graphics::GetGAPI();
  1848. #ifdef URHO3D_OPENGL
  1849. if (gapi == GAPI_OPENGL)
  1850. return GetGL3Support_OGL();
  1851. #endif
  1852. #ifdef URHO3D_D3D9
  1853. if (gapi == GAPI_D3D9)
  1854. return GetGL3Support_D3D9();
  1855. #endif
  1856. #ifdef URHO3D_D3D11
  1857. if (gapi == GAPI_D3D11)
  1858. return GetGL3Support_D3D11();
  1859. #endif
  1860. return {}; // Prevent warning
  1861. }
  1862. unsigned Graphics::GetAlphaFormat()
  1863. {
  1864. GAPI gapi = Graphics::GetGAPI();
  1865. #ifdef URHO3D_OPENGL
  1866. if (gapi == GAPI_OPENGL)
  1867. return GetAlphaFormat_OGL();
  1868. #endif
  1869. #ifdef URHO3D_D3D9
  1870. if (gapi == GAPI_D3D9)
  1871. return GetAlphaFormat_D3D9();
  1872. #endif
  1873. #ifdef URHO3D_D3D11
  1874. if (gapi == GAPI_D3D11)
  1875. return GetAlphaFormat_D3D11();
  1876. #endif
  1877. return {}; // Prevent warning
  1878. }
  1879. unsigned Graphics::GetLuminanceFormat()
  1880. {
  1881. GAPI gapi = Graphics::GetGAPI();
  1882. #ifdef URHO3D_OPENGL
  1883. if (gapi == GAPI_OPENGL)
  1884. return GetLuminanceFormat_OGL();
  1885. #endif
  1886. #ifdef URHO3D_D3D9
  1887. if (gapi == GAPI_D3D9)
  1888. return GetLuminanceFormat_D3D9();
  1889. #endif
  1890. #ifdef URHO3D_D3D11
  1891. if (gapi == GAPI_D3D11)
  1892. return GetLuminanceFormat_D3D11();
  1893. #endif
  1894. return {}; // Prevent warning
  1895. }
  1896. unsigned Graphics::GetLuminanceAlphaFormat()
  1897. {
  1898. GAPI gapi = Graphics::GetGAPI();
  1899. #ifdef URHO3D_OPENGL
  1900. if (gapi == GAPI_OPENGL)
  1901. return GetLuminanceAlphaFormat_OGL();
  1902. #endif
  1903. #ifdef URHO3D_D3D9
  1904. if (gapi == GAPI_D3D9)
  1905. return GetLuminanceAlphaFormat_D3D9();
  1906. #endif
  1907. #ifdef URHO3D_D3D11
  1908. if (gapi == GAPI_D3D11)
  1909. return GetLuminanceAlphaFormat_D3D11();
  1910. #endif
  1911. return {}; // Prevent warning
  1912. }
  1913. unsigned Graphics::GetRGBFormat()
  1914. {
  1915. GAPI gapi = Graphics::GetGAPI();
  1916. #ifdef URHO3D_OPENGL
  1917. if (gapi == GAPI_OPENGL)
  1918. return GetRGBFormat_OGL();
  1919. #endif
  1920. #ifdef URHO3D_D3D9
  1921. if (gapi == GAPI_D3D9)
  1922. return GetRGBFormat_D3D9();
  1923. #endif
  1924. #ifdef URHO3D_D3D11
  1925. if (gapi == GAPI_D3D11)
  1926. return GetRGBFormat_D3D11();
  1927. #endif
  1928. return {}; // Prevent warning
  1929. }
  1930. unsigned Graphics::GetRGBAFormat()
  1931. {
  1932. GAPI gapi = Graphics::GetGAPI();
  1933. #ifdef URHO3D_OPENGL
  1934. if (gapi == GAPI_OPENGL)
  1935. return GetRGBAFormat_OGL();
  1936. #endif
  1937. #ifdef URHO3D_D3D9
  1938. if (gapi == GAPI_D3D9)
  1939. return GetRGBAFormat_D3D9();
  1940. #endif
  1941. #ifdef URHO3D_D3D11
  1942. if (gapi == GAPI_D3D11)
  1943. return GetRGBAFormat_D3D11();
  1944. #endif
  1945. return {}; // Prevent warning
  1946. }
  1947. unsigned Graphics::GetRGBA16Format()
  1948. {
  1949. GAPI gapi = Graphics::GetGAPI();
  1950. #ifdef URHO3D_OPENGL
  1951. if (gapi == GAPI_OPENGL)
  1952. return GetRGBA16Format_OGL();
  1953. #endif
  1954. #ifdef URHO3D_D3D9
  1955. if (gapi == GAPI_D3D9)
  1956. return GetRGBA16Format_D3D9();
  1957. #endif
  1958. #ifdef URHO3D_D3D11
  1959. if (gapi == GAPI_D3D11)
  1960. return GetRGBA16Format_D3D11();
  1961. #endif
  1962. return {}; // Prevent warning
  1963. }
  1964. unsigned Graphics::GetRGBAFloat16Format()
  1965. {
  1966. GAPI gapi = Graphics::GetGAPI();
  1967. #ifdef URHO3D_OPENGL
  1968. if (gapi == GAPI_OPENGL)
  1969. return GetRGBAFloat16Format_OGL();
  1970. #endif
  1971. #ifdef URHO3D_D3D9
  1972. if (gapi == GAPI_D3D9)
  1973. return GetRGBAFloat16Format_D3D9();
  1974. #endif
  1975. #ifdef URHO3D_D3D11
  1976. if (gapi == GAPI_D3D11)
  1977. return GetRGBAFloat16Format_D3D11();
  1978. #endif
  1979. return {}; // Prevent warning
  1980. }
  1981. unsigned Graphics::GetRGBAFloat32Format()
  1982. {
  1983. GAPI gapi = Graphics::GetGAPI();
  1984. #ifdef URHO3D_OPENGL
  1985. if (gapi == GAPI_OPENGL)
  1986. return GetRGBAFloat32Format_OGL();
  1987. #endif
  1988. #ifdef URHO3D_D3D9
  1989. if (gapi == GAPI_D3D9)
  1990. return GetRGBAFloat32Format_D3D9();
  1991. #endif
  1992. #ifdef URHO3D_D3D11
  1993. if (gapi == GAPI_D3D11)
  1994. return GetRGBAFloat32Format_D3D11();
  1995. #endif
  1996. return {}; // Prevent warning
  1997. }
  1998. unsigned Graphics::GetRG16Format()
  1999. {
  2000. GAPI gapi = Graphics::GetGAPI();
  2001. #ifdef URHO3D_OPENGL
  2002. if (gapi == GAPI_OPENGL)
  2003. return GetRG16Format_OGL();
  2004. #endif
  2005. #ifdef URHO3D_D3D9
  2006. if (gapi == GAPI_D3D9)
  2007. return GetRG16Format_D3D9();
  2008. #endif
  2009. #ifdef URHO3D_D3D11
  2010. if (gapi == GAPI_D3D11)
  2011. return GetRG16Format_D3D11();
  2012. #endif
  2013. return {}; // Prevent warning
  2014. }
  2015. unsigned Graphics::GetRGFloat16Format()
  2016. {
  2017. GAPI gapi = Graphics::GetGAPI();
  2018. #ifdef URHO3D_OPENGL
  2019. if (gapi == GAPI_OPENGL)
  2020. return GetRGFloat16Format_OGL();
  2021. #endif
  2022. #ifdef URHO3D_D3D9
  2023. if (gapi == GAPI_D3D9)
  2024. return GetRGFloat16Format_D3D9();
  2025. #endif
  2026. #ifdef URHO3D_D3D11
  2027. if (gapi == GAPI_D3D11)
  2028. return GetRGFloat16Format_D3D11();
  2029. #endif
  2030. return {}; // Prevent warning
  2031. }
  2032. unsigned Graphics::GetRGFloat32Format()
  2033. {
  2034. GAPI gapi = Graphics::GetGAPI();
  2035. #ifdef URHO3D_OPENGL
  2036. if (gapi == GAPI_OPENGL)
  2037. return GetRGFloat32Format_OGL();
  2038. #endif
  2039. #ifdef URHO3D_D3D9
  2040. if (gapi == GAPI_D3D9)
  2041. return GetRGFloat32Format_D3D9();
  2042. #endif
  2043. #ifdef URHO3D_D3D11
  2044. if (gapi == GAPI_D3D11)
  2045. return GetRGFloat32Format_D3D11();
  2046. #endif
  2047. return {}; // Prevent warning
  2048. }
  2049. unsigned Graphics::GetFloat16Format()
  2050. {
  2051. GAPI gapi = Graphics::GetGAPI();
  2052. #ifdef URHO3D_OPENGL
  2053. if (gapi == GAPI_OPENGL)
  2054. return GetFloat16Format_OGL();
  2055. #endif
  2056. #ifdef URHO3D_D3D9
  2057. if (gapi == GAPI_D3D9)
  2058. return GetFloat16Format_D3D9();
  2059. #endif
  2060. #ifdef URHO3D_D3D11
  2061. if (gapi == GAPI_D3D11)
  2062. return GetFloat16Format_D3D11();
  2063. #endif
  2064. return {}; // Prevent warning
  2065. }
  2066. unsigned Graphics::GetFloat32Format()
  2067. {
  2068. GAPI gapi = Graphics::GetGAPI();
  2069. #ifdef URHO3D_OPENGL
  2070. if (gapi == GAPI_OPENGL)
  2071. return GetFloat32Format_OGL();
  2072. #endif
  2073. #ifdef URHO3D_D3D9
  2074. if (gapi == GAPI_D3D9)
  2075. return GetFloat32Format_D3D9();
  2076. #endif
  2077. #ifdef URHO3D_D3D11
  2078. if (gapi == GAPI_D3D11)
  2079. return GetFloat32Format_D3D11();
  2080. #endif
  2081. return {}; // Prevent warning
  2082. }
  2083. unsigned Graphics::GetLinearDepthFormat()
  2084. {
  2085. GAPI gapi = Graphics::GetGAPI();
  2086. #ifdef URHO3D_OPENGL
  2087. if (gapi == GAPI_OPENGL)
  2088. return GetLinearDepthFormat_OGL();
  2089. #endif
  2090. #ifdef URHO3D_D3D9
  2091. if (gapi == GAPI_D3D9)
  2092. return GetLinearDepthFormat_D3D9();
  2093. #endif
  2094. #ifdef URHO3D_D3D11
  2095. if (gapi == GAPI_D3D11)
  2096. return GetLinearDepthFormat_D3D11();
  2097. #endif
  2098. return {}; // Prevent warning
  2099. }
  2100. unsigned Graphics::GetDepthStencilFormat()
  2101. {
  2102. GAPI gapi = Graphics::GetGAPI();
  2103. #ifdef URHO3D_OPENGL
  2104. if (gapi == GAPI_OPENGL)
  2105. return GetDepthStencilFormat_OGL();
  2106. #endif
  2107. #ifdef URHO3D_D3D9
  2108. if (gapi == GAPI_D3D9)
  2109. return GetDepthStencilFormat_D3D9();
  2110. #endif
  2111. #ifdef URHO3D_D3D11
  2112. if (gapi == GAPI_D3D11)
  2113. return GetDepthStencilFormat_D3D11();
  2114. #endif
  2115. return {}; // Prevent warning
  2116. }
  2117. unsigned Graphics::GetReadableDepthFormat()
  2118. {
  2119. GAPI gapi = Graphics::GetGAPI();
  2120. #ifdef URHO3D_OPENGL
  2121. if (gapi == GAPI_OPENGL)
  2122. return GetReadableDepthFormat_OGL();
  2123. #endif
  2124. #ifdef URHO3D_D3D9
  2125. if (gapi == GAPI_D3D9)
  2126. return GetReadableDepthFormat_D3D9();
  2127. #endif
  2128. #ifdef URHO3D_D3D11
  2129. if (gapi == GAPI_D3D11)
  2130. return GetReadableDepthFormat_D3D11();
  2131. #endif
  2132. return {}; // Prevent warning
  2133. }
  2134. unsigned Graphics::GetFormat(const String& formatName)
  2135. {
  2136. GAPI gapi = Graphics::GetGAPI();
  2137. #ifdef URHO3D_OPENGL
  2138. if (gapi == GAPI_OPENGL)
  2139. return GetFormat_OGL(formatName);
  2140. #endif
  2141. #ifdef URHO3D_D3D9
  2142. if (gapi == GAPI_D3D9)
  2143. return GetFormat_D3D9(formatName);
  2144. #endif
  2145. #ifdef URHO3D_D3D11
  2146. if (gapi == GAPI_D3D11)
  2147. return GetFormat_D3D11(formatName);
  2148. #endif
  2149. return {}; // Prevent warning
  2150. }
  2151. void RegisterGraphicsLibrary(Context* context)
  2152. {
  2153. Animation::RegisterObject(context);
  2154. Material::RegisterObject(context);
  2155. Model::RegisterObject(context);
  2156. Shader::RegisterObject(context);
  2157. Technique::RegisterObject(context);
  2158. Texture2D::RegisterObject(context);
  2159. Texture2DArray::RegisterObject(context);
  2160. Texture3D::RegisterObject(context);
  2161. TextureCube::RegisterObject(context);
  2162. Camera::RegisterObject(context);
  2163. Drawable::RegisterObject(context);
  2164. Light::RegisterObject(context);
  2165. StaticModel::RegisterObject(context);
  2166. StaticModelGroup::RegisterObject(context);
  2167. Skybox::RegisterObject(context);
  2168. AnimatedModel::RegisterObject(context);
  2169. AnimationController::RegisterObject(context);
  2170. BillboardSet::RegisterObject(context);
  2171. ParticleEffect::RegisterObject(context);
  2172. ParticleEmitter::RegisterObject(context);
  2173. RibbonTrail::RegisterObject(context);
  2174. CustomGeometry::RegisterObject(context);
  2175. DecalSet::RegisterObject(context);
  2176. Terrain::RegisterObject(context);
  2177. TerrainPatch::RegisterObject(context);
  2178. DebugRenderer::RegisterObject(context);
  2179. Octree::RegisterObject(context);
  2180. Zone::RegisterObject(context);
  2181. }
  2182. }