2d rotation and scaling speed

BlitzMax Forums/BlitzMax Beginners Area/2d rotation and scaling speed

SMC(Posted 2006) [#1]
How fast are the 2d rotation and scaling routines in blitz max? Could I do large amounts of it on multiple sprites in real time on a lower end (700MHz-1GHz) machine in real time?

Thanks


ImaginaryHuman(Posted 2006) [#2]
It depends on what your graphics hardware can do, but in general it is very fast.

Typically, I find that there is no difference in speed between drawing an image without rotation, and drawing it with rotation. The system will use matrices to work out where exactly the pixel should be, which includes handling any rotation, regardless of whether you position your image with no rotation or with some rotation.

I don't know if some graphics cards optimize so that when there is `no rotation` ie angle is 0, it draws even faster, but from my direct experienec it seems to be the same.

The same applies to scaling, albeit that with a larger scale factor things will obviously take more GPU time, or less with a lower scale.

With a screenfull of bouncing-around zooming-in-and out images, it didn't seem to make any difference to the speed to specify a rotation angle for every image.

You can also specify that your images will by `filtered` ie smoothed, so that when they scale or rotate they are sub-pixel accurate/antialiased, which is even nicer.

In Max you also automatically can apply a color tint to every image in realtime which has no additional cost, plus you can flip the image vertically or horizontally in realtime at no extra cost. Technically you can also rotate your images in 3D and have it be no slower, as well, but Max2D - Max's default 2d graphics engine, doesn't have the functionality to specify rotation in 3D, at the moment anyway. That's where direct OpenGL or DirectX programming comes in.


Grey Alien(Posted 2006) [#3]
I'm interested in this answer too. Maybe make a test (i.e. no rotation scaling versus some rotation scaling) and try it on lots of PCs. My gut feeling is some modern cards will do it just as fast but older ones might not...


SMC(Posted 2006) [#4]
That's awsome. Thanks for the info AngelDaniel.


ImaginaryHuman(Posted 2006) [#5]
For your specification I would say that's pretty good, but it depends much more on what your graphics card is, than your CPU. Maybe you are used to some other version of blitz where it uses the cpu for rendering, but on Max it uses the gpu. If you have a gfx card that has a good fill rate, let's say 1 billion texels/second, or maybe at least 6-7 milliion, that's probably fine for doing screenfulls of rotating scaling tinting realtime images.


Robert Cummings(Posted 2006) [#6]
FYI scaling will slow down even modern cards through overdraw.

Fillrate is the main weakness of even modern cards and this limit can quickly be touched on in Blitzmax, moreso than the average AAA game!

Suprising? well no, because one tiny 16x16 expanded to the screen and drawn 10 times is equivelent of a screen's worth of fill rate! thats quite a lot.... it is akin to raising the resolution of your game massively, and the main culprit of bmax slowdowns.


SMC(Posted 2006) [#7]
Right now I'm using blitz plus and it can't do that sort of stuff in real time. Someday though when I get to a point where I really want to try and push the limits for what I can do in 2d I would like to be able to do this kind of stuff. That's why I wanted to know about blitz max and what it can do. I had heard that OpenGL could do some blazing fast 2d (I'm assuming this is bmax primary method for doing graphics) and had hoped max would take advantage of this. It seems I won't be disapointed when I switch over in the distant future.

Also, I'm currently using an el cheap'o pc with a 1.1GHz Celeron cpu and an integrated gpu. I figure if I can get decent frame rates on this thing then everyone else should be OK too, at least that's the plan :D


tonyg(Posted 2006) [#8]
Try running the rockout demo. That has lots of rotated, alpha'd images.


ImaginaryHuman(Posted 2006) [#9]
OEJ: That's obvious, if you make something larger it obviously has more pixels to be drawn so will be slower.


Robert Cummings(Posted 2006) [#10]
Yep, obvious when you know.