Recent

Author Topic: GLScene Bug: SetGLSceneMediaDir  (Read 4397 times)

Handoko

  • Hero Member
  • *****
  • Posts: 5122
  • My goal: build my own game engine using Lazarus
GLScene Bug: SetGLSceneMediaDir
« on: September 16, 2019, 04:34:16 pm »
I've been interested to explore more about GLScene, but didn't have time for it. Today, using OPM I installed GLScene but almost all the demos and examples failed to run properly.

Where should I report the bug? Here or on GLScene's forum?

The very first bug and the most important one is the name case issue. This below is the original code of SetGLSceneMediaDir in GLUtils.pas, which is buggy:

Code: Pascal  [Select][+][-]
  1. Function SetGLSceneMediaDir:string;
  2. var
  3.   path: UTF8String;
  4.   p: integer;
  5. begin
  6.    result:='';
  7.  
  8.    // We need to lower case path because the functions are case sensible
  9. //   path := lowercase(ExtractFilePath(ParamStrUTF8(0)));
  10.    path := lowercase(ExtractFilePath(ParamStr(0)));
  11.    p := Pos('samples', path);
  12.    Delete(path, p + 7, Length(path));
  13.    path := IncludeTrailingPathDelimiter(IncludeTrailingPathDelimiter(path) + 'media');
  14.    SetCurrentDir(path);
  15.    // SetCurrentDirUTF8(path) -->  NOT WORKING ON W10 64Bits !
  16.      // We need to store the result in a global var "MediaPath"
  17.      // The function SetCurrentDirUTF8 return TRUE but we are always in the application's folder
  18.      // NB These functions provide from LazFileUtils unit and not from deprecated functions in FileUtils unit.
  19.  
  20.    MediaPath:=Path ;
  21.    result:=path;
  22.  
  23. end;

Remove the lowercase function and make the S uppercase in 'samples', will make it works on Linux:

Code: Pascal  [Select][+][-]
  1. function SetGLSceneMediaDir:string;
  2. var
  3.   path: UTF8String;
  4.   p: integer;
  5. begin
  6.    result:='';
  7.  
  8.    path := ExtractFilePath(ParamStr(0));
  9.    p := Pos('Samples', path);
  10.    Delete(path, p + 7, Length(path));
  11.    path := IncludeTrailingPathDelimiter(IncludeTrailingPathDelimiter(path) + 'media');
  12.    SetCurrentDir(path);
  13.  
  14.    MediaPath:=Path;
  15.    result:=path;
  16.  
  17. end;

Tested on Lazarus 2.0.4 GTK2 Linux-64. I'm not sure what is the version of GLScene. I've just installed it using OPM, it maybe the latest version.

Below is the screenshot, after the bug fix:
« Last Edit: September 16, 2019, 04:39:07 pm by Handoko »

BeanzMaster

  • Sr. Member
  • ****
  • Posts: 268
Re: GLScene Bug: SetGLSceneMediaDir
« Reply #1 on: September 17, 2019, 04:11:21 pm »
Hi Handoko, for reporting it's better on GLScene forum, because i've received automatically notification on new message.
This bug is my fault  :P Because i always forgot Linux is case sensitive and because i'd like to use Camel Case so... thanks for patch. I'll send the change soon as possible

Best regards

 

TinyPortal © 2005-2018