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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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!?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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 ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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!?
It's not just AA. There are many issues with it. RenderToBitmap also works, but with other issues.
Hi you can try to use FBO renderer for create a snapshot. see demos\rendering\rendertotexture
Last edit: Jerome.D (BeanzMaster) 2016-09-14
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.
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
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).
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.
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 ?
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.