ewjordan
Ex Member
Re: Scrolling a very large map
Reply #2 - Aug 27th , 2007, 11:59pm
One thing confuses me about this - from my testing (and in theory), moving a very large graphic around should not slow down that much in any of the renderers, as I'm pretty sure they are all optimized to clip properly (I'm absolutely positive that P3D is, and Java2d really should be). Once the graphic is loaded, as long as it's not altered, the time it takes to draw should be proportional to the number of pixels actually drawn to the screen rather than to the size of the image - internally, the pixels outside of the screen should never be encountered thanks to the pre-draw clipping of the rectangle. Are you perhaps doing something processor intensive like reloading the image every frame? Otherwise I can't quite see why the scale of the image should matter that much. That said, what are the dimensions of the image you're using? I just tested a 7000x600 PNG and it seems to go perfectly smoothly (~60 fps) without any sort of tricks being employed (furthermore, it seems to go no slower than a 640x480 image filling the screen, which suggests that it's really the drawn pixels that are the bottleneck). If you're talking about something far bigger than that, maybe the real issue is that the amount of memory the image itself is taking up is causing the garbage collector to freak out every frame, or something like that - in that case the solution will be tough, because the graphic is just eating up too much memory, so you'd have to break it up and load it in pieces as you need them. BTW, if performance is a real issue, speed for OpenGL in Processing scales (unless you _really_ tax the graphics card) per polygon rather than per pixel, so you could always try using that, though on my graphics card the max texture resolution is 2048x2048, so you'll definitely need to do some tiling.