Graphics.cpp 59 KB

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