In 2d graphics, what's the performance overhead of rendering to a target, then to the screen?

StackOverflow https://stackoverflow.com//questions/9575084

  •  07-12-2019
  •  | 
  •  

Question

I'm making a splitscreen game. When I render each of the splitscreens, there is some overlap outside the boundaries of the screen.

The screen will be say 10x10 tiles big. If you move half a tile to the right, assuming the splitscreen view is centered, displayed on the screen is now half a tile on the left and right edges.

However, it's not possible for me to render half a tile, so the full tile is rendered. I have to render an extra tile (I actually render 12 to make it easier) so that when you move, there isn't a black gap at the edge.

If the splitscreen is the full size of the screen this overlap is not a problem. However if you render two splitscreens side by side, whichever is drawn last will overlap the other if there are any bits that go outside the lines, such as the other half of the visible half tiles.

I am thinking the solution is to render each splitscreen to a texture, and draw the texture onto the screen, cropping out the bits that overlap the boundaries.

I can't think why there should be much performance overhead associated with this, as it will be the rendering of one texture to the screen with no transforms of effects. But I am wondering if I am mistaken, and if perhaps this will slow the game down considerably.

Is there a better solution, or should this one be fine?

Was it helpful?

Solution

In general, this should be negligible. All graphics hardware that I have ever worked with renders to an alternating buffer in video memory. It is generally just as easy to set up a render target to an arbitrary texture in memory. Then, the only overhead would be the operation to copy the texture(s) to the render buffer. Not zero time, but very little surely. If you are much cleverer than I, you may be able to treat segments of your standard render buffer as textures, and avoid the copy. However, I am certainly no expert in unspecified, arbitrary, or imaginary graphics systems, so I guess without more information I should not be so presumptuous ;)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top