[no irrlicht bug]Error in rect? (Example 6. 2dgraphics)

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
ping-pong2012
Posts: 17
Joined: Mon Sep 17, 2012 8:54 pm

[no irrlicht bug]Error in rect? (Example 6. 2dgraphics)

Post by ping-pong2012 »

Build: Windows 7 in Irrlicht Example 06 2D Graphics (32-bit on a 64-bit system, 32-bit DLL fast math compiled fresh)
Code::Blocks 10.05 and the included MingW version
Irrlicht 1.7.3 or SVN 2012-09-16 trunk
All renderers, NVidia 9800gt and AMD 6320

I make a basic array in the example, here's the function for resetting it:
http://pastebin.com/2ynu9PZ1

I have another function to print the array which basically looks the same.

I declare or whatever the array in main and before the while loop with
int myarray[4][4];

Then I call:
initmyarray(myarray);

Then I print the array. If I print the array before:
core::rect<s32> imp2(387, 15,423,78);

The array prints all zeroes as expected.

If I print the array after the imp2 line, the last three elements are 387, 15, and 423 (elements 5,3 , 5,4, and 5,5). These numbers are the same as the first three numbers in the imp2 rectangle coordinates.

If I initalize the array after the imp line, BOTH of the imps blink during the rendering cycle, they literally turn transparent for a fraction of a second, during which I can see the background, and then they blink back into existence and continue their animation and color cycling.

There are no compiler errors or warnings whatsoever, and the program has no errors otherwise. If I comment out the initialize line, the imps run fine.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Error in rect? (Example 6. 2dgraphics)

Post by CuteAlien »

Well, you're wrong with the no errors otherwise ;-)

If you have an array of size 4 then it's indices go from 0-3 and not from 0-4. Meaning you write and read into parts of the memory which you have not allocated.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
ping-pong2012
Posts: 17
Joined: Mon Sep 17, 2012 8:54 pm

Re: [no irrlicht bug]Error in rect? (Example 6. 2dgraphics)

Post by ping-pong2012 »

Thank you for the quick reply, I really REALLY hate stupid programming conventions.
Post Reply