View Issue Details

IDProjectCategoryView StatusLast Update
0016890Lazarus CCRglscenepublic2020-02-03 13:01
ReporterFabio Luis Girardi Assigned ToMattias Gaertner  
PrioritynormalSeverityminorReproducibilityalways
Status assignedResolutionopen 
Platformx64OSLinux 
Summary0016890: TGLSceneViewer doesn't show anything without resize it under GTK2
DescriptionTGLSceneViewer doesn't show anything without resize it under GTK2. This occurs in runtime and Design time. If the control (GLSceneViewer) cannot be resized (Align=alNone) it only shows the background color. After the first resize, it works very well.

My Lazarus revision is 26154
My FPC version is 2.5.1
Steps To ReproduceOpen a glscene demo (under glscene folder/Demos/materials/dyncubemap/dyncubemap.lpi) under Lazarus 0.9.29 Linux amd64.


if you you see only a black background, resize the form to see the graphics.

The same steps works to an compiled application.
TagsNo tags attached.
WidgetsetGTK 2
Attached Files

Activities

Fabio Luis Girardi

2010-07-09 20:18

reporter   ~0039203

Related 0016220

Burkhard Carstens

2010-07-10 11:24

developer   ~0039221

Don't expect anything soon. I'm still using gtk1 and (due to deprecation of gtk1 support) a very old lazarus version. So I need to setup a new vm with a recent lazarus to dig into this, but I'm extremely busy with other stuff right now.

2010-07-10 14:39

 

gllingtkcontext.pas.patch (448 bytes)   
--- tmp/rabbitvcs-1-base-gllingtkcontext.pas 
+++ home/fabiolg/desenvolvimento/glscene10/Source/platform/gllingtkcontext.pas 
@@ -14,11 +14,11 @@
 
 uses
   xlib, Classes, sysutils, GLCrossPlatform, GLContext, LCLProc, Forms, Controls, OpenGL1x,
-  x, xutil, GTKProc,
+  x, xutil,
 {$ifdef LCLGTK2}
-  gtk2, gdk2, gdk2x, gtkdef;
+  gtk2, gdk2, gdk2x, Gtk2Def, Gtk2Proc;
 {$else}
-  gtk, gtkdef, gdk;
+  GTKProc, gtk, gtkdef, gdk;
 {$endif}
 
 type
gllingtkcontext.pas.patch (448 bytes)   

Fabio Luis Girardi

2010-07-10 14:39

reporter   ~0039232

Here a small patch to get glscene working on recent lazarus version.

Fabio Luis Girardi

2010-07-10 15:12

reporter   ~0039233

Debugging the TGLSceneViewerLCL.WMSize I see:

Message.Width=1 and Message.Height=1


So, the buffer was sized to 1x1, that shows nothing... maybe is a LCL bug...

Fabio Luis Girardi

2010-07-10 15:53

reporter   ~0039234

My temp workaround:

procedure TGLSceneViewerLCL.Loaded;
var
   x:TLMSize;
begin
   inherited Loaded;
   // initiate window creation
   HandleNeeded;
   x.Height:=Height;
   x.Width:=Width;
   x.Msg := LM_SIZE;
   x.SizeType := 6; // force realign
   WMSize(x);
end;

Mattias Gaertner

2010-07-10 17:20

manager   ~0039238

Last edited: 2010-07-10 18:12

I tried the glscene from
http://wiki.lazarus.freepascal.org/GLScene
using
svn co http://svn.freepascal.org/svn/fpcprojects/glscene/trunk glscene

I compiled for gtk2 and had to fixed glscene/Source/platform/gllingtkcontext.pas:

{$ifdef LCLGTK2}
  Gtk2Proc, gtk2, gdk2, gdk2x, Gtk2Def;
{$else}
  GTKProc, gtk, gtkdef, gdk;
{$endif}

Then I compiled Demos/materials/dyncubemap/dyncubemap.lpi

It started in a terminal and it bombed. It showed some LCL warnings:
TWinControl.CreateWnd creating Handle during loading Panel1:TPanel csDesigning=False

I went to the LCL and set a break point on that line. Via the callstack I found
out, that this line tried to create the handle so early:
 Source/platform/gllclviewer.pas:488

procedure TGLSceneViewerLCL.Loaded;
begin
   inherited Loaded;
   // initiate window creation
   HandleNeeded;
end;

Instead of waiting for the LCL to create the Handle it creates the Handle right
after loading some values. Before the LCL had the time to process the values
and some other components are still loading. I wondered why and commented the
line. Running again and got the same exception:

TGLCONTEXT__ACTIVATE, line 1350 of glscene/Source/glcontext.pas

      if not IsValid then
         raise EGLContext.Create(cContextNotCreated);

What does IsValid? It is abstract. It is a TGLGtkContext, which is defined
glscene/Source/platform/gllingtkcontext.pas.

It turned out that TGLContext.CreateMemoryContext is not implemented.

Burkhard Carstens

2010-07-10 18:49

developer   ~0039241

@Mattias
 {$ifdef LCLGTK2}
   Gtk2Proc, gtk2, gdk2, gdk2x, Gtk2Def;
 {$else}
   GTKProc, gtk, gtkdef, gdk;
 {$endif}

Will this compile with laz-0.9.28 ?

I don't know why HandleNeeded is called so early. However, with laz-0.9.28 and gtk1 I have no problems.

IsValid checks if the fRenderingContext is instantiated (gllingtkcontext, line 323).

CreateMemoryContext is indeed not implemented yet. I tried it two ar three times on a lazy sunday afternoon, but had to give up in the evening... :-)
So this demo can't work on linux.

@Fabio:
Does disabling the "HandleNeeded" line in
Source/platform/gllclviewer.pas:488
make any difference for you?

Fabio Luis Girardi

2010-07-10 19:54

reporter   ~0039246

Disabling the HandleNeeded and the call to WMSize procedure (my workaround) I get a empty glsceneviewer (only the background color).

Disabling only the HandleNeeded calling WMSize to correct the size, I get a empty glsceneviewer again.

Mattias Gaertner

2010-07-10 20:09

manager   ~0039247

Fabio, do you understand, that the example can not work, because it requires CreateMemoryContext, which is not implemented yet in glscene for gtk?

Fabio Luis Girardi

2010-07-10 20:28

reporter   ~0039248

Last edited: 2010-07-10 20:37

Mattias: Yes, this demo don't works, but others (that I think that don't use CreateMemoryContext) is working to me (doing a resize on TGLSceneViewer after it loaded disabling handleneeded and my workaround)

Can you try Demos/meshes/subdivide?

Mattias Gaertner

2010-07-10 20:36

manager   ~0039249

Please improve the steps to reproduce.

Fabio Luis Girardi

2010-07-10 20:47

reporter   ~0039250

At runtime:

1 - Open the oglscene/Demos/meshes/subdivide

2 - Run it

3 - Click on button called "Load"

4 - Resize the window (that will resize the GLSceneViewer because that it is aligned at left of the window, Align=alLeft).

5 - See the it working.


At design time:

1 - Open the Demo/materials/cubemap

2 - If you have a black window, resize it (GLSceneViewer have Align=alClient).

3 - See the teapot1.

Patrick Chevalley

2010-08-17 17:31

reporter   ~0040258

It work without resizing if you put the GLSceneViewer on a TPanel instead of directly to the TForm.

The Gtk2proc change is necessary for 0.9.29 but it not compile with 0.9.28.
On other application I have use LCLVersion with
{$if (lcl_major=0) and (lcl_minor=9) and (lcl_release<29)}
But this not work here because it is in the Interface Uses.

I also commented HandleNeeded; , this suppress all the warning on program startup and I not notice any problem.

Burkhard Carstens

2011-01-31 21:23

developer   ~0045648

This is obviously caused by the fact that we only receive one WMSize message with width=height=1. This is probably the initial msg from the interface. However, we don't receive a WMSize with the real width,height loaded from the resource.

I'd consider this a LCL bug. I don't know whether this is a regression or not. Maybe someone else knows ..

The proposed fix (calling wmsize in Loaded) only works, if HandleNeeded is called before. Otherwise we get the width=height=1 after the Loaded is done.
As far as I understand, calling HandleNeeded in Loaded is bad practise, so I did not apply the patch.

Mattias, any suggestion?

Fabio Luis Girardi

2020-02-03 13:01

reporter   ~0120858

Please close this. It's working on latest versions of Lazarus and GLScene.

Issue History

Date Modified Username Field Change
2010-07-09 20:13 Fabio Luis Girardi New Issue
2010-07-09 20:13 Fabio Luis Girardi Widgetset => GTK 2
2010-07-09 20:18 Fabio Luis Girardi Note Added: 0039203
2010-07-10 11:14 Burkhard Carstens Status new => assigned
2010-07-10 11:14 Burkhard Carstens Assigned To => Burkhard Carstens
2010-07-10 11:24 Burkhard Carstens Note Added: 0039221
2010-07-10 14:39 Fabio Luis Girardi File Added: gllingtkcontext.pas.patch
2010-07-10 14:39 Fabio Luis Girardi Note Added: 0039232
2010-07-10 15:12 Fabio Luis Girardi Note Added: 0039233
2010-07-10 15:53 Fabio Luis Girardi Note Added: 0039234
2010-07-10 17:20 Mattias Gaertner Note Added: 0039238
2010-07-10 18:12 Mattias Gaertner Note Edited: 0039238
2010-07-10 18:49 Burkhard Carstens Note Added: 0039241
2010-07-10 19:54 Fabio Luis Girardi Note Added: 0039246
2010-07-10 20:09 Mattias Gaertner Note Added: 0039247
2010-07-10 20:28 Fabio Luis Girardi Note Added: 0039248
2010-07-10 20:36 Mattias Gaertner Note Added: 0039249
2010-07-10 20:37 Fabio Luis Girardi Note Edited: 0039248
2010-07-10 20:47 Fabio Luis Girardi Note Added: 0039250
2010-08-17 17:31 Patrick Chevalley Note Added: 0040258
2011-01-31 21:23 Burkhard Carstens Note Added: 0045648
2011-01-31 21:24 Burkhard Carstens Assigned To Burkhard Carstens => Mattias Gaertner
2020-02-03 13:01 Fabio Luis Girardi Note Added: 0120858