renderTargetTexture.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. // Copyright (C) 2008-2012 Christian Stehno, Colin MacDonald
  2. // No rights reserved: this software is in the public domain.
  3. #include "testUtils.h"
  4. using namespace irr;
  5. //! Tests rendering RTTs with draw2DImage
  6. /** This test is very special in its setup, problematic situation was found by stefbuet. */
  7. static bool testWith2DImage(video::E_DRIVER_TYPE driverType)
  8. {
  9. IrrlichtDevice *device = createDevice(driverType, core::dimension2d<u32> (256, 128));
  10. if (!device)
  11. return true; // No error if device does not exist
  12. video::IVideoDriver *driver = device->getVideoDriver ();
  13. scene::ISceneManager *smgr = device->getSceneManager ();
  14. if (!driver->queryFeature(video::EVDF_RENDER_TO_TARGET))
  15. {
  16. device->closeDevice();
  17. device->run();
  18. device->drop();
  19. return true;
  20. }
  21. stabilizeScreenBackground(driver);
  22. logTestString("Testing driver %ls\n", driver->getName());
  23. video::ITexture *image = driver->getTexture ("../media/irrlichtlogo2.png");
  24. video::ITexture *RTT_texture = driver->addRenderTargetTexture (core::dimension2d < u32 > (256, 128));
  25. smgr->addCameraSceneNode (0, core::vector3df (100, 100, 100),
  26. core::vector3df (0, 0, 0));
  27. /*to reproduce the bug :
  28. -draw the image : it's normal
  29. -apply an RTT texture to a model
  30. -remove the model
  31. -draw the image again : it's flipped
  32. */
  33. video::SColor colors[4]={0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff};
  34. //draw the image :
  35. driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor (255, 200, 200, 200));
  36. driver->draw2DImage (image,
  37. core::rect < s32 >
  38. (64 - image->getSize ().Width / 2,
  39. 64 - image->getSize ().Height / 2,
  40. 64 + image->getSize ().Width / 2,
  41. 64 + image->getSize ().Height / 2),
  42. core::rect < s32 > (0, 0, image->getSize ().Width,
  43. image->getSize ().Height), 0, colors,
  44. true);
  45. driver->endScene ();
  46. //then create a model and apply to it the RTT Texture
  47. //rendering the model is important, if not rendered 1 time, bug won't appear.
  48. //after the render, we remove the node : important, if not done, bug won't appear too.
  49. scene::IMesh *modelMesh = smgr->getMesh ("../media/earth.x");
  50. scene::ISceneNode *modelNode = smgr->addMeshSceneNode(modelMesh);
  51. modelNode->setMaterialTexture (0, RTT_texture);
  52. driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor (255, 200, 200, 200));
  53. smgr->drawAll();
  54. driver->endScene();
  55. modelNode->remove();
  56. //then we render the image normaly
  57. //it's now fliped...
  58. for (u32 i=0; i<10; ++i)
  59. {
  60. driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor (255, 200, 200, 200));
  61. //draw img
  62. driver->draw2DImage (image,
  63. core::rect < s32 >
  64. (64 - image->getSize ().Width / 2,
  65. 64 - image->getSize ().Height / 2,
  66. 64 + image->getSize ().Width / 2,
  67. 64 + image->getSize ().Height / 2),
  68. core::rect < s32 > (0, 0, image->getSize ().Width,
  69. image->getSize ().Height), 0,
  70. colors, true);
  71. //call this is important :
  72. //if not called, the bug won't appear
  73. smgr->drawAll();
  74. driver->endScene();
  75. }
  76. bool result = takeScreenshotAndCompareAgainstReference(driver, "-rttWith2DImage.png", 99.9f);
  77. device->closeDevice();
  78. device->run();
  79. device->drop();
  80. return result;
  81. }
  82. bool rttAndZBuffer(video::E_DRIVER_TYPE driverType)
  83. {
  84. SIrrlichtCreationParameters cp;
  85. cp.WindowSize.set(160,120);
  86. cp.Bits = 32;
  87. cp.AntiAlias = 4;
  88. cp.DriverType = driverType;
  89. IrrlichtDevice* nullDevice = createDevice(video::EDT_NULL);
  90. cp.WindowSize = nullDevice->getVideoModeList()->getDesktopResolution();
  91. nullDevice->closeDevice();
  92. nullDevice->run();
  93. nullDevice->drop();
  94. cp.WindowSize -= core::dimension2d<u32>(100, 100);
  95. IrrlichtDevice* device = createDeviceEx(cp);
  96. if (!device)
  97. return true;
  98. video::IVideoDriver* vd = device->getVideoDriver();
  99. scene::ISceneManager* sm = device->getSceneManager();
  100. if (!vd->queryFeature(video::EVDF_RENDER_TO_TARGET))
  101. {
  102. device->closeDevice();
  103. device->run();
  104. device->drop();
  105. return true;
  106. }
  107. stabilizeScreenBackground(vd);
  108. logTestString("Testing driver %ls\n", vd->getName());
  109. video::ITexture* renderTargetTex = vd->addRenderTargetTexture(cp.WindowSize, "rt", video::ECF_A32B32G32R32F);
  110. video::ITexture* renderTargetDepth = vd->addRenderTargetTexture(cp.WindowSize, "rtd", video::ECF_D16);
  111. video::IRenderTarget* renderTarget = vd->addRenderTarget();
  112. renderTarget->setTexture(renderTargetTex, renderTargetDepth);
  113. video::S3DVertex vertices[4];
  114. vertices[0].Pos.Z = vertices[1].Pos.Z = vertices[2].Pos.Z = vertices[3].Pos.Z = 1.0f;
  115. vertices[0].Pos.Y = vertices[1].Pos.Y = 1.0f;
  116. vertices[2].Pos.Y = vertices[3].Pos.Y = -1.0f;
  117. vertices[0].Pos.X = vertices[3].Pos.X = -1.0f;
  118. vertices[1].Pos.X = vertices[2].Pos.X = 1.0f;
  119. vertices[0].TCoords.Y = vertices[1].TCoords.Y = 0.0f;
  120. vertices[2].TCoords.Y = vertices[3].TCoords.Y = 1.0f;
  121. vertices[0].TCoords.X = vertices[3].TCoords.X = 1.0f;
  122. vertices[1].TCoords.X = vertices[2].TCoords.X = 0.0f;
  123. u16 indices[6] = {0, 1, 3, 1, 2, 3};
  124. video::SMaterial rtMat;
  125. rtMat.BackfaceCulling = false;
  126. rtMat.Lighting = false;
  127. rtMat.TextureLayer[0].TextureWrapU =
  128. rtMat.TextureLayer[0].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
  129. sm->addLightSceneNode(NULL, core::vector3df(0, 50, 0),
  130. video::SColorf(1, 1, 1), 100);
  131. sm->addCameraSceneNode(NULL, core::vector3df(0, 10, 0));
  132. const scene::IGeometryCreator* geom = sm->getGeometryCreator();
  133. scene::IMeshManipulator* manip = sm->getMeshManipulator();
  134. scene::IMesh* mesh;
  135. scene::ISceneNode* node;
  136. mesh = geom->createCubeMesh(core::vector3df(10, 10, 10));
  137. manip->setVertexColors(mesh, video::SColor(255, 0, 0, 255));
  138. node = sm->addMeshSceneNode(mesh, NULL, -1, core::vector3df(0, 0, 30));
  139. node->getMaterial(0).EmissiveColor = video::SColor(255, 0, 0, 30);
  140. mesh->drop();
  141. mesh = geom->createSphereMesh(5.0f, 32, 32);
  142. node = sm->addMeshSceneNode(mesh, NULL, -1, core::vector3df(0, 0, 50));
  143. node->getMaterial(0).EmissiveColor = video::SColor(255, 30, 30, 30);
  144. mesh->drop();
  145. mesh = geom->createConeMesh(5.0f, 10.0f, 32, video::SColor(255, 255, 0, 0), video::SColor(255, 255, 0, 0));
  146. node = sm->addMeshSceneNode(mesh, NULL, -1, core::vector3df(0, 0, 70));
  147. node->getMaterial(0).EmissiveColor = video::SColor(255, 30, 0, 0);
  148. mesh->drop();
  149. {
  150. vd->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(255, 0, 0, 0));
  151. vd->setRenderTargetEx(renderTarget, video::ECBF_COLOR | video::ECBF_DEPTH);
  152. sm->drawAll();
  153. vd->setRenderTargetEx(0, 0, 0);
  154. vd->setTransform(video::ETS_WORLD, core::IdentityMatrix);
  155. vd->setTransform(video::ETS_VIEW, core::IdentityMatrix);
  156. vd->setTransform(video::ETS_PROJECTION, core::IdentityMatrix);
  157. rtMat.setTexture(0, renderTargetTex);
  158. vd->setMaterial(rtMat);
  159. vd->drawIndexedTriangleList(vertices, 4, indices, 2);
  160. vd->endScene();
  161. }
  162. bool result = takeScreenshotAndCompareAgainstReference(vd, "-rttAndZBuffer.png");
  163. device->closeDevice();
  164. device->run();
  165. device->drop();
  166. return result;
  167. }
  168. // result should be two times the same blind text on the left side, and
  169. // the fireball image (with a very small text inside) in the middle of the screen
  170. // drivers that don't support image scaling will show a pink background instead
  171. bool rttAndText(video::E_DRIVER_TYPE driverType)
  172. {
  173. IrrlichtDevice* device = createDevice(driverType, core::dimension2d<u32>(160, 120));
  174. if (!device)
  175. return true;
  176. video::IVideoDriver* driver = device->getVideoDriver();
  177. gui::IGUIEnvironment* guienv = device->getGUIEnvironment();
  178. if (!driver->queryFeature(video::EVDF_RENDER_TO_TARGET))
  179. {
  180. device->closeDevice();
  181. device->run();
  182. device->drop();
  183. return true;
  184. }
  185. logTestString("Testing driver %ls\n", driver->getName());
  186. //RTT
  187. video::ITexture* renderTargetTex = driver->addRenderTargetTexture(core::dimension2d<u32>(256, 256), "rt");
  188. video::ITexture* renderTargetDepth = driver->addRenderTargetTexture(core::dimension2d<u32>(256, 256), "rtd", video::ECF_D16);
  189. video::IRenderTarget* renderTarget = driver->addRenderTarget();
  190. renderTarget->setTexture(renderTargetTex, renderTargetDepth);
  191. stabilizeScreenBackground(driver);
  192. driver->beginScene(0, video::SColor(255,255, 255, 255));
  193. driver->setRenderTargetEx(renderTarget, video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(255,255,0,255));
  194. driver->draw2DImage(driver->getTexture("../media/fireball.bmp"), core::recti(0, 0, renderTargetTex->getSize().Width, renderTargetTex->getSize().Height), core::recti(0, 0, 64, 64));
  195. guienv->getBuiltInFont()->draw(L"OMGGG =!", core::rect<s32>(120, 100, 256, 256), video::SColor(255, 0, 0, 255));
  196. driver->setRenderTargetEx(0, 0, 0);
  197. driver->endScene();
  198. scene::ISceneManager* smgr = device->getSceneManager();
  199. scene::ISceneNode* cube = smgr->addCubeSceneNode(20);
  200. cube->setMaterialFlag(video::EMF_LIGHTING, false);
  201. cube->setMaterialTexture(0, renderTargetTex); // set material of cube to render target
  202. smgr->addCameraSceneNode(0, core::vector3df(0, 0, -30));
  203. // create a long text to produce much difference in failing result pictures
  204. gui::IGUIStaticText* text = guienv->addStaticText(L"asdddddddoamgmoasmgom\nfoaomsodommogdd\nddddddddd", core::rect<s32>(10, 20, 100, 160));
  205. driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(255,255, 255, 255));
  206. cube->setVisible(false);
  207. smgr->drawAll();
  208. guienv->drawAll();
  209. cube->setVisible(true);
  210. smgr->drawAll();
  211. video::SMaterial mat(cube->getMaterial(0));
  212. driver->setMaterial(mat);
  213. text->setRelativePosition(core::position2di(10,30));
  214. guienv->drawAll();
  215. driver->endScene();
  216. bool result = takeScreenshotAndCompareAgainstReference(driver, "-rttAndText.png");
  217. device->closeDevice();
  218. device->run();
  219. device->drop();
  220. return result;
  221. }
  222. static void Render(IrrlichtDevice* device, video::IRenderTarget* rt, core::vector3df& pos1,
  223. core::vector3df& pos2, scene::IAnimatedMesh* sphereMesh, core::vector3df& pos3, core::vector3df& pos4)
  224. {
  225. video::IVideoDriver* driver = device->getVideoDriver();
  226. driver->setRenderTargetEx(rt, video::ECBF_COLOR | video::ECBF_DEPTH);
  227. device->getSceneManager()->drawAll();
  228. video::SMaterial mat;
  229. mat.ColorMaterial=video::ECM_NONE;
  230. mat.AmbientColor.set(255, 80, 80, 80);
  231. mat.DiffuseColor.set(255, 120, 30, 210);
  232. mat.SpecularColor.set(255,80,80,80);
  233. mat.Shininess = 8.f;
  234. core::matrix4 m;
  235. m.setTranslation(pos1);
  236. driver->setTransform(video::ETS_WORLD, m);
  237. driver->setMaterial(mat);
  238. driver->drawMeshBuffer(sphereMesh->getMeshBuffer(0));
  239. m.setTranslation(pos2);
  240. mat.Shininess=0.f;
  241. driver->setTransform(video::ETS_WORLD, m);
  242. driver->setMaterial(mat);
  243. driver->drawMeshBuffer(sphereMesh->getMeshBuffer(0));
  244. m.setTranslation(pos3);
  245. mat.Shininess=8.f;
  246. driver->setTransform(video::ETS_WORLD, m);
  247. driver->setMaterial(mat);
  248. driver->drawMeshBuffer(sphereMesh->getMeshBuffer(0));
  249. m.setTranslation(pos4);
  250. mat.Shininess=0.f;
  251. driver->setTransform(video::ETS_WORLD, m);
  252. driver->setMaterial(mat);
  253. driver->drawMeshBuffer(sphereMesh->getMeshBuffer(0));
  254. }
  255. bool rttAndAntiAliasing(video::E_DRIVER_TYPE driverType)
  256. {
  257. SIrrlichtCreationParameters cp;
  258. cp.DriverType = driverType;
  259. cp.WindowSize = core::dimension2di(160, 120);
  260. cp.AntiAlias = 2;
  261. cp.Vsync = true;
  262. IrrlichtDevice* device = createDeviceEx(cp);
  263. if (!device)
  264. return true;
  265. video::IVideoDriver* driver = device->getVideoDriver();
  266. if ((driver->getDriverAttributes().getAttributeAsInt("AntiAlias")<2) ||
  267. (!driver->queryFeature(video::EVDF_RENDER_TO_TARGET)))
  268. {
  269. device->closeDevice();
  270. device->run();
  271. device->drop();
  272. return true;
  273. }
  274. stabilizeScreenBackground(driver);
  275. logTestString("Testing driver %ls\n", driver->getName());
  276. // sphere mesh
  277. scene::IAnimatedMesh* sphereMesh = device->getSceneManager()->addSphereMesh("atom", 1, 32, 32);
  278. // cam
  279. scene::ICameraSceneNode* cam = device->getSceneManager()->addCameraSceneNode(NULL, core::vector3df(0, 1, -5), core::vector3df(0, 0, 0));
  280. cam->setNearValue(0.01f);
  281. cam->setFarValue(100.f);
  282. cam->updateAbsolutePosition();
  283. device->getSceneManager()->setActiveCamera(cam);
  284. device->getSceneManager()->addLightSceneNode(0, core::vector3df(10,10,10));
  285. device->getSceneManager()->setAmbientLight(video::SColorf(0.3f,0.3f,0.3f));
  286. float radius = 3.f;
  287. core::vector3df pos1(-radius,0,0);
  288. core::vector3df pos2(radius,0,0);
  289. core::vector3df pos3(0,0,radius);
  290. core::vector3df pos4(0,0,-radius);
  291. core::matrix4 m;
  292. gui::IGUIStaticText* st = device->getGUIEnvironment()->addStaticText(L"", core::recti(0,0,200,20), false, false);
  293. st->setOverrideColor(video::SColor(255,255,255,0));
  294. core::dimension2du dim_txt = core::dimension2du(160/2, 120/2);
  295. video::ITexture* renderTargetTex1 = driver->addRenderTargetTexture(dim_txt, "rt1", device->getColorFormat());
  296. video::ITexture* renderTargetTex2 = driver->addRenderTargetTexture(dim_txt, "rt2", device->getColorFormat());
  297. video::ITexture* renderTargetTex3 = driver->addRenderTargetTexture(dim_txt, "rt3", video::ECF_A8R8G8B8);
  298. video::ITexture* renderTargetTex4 = driver->addRenderTargetTexture(dim_txt, "rt4", device->getColorFormat());
  299. video::ITexture* renderTargetDepth = driver->addRenderTargetTexture(dim_txt, "rtd", video::ECF_D16);
  300. video::IRenderTarget* renderTarget1 = driver->addRenderTarget();
  301. renderTarget1->setTexture(renderTargetTex1, renderTargetDepth);
  302. video::IRenderTarget* renderTarget2 = driver->addRenderTarget();
  303. renderTarget2->setTexture(renderTargetTex2, renderTargetDepth);
  304. video::IRenderTarget* renderTarget3 = driver->addRenderTarget();
  305. renderTarget3->setTexture(renderTargetTex3, renderTargetDepth);
  306. video::IRenderTarget* renderTarget4 = driver->addRenderTarget();
  307. renderTarget4->setTexture(renderTargetTex4, renderTargetDepth);
  308. device->getSceneManager()->setActiveCamera(cam);
  309. device->getVideoDriver()->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(255,0,0,0));
  310. #if 1
  311. st->setText(L"Texture Rendering");
  312. Render(device, renderTarget1, pos1, pos2, sphereMesh, pos3, pos4);
  313. Render(device, renderTarget2, pos1, pos2, sphereMesh, pos3, pos4);
  314. Render(device, renderTarget3, pos1, pos2, sphereMesh, pos3, pos4);
  315. Render(device, renderTarget4, pos1, pos2, sphereMesh, pos3, pos4);
  316. device->getVideoDriver()->setRenderTargetEx(0, video::ECBF_COLOR | video::ECBF_DEPTH);
  317. device->getVideoDriver()->draw2DImage(renderTargetTex1, core::position2di(0, 0));
  318. device->getVideoDriver()->draw2DImage(renderTargetTex2, core::position2di(80, 0));
  319. device->getVideoDriver()->draw2DImage(renderTargetTex3, core::position2di(0, 60));
  320. device->getVideoDriver()->draw2DImage(renderTargetTex4, core::position2di(80, 60));
  321. #else
  322. ITexture* rt0 = NULL;
  323. Render(device, rt0, pos1, pos2, sphereMesh, pos3, pos4);
  324. #endif
  325. st->draw();
  326. device->getVideoDriver()->endScene();
  327. bool result = takeScreenshotAndCompareAgainstReference(driver, "-rttAndAntiAlias.png", 98.25f);
  328. device->closeDevice();
  329. device->run();
  330. device->drop();
  331. return result;
  332. }
  333. bool rttFormats(video::E_DRIVER_TYPE driverType)
  334. {
  335. SIrrlichtCreationParameters cp;
  336. cp.DriverType = driverType;
  337. cp.WindowSize = core::dimension2di(160, 120);
  338. IrrlichtDevice* device = createDeviceEx(cp);
  339. if (!device)
  340. return true;
  341. video::IVideoDriver* driver = device->getVideoDriver();
  342. logTestString("Testing driver %ls\n", driver->getName());
  343. video::ITexture* tex = 0;
  344. {
  345. tex = device->getVideoDriver()->addRenderTargetTexture(core::dimension2du(256,256), "rt", video::ECF_A1R5G5B5);
  346. if (tex)
  347. {
  348. if (tex->getColorFormat() != video::ECF_A1R5G5B5)
  349. logTestString("Format changed: ECF_A1R5G5B5 to %x\n", tex->getColorFormat());
  350. else
  351. logTestString("Format supported: ECF_A1R5G5B5\n");
  352. driver->removeTexture(tex);
  353. tex=0;
  354. }
  355. else
  356. logTestString("Format unsupported: ECF_A1R5G5B5\n");
  357. }
  358. {
  359. tex = device->getVideoDriver()->addRenderTargetTexture(core::dimension2du(256,256), "rt", video::ECF_R5G6B5);
  360. if (tex)
  361. {
  362. if (tex->getColorFormat() != video::ECF_R5G6B5)
  363. logTestString("Format changed: ECF_R5G6B5 to %x\n", tex->getColorFormat());
  364. else
  365. logTestString("Format supported: ECF_R5G6B5\n");
  366. driver->removeTexture(tex);
  367. tex=0;
  368. }
  369. else
  370. logTestString("Format unsupported: ECF_R5G6B5\n");
  371. }
  372. {
  373. tex = device->getVideoDriver()->addRenderTargetTexture(core::dimension2du(256,256), "rt", video::ECF_R8G8B8);
  374. if (tex)
  375. {
  376. if (tex->getColorFormat() != video::ECF_R8G8B8)
  377. logTestString("Format changed: ECF_R8G8B8 to %x\n", tex->getColorFormat());
  378. else
  379. logTestString("Format supported: ECF_R8G8B8\n");
  380. driver->removeTexture(tex);
  381. tex=0;
  382. }
  383. else
  384. logTestString("Format unsupported: ECF_R8G8B8\n");
  385. }
  386. {
  387. tex = device->getVideoDriver()->addRenderTargetTexture(core::dimension2du(256,256), "rt", video::ECF_A8R8G8B8);
  388. if (tex)
  389. {
  390. if (tex->getColorFormat() != video::ECF_A8R8G8B8)
  391. logTestString("Format changed: ECF_A8R8G8B8 to %x\n", tex->getColorFormat());
  392. else
  393. logTestString("Format supported: ECF_A8R8G8B8\n");
  394. driver->removeTexture(tex);
  395. tex=0;
  396. }
  397. else
  398. logTestString("Format unsupported: ECF_A8R8G8B8\n");
  399. }
  400. {
  401. tex = device->getVideoDriver()->addRenderTargetTexture(core::dimension2du(256,256), "rt", video::ECF_R16F);
  402. if (tex)
  403. {
  404. if (tex->getColorFormat() != video::ECF_R16F)
  405. logTestString("Format changed: ECF_R16F to %x\n", tex->getColorFormat());
  406. else
  407. logTestString("Format supported: ECF_R16F\n");
  408. driver->removeTexture(tex);
  409. tex=0;
  410. }
  411. else
  412. logTestString("Format unsupported: ECF_R16F\n");
  413. }
  414. {
  415. tex = device->getVideoDriver()->addRenderTargetTexture(core::dimension2du(256,256), "rt", video::ECF_G16R16F);
  416. if (tex)
  417. {
  418. if (tex->getColorFormat() != video::ECF_G16R16F)
  419. logTestString("Format changed: ECF_G16R16F to %x\n", tex->getColorFormat());
  420. else
  421. logTestString("Format supported: ECF_G16R16F\n");
  422. driver->removeTexture(tex);
  423. tex=0;
  424. }
  425. else
  426. logTestString("Format unsupported: ECF_G16R16F\n");
  427. }
  428. {
  429. tex = device->getVideoDriver()->addRenderTargetTexture(core::dimension2du(256,256), "rt", video::ECF_A16B16G16R16F);
  430. if (tex)
  431. {
  432. if (tex->getColorFormat() != video::ECF_A16B16G16R16F)
  433. logTestString("Format changed: ECF_A16B16G16R16F to %x\n", tex->getColorFormat());
  434. else
  435. logTestString("Format supported: ECF_A16B16G16R16F\n");
  436. driver->removeTexture(tex);
  437. tex=0;
  438. }
  439. else
  440. logTestString("Format unsupported: ECF_A16B16G16R16F\n");
  441. }
  442. {
  443. tex = device->getVideoDriver()->addRenderTargetTexture(core::dimension2du(256,256), "rt", video::ECF_R32F);
  444. if (tex)
  445. {
  446. if (tex->getColorFormat() != video::ECF_R32F)
  447. logTestString("Format changed: ECF_R32F to %x\n", tex->getColorFormat());
  448. else
  449. logTestString("Format supported: ECF_R32F\n");
  450. driver->removeTexture(tex);
  451. tex=0;
  452. }
  453. else
  454. logTestString("Format unsupported: ECF_R32F\n");
  455. }
  456. {
  457. tex = device->getVideoDriver()->addRenderTargetTexture(core::dimension2du(256,256), "rt", video::ECF_G32R32F);
  458. if (tex)
  459. {
  460. if (tex->getColorFormat() != video::ECF_G32R32F)
  461. logTestString("Format changed: ECF_G32R32F to %x\n", tex->getColorFormat());
  462. else
  463. logTestString("Format supported: ECF_G32R32F\n");
  464. driver->removeTexture(tex);
  465. tex=0;
  466. }
  467. else
  468. logTestString("Format unsupported: ECF_G32R32F\n");
  469. }
  470. {
  471. tex = device->getVideoDriver()->addRenderTargetTexture(core::dimension2du(256,256), "rt", video::ECF_A32B32G32R32F);
  472. if (tex)
  473. {
  474. if (tex->getColorFormat() != video::ECF_A32B32G32R32F)
  475. logTestString("Format changed: ECF_A32B32G32R32F to %x\n", tex->getColorFormat());
  476. else
  477. logTestString("Format supported: ECF_A32B32G32R32F\n");
  478. driver->removeTexture(tex);
  479. tex=0;
  480. }
  481. else
  482. logTestString("Format unsupported: ECF_A32B32G32R32F\n");
  483. }
  484. device->closeDevice();
  485. device->run();
  486. device->drop();
  487. return true;
  488. }
  489. bool renderTargetTexture(void)
  490. {
  491. bool result = true;
  492. TestWithAllDrivers(testWith2DImage);
  493. #if 0
  494. TestWithAllDrivers(rttAndZBuffer);
  495. #endif
  496. TestWithAllDrivers(rttAndAntiAliasing);
  497. TestWithAllDrivers(rttAndText);
  498. logTestString("Test RTT format support\n");
  499. TestWithAllHWDrivers(rttFormats);
  500. return result;
  501. }