I've modified the 13.RenderToTexture example to lock the texture after it has been drawn to and unlock it afterwards. However, when it tries to lock (read-only turn on and off) the texture, the whole thing crashes. This is using the latest trunk revision of Irrlicht.
I didn't want to paste the entire source code, because I only added 4 lines (lock, unlock, debug output) to the example. So make it more readable, the following is the output of s vn diff..
Code: Select all
Index: main.cpp
===================================================================
--- main.cpp (revision 1775)
+++ main.cpp (working copy)
@@ -194,7 +194,12 @@
// set back old render target
// The buffer might have been distorted, so clear it
driver->setRenderTarget(0, true, true, 0);
-
+
+ printf("Run\n");
+ rt->lock(true);
+ printf("Locked\n");
+ rt->unlock();
+ printf("Unlocked\n");
// make the cube visible and set the user controlled camera as active one
test->setVisible(true);
smgr->setActiveCamera(fpsCamera);
Code: Select all
Irrlicht Engine version 1.4.2
Linux 2.6.24-21-generic #1 SMP Tue Oct 21 23:43:45 UTC 2008 i686
Creating X window...
Visual chosen: : 37
Using renderer: OpenGL 1.4
Mesa DRI Intel(R) 965GM 4.1.3002 x86/MMX/SSE2: Tungsten Graphics, Inc
OpenGL driver version is 1.2 or better.
GLSL not available.
Loaded mesh: ../../media/faerie.md2
Loaded texture: /home/kkrizka/Sources/irrlicht/media/faerie2.bmp
Run
Locked
*** glibc detected *** ./13.RenderToTexture: double free or corruption (fasttop): 0x088107f0 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6[0xb776fa85]
/lib/tls/i686/cmov/libc.so.6(cfree+0x90)[0xb77734f0]
/usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0xb793bb11]
/home/kkrizka/Sources/irrlicht/lib/Linux/libIrrlicht.so.1(_ZN3irr4core12irrAllocatorIcE10deallocateEPc+0x1f)[0xb7c58655]
/home/kkrizka/Sources/irrlicht/lib/Linux/libIrrlicht.so.1(_ZN3irr4core6stringIcNS0_12irrAllocatorIcEEED1Ev+0x2a)[0xb7c58aea]
/home/kkrizka/Sources/irrlicht/lib/Linux/libIrrlicht.so.1(_ZN3irr5video8ITextureD0Ev+0x43)[0xb7d712a3]
./13.RenderToTexture[0x80495e8]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0)[0xb771a450]
./13.RenderToTexture(__gxx_personality_v0+0x69)[0x8048cf1]
======= Memory map: ========
08048000-0804b000 r-xp 00000000 08:04 16269571 /home/kkrizka/Sources/irrlicht/bin/Linux/13.RenderToTexture
0804b000-0804c000 rwxp 00002000 08:04 16269571 /home/kkrizka/Sources/irrlicht/bin/Linux/13.RenderToTexture
0804c000-099bb000 rwxp 0804c000 00:00 0 [heap]
b3000000-b3021000 rwxp b3000000 00:00 0
b3021000-b3100000 ---p b3021000 00:00 0
b31a0000-b3300000 rwxp b31a0000 00:00 0
b3300000-b3308000 r-xp 00000000 08:02 58736 /usr/lib/libXcursor.so.1.0.2
b3308000-b3309000 rwxp 00007000 08:02 58736 /usr/lib/libXcursor.so.1.0.2
b3317000-b3601000 rwxp b3317000 00:00 0
b3601000-b5601000 rwxs e2e34000 00:0e 14229 /dev/dri/card0
b5601000-b5d91000 rwxs e26a4000 00:0e 14229 /dev/dri/card0
b5d91000-b6521000 rwxs e1f14000 00:0e 14229 /dev/dri/card0
b6521000-b6ca6000 rwxs e0100000 00:0e 14229 /dev/dri/card0
b6ca6000-b742b000 rwxs e0100000 00:0e 14229 /dev/dri/card0
b742b000-b744a000 r-xp 00000000 08:02 58966 /usr/lib/libexpat.so.1.5.2
b744a000-b744c000 rwxp 0001e000 08:02 58966 /usr/lib/libexpat.so.1.5.2
b745a000-b7672000 r-xp 00000000 08:02 59933 /usr/lib/dri/i965_dri.so
b7672000-b7686000 rwxp 00218000 08:02 59933 /usr/lib/dri/i965_dri.so
b7686000-b7692000 rwxp b7686000 00:00 0
b7692000-b7696000 r-xp 00000000 08:02 58740 /usr/lib/libXdmcp.so.6.0.0
b7696000-b7697000 rwxp 00003000 08:02 58740 /usr/lib/libXdmcp.so.6.0.0
b7697000-b7698000 rwxp b7697000 00:00 0
b7698000-b76af000 r-xp 00000000 08:02 59570 /usr/lib/libxcb.so.1.0.0
b76af000-b76b0000 rwxp 00016000 08:02 59570 /usr/lib/libxcb.so.1.0.0
b76b0000-b76b1000 r-xp 00000000 08:02 59568 /usr/lib/libxcb-xlib.so.0.0.0
b76b1000-b76b2000 rwxp 00000000 08:02 59568 /usr/lib/libxcb-xlib.so.0.0.0
b76b2000-b76b4000 r-xp 00000000 08:02 58729 /usr/lib/libXau.so.6.0.0
b76b4000-b76b5000 rwxp 00001000 08:02 58729 /usr/lib/libXau.so.6.0.0
b76b5000-b76be000 r-xp 00000000 08:02 58926 /usr/lib/libdrm.so.2.3.0
b76be000-b76bf000 rwxp 00008000 08:02 58926 /usr/lib/libdrm.so.2.3.0
b76bf000-b76c1000 r-xp 00000000 08:02 19043 /lib/tls/i686/cmov/libdl-2.7.so
b76c1000-b76c3000 rwxp 00001000 08:02 19043 /lib/tls/i686/cmov/libdl-2.7.so
b76c3000-b76c4000 rwxp b76c3000 00:00 0
b76c4000-b76d8000 r-xp 00000000 08:02 20279 /lib/tls/i686/cmov/libpthread-2.7.so
b76d8000-b76da000 rwxp 00013000 08:02 20279 /lib/tls/i686/cmov/libpthread-2.7.so
b76da000-b76dc000 rwxp b76da000 00:00 0
b76dc000-b76e0000 r-xp 00000000 08:02 58746 /usr/lib/libXfixes.so.3.1.0
b76e0000-b76e1000 rwxp 00003000 08:02 58746 /usr/lib/libXfixes.so.3.1.0
b76e1000-b76e3000 r-xp 00000000 08:02 58738 /usr/lib/libXdamage.so.1.1.0
b76e3000-b76e4000 rwxp 00001000 08:02 58738 /usr/lib/libXdamage.so.1.1.0
b76e4000-b7703000 r-xp 00000000 08:02 59259 /usr/lib/libjpeg.so.62.0.0
b7703000-b7704000 rwxp 0001e000 08:02 59259 /usr/lib/libjpeg.so.62.0.0
b7704000-b784d000 r-xp 00000000 08:02 19040 /lib/tls/i686/cmov/libc-2.7.so
b784d000-b784e000 r-xp 00149000 08:02 19040 /lib/tls/i686/cmov/libc-2.7.so
b784e000-b7850000 rwxp 0014a000 08:02 19040 /lib/tls/i686/cmov/libc-2.7.so
b7850000-b7854000 rwxp b7850000 00:00 0
b7854000-b785e000 r-xp 00000000 08:02 595692 /lib/libgcc_s.so.1
b785e000-b785f000 rwxp 0000a000 08:02 595692 /lib/libgcc_s.so.1
b785f000-b7882000 r-xp 00000000 08:02 19045 /lib/tls/i686/cmov/libm-2.7.so
b7882000-b7884000 rwxp 00023000 08:02 19045 /lib/tls/i686/cmov/libm-2.7.so
b7884000-b796c000 r-xp 00000000 08:02 61741 /usr/lib/libstdc++.so.6.0.9
b796c000-b796f000 r-xp 000e8000 08:02 61741 /usr/lib/libstdc++.so.6.0.9
b796f000-b7971000 rwxp 000eb000 08:02 61741 /usr/lib/libstdc++.so.6.0.9
b7971000-b7977000 rwxp b7971000 00:00 0
b7977000-b7a5b000 r-xp 00000000 08:02 58723 /usr/lib/libX11.so.6.2.0
b7a5b000-b7a5e000 rwxp 000e4000 08:02 58723 /usr/lib/libX11.so.6.2.0
b7a5e000-b7a6b000 r-xp 00000000 08:02 58744 /usr/lib/libXext.so.6.4.0
b7a6b000-b7a6c000 rwxp 0000d000 08:02 58744 /usr/lib/libXext.so.6.4.0
b7a6c000-b7a70000 r-xp 00000000 08:02 58780 /usr/lib/libXxf86vm.so.1.0.0
b7a70000-b7a71000 rwxp 00003000 08:02 58780 /usr/lib/libXxf86vm.so.1.0.0
b7a71000-b7a72000 rwxp b7a71000 00:00 0
b7a72000-b7acd000 r-xp 00000000 08:02 58682 /usr/lib/libGL.so.1.2
b7acd000-b7ad3000 rwxp 0005b000 08:02 58682 /usr/lib/libGL.so.1.2
b7ad3000-b7ad4000 rwxp b7ad3000 00:00 0
b7ad6000-b7add000 r-xp 00000000 08:02 58766 /usr/lib/libXrender.so.1.3.0
b7add000-b7ade000 rwxp 00007000 08:02 58766 /usr/lib/libXrender.so.1.3.0
b7ade000-b7ae0000 rwxs f8d31000 00:0e 14229 /dev/dri/card0
b7ae0000-b7ae2000 rwxp b7ae0000 00:00 0
b7ae2000-b7f15000 r-xp 00000000 08:04 14483562 /home/kkrizka/Sources/irrlicht/lib/Linux/libIrrlicht.so.1.4.2
b7f15000-b7f43000 rwxp 00433000 08:04 14483562 /home/kkrizka/Sources/irrlicht/lib/Linux/libIrrlicht.so.1.4.2
b7f43000-b7f46000 rwxp b7f43000 00:00 0
b7f46000-b7f47000 r-xp b7f46000 00:00 0 [vdso]
b7f47000-b7f61000 r-xp 00000000 08:02 595749 /lib/ld-2.7.so
b7f61000-b7f63000 rwxp 00019000 08:02 595749 /lib/ld-2.7.so
bf873000-bf888000 rw-p bffeb000 00:00 0 [stack]
Aborted