Archived

This topic is now archived and is closed to further replies.

edegiuli

Accessing surfaces/textures directly

Recommended Posts

I''m trying to use D3D8 as a framework for a 2D program, using the method described in the article on this site. (ie orthagonal projection matrix, 4 vert triangle fan mapped to the screen) Everything works OK, but now I want to create my own texture for the rectangle. I want to create it procedurally, so I need direct access to the memory where it is stored. Should I be creating a texture or a surface? Right now I have an empty texture that I made with D3DXCreateTexture, but I don''t know what to do with it. Can anyone help? Eric

Share this post


Link to post
Share on other sites
This question seems to come up a lot in one form or another. Basically a texture is a chain of surfaces (because you need multiple surface levels for mip mapping). You can just create a texture and call IDirect3DTexture8::LockRect to get a pointer to the actual bits of the texture. The only thing to note is that you will get back a Pitch for the texture as well as a pointer. The pitch tells you the distance in bytes between successive rows in the texture, since this is NOT always equal to the texture width (mainly because alignment issues). If you create the texture yourself, you should know the format RGB ARGB, etc, as well as width and hieght, otherwise you can query from IDirect3DTexture8::GetLevelDesc.

Share this post


Link to post
Share on other sites