Results 1 to 4 of 4

Thread: Cannot load textures from memory

  1. #1

    Cannot load textures from memory

    Hi all

    I have a problem with loading a texture from memory.
    I use this code:

    Code:
        
    Stream := TMemoryStream.Create;
        try
          fBitmap.SaveToStream(Stream);
          if fFormat = pf16bit then
            fmt := D3DFMT_R5G6B5
          else
            fmt := D3DFMT_A8R8G8B8;
          {create texture from memory}
          HR := D3DXCreateTextureFromFileInMemoryEx(Graphic.fD3DDevice,
    Stream.Memory,Stream.Size,0,0,0,0,
    fmt,D3DPOOL_DEFAULT,D3DX_FILTER_NONE,
    D3DX_DEFAULT,fTransColor,nil,nil,fTexture);
          if Failed(HR) then
          begin
            //Report error....
          end;
        finally
          Stream.Free;
        end;
    The function returns D3DERR_INVALIDCALL but i cant figure out why,

    Can anyone help me??
    thanx

    P.S [pascal][/pascal] doesn't seem to work
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  2. #2

    Cannot load textures from memory

    Maybe that is bacause you are trying to create texture with dimentions WxH = 0x0? Nil texture? :shock: :lol:
    Please read decription of this function and it's parameters in documentation.

    Btw, why are you using Ex variant of function?
    There are only 10 types of people in this world; those who understand binary and those who don't.

  3. #3

    Cannot load textures from memory

    Maybe that is bacause you are trying to create texture with dimentions WxH = 0x0? Nil texture? Shocked Laughing
    Please read decription of this function and it's parameters in documentation.
    I've done that and it says:
    Width
    [in] Width in pixels. If this value is zero or D3DX_DEFAULT, the dimensions are taken from the file.
    Height
    [in] Height, in pixels. If this value is zero or D3DX_DEFAULT, the dimensions are taken from the file.
    So that shouldn't be the problem.
    Even when i do:

    Code:
          {create texture from memory}
          HR := D3DXCreateTextureFromFileInMemoryEx(Graphic.fD3DDevice,Stream.Memory,Stream.Size,
                          fBitmap.Width,fBitmap.Height,0,0,fmt,D3DPOOL_DEFAULT,D3DX_FILTER_NONE,D3DX_DEFAULT,fTransColor,nil,nil,fTexture);
    The bug is still there.

    I am using the ex version because i want to set the transparent color and the format/filtering/mipmapping settings for the texture.
    I'll implement these later.

    Do you know a way of fixing this?? :?
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  4. #4

    Cannot load textures from memory

    Seems like i have fixed the bug

    Stream.Memory should be: Stream.Memory^
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •