renderTargetTexture.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  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> (128, 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 > (128, 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 (true, true, 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 (true, true, 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 (true, true, 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* rt = vd->addRenderTargetTexture(cp.WindowSize, "rt", video::ECF_A32B32G32R32F);
  110. video::S3DVertex vertices[4];
  111. vertices[0].Pos.Z = vertices[1].Pos.Z = vertices[2].Pos.Z = vertices[3].Pos.Z = 1.0f;
  112. vertices[0].Pos.Y = vertices[1].Pos.Y = 1.0f;
  113. vertices[2].Pos.Y = vertices[3].Pos.Y = -1.0f;
  114. vertices[0].Pos.X = vertices[3].Pos.X = -1.0f;
  115. vertices[1].Pos.X = vertices[2].Pos.X = 1.0f;
  116. vertices[0].TCoords.Y = vertices[1].TCoords.Y = 0.0f;
  117. vertices[2].TCoords.Y = vertices[3].TCoords.Y = 1.0f;
  118. vertices[0].TCoords.X = vertices[3].TCoords.X = 1.0f;
  119. vertices[1].TCoords.X = vertices[2].TCoords.X = 0.0f;
  120. u16 indices[6] = {0, 1, 3, 1, 2, 3};
  121. video::SMaterial rtMat;
  122. rtMat.BackfaceCulling = false;
  123. rtMat.Lighting = false;
  124. rtMat.TextureLayer[0].TextureWrapU =
  125. rtMat.TextureLayer[0].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
  126. sm->addLightSceneNode(NULL, core::vector3df(0, 50, 0),
  127. video::SColorf(1, 1, 1), 100);
  128. sm->addCameraSceneNode(NULL, core::vector3df(0, 10, 0));
  129. const scene::IGeometryCreator* geom = sm->getGeometryCreator();
  130. scene::IMeshManipulator* manip = sm->getMeshManipulator();
  131. scene::IMesh* mesh;
  132. scene::ISceneNode* node;
  133. mesh = geom->createCubeMesh(core::vector3df(10, 10, 10));
  134. manip->setVertexColors(mesh, video::SColor(255, 0, 0, 255));
  135. node = sm->addMeshSceneNode(mesh, NULL, -1, core::vector3df(0, 0, 30));
  136. node->getMaterial(0).EmissiveColor = video::SColor(255, 0, 0, 30);
  137. mesh->drop();
  138. mesh = geom->createSphereMesh(5.0f, 32, 32);
  139. node = sm->addMeshSceneNode(mesh, NULL, -1, core::vector3df(0, 0, 50));
  140. node->getMaterial(0).EmissiveColor = video::SColor(255, 30, 30, 30);
  141. mesh->drop();
  142. mesh = geom->createConeMesh(5.0f, 10.0f, 32, video::SColor(255, 255, 0, 0), video::SColor(255, 255, 0, 0));
  143. node = sm->addMeshSceneNode(mesh, NULL, -1, core::vector3df(0, 0, 70));
  144. node->getMaterial(0).EmissiveColor = video::SColor(255, 30, 0, 0);
  145. mesh->drop();
  146. {
  147. vd->beginScene(true, true, video::SColor(255, 0, 0, 0));
  148. vd->setRenderTarget(rt);
  149. sm->drawAll();
  150. vd->setRenderTarget(NULL);
  151. vd->setTransform(video::ETS_WORLD, core::IdentityMatrix);
  152. vd->setTransform(video::ETS_VIEW, core::IdentityMatrix);
  153. vd->setTransform(video::ETS_PROJECTION, core::IdentityMatrix);
  154. rtMat.setTexture(0, rt);
  155. vd->setMaterial(rtMat);
  156. vd->drawIndexedTriangleList(vertices, 4, indices, 2);
  157. vd->endScene();
  158. }
  159. bool result = takeScreenshotAndCompareAgainstReference(vd, "-rttAndZBuffer.png");
  160. device->closeDevice();
  161. device->run();
  162. device->drop();
  163. return result;
  164. }
  165. // result should be two times the same blind text on the left side, and
  166. // the fireball image (with a very small text inside) in the middle of the screen
  167. // drivers that don't support image scaling will show a pink background instead
  168. bool rttAndText(video::E_DRIVER_TYPE driverType)
  169. {
  170. IrrlichtDevice* device = createDevice(driverType, core::dimension2d<u32>(160, 120));
  171. if (!device)
  172. return true;
  173. video::IVideoDriver* driver = device->getVideoDriver();
  174. gui::IGUIEnvironment* guienv = device->getGUIEnvironment();
  175. if (!driver->queryFeature(video::EVDF_RENDER_TO_TARGET))
  176. {
  177. device->closeDevice();
  178. device->run();
  179. device->drop();
  180. return true;
  181. }
  182. logTestString("Testing driver %ls\n", driver->getName());
  183. //RTT
  184. video::ITexture* rt = driver->addRenderTargetTexture(core::dimension2d<u32>(256, 256), "rt");
  185. if (!rt)
  186. {
  187. device->closeDevice();
  188. device->run();
  189. device->drop();
  190. return false;
  191. }
  192. stabilizeScreenBackground(driver);
  193. driver->beginScene(true, true, video::SColor(255,255, 255, 255));
  194. driver->setRenderTarget(rt, true, true, video::SColor(255,255,0,255));
  195. driver->draw2DImage(driver->getTexture("../media/fireball.bmp"), core::recti(0, 0,rt->getSize().Width,rt->getSize().Height), core::recti(0,0,64,64));
  196. guienv->getBuiltInFont()->draw(L"OMGGG =!", core::rect<s32>(120, 100, 256, 256), video::SColor(255, 0, 0, 255));
  197. driver->setRenderTarget(0);
  198. driver->endScene();
  199. scene::ISceneManager* smgr = device->getSceneManager();
  200. scene::ISceneNode* cube = smgr->addCubeSceneNode(20);
  201. cube->setMaterialFlag(video::EMF_LIGHTING, false);
  202. cube->setMaterialTexture(0, rt); // set material of cube to render target
  203. smgr->addCameraSceneNode(0, core::vector3df(0, 0, -30));
  204. // create a long text to produce much difference in failing result pictures
  205. gui::IGUIStaticText* text = guienv->addStaticText(L"asdddddddoamgmoasmgom\nfoaomsodommogdd\nddddddddd", core::rect<s32>(10, 20, 100, 160));
  206. driver->beginScene(true, true, video::SColor(255,255, 255, 255));
  207. cube->setVisible(false);
  208. smgr->drawAll();
  209. guienv->drawAll();
  210. cube->setVisible(true);
  211. smgr->drawAll();
  212. video::SMaterial mat(cube->getMaterial(0));
  213. driver->setMaterial(mat);
  214. text->setRelativePosition(core::position2di(10,30));
  215. guienv->drawAll();
  216. driver->endScene();
  217. bool result = takeScreenshotAndCompareAgainstReference(driver, "-rttAndText.png");
  218. device->closeDevice();
  219. device->run();
  220. device->drop();
  221. return result;
  222. }
  223. static void Render(IrrlichtDevice* device, video::ITexture* rt, core::vector3df& pos1,
  224. core::vector3df& pos2, scene::IAnimatedMesh* sphereMesh, core::vector3df& pos3, core::vector3df& pos4)
  225. {
  226. video::IVideoDriver* driver = device->getVideoDriver();
  227. driver->setRenderTarget(rt);
  228. device->getSceneManager()->drawAll();
  229. video::SMaterial mat;
  230. mat.ColorMaterial=video::ECM_NONE;
  231. mat.AmbientColor.set(255, 80, 80, 80);
  232. mat.DiffuseColor.set(255, 120, 30, 210);
  233. mat.SpecularColor.set(255,80,80,80);
  234. mat.Shininess = 8.f;
  235. core::matrix4 m;
  236. m.setTranslation(pos1);
  237. driver->setTransform(video::ETS_WORLD, m);
  238. driver->setMaterial(mat);
  239. driver->drawMeshBuffer(sphereMesh->getMeshBuffer(0));
  240. m.setTranslation(pos2);
  241. mat.Shininess=0.f;
  242. driver->setTransform(video::ETS_WORLD, m);
  243. driver->setMaterial(mat);
  244. driver->drawMeshBuffer(sphereMesh->getMeshBuffer(0));
  245. m.setTranslation(pos3);
  246. mat.Shininess=8.f;
  247. driver->setTransform(video::ETS_WORLD, m);
  248. driver->setMaterial(mat);
  249. driver->drawMeshBuffer(sphereMesh->getMeshBuffer(0));
  250. m.setTranslation(pos4);
  251. mat.Shininess=0.f;
  252. driver->setTransform(video::ETS_WORLD, m);
  253. driver->setMaterial(mat);
  254. driver->drawMeshBuffer(sphereMesh->getMeshBuffer(0));
  255. }
  256. bool rttAndAntiAliasing(video::E_DRIVER_TYPE driverType)
  257. {
  258. SIrrlichtCreationParameters cp;
  259. cp.DriverType = driverType;
  260. cp.WindowSize = core::dimension2di(160, 120);
  261. cp.AntiAlias = 2;
  262. cp.Vsync = true;
  263. IrrlichtDevice* device = createDeviceEx(cp);
  264. if (!device)
  265. return true;
  266. video::IVideoDriver* driver = device->getVideoDriver();
  267. if ((driver->getDriverAttributes().getAttributeAsInt("AntiAlias")<2) ||
  268. (!driver->queryFeature(video::EVDF_RENDER_TO_TARGET)))
  269. {
  270. device->closeDevice();
  271. device->run();
  272. device->drop();
  273. return true;
  274. }
  275. stabilizeScreenBackground(driver);
  276. logTestString("Testing driver %ls\n", driver->getName());
  277. // sphere mesh
  278. scene::IAnimatedMesh* sphereMesh = device->getSceneManager()->addSphereMesh("atom", 1, 32, 32);
  279. // cam
  280. scene::ICameraSceneNode* cam = device->getSceneManager()->addCameraSceneNode(NULL, core::vector3df(0, 1, -5), core::vector3df(0, 0, 0));
  281. cam->setNearValue(0.01f);
  282. cam->setFarValue(100.f);
  283. cam->updateAbsolutePosition();
  284. device->getSceneManager()->setActiveCamera(cam);
  285. device->getSceneManager()->addLightSceneNode(0, core::vector3df(10,10,10));
  286. device->getSceneManager()->setAmbientLight(video::SColorf(0.3f,0.3f,0.3f));
  287. float radius = 3.f;
  288. core::vector3df pos1(-radius,0,0);
  289. core::vector3df pos2(radius,0,0);
  290. core::vector3df pos3(0,0,radius);
  291. core::vector3df pos4(0,0,-radius);
  292. core::matrix4 m;
  293. gui::IGUIStaticText* st = device->getGUIEnvironment()->addStaticText(L"", core::recti(0,0,200,20), false, false);
  294. st->setOverrideColor(video::SColor(255,255,255,0));
  295. core::dimension2du dim_txt = core::dimension2du(160/2, 120/2);
  296. video::ITexture* rt1 = device->getVideoDriver()->addRenderTargetTexture(dim_txt, "rt1", device->getColorFormat());
  297. video::ITexture* rt2 = device->getVideoDriver()->addRenderTargetTexture(dim_txt, "rt2", device->getColorFormat());
  298. video::ITexture* rt3 = device->getVideoDriver()->addRenderTargetTexture(dim_txt, "rt3", video::ECF_A8R8G8B8);
  299. video::ITexture* rt4 = device->getVideoDriver()->addRenderTargetTexture(dim_txt, "rt4", device->getColorFormat());
  300. device->getSceneManager()->setActiveCamera(cam);
  301. device->getVideoDriver()->beginScene();
  302. #if 1
  303. st->setText(L"Texture Rendering");
  304. Render(device, rt1, pos1, pos2, sphereMesh, pos3, pos4);
  305. Render(device, rt2, pos1, pos2, sphereMesh, pos3, pos4);
  306. Render(device, rt3, pos1, pos2, sphereMesh, pos3, pos4);
  307. Render(device, rt4, pos1, pos2, sphereMesh, pos3, pos4);
  308. device->getVideoDriver()->setRenderTarget(0);
  309. device->getVideoDriver()->draw2DImage(rt1, core::position2di(0,0));
  310. device->getVideoDriver()->draw2DImage(rt2, core::position2di(80,0));
  311. device->getVideoDriver()->draw2DImage(rt3, core::position2di(0,60));
  312. device->getVideoDriver()->draw2DImage(rt4, core::position2di(80,60));
  313. #else
  314. ITexture* rt0 = NULL;
  315. Render(device, rt0, pos1, pos2, sphereMesh, pos3, pos4);
  316. #endif
  317. st->draw();
  318. device->getVideoDriver()->endScene();
  319. bool result = takeScreenshotAndCompareAgainstReference(driver, "-rttAndAntiAlias.png");
  320. device->closeDevice();
  321. device->run();
  322. device->drop();
  323. return result;
  324. }
  325. bool rttFormats(video::E_DRIVER_TYPE driverType)
  326. {
  327. SIrrlichtCreationParameters cp;
  328. cp.DriverType = driverType;
  329. cp.WindowSize = core::dimension2di(160, 120);
  330. IrrlichtDevice* device = createDeviceEx(cp);
  331. if (!device)
  332. return true;
  333. video::IVideoDriver* driver = device->getVideoDriver();
  334. logTestString("Testing driver %ls\n", driver->getName());
  335. video::ITexture* tex = 0;
  336. {
  337. tex = device->getVideoDriver()->addRenderTargetTexture(core::dimension2du(256,256), "rt", video::ECF_A1R5G5B5);
  338. if (tex)
  339. {
  340. if (tex->getColorFormat() != video::ECF_A1R5G5B5)
  341. logTestString("Format changed: ECF_A1R5G5B5 to %x\n", tex->getColorFormat());
  342. else
  343. logTestString("Format supported: ECF_A1R5G5B5\n");
  344. driver->removeTexture(tex);
  345. tex=0;
  346. }
  347. else
  348. logTestString("Format unsupported: ECF_A1R5G5B5\n");
  349. }
  350. {
  351. tex = device->getVideoDriver()->addRenderTargetTexture(core::dimension2du(256,256), "rt", video::ECF_R5G6B5);
  352. if (tex)
  353. {
  354. if (tex->getColorFormat() != video::ECF_R5G6B5)
  355. logTestString("Format changed: ECF_R5G6B5 to %x\n", tex->getColorFormat());
  356. else
  357. logTestString("Format supported: ECF_R5G6B5\n");
  358. driver->removeTexture(tex);
  359. tex=0;
  360. }
  361. else
  362. logTestString("Format unsupported: ECF_R5G6B5\n");
  363. }
  364. {
  365. tex = device->getVideoDriver()->addRenderTargetTexture(core::dimension2du(256,256), "rt", video::ECF_R8G8B8);
  366. if (tex)
  367. {
  368. if (tex->getColorFormat() != video::ECF_R8G8B8)
  369. logTestString("Format changed: ECF_R8G8B8 to %x\n", tex->getColorFormat());
  370. else
  371. logTestString("Format supported: ECF_R8G8B8\n");
  372. driver->removeTexture(tex);
  373. tex=0;
  374. }
  375. else
  376. logTestString("Format unsupported: ECF_R8G8B8\n");
  377. }
  378. {
  379. tex = device->getVideoDriver()->addRenderTargetTexture(core::dimension2du(256,256), "rt", video::ECF_A8R8G8B8);
  380. if (tex)
  381. {
  382. if (tex->getColorFormat() != video::ECF_A8R8G8B8)
  383. logTestString("Format changed: ECF_A8R8G8B8 to %x\n", tex->getColorFormat());
  384. else
  385. logTestString("Format supported: ECF_A8R8G8B8\n");
  386. driver->removeTexture(tex);
  387. tex=0;
  388. }
  389. else
  390. logTestString("Format unsupported: ECF_A8R8G8B8\n");
  391. }
  392. {
  393. tex = device->getVideoDriver()->addRenderTargetTexture(core::dimension2du(256,256), "rt", video::ECF_R16F);
  394. if (tex)
  395. {
  396. if (tex->getColorFormat() != video::ECF_R16F)
  397. logTestString("Format changed: ECF_R16F to %x\n", tex->getColorFormat());
  398. else
  399. logTestString("Format supported: ECF_R16F\n");
  400. driver->removeTexture(tex);
  401. tex=0;
  402. }
  403. else
  404. logTestString("Format unsupported: ECF_R16F\n");
  405. }
  406. {
  407. tex = device->getVideoDriver()->addRenderTargetTexture(core::dimension2du(256,256), "rt", video::ECF_G16R16F);
  408. if (tex)
  409. {
  410. if (tex->getColorFormat() != video::ECF_G16R16F)
  411. logTestString("Format changed: ECF_G16R16F to %x\n", tex->getColorFormat());
  412. else
  413. logTestString("Format supported: ECF_G16R16F\n");
  414. driver->removeTexture(tex);
  415. tex=0;
  416. }
  417. else
  418. logTestString("Format unsupported: ECF_G16R16F\n");
  419. }
  420. {
  421. tex = device->getVideoDriver()->addRenderTargetTexture(core::dimension2du(256,256), "rt", video::ECF_A16B16G16R16F);
  422. if (tex)
  423. {
  424. if (tex->getColorFormat() != video::ECF_A16B16G16R16F)
  425. logTestString("Format changed: ECF_A16B16G16R16F to %x\n", tex->getColorFormat());
  426. else
  427. logTestString("Format supported: ECF_A16B16G16R16F\n");
  428. driver->removeTexture(tex);
  429. tex=0;
  430. }
  431. else
  432. logTestString("Format unsupported: ECF_A16B16G16R16F\n");
  433. }
  434. {
  435. tex = device->getVideoDriver()->addRenderTargetTexture(core::dimension2du(256,256), "rt", video::ECF_R32F);
  436. if (tex)
  437. {
  438. if (tex->getColorFormat() != video::ECF_R32F)
  439. logTestString("Format changed: ECF_R32F to %x\n", tex->getColorFormat());
  440. else
  441. logTestString("Format supported: ECF_R32F\n");
  442. driver->removeTexture(tex);
  443. tex=0;
  444. }
  445. else
  446. logTestString("Format unsupported: ECF_R32F\n");
  447. }
  448. {
  449. tex = device->getVideoDriver()->addRenderTargetTexture(core::dimension2du(256,256), "rt", video::ECF_G32R32F);
  450. if (tex)
  451. {
  452. if (tex->getColorFormat() != video::ECF_G32R32F)
  453. logTestString("Format changed: ECF_G32R32F to %x\n", tex->getColorFormat());
  454. else
  455. logTestString("Format supported: ECF_G32R32F\n");
  456. driver->removeTexture(tex);
  457. tex=0;
  458. }
  459. else
  460. logTestString("Format unsupported: ECF_G32R32F\n");
  461. }
  462. {
  463. tex = device->getVideoDriver()->addRenderTargetTexture(core::dimension2du(256,256), "rt", video::ECF_A32B32G32R32F);
  464. if (tex)
  465. {
  466. if (tex->getColorFormat() != video::ECF_A32B32G32R32F)
  467. logTestString("Format changed: ECF_A32B32G32R32F to %x\n", tex->getColorFormat());
  468. else
  469. logTestString("Format supported: ECF_A32B32G32R32F\n");
  470. driver->removeTexture(tex);
  471. tex=0;
  472. }
  473. else
  474. logTestString("Format unsupported: ECF_A32B32G32R32F\n");
  475. }
  476. device->closeDevice();
  477. device->run();
  478. device->drop();
  479. return true;
  480. }
  481. bool renderTargetTexture(void)
  482. {
  483. bool result = true;
  484. TestWithAllDrivers(testWith2DImage);
  485. #if 0
  486. TestWithAllDrivers(rttAndZBuffer);
  487. #endif
  488. TestWithAllDrivers(rttAndAntiAliasing);
  489. TestWithAllDrivers(rttAndText);
  490. logTestString("Test RTT format support\n");
  491. TestWithAllHWDrivers(rttFormats);
  492. return result;
  493. }