   Direct3D equivalent functions
  Does anyone know if there are any Direct3D functions that are equivalent to the following OpenGL functions:1.) glTexImage2D2.) glCopyTexImage2D3.) glReadPixelsThanks,   
  You should look for IDirect3DDevice9::StretchRect, IDirect3DDevice9::GetRenderTargetData, IDirect3DSurface9::LockRect or D3DXLoadSurfaceFromSurface depending on your exact use case.   ;  I took a look at some of those functions; however, I wasn't sure how those could help with doing something that is equivalent to glTexImage2D in openGL. The main trouble I am having is that the glTexImage2D lets you specify the data type of the incoming pixel data and then it magically generates your texture. The problem I am having is that my pixel data is floats and I have to somehow to copy that data into a texture in Direct3D, I believe Direct3D assumes the data is in bytes. I'm not quite how to copy my float pixel data into a Direct3D texture.   ;Quote:Original post by axv4745I'm not quite how to copy my float pixel data into a Direct3D texture.Okay, so you've just got an array of regular C/C++ float's, right?D3D has formats to handle 1, 2 or 4 floats per pixel - D3DFMT_R32F, D3DFMT_G32R32F and D3DFMT_A32B32G32R32F.The first step would be to create an IDirect3DTexture9 via IDirect3DDevice9::CreateTexture(). That part should be fairly straight forward. Once successfully complete (note: not all hardware can support floating point textures!) you've got yourself some VRAM to play with.To fill the data you use IDirect3DTexture9::LockRect() - you'll receive a pointer, VOID*, where you can start writing (or just a memcpy_s()) your real data.Depending on which of the aforementioned formats you're using, a simple reinterpret_cast should be sufficient:D3DLOCKED_RECT pRect;pTexture->LockRect( 0, 0, &pRect, 0 );// The following cast would work for D3DFMT_A32B32G32R32F:D3DXVECTOR4 *pPixelData = reinterpret_cast< D3DXVECTOR4* >( pRect.pBits );// Mess with your pPixelData[] here...pTexture->UnlockRect( 0 );You should then be set up to render from your texture however you see fit [smile]hthJack   ;  I've always used D3DXLoadSurfaceFromMemory(), if the source format is recognizable by DirectX.You create a texture normally (IDirect3DDevice9::CreateTexture() or D3DXCreateTexture()).  You then get the primary surface of the texture (IDirect3DTexture9::GetSurfaceLevel()).  At this point, you use the D3DXLoadSurfaceFromMemory() function to copy data from your own buffer in memory to the surface that you just obtained from the texture.  After that is done, release the surface, and then use the texture like normal.  If you use mipmaps, then you can call IDirect3DTexture9::SetAutoGenFilterType() and IDirect3DTexture9::GenerateMipSubLevels() on the texture to automatically do that for you.Essentially, D3DXLoadSurfaceFromMemory() does all the work of locking/unlocking the surface data, and converting from the buffer format to the surface format.   