-
Redraw regions not working in BitmapData/Flash 9?
If I make a BitmapData covering the whole screen and update with one small draw() or setpixel(), and turn on redraw regions, why is the whole screen updated? In Flash 8 it only updated the parts I changed in BitmapData. Very annoying. Is there any solution to do an efficent update? It could be quite critical in games etc.
kind regards
Tomas
Last edited by erixon; 12-09-2008 at 05:57 PM.
-
Funkalicious
Originally Posted by erixon
It could be quite critical in games etc.
http://board.flashkit.com/board/show...opypixels+fast
Copypixels is just that fast that it doesn't matter. Draw is a bit slower, so that could matter. To solve this you could use precaching, by using draw to precache the bitmapdata's you'll need and copypixel them when needed.
-
Senior Member
I'm pretty sure it isn't actually. Turn off your blanking between frames to check
-
Not sure if you understood right, if I make a bitmap like 600x400 or 800x600 the frame rate is not good if it need to redraw the whole surface every frame. Its nice with bitmapdata because you can use fast copypixel or draw on it but as movieclips have "redraw regions" from Flash 8 to Flash 9 they seem to remove the "redraw regions" on bitmapdata so it updates the whole bitmap instead. Had been very efficient in games or like a drawing surface if only the updated areas where redrawn to scene.
Blanking is?
I do one setPixel in BitmapData and the red rectangle shows around whole big BitmapData and it going slow because I doing it every frame.
Last edited by erixon; 12-10-2008 at 02:37 PM.
-
Funkalicious
I understood, I'm just saying that it will slow games isn't true. Well it is, if you've got thousands of enemies on stage. I haven't really tested it, but my game should easily do more than 500 copypixels per frame. The whole of the bitmap has to update, as I wipe the bitmap with a fillrect() (I believe this is what hatu means by blanking) and then stamp the new frame on it, one object at a time.
Your worries about it bieng slow are a bit over the top. It would be if you're creating a zombiegame with thousands of zombies on screen, but that's quite unlikely.
-
Don't you agree if you have a bitmap covering the whole screen (say 800x600 or bigger) that you created dynamically and want to do some small changes per frame, that Flash have to copy 800x600 pixels = 480.000 pixels from bitmap to screen per frame (as showed by redraw regions and slow updates).
If you sit with a 3Ghz you can probably flush out like 640x480 in 50fps, but the CPU fan become noisy and not easy for all computers.
Ok you can't get everything in Flash, but it worked fine in Flash 8 so it feel little bit strange to build with actionscript 2 to achieve that.
-
Senior Member
I think Todorus' point, which you're missing is, doing ONE pixel drawing every frame is a bad test of what's going on. Do a hundred pixels draws in one frame and see if it changes anything. See, if Flash is able to redraw the entire screen in 1 frame after 1 pixel changed, why would it be any slower after 2 pixels changed?
-
Senior Member
Yes, whole bitmap is redrawn every time even when you change just one single pixel. However, the speed gain comes from the fact that no matter how many pixels you change, it will take exactly same time to update the screen. So, more things you have on screen, more you will gain compared with separate movie clips.
Its also true that speed largely depends on the size of your game. 800x600 can be currently too slow for real game, I have not done any games larger then 600x450 and with that size FP9 and 10 can run pretty fast, updating full-stage bitmap without slowdown. Highest fps I have used is 40 and I see no reason to raise it more unless you want to crash computers and let most people play the game at half speed.
-
Senior Member
Ah okay I understood you wrong. There is only one DisplayObject as far as "show redraw regions" is concerned. That's the Bitmap object and your BitmapData that you're manipulating is inside it. So that's not a very good indicator in this case.
and by blanking I meant clearing the screen, drawing it over with black, etc.
-
Not everybody seems to understand here, shortly if you have a big bitmap and want to "paint" in it, you are limited to update whole bitmap to screen on every update, Flash is not using any "redrawn regions" in Bitmaps from Flash 9+ what I can see. Say for example if you want soft "trails" on some objects on screen moving over a big area, it could have been efficient with a bitmap and "redraw regions" in it.
Anyway I have to live with it..or programming actionscript 2.
-
Senior Member
Try to understand that a "blit" of one big surface can be faster than several small ones (dirty rectangle method), especially if it's using graphics hardware to do that blit.
-
Yes Ray Beez, of course, sorry I didn't want to be insolent. But with "redrawn regions" you can optimize a lot to make them small with static parts etc. Just didn't want to spoil a good idea when I learnt how earlier version worked ;-)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|