Streaming GLVfsPak to GLMaterialLibrary prob

Help
2011-03-14
2013-03-15
  • Cloud Strife
    Cloud Strife
    2011-03-14

    Hey guys, i'm having the following problem. I'm simply trying to load some jpg textures from a pak file with GLVfsPak to a Material Library but no matter what, i can't get it to work. Here's my code:

      
    var
      i: integer;
      LibBalls: TGLMaterialLibrary;
      PakBalls: TGLVfsPak;
    begin
      PakBalls := TGLVfsPak.Create(Self);
      PakBalls.LoadFromFile('ballz.pak', fmOpenReadWrite or fmShareDenyWrite);
      LibBalls := TGLMaterialLibrary.Create(Self);
      for i := 0 to PakBalls.Files.Count - 1 do begin
        LibBalls.AddMaterialsFromStream(PakBalls.GetFile(PakBalls.Files.Strings[i]));
        LibBalls.Materials[i].Material.Texture.TextureMode := tmModulate;
        LibBalls.Materials[i].Material.Texture.Disabled := false;
      end;
    end;
    

    The pak file is loading correctly in PakBalls. The error i get is "TBinaryReader, read type error." at AddMaterialsFromStream. Oh, i also forgot to mention that i'm writing in DelphiXE.

    Any help will be trully appreciated!

     
  • Cloud Strife
    Cloud Strife
    2011-03-14

    A small correction, BBCode seems to hate Delphi :P

    for i := 0 to PakBalls.Files.Count - 1 do begin 
      LibBalls.AddMaterialsFromStream(PakBalls.GetFile(PakBalls.Files.Strings[ i ])); 
      LibBalls.Materials[ i ].Material.Texture.TextureMode := tmModulate;
      LibBalls.Materials[ i ].Material.Texture.Disabled := false;
    end;
    
     
  • Cloud Strife
    Cloud Strife
    2011-03-15

    Anyway, i think i got it working. I changed the loop to:

    for i := 0 to PakBalls.Files.Count - 1 do begin
      LibBalls.AddTextureMaterial(IntToStr(i + 1), PakBalls.Files.Strings[ i ], true);
      with LibBalls.Materials[ i ].Material do begin
        Texture.TextureMode := tmModulate;
        Texture.Disabled := false;
      end;
    end;