0
어떻게 여러 Texture2D를 하나의 큰 Texture2D에 합칠 수 있습니까? 맵을 덩어리로 분할하여 등각 타일 게임을 최적화하려고합니다.XNA "Texture2D"합병
나는 인터넷 검색을 시도하고 "RenderTarget2D"에 관한 기사를 찾았지만 이것을 구현하는 방법은 확실하지 않습니다.
감사합니다. Sam.
어떻게 여러 Texture2D를 하나의 큰 Texture2D에 합칠 수 있습니까? 맵을 덩어리로 분할하여 등각 타일 게임을 최적화하려고합니다.XNA "Texture2D"합병
나는 인터넷 검색을 시도하고 "RenderTarget2D"에 관한 기사를 찾았지만 이것을 구현하는 방법은 확실하지 않습니다.
감사합니다. Sam.
신경 쓰지 마라. 나는 그것을 해결했다.
이것을 찾고있는 사람이라면 spriteBatch를 사용하여 화면과 마찬가지로 기본적으로 "RenderTarget2D"를 그립니다.
오히려 가난한 설명은RenderTarget2D render; //declare target
render = new RenderTarget2D(GraphicsDevice, (int)(tileSize.X * numberOfTiles.X), (int)(tileSize.Y * numberOfTiles.Y), 0, SurfaceFormat.Color); //assign target, where tileSize is the size of a tile and numberOfTiles is the number of tiles you are rendering
GraphicsDevice.SetRenderTarget(0, render); //Target the render instead of the backbuffer
batch.Begin();
//draw each tile
batch.End();
GraphicsDevice.SetRenderTarget(0, null); //target the backbuffer again
Texture2D myTexture = render.GetTexture(); //store texture in Texture2D variable
죄송합니다
- 튜토리얼에서 내 첫 번째 시도.
마지막 줄은 XNA 4.0에서 작동하지 않습니다. 'GetData'와'SetData'를 사용하여 일반 Texture2D에 복사해야합니다. 또는'RenderTarget2D.ContentLost'를 처리해야합니다. ([여기] (http://blogs.msdn.com/b/shawnhar/archive/2010/03/26/rendertarget-changes-in-xna-game-studio-4-0.aspx) 및 [ 여기] (http://stackoverflow.com/a/5509633/165500) 및 [여기] (http://stackoverflow.com/a/6900213/165500)). –