~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to tests/renderTargetTexture.cpp

  • Committer: Mantas Kriaučiūnas
  • Date: 2011-07-18 13:06:25 UTC
  • Revision ID: mantas@akl.lt-20110718130625-c5pvifp61e7kj1ol
Included whole irrlicht SVN libraries to work around launchpad recipe issue with quilt, see https://answers.launchpad.net/launchpad/+question/165193

Show diffs side-by-side

added added

removed removed

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