renderTargetTexture.cpp 20 KB

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