ID3DXSprite & ID3DXRenderToSurface
My user interface is drawn by loading bitmaps to textures, then rendering them to the screen using ID3DXSprite. I''m at the point now where I''m trying to create a scrolling window. This is how I''m trying to implement it:
[In ctor]
1. Create a target IDirect3DTexture9 the size of the total scrolling surface, specifying D3DUSAGE_RENDERTARGET.
2. Get the top level IDirect3DSurface9 of that texture.
3. Create ID3DXRenderToSurface.
[In render function]
// Start rendering to target surface?
ID3DXRenderToSurface->BeginScene(the IDirect3DSurface9, NULL)
// Draw the source texture onto the surface?
ID3DXSprite->Draw(the source IDirect3DTexture9, ...);
// Stop rendering to target surface?
ID3DXRenderToSurface->EndScene(0)
// Draw the target texture to the back buffer?
ID3DXSprite->Draw(the target IDirect3DTexture9, ...);
Since I''m posting about this, this doesn''t work. The target texture is rendered, but contains color garbage.
So I guess my questions are:
1. After the call to BeginScene(), will the IDirect3DSurface9 be the render target of the ID3DXSprite->Draw() function? Or do I need to make a seperate call to SetRenderTarget()? If ID3DXRenderToSurface doesn''t manager the render target, then what does it do?
2. Does the texture need to be created with D3DUSAGE_RENDERTARGET or D3DUSAGE_DYNAMIC flags?
ID3DXSprite is useful because I can set the source RECT, and only draw a portion of the target texture, and achieving a smooth scrolling effect by changing the values in that RECT.
Hopefully my explanation of what I''m trying to do and why I''m trying to do it isn''t too vague. This has really been the only sticky part in coding a decent UI. Has anyone had any experience in doing something similar to this?
Thanks,
Matt
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement