Original Post
🔒 Locked
rendering to texture
Advertisement
If you are using lights make sure you have the correct material set.
Make sure that when you rendered the triangle that the correct vertex format was set. Recheck all your state settings such as textures are set correctly, you are clearing the surface before rendering to it.
Example C#
I hope this helps.
Take care.
Make sure that when you rendered the triangle that the correct vertex format was set. Recheck all your state settings such as textures are set correctly, you are clearing the surface before rendering to it.
Example C#
//Create some variables for the render to texture methodtexture = new Texture(renderer.Device, 128, 128, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default);surface = texture.GetSurfaceLevel(0);//Render to texture methodprivate void RenderToTexture(){ Surface oldRenderTarget = renderer.Device.GetRenderTarget(0); renderer.Device.SetRenderTarget(0, surface); renderer.Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black.ToArgb(), 1.0f, 0); renderer.Device.BeginScene(); renderer.Device.Material = material; renderer.Device.Transform.World = matWorld; cube.DrawSubset(0); renderer.Device.EndScene(); renderer.Device.SetRenderTarget(0, oldRenderTarget);}//Call the Render method and Render to texture first.//The Sprite will then render our rendered-to-texture texturepublic void Render(){ RenderToTexture(); renderer.BeginRender(Color.Black); renderer.Device.Material = material; renderer.Device.Transform.World = matWorld; cube.DrawSubset(0); using(Sprite s = new Sprite(renderer.Device)) { s.Begin(SpriteFlags.None); s.Draw(texture, new Rectangle(0, 0, 128, 128), new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.0f, 0.0f), Color.White); s.End(); } renderer.EndRender();}I hope this helps.
Take care.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement