d3dx9: Texturing functions

Philip Nilsson pnilsson at nullref.se
Mon Apr 21 12:00:05 CDT 2008

On Sat, Apr 19, 2008 at 10:11:06AM +0200, tony.wasserka at freenet.de wrote:
> So, the first thing I want to make sure is that we redirect the function calls correctly in order
> to reduce double coding.
> This means on the one hand that we should call the Extended versions of each function
> from inside of the simpler ones (most default parameters for the Ex functions are
> on MSDN) and on the other hand that we unify all D3DXCreateTextureFromXXEx
> functions somehow. I don't know how Resources are stored internally, but I guess
> the simplest would be to redirect all of them to D3DXCreateTextureFromFileInMemory, i.e.
> when D3DXCreateTextureFromFile is called we read the file into memory and call the
> InMemory function. I hope this shouldn't be too hard to be applied to the resource function
> either. Of course, this should also be done at the corresponding Surface, Volume and
> cube texture functions.
> Also, I haven't looked too much into it yet, but I guess we could go even a step further
> and define the CreateTextuteFromXX calls like this:
> 1. Redirect to the corresponding D3DXCreateXFromFileInMemoryEx call
> 2. Call D3DXCheckXRequirements
> 3. Call IDirect3DDevice9::CreateTexture
> 4. Lock its surface
> 5. Call LoadSurfaceFromFileEx with it
> This would reduce most of our coding work on LoadSurfaceFromFileEx.
> However, there are still plenty of formats supported by the texturing functions
> and thus, plenty of work for us to do. IIRC we once came to the decision to
> use libraries like libpng or so to reduce that work, too, so we'd just need
> to implement formats like .dds.

I can't remember what the differences are between the CreateTexture and
LoadSurface functions, but this is what I'd do for the LoadSurface functions:

LoadSurfaceFromMemory (read data with the specified pixel format)
  LoadSurfaceFromFileInMemory (parse image format, read actual data into memory)
    LoadSurfaceFromFile (open file, read contents into memory)
	LoadSurfaceFromResource (open resource, read contents into memory)
  LoadSurfaceFromSurface (read image data from a surface)

This would mean two huge chunks of code: One which parses image formats
(LoadSurfaceFromFileInMemory), and one which handles all the resizing,
conversion, filtering and stuff (LoadSurfaceFromMemory).

Philip Nilsson

More information about the wine-devel mailing list