Menu

Polygons not visible

Help
2019-02-18
2020-06-25
1 2 > >> (Page 1 of 2)
  • John Ioannides

    John Ioannides - 2019-02-18

    Hello,

    I have some old code to create and display GLPolygons that worked ok, however I just upgraded to Rio and installed the latest GLScene version and the same code does not seem to work (I attached the output of my app as it works complied with previous version of GLScene and with the latest 1.8)

    poly := TGLPolygon.Create(glscene1);
    // add nodes ///
    ..........................
    poly.Division := 100;
    poly.VisibilityCulling := vcObjectBased;
    poly.Parts := [pptop];
    poly.Material.BlendingMode := bmOpaque;
    poly.Material.FrontProperties.Ambient.AsWinColor := clblack;
    poly.Material.FrontProperties.Diffuse.AsWinColor := SomeColor
    poly.Material.FrontProperties.Diffuse.Alpha := 0.8;//0.80;
    poly.Material.PolygonMode := pmFill;
    poly.Material.BackProperties.Diffuse.AsWinColor := foo^.Color;
    poly.Material.BackProperties.Diffuse.Alpha := 0.30;//0.30;
    poly.Material.BackProperties.Ambient.AsWinColor := clblack;

    Can anyone please suggest what I should change in order to make the polygons visible?

    Regards

     
    👍
    1
  • Jerome.D (BeanzMaster)

    Hi John can you upload a simple demo for testing please, it will be more easy for me to track the problem et answer to you and i'll can made change in code if needed.

    Regards

     
    • John Ioannides

      John Ioannides - 2019-02-18

      Hello,

      Thank you for your swift reply! Please find attached a simple project but I am not sure the plane coordinates are ok. However I would expect to see something :)

      Regards

       

      Last edit: John Ioannides 2019-02-18
  • Jerome.D (BeanzMaster)

    Hum, It's weird because with Delphi RIO 10.3 Community Edition and the latest version of GLScene 1.8 ,with your sample all seems good (See screenshot)

    What your Graphic Card model ?
    Check and update the GPU driver

     
  • Jerome.D (BeanzMaster)

    Hum,

    First you don't need to pass GLScene1 as parameter in surface_plane := TGLPlane.Create(GLScene1); try to just do" surface_plane := TGLPlane.Create(nil);" because after you add it in DummyCube with" GLDummyCube.AddChild(surface_plane);"
    An other way is directly to do " surface_plane := TGLPlane.CreateAsChild(GLDummyCube);"

    So perhaps in your original application the order of your objects are not good and if you use DummyCube as parent check visibility and Culling properties

    I see, also if you use DirectOpenGL between 2 be careful to restore the openGL's States correctly after the rendering

    Cheers

     

    Last edit: Jerome.D (BeanzMaster) 2019-02-18
  • John Ioannides

    John Ioannides - 2019-02-18

    Hello, I am afraid I do not know what to check exactly, I wrote that code many years ago and until recently with GLScene 1.5 it was working ok. Would it be possible for you to modify my project to draw a simple polygon so that I can see the changes you mentioned?

    Thank you very much for your time and effort.

    Regards

     
  • John Ioannides

    John Ioannides - 2019-02-20

    Hello,

    I changed the PolygonMode from fill to lines and the result I get is not what I was expecting, maybe something changed to the way a polyline should be defined?

    Regards

     

    Last edit: John Ioannides 2019-02-20
  • Jerome.D (BeanzMaster)

    Hi, like i said your little sample work perfectly on my PC without change your code.
    Can you upload your whole project for can i'll test ?

    What is your GPU Card ?

    Regards

     
    • John Ioannides

      John Ioannides - 2019-02-21

      Hello,

      If you check the screenshot you sent me you will see that only the 2 planes are visible, the polyline is not, that is the part that is not working. My guess is that I will have to remove the polyline and replace it with a plane or switch back to 1.5

      Thank you very much for your time and effort, I really do appreciate it!

      Regards

       
  • Jerome.D (BeanzMaster)

    Hi Ok i don't understand

    Try to set PolygonMode to pmLines

     
  • Jerome.D (BeanzMaster)

    Check and run \GLScene\Samples\Delphi\Demos\collisions\TriangleBox tell if it work and if you see the triangle polygon.

     
    • John Ioannides

      John Ioannides - 2019-02-22

      Hello,

      I checked the demo, the triangle polygon (GLPolygon1) is not visible, only the lines are plotted (GLLines2), if you comment out lines 137 to 140 then only the points appear.

       

      Last edit: John Ioannides 2019-02-22
  • Andrzej Karwowski

    I have similar problem with Delphi 10.2 and GLScene. When I choose Win32 as target platform (which I prefer) polygons are not visible. If I change target to Win64 all polygons appear.

     
    • John Ioannides

      John Ioannides - 2019-02-25

      I had to roll back to 1.5 to solve this issue but it would be nice to have this issue fixed in the latest version.

       
      • Andrzej Karwowski

        Thank you for the information, perhaps I will do the same. I hope that the GLScene team will fix it.

         
  • Pavel Vassiliev

    Pavel Vassiliev - 2019-02-28

    John,
    It's a weird behaviour for polygon's drawing with ok on win64 and empty in win32. The reason not found yet.
    PW

     
  • Pavel Vassiliev

    Pavel Vassiliev - 2019-02-28

    John,
    Maybe the reason is rooted in changing some dynamic methods to virtual or declaring inlines, I really don't guess what's the matter now. Will search later.
    PW

     
  • Reinier Sterkenburg

    I have the same problem and solution: on win32 polygons don't show up, but on win64 they do..

     
  • Niels Bach-Sørensen

    I have this issue as well. Does anyone have an approximate timeframe for a fix?

     
  • Filippo Forlani

    Filippo Forlani - 2019-04-08

    I have the same problem with different PC delphi 10.1

     
  • Egroc

    Egroc - 2019-05-24

    Same problem here. I cannot view TGLPolygon on Win32. If compile Win64 TGLPolygon shows but no transparency/blend affected, only solid TGLPolygon...

    Issue is in versión 1.6 and up. 1.5 Works OK. Tested on delphi XE7 and 10.3, both fails. Tested on various Nvidia Geforce cards, all failed.

    Any solution for this problem?

     
  • Marco Farina

    Marco Farina - 2019-07-18

    I have the same problem (Delphi XE 10.3 Rio): polygons shows correctly when compiling Win64, but nothing Win32. Just downloaded the latest version of OpenGL but nothing changed. Any suggestion?

     
  • LefjuCabro

    LefjuCabro - 2019-12-06

    Hi,
    Do you have any suggestion about resolving this ? Is there any modifications that we could apply in source ?
    I cannot compile my app to Win64.
    Regards

     
  • bobmc

    bobmc - 2020-02-18

    Same problem here, TGLPolygons don't show in 32bits, only in 64bits.

     
  • Jerome.D (BeanzMaster)

    Hi to all , this problem seems to be an kind of range overflow so
    the only problem i see it's in the code of polygon itself or in vectors's formula

    I don't have Delphi, only Lazarus. But with Lazarus the "\GLScene\Samples\Delphi\Demos\collisions\TriangleBox " work perfectly by compiling it in Win32 and Win64

    In the Lazarus's code
    In GLGeomObject unit we have

    procedure TGLPolygon.BuildList(var rci: TGLRenderContextInfo);
    var
      Normal: TAffineVector;
      pNorm: PAffineVector;
    begin
      if (Nodes.Count > 1) then
      begin
        Normal := Nodes.Normal;
        if VectorIsNull(Normal) then
          pNorm := nil
        else
          pNorm := @Normal;
        if ppTop in FParts then
        begin
          if SplineMode = lsmLines then
            Nodes.RenderTesselatedPolygon(true, pNorm, 1)
          else
            Nodes.RenderTesselatedPolygon(true, pNorm, Division);
        end;
        // tessellate bottom polygon
        if ppBottom in FParts then
        begin
          if Assigned(pNorm) then
            NegateVector(Normal);
          if SplineMode = lsmLines then
            Nodes.RenderTesselatedPolygon(true, pNorm, 1, true)
          else
            Nodes.RenderTesselatedPolygon(true, pNorm, Division, true);
        end;
      end;
    end;  
    

    in GLNodes.pas

    procedure TGLNodes.RenderTesselatedPolygon(ATextured: Boolean;
      ANormal: PAffineVector = nil; ASplineDivisions: Integer = 1;
      AInvertNormals: Boolean = False);
    var
      I: Integer;
      Tess: PGLUTesselator;
      DblVector: TAffineDblVector;
      Spline: TCubicSpline;
      SplinePos: PAffineVector;
      F: Single;
    
    begin
      if Count > 2 then
      begin
        // Create and initialize the GLU tesselator
        Tess := GluNewTess;
        GluTessCallback(Tess, GLU_TESS_BEGIN, @GL.Begin_);
        if ATextured then
          GluTessCallback(Tess, GLU_TESS_VERTEX, @TessIssueVertex)
        else
          GluTessCallback(Tess, GLU_TESS_VERTEX, @GL.Vertex3fv);
        GluTessCallback(Tess, GLU_TESS_END, @GL.End_);
        GluTessCallback(Tess, GLU_TESS_ERROR, @TessError);
        GluTessCallback(Tess, GLU_TESS_COMBINE, @TessCombine);
        NbExtraVertices := 0;
        // Issue normal
        if Assigned(ANormal) then
        begin
          GL.Normal3fv(PGLFloat(ANormal));
          GluTessNormal(Tess, ANormal^.V[0], ANormal^.V[1], ANormal^.V[2]);
        end;
        // Issue polygon
        GluTessBeginPolygon(Tess, nil);
        GluTessBeginContour(Tess);
        if ASplineDivisions <= 1 then
        begin
          // no spline, use direct coordinates
          GetMem(NewVertices, Count * SizeOf(TAffineVector));
          if AInvertNormals then
          begin
            for I := Count - 1 downto 0 do
            begin
              SetVector(DblVector, PAffineVector(Items[I].AsAddress)^);
              GluTessVertex(Tess, DblVector, Items[I].AsAddress);
            end;
          end
          else
          begin
            for I := 0 to Count - 1 do
            begin
              SetVector(DblVector, PAffineVector(Items[I].AsAddress)^);
              GluTessVertex(Tess, DblVector, Items[I].AsAddress);
            end;
          end;
        end
        else
        begin
          // cubic spline
          GetMem(NewVertices, 2 * ASplineDivisions * Count * SizeOf(TAffineVector));
          Spline := CreateNewCubicSpline;
          F := 1.0 / ASplineDivisions;
          if AInvertNormals then
          begin
            for I := ASplineDivisions * (Count - 1) downto 0 do
            begin
              SplinePos := AllocNewVertex;
              Spline.SplineAffineVector(I * F, SplinePos^);
              SetVector(DblVector, SplinePos^);
              GluTessVertex(Tess, DblVector, SplinePos);
            end;
          end
          else
          begin
            for I := 0 to ASplineDivisions * (Count - 1) do
            begin
              SplinePos := AllocNewVertex;
              Spline.SplineAffineVector(I * F, SplinePos^);
              SetVector(DblVector, SplinePos^);
              GluTessVertex(Tess, DblVector, SplinePos);
            end;
          end;
          Spline.Free;
        end;
        GluTessEndContour(Tess);
        GluTessEndPolygon(Tess);
        // release stuff
        if Assigned(NewVertices) then
          FreeMem(NewVertices);
        GluDeleteTess(Tess);
      end;
    end; 
    

    In GLVectorGeometry. pas

    procedure NegateVector(var v : TAffineVector);
    // EAX contains address of v
    {$ifndef GEOMETRY_NO_ASM}
    asm
          FLD DWORD PTR [EAX]
          FCHS
          FSTP DWORD PTR [EAX]
          FLD DWORD PTR [EAX+4]
          FCHS
          FSTP DWORD PTR [EAX+4]
          FLD DWORD PTR [EAX+8]
          FCHS
          FSTP DWORD PTR [EAX+8]
    {$else}
    begin
       v.V[0]:=-v.V[0];
       v.V[1]:=-v.V[1];
       v.V[2]:=-v.V[2];
    {$endif}
    end;  
    

    So in first try to disable ASM by activate GEOMETRY_NO_ASM and GLS_NO_ASM in GLScene.inc like this

    // De-Activate assembly routines in GLVectorGeometry.pas
    {$DEFINE GEOMETRY_NO_ASM} 
    
    // De-Activate assembly routines in other GLS units.
    {$DEFINE GLS_NO_ASM}  
    

    You can also try to enabled those options to help tracking bugs

    // Activate Logging
    {$DEFINE GLS_LOGGING}
    
    // Activate OpenGL debug mode
    {$DEFINE GLS_OPENGL_DEBUG} 
    

    And if someone can diff those code below, it will be help

    Cheers

     

    Last edit: Jerome.D (BeanzMaster) 2020-02-26
1 2 > >> (Page 1 of 2)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.