No announcement yet.

Should Open GL fully work right now?

  • Filter
  • Time
  • Show
Clear All
new posts

  • Should Open GL fully work right now?

    I tried changing the DeviceTechnology to OpenGL on all the Delphi Examples, but everytime I get an access violation. Or you I have to do more than just change that value in
    "FDevice := TDevice.Create(TDeviceTechnology.OpenGL);" ?

    It's not a big deal, since on Windows there is really no good reason to switch from Direct3D. I was just curious if this was supposed to work right now.

  • #2
    On Windows, OpenGL support is experimental and mainly required for cross-platform testing. However, it should be working - I could reproduce the issue in FreePascal/Lazarus, but not in any of C/C++ examples. A fix will come shortly.


    • #3
      "On Windows, OpenGL support is experimental and mainly required for cross-platform testing."

      That was my thought why I tested it. Thanks for the info. 👍


      • #4
        This was addressed in latest Afterwarp v2.0.1 update. It was more an interface issue with existing examples, which has been corrected - now you can create normal and "wrapped" device. "Wrapped" device works with OpenGL, when an existing context has already been created, like in case of Lazarus examples running on Linux. In Lazarus, to avoid flicker on Linux, you have to use TOpenGLContext component (I don't know how they make it flicker free as identical code in TCustomRenderingControl in PXT.Control.pas still produces flicker).

        Anyway, now all Delphi and FreePascal/Lazarus examples on Windows should work with either Direct3D or OpenGL backend that you select during device creation. For Lazarus on Linux, a wrapped device is used instead along with TOpenGLContext - currently, this is made via conditional compilation.

        As an additional note, OpenGL support on Windows uses mostly the same codepath as on Linux/Unix platforms, except for a few minor workarounds around driver bugs, so it can also be used in production environment. The reason why it is considered experimental (and will always be) is due to driver bugs, which lately seem to be getting more common, especially when running under VM. Surely, when we get notified of a particular issue, we try to include a workaround in the framework when running under a particular driver, but it's difficult to keep up with existing driver bugs getting solved and new ones coming in.


        • #5
          Great. Also, Parallax mapping looks awesome!


          • #6
            When you use Drawable Textures with OpenGL and create these textures with anything other than 0 multisamples then the texture becomes black.

            I noticed that in the Drawable Texture Example you copy the multisampled texture to a non multisampled one before drawing it and I wondered why before. Is this the reason why? As a workaround to this OpenGL behavior?


            • #7
              You can't use multisampled textures directly. So, after drawing to a multisampled texture, you need to copy its contents to a non-multisample texture, which can then be used for drawing with canvas. This applies both to Direct3D and OpenGL. If you try to use multisampled texture directly, under some circumstances and drivers, it may kind of work, but if you enable debug mode, you should get a warning about it.


              • #8
                whoops.. didnt know that


                • #9
                  Im stuck with another little problem which is kinda related so I didnt make a new thread.

                  I want to render one drawable texture onto another.

                  Click image for larger version  Name:	e15d1ee257c6ddc7be7397ae725f9e3f.png Views:	0 Size:	57.0 KB ID:	308
                  I am developing a graphical UI. There is the main Drawable that contains the whole screen. And another one for the Popup Menu. I want to put it into its own texture so I can later animate its appearing.

                  the Left popup menu (its drawable texture I mean) was drawn directly to the screen and appears as sharp as it should be (all filter settings are set to nearest)
                  The right one was drawn onto the first drawable and appears to be blurred like rendered with Linear filtering. Both btw are copied to a Non MSAA Texture.

                  First I thought it was a filter/samplerstate issue but with Open GL the right one isnt rendered at all. So I have to assume that I once again did something in a way that is not supposed to be done that way.

                  So is there something that I need to pay attention to when I render one drawable onto another?
                  Last edited by Zimond; 02-03-2022, 03:19 PM.


                  • #10
                    I can't really tell what it is without seeing the source code. When rendering the second texture, make sure to set the appropriate canvas attributes, e.g.:
                    FCanvas.Attributes := [];
                    FCanvas.SetSamplerState(TCanvasSamplerState.Create (TTextureFilter.Nearest, TTextureFilter.Nearest));
                    FCanvas.ContextState := TCanvasContextState.FlatText;
                    Specifically, "TCanvasContextState.FlatText" instead of "TCanvasContextState.FlatScene" should help - under certain drivers, especially Nvidia ones, it still does some kind of filtering, which results in minimal blurriness. "FlatText" option disables multisampling antialiasing so seems to work better.

                    Also, an UI framework is coming soon with Afterwarp - it is partially leaked in last release, so will be formally present in the next update. This was the big feature under development that haven't been announced yet.


                    • #11
                      I used FlatText and Nearest already. I have now simply added a second drawable to the Drawable Texture Demo and that works with both with Direct3D and OpenGl and looks sharp.
                      Thats good to know. So I have definitly made some other mistakes.. I will open a cold one and slowly get through my Lasagne Code and hopefully find whats causing this.

                      Click image for larger version

Name:	135da5f90b52df373018f403f7c4a4b4.png
Views:	49
Size:	79.5 KB
ID:	311

                      Also, an UI framework is coming soon with Afterwarp - it is partially leaked in last release, so will be formally present in the next update. This was the big feature under development that haven't been announced yet.
                      Oh damn so maybe I am wasting my time here ^^
                      Nuh, unless you are going to implement also some Gaming related functions I want to add some animation effects for windows rolling out or like particles falling of the mainbar, glowing buttons stuff like that. I think I maybe bit off more than I can chew with this but ill try it anyway Skins are already working.

                      Click image for larger version

Name:	98f771d0fb7571f2a09bd82f7443367e.png
Views:	46
Size:	265.7 KB
ID:	312


                      • #12
                        oh boy... I found it. I had to set Flattext also before I render the Main Drawable Texture to the screen. I thought you only have to do that right before you render text. Now it's perfectly sharp.
                        Click image for larger version

Name:	10944cd4de876883e509e97e3153cc9a.png
Views:	48
Size:	37.7 KB
ID:	314


                        • #13
                          This looks really nice, keep up great work!