Not Drawing uneeded
Blitz3D Forums/Blitz3D Programming/Not Drawing uneeded
| ||
I have a quick question, how, using 2D code, do you make the game not draw what is off the screen, and then draw it when it comes on screen? I figure this will make my game run smoother. -Kevin |
| ||
Quite simply, you wouldn't draw anything that is within the bounds of the screen. I'm not sure Blitz would even execute a draw command if the position parameters were off screen, nor for that matter would DirectX. |
| ||
Just do a simple check if the X and Y values of the image are less than 0-image_width and 0-image_height, or greater than the screen resolution. |
| ||
oh ok. so if i have an image greater than the screen, it wont draw anything outside the screen parameters by default? Ok thanks, that helps. I just thought it did because someone mentioned on another post that i should do that... |
| ||
I'm not sure Blitz would even execute a draw command if the position parameters were off screen, nor for that matter would DirectX I tryed this out and finds out that it is correct. DX handle this kind of things for you. Thoe you may want to skipp the AI if its offscreen. |
| ||
Firstly - how much are you afraid of drawing offscreen? I mean are you talking aabout a huge map of stuff? If you are - don't just leave it lying around in memory, you'll need a make/delete entity type system to see a real speed increase. Show and hide systems are much slower. |
| ||
Ya im not worried about it any more. It is just some advice i got, but i really dont think it applies much with what i am doing. |
| ||
I don't see how it can *not* apply. If you're doing 2d drawing, why would you want to waste time drawing something you can't see or even waste time checking to see if it can be drawn. Neither Blitz nor DirectX can optimize the checks like you can, so it has to check every single time, whereas you could actually sort your objects or if they're in an array ( like a tilemap ) even better, you automatically know where the bounds are. Just because it's not executed doesn't mean it wasn't wasting valuable cycles checking to see if it should be executed. |
| ||
WEll this is really kind of offtopic, but ill ask it anyway. I made a 5000 by 5000 pixel terrain picture for use as the 2d landscape, but it cut off around 1500 by 1500 or so. What i meen by that is that it was just black beyond that point. Is this due to the fact i reached blitzes pixel limits or something and what would those pixel limits happen to be? Is there any solution to this? |
| ||
1675*50000*32Bit would be 32Meg. So Im guessing that was you card limet |
| ||
Oh really? i guess that would be the problem My graphics card is a Radeon X1300. Is that a 32meg card? |
| ||
By my reckoning you're trying to create an image which is 8192x8192 ( nearest power of two which is over 5000 ) and not only do many card have a 4096x4096 pixel size limit, but I think that ( doing the math in my head ) would take up 256MB of video memory. |
| ||
Oh ok. I guess it will have to be a pretty small map then. Thanks for your help again everyone. |
| ||
Hope you not making a 2d map in 3d this way only. If you are doing a blockbuster. why not use sevveral small 32x32 sized squares. (aka 4 vertices or 2 triangles per quad) you can make em single surface too. that way it will save texture memmory and be fast. a level can have like 3.500.000 squares of 32x32 pixels. |
| ||
Ya that idea occured to me. I dont know what the problem WAS, but i tried the map a second time and it worked, so im back to work. Thanks for all your help though! -Kevin |