Skip to main content
GameDev.net gamedev.net
🔒 Locked

texture.lock - c#

Started by brekehan Sep 13, 2006 at 10:18 PM 0 replies 900+ views
Original Post
brekehan
brekehan
My overall goal is to get a rectangular portion of my texture and make another texture of it. I saw that texture.lock takes a rect as a parameter, but it keeps failing with an invalid call exception. Does anyone have an example of how to do this whether it be with this function or another? 1 ) Load a texture from file 2 ) Grab a rect from it 3 ) make a new texture from that rect
vermilion_wizard
vermilion_wizard
the way I do it is probably not the best way. But I create a new texture, and a RenderToTexture object, then just draw a quad from your source texture onto it.

Texture t = new Texture(device, surfaceWidth, surfaceHeight, 1, Usage.None,Format.A8R8G8B8, Pool.Managed); Direct3D.Surface surfaceTarget = t.GetSurfaceLevel(0);renderToSurface = new RenderToSurface(device, SurfaceWidth, SurfaceHeight,            Format.A8R8G8B8, false, DepthFormat.D16); Viewport vp = new Viewport();vp.X = 0;vp.Y = 0;vp.Width = surfaceWidth;vp.Height = surfaceHeight;renderToSurface.BeginScene(surfaceTarget, vp);// draw quad hererenderToSurface.EndScene();

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.