Recent

Author Topic: Trying to use GLScene  (Read 2068 times)

AussieUser

  • New Member
  • *
  • Posts: 11
Trying to use GLScene
« on: August 30, 2024, 11:53:39 am »
Hi All,

I just downloaded and installed GLSceneLazarus . On trying a simple project that uses GLScene, the compile aborts with a missing component jpegforlazarus. The LPK file for this is nowhere on my computer. Can anyone point me towards where I can find it ?

Thank you very much.

hennerd

  • New member
  • *
  • Posts: 7
Re: Trying to use GLScene
« Reply #1 on: August 30, 2024, 01:14:23 pm »
try to add/replace as ImagesForLazarus as a required package

AussieUser

  • New Member
  • *
  • Posts: 11
Re: Trying to use GLScene
« Reply #2 on: August 30, 2024, 10:47:45 pm »
ImagesForLazarus is allredy installed.

AussieUser

  • New Member
  • *
  • Posts: 11
Re: Trying to use GLScene
« Reply #3 on: August 31, 2024, 01:11:13 am »
When compiling package runtime get error as shown below

    celKOI8ToUTF8:
      Result := KOI8ToUTF8(aValue);   

AussieUser

  • New Member
  • *
  • Posts: 11
Re: Trying to use GLScene
« Reply #4 on: August 31, 2024, 01:58:39 am »
Is there any comprehensive documentation on Lazarus GLScene?

AussieUser

  • New Member
  • *
  • Posts: 11
Re: Trying to use GLScene
« Reply #5 on: August 31, 2024, 05:14:46 am »
Can someone explain why this isn't working. I just get a black screen, I want to see a sphere. Any help appreciated.

unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, GLScene, GLViewer,
  GLVectorGeometry, GLVectorTypes, GLObjects;

type
  { TForm1 }

  TForm1 = class(TForm)
  private
    Scene: TGLScene;
    Viewer: TGLSceneViewer;
    Camera: TGLCamera;
    Sphere: TGLSphere;
    Light: TGLLightSource;
  public
    constructor Create(AOwner: TComponent); override;
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

constructor TForm1.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);

  // Create the scene
  Scene := TGLScene.Create(Self);

  // Create the camera and set its position

  Camera := TGLCamera.Create(Scene);
  Camera.Position.SetPoint(0, 0, 10);  // Set the camera 10 units away from the scene
 // Camera.PointTo(TVector(0,0,0),TVector(0,1,0));
  // Add a light source to the scene
  Light := TGLLightSource.Create(Scene);
  Light.Position.SetPoint(5, 5, 5);    // Place the light source at (5, 5, 5)

  // Create a sphere and place it at the center of the scene
  Sphere := TGLSphere.Create(Scene);
  Sphere.Radius := 10.0;                // Set the radius of the sphere to 1 unit
  Sphere.Position.SetPoint(0, 0, 0);   // Set the position of the sphere

  // Set up the GLSceneViewer
  Viewer := TGLSceneViewer.Create(Scene);
  Viewer.Parent := Form1;               // Attach the viewer to the form
  Viewer.Align := alClient;            // Set it to fill the form
  Viewer.Camera := Camera;             // Assign the camera to the viewer

  // Start rendering the scene
  Viewer.Invalidate;
end;

end.                               

TRon

  • Hero Member
  • *****
  • Posts: 3791
Re: Trying to use GLScene
« Reply #6 on: August 31, 2024, 05:30:33 am »
Please use codetags

The first thing I noticed is that sceneviewer's owner should be the form. The owner of these components that you create should be the form.

And since you seem to be doing everything manually. Also take care of setting the parents.
« Last Edit: August 31, 2024, 05:35:38 am by TRon »
I do not have to remember anything anymore thanks to total-recall.

AussieUser

  • New Member
  • *
  • Posts: 11
Re: Trying to use GLScene
« Reply #7 on: August 31, 2024, 05:35:08 am »
Thanks. I'm very new to GLScene. I would appreciate a short program that does things properly to save me mucking about too much.

TRon

  • Hero Member
  • *****
  • Posts: 3791
Re: Trying to use GLScene
« Reply #8 on: August 31, 2024, 05:37:15 am »
You are aware that the package comes with a bunch of examples (i counted over 30) ?

You seem to be creating these components at runtime but what you should be doing is use the visual designer.

edit: just load one of the examples and you can see for yourself what that entails.
« Last Edit: August 31, 2024, 05:39:04 am by TRon »
I do not have to remember anything anymore thanks to total-recall.

AussieUser

  • New Member
  • *
  • Posts: 11
Re: Trying to use GLScene
« Reply #9 on: August 31, 2024, 05:42:49 am »
All the examples I saw were based on Delphi, even those in the Lazarus folder. If you could point me to a Lazarus one that would be good.

TRon

  • Hero Member
  • *****
  • Posts: 3791
Re: Trying to use GLScene
« Reply #10 on: August 31, 2024, 05:46:35 am »
I can only see lazarus examples (the lfm extention in use is a dead giveaway).

Where did you got the package from ?, it can be installed by using OPM and seems completely Lazarus oriented.
I do not have to remember anything anymore thanks to total-recall.

AussieUser

  • New Member
  • *
  • Posts: 11
Re: Trying to use GLScene
« Reply #11 on: August 31, 2024, 06:03:41 am »
Well, I got some of the examples to run but I only saw a white screen. When I moved the mouse in the viewer I got the occasional flash of an object there, but it disappeared.

Any ideas on that?

TRon

  • Hero Member
  • *****
  • Posts: 3791
Re: Trying to use GLScene
« Reply #12 on: August 31, 2024, 06:30:04 am »
Any ideas on that?
Unfortunately, no.

It is not possible for me to install the OPM glscene package and there is no repository to be able to correct the error or report the bug (something that I explicitly warned for in the past).
I do not have to remember anything anymore thanks to total-recall.

wp

  • Hero Member
  • *****
  • Posts: 12524
Re: Trying to use GLScene
« Reply #13 on: August 31, 2024, 01:29:03 pm »
There are so many links to GLScene that it's hard to find the correct one.
- The official repository is hosted at github: https://github.com/glscene/GLScene - it is Delphi only, however.
- There is also a svn repository at sourceforce: https://sourceforge.net/p/glscene/code/HEAD/tree/, at first glance identical with the github repo. In the branches subfolder, however, there is a GLSceneLCL folder, and this is the Lazarus adaption of the code.
- The version distributed by OPM seems to be identical with the sourceforge GLSceneLCL.
- Older versions referred to by the wiki article (https://wiki.freepascal.org/GLScene) should not be used any more.

Since the OPM version corresponds to the sourceforge GLSceneLCL version, I think any bug reports and patches should be directed to the sourceforge bug tracker https://sourceforge.net/p/glscene/_list/tickets.

Unfortunately it seems that GLSceneLCL has not been tested with recent Laz/FPC versions:
When compiling package runtime get error as shown below

    celKOI8ToUTF8:
      Result := KOI8ToUTF8(aValue);
This is because in Laz 2.2 the funtion KOI8ToUF8 has been renamed to KOI8RToUTF8. Therefore, in unit GLSLanguage, procedureTGLLanguage.EncodeToUTF8, change KOI8ToUTF8 to KOI8RToUTF8.

Well, I got some of the examples to run but I only saw a white screen. When I moved the mouse in the viewer I got the occasional flash of an object there, but it disappeared.
I see this, too, but did not yet find the location where an additional "Refresh" or "SwapBuffers" must be inserted. Any ideas are welcome. I'll report the fix to the sourceforge GLSceneLCL then, and update OPM.

[EDIT] Found this in the German Lazarus forum (https://www.lazarusforum.de/viewtopic.php?p=142034#p142034): Set the form's DoubleBuffered property to false, and the graphic will appear. Alternatively it is also sufficient to set the GLSViewer's DoubleBuffered to false in the OnCreate event of the form, or to get it fixed permanently, to add "DoubleBuffered := false" at the end of the TGLSceneViewer.Create.
« Last Edit: August 31, 2024, 02:09:23 pm by wp »

TRon

  • Hero Member
  • *****
  • Posts: 3791
Re: Trying to use GLScene
« Reply #14 on: August 31, 2024, 02:35:58 pm »
There are so many links to GLScene that it's hard to find the correct one.
Thank you for the extensive (re)search wp. Just saying that if I have to go through all these hoops (by guessing) then I already lost my interest.

The json package data information from OPM is not clear to me.
Code: Text  [Select][+][-]
  1.  "PackageData68" : {
  2.     "Name" : "GLScene",
  3.     "DisplayName" : "GLScene",
  4.     "Category" : "Graphics",
  5.     "CommunityDescription" : "GLScene is an OpenGL based 3D library for Delphi, C++Builder and Lazarus. It provides visual components and objects allowing description and rendering of 3D scenes in graphic applications.",
  6.     "ExternalDependecies" : "",
  7.     "OrphanedPackage" : 0,
  8.     "RepositoryFileName" : "GLScene.zip",
  9.     "RepositoryFileSize" : 27552020,
  10.     "RepositoryFileHash" : "6acb00be27d52d780ac139e98a629132",
  11.     "RepositoryDate" : 4.4402816899155092E+004,
  12.     "PackageBaseDir" : "GLSceneLCL\\/",
  13.     "HomePageURL" : "https://sourceforge.net/projects/glscene/",
  14.     "DownloadURL" : "",
  15.     "SVNURL" : ""
  16.   },
  17.  


Quote
Unfortunately it seems that GLSceneLCL has not been tested with recent Laz/FPC versions:
It is (can) not work(ing) since revision 6979 (7 years ago), see this file and its conditionals. At least that is where things get stuck on/for linux x86_64.
« Last Edit: August 31, 2024, 02:39:33 pm by TRon »
I do not have to remember anything anymore thanks to total-recall.

 

TinyPortal © 2005-2018