Menu

TGLMemoryViewer alternative

Help
Edwin
2016-07-29
2016-09-19
  • Edwin

    Edwin - 2016-07-29

    In my application I need rendered images of the 3D scene for reporting purposes. Currently I'm using a TGLMemoryViewer to render the scene and fetch an image with Buffer.CreateSnapShot. Although it sounded perfectly fine in theory, practice was a little different. The rendering quality is absolutely terrible and I suspect that it uses some sort of software backup to render.

    What would be the best alternative way to get an image?

    Note that snapshotting a TGLSceneViewer is not an option because the scene is often not on screen.

     
  • Torud

    Torud - 2016-08-25

    Hi, I am working as well on things like this and was looking yesterday inside the sources of GLScene.
    CreateSnapShot is rendering official in lowest quality. You will find this as comment directly after the code. Look here:

    in GLScene.pas line 8674 you will see this:
    AntiAliasing := aaNone; // no AA for bitmap rendering

    I wonder why I always receive an Error, after changing this from aaNone aa8x;
    Maybe I have to compile this before again!?

     
  • Edwin

    Edwin - 2016-09-13

    It's not just AA. There are many issues with it. RenderToBitmap also works, but with other issues.

     
  • Jerome.D (BeanzMaster)

    Hi you can try to use FBO renderer for create a snapshot. see demos\rendering\rendertotexture

     

    Last edit: Jerome.D (BeanzMaster) 2016-09-14
  • Edwin

    Edwin - 2016-09-15

    Turning a TGLFBORenderer into a separate thing for offscreen rendering is not quite as straightforward as it looks. So far I managed to create either "Texture error"s and worse.

     
  • Jerome.D (BeanzMaster)

    Hi i take look into glscene.pas instead CreateSnapShot you can use :
    function TGLSceneBuffer.CreateSnapShotBitmap: TGLBitmap; //with the viewer resolution
    procedure TGLSceneBuffer.RenderToBitmap(ABitmap: TGLBitmap; DPI: Integer); // Create a TGLBitmap with your resolution and set DPI to 300 for hi-resolution

    These two functions don't render the scene in the same way

    see in glscene.pas approximatively from line 8380 to 8700

     
  • Edwin

    Edwin - 2016-09-16

    CreateSnapShotBitmap is essentially the same as CreateSnapShot. In fact, it calls the later. RenderToBitmap seems better, with the exception of it not rendering text properly (see other thread).

     
  • Jerome.D (BeanzMaster)

    Hum we must see more deeply in the code, i suggest to search in the GLObject Render procedure. The entry point is TGLScene.Render for following how each object is rendered.

    it not rendering text properly (see other thread).

    In this case, take a look in the TGLFlatText Render procedure (or something like that, i don't remember exactly) and up throw the parent object's render procedure for trying to find where is the bug (if exist).
    I think using FBORender can be a good solution and compromise. A GLScene viewer can have any dimension and he can be invisble.

    Just a question Edwin what do you do with the rendered bitmap ? Do you apply some filters or something else ?

     
  • Edwin

    Edwin - 2016-09-19

    Bitmaps are created for generating printable reports.

    The TGLFlatText problem is probably (as mentioned in the other thread) something going wrong with the generated font texture. Not the easiest code to work through.

    But I think I have at least a start for the problem with CreateSnapShot.

    This has to do with GL states being incorrect. My scene contains a number of DirectOpenGL objects that render arrays of triangles (and optionally lines). The triangles use a 1D texture for color and are rendered with lighting disabled. What appears to happen is that everything works fine while rendering to screen, but when CreateSnapShot does it, the lighting goes back on after the first DirectOpenGL object and "rci.GLStates.Disable(stLighting);" won't turn it off anymore. However, if I issue "glDisable(GL_LIGHTING);", then lighting does turn off.

    This is not the first time I've had issues with the new context stuff. For the DirectOpenGL objects that draw lines I can't use the rci. and GL. at all because all rendering after it gets messed up.

    I should really try a newer version. Although I can't find any commits that appear relevant, I could have missed important fixes.

     

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.