• Advertisement
Sign in to follow this  

Terrain Rendering and reading texture pixels directly.

This topic is 4487 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I'm somewhat experienced with the fundamentals of DirectX 9 and I just wanted to say that this is a great SDK to work with. One of the few things Microsoft-made that I actually like. Unfortunately, recently, I questioned whether or not I'll still pursue game development professionally. This question was raised after reading a particular article on how the industry evolved. How creativity is lacking, how developers are forced to meet impossible deadlines and release games infested with unbarable bugs, etc. Anyways, I still code or try to code games at a hobbyist level. I'm currently following this amazing book. And now I'm up to Terrain Rendering. The example in this chapter uses a .raw file to get the terrain data from. The only image making application I have are GIMP and Windows Paint. Unfortunately, none of these two applications could export 8-bit RAW files. So I'm going to use either the TGA or PNG format to represent my terrain data, exported as greyscale though. I was wondering how I could gain access to a texture's pixel data using IDirect3DTexture9. My guess is by using LockRect or GetSurfaceLevel but I could be wrong. [Edited by - GhostBlazer on October 9, 2005 5:09:30 PM]

Share this post


Link to post
Share on other sites
Advertisement
That is correct, but be careful because locking a texture can be very slow if you create it using D3DPOOL_MANAGED. If you do this, DX must copy the texture from video to system memory (something you definately don't want to be doing each frame).

Share this post


Link to post
Share on other sites
Quote:
Original post by hogwash
That is correct, but be careful because locking a texture can be very slow if you create it using D3DPOOL_MANAGED. If you do this, DX must copy the texture from video to system memory (something you definately don't want to be doing each frame).

Managed-pool resources have a copy residing in system memory. Locking such resources for reading only (READONLY flag in lock) reads from the system memory copy. Locking for writing triggers a system to video memory transfer. Either way, no video memory to system memory transfers are triggered.

Default-pool resource locks for reading trigger video memory to system memory transfers, which are slow.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement