   D3DXCreateVolumeTextureFromFileInMemoryEx
  I am trying to figure out how to create a volume texture from a 3D image I have in memory.  For 2D images in memory, I have used D3DXCreateTextureFromFileInMemoryEx by creating a BITMAPFILEHEADER/BITMAPV4HEADER pair of structures, filling in all the values and attaching the 2D image from memory, and then passing it as the LPCVOID pSrcData parameter (the second parameter of the function).  The DX documentation that ships with the SDK download (using the December 2005 distribution) has the following comment in both functions for pSrcData:  "Pointer to the file in memory from which to create the texture."  But I see no discussion about what types of data this parameter can point to (other than support for standard file formats).For the 3D images in memory, I have no clue what to pass as pSrcData.  The BITMAP structures appear not to have support for 3D images.  There is a width and a height parameter, but nothing that appears to support "depth" (the size of the third dimension of the image).Any clues on how to do this?  References to documentation that describes how to do this?  Thanks for any help.   
  The only texture format I'm aware of, that supports volume textures, is .DDS. I'm not sure exactly how you'd generate headers for a DDS file in runtime (other than saving it to the disk and reading from it).I think the Create**FromFileInMemory() functions were created for when you need to open archives or package files, and not for loading a data stream from memory. In your case, I think it would be much simpler to create an empty volume texture and lock and copy the data yourself, from your memory stream. Is this not possible in your situation?   ;  My problem is that I am used to OpenGL, where I create a texture using glTexImage{1,2,3}D and pass in *all* the image information, including the size of each dimension.  My using the Create*FromFileInMemoryEx functions was an attempt to do something similer.I lack the experience with DirectX to do what ought to be simple, I suppose.  The D3DXCreateTexture and D3DXCreateVolumeTexture functions let me specify some image information, but not the actual data.  I did not see anything like "SetTextureData" or some such.  Guess I just need to dig deeper into the documentation and examples and find out how to do this.Thanks.;  After digging through the DX docs, I managed to use D3DXCreateTexture to create a 2D texture, locked the texture, copied my image data to level0, and unlocked.  The texture creation used a parameter of 0 for "levels".  I called GetLevelCount to see if the mipmap levels were created.  The image is 256-by-256 and the level count is 9.  I ran my test application, but the textured objects had a lot of black and only when I was close to the objects did I see the image I expected.  So I turned off mipmapping in my application code, and the texture showed up fine.Digging some more through the docs, it appears you have to create your own mipmap data and copy to each level.  Or you can muck around with D3DUSAGE_AUTOGENMIPMAP and hope the card supports it.This is one hell of a large chunk of code just to create a texture and its image data.  Am I missing something simpler?  Or is this what folks have to do when using DirectX?  My gawd, OpenGL's glTexImage2D and gluBuild2DMipmaps encapsulate this entire process.  Is there nothing in DirectX to encapsulate it also?   ;  Hmm, I'm a little confused - you started off talking about 3D/volume textures, and your latest post talks about creating a regular 2D texture??The D3DXCreate...FromFileInMemory[Ex]() functions assume you've (effectively) stream in the binary data from a file on the disk exactly as-is. Complete with headers and original formatting. They're particularly useful if you implement your own archive/compression formats and/or wish to implement some forms of streaming.Quote:Original post by Wasting TimeThis is one hell of a large chunk of code just to create a texture and its image data.  Am I missing something simpler?  Or is this what folks have to do when using DirectX?  My gawd, OpenGL's glTexImage2D and gluBuild2DMipmaps encapsulate this entire process.  Is there nothing in DirectX to encapsulate it also?Hehe, OpenGL != Direct3D [wink]The various D3DX functions cover the majority of cases, but as soon as you wish to do something different then it's down to you. Yes, that can be tricky/tedious.Cheers,Jack   ;Quote:Original post by jollyjeffersHmm, I'm a little confused - you started off talking about 3D/volume textures, and your latest post talks about creating a regular 2D texture??I have working code that uses D3DXCreateTextureFromFileInMemoryEx.  I thought I would first replace this with D3DXCreateTexture and whatever else it takes to reproduce what I currently have.  Assuming this works, my next step is to do the same thing for volume textures.  In fact I got the 2D replacement code to work the same as long as I used D3DUSAGE_AUTOGENMIPMAP.  So I'll implement/test the 3D stuff now.Quote:The D3DXCreate...FromFileInMemory[Ex]() functions assume you've (effectively) stream in the binary data from a file on the disk exactly as-is. Complete with headers and original formatting. They're particularly useful if you implement your own archive/compression formats and/or wish to implement some forms of streaming.That was my goal, but the documentation I looked at seems to indicate that the input is always of some standard file format.  Nothing about user-defined formats.  In the short term, I just took my data and shoved it into a BMP format, which, as my original post was about, did not appear to extend to 3D data.Quote:Hehe, OpenGL != Direct3D [wink]The various D3DX functions cover the majority of cases, but as soon as you wish to do something different then it's down to you. Yes, that can be tricky/tedious.Tricky/tedious?  The phrase that came to mind was "pain in the arse" :)  I can see that Direct3D gives you control at a lower-level than OpenGL, but a set of "layered" interfaces would have been nice.  Assembly languages give you a lot of low-level control, but a language like C or C++ is a higher-level "layer", something that for most newbies is easier to learn and work with first.  When you are ready to dig deeper into the guts, then you learn assembly :)