Page 1 of 1

ViewPort 1282 Error

Posted: Thu Nov 20, 2014 8:49 am
by 16561419
Hi,

whenever I call the draw procedure of a OpenGL TChart I get an error message:

ViewPort 1282, VCLTee.TeeGLCanvas.pas, line 923

Just execute this code on a TChart (MyChart) in OpenGL mode:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
const
  ReportChartWidthC = 800;
  ReportChartHeightC = 600;
var
  PaintRect: TRect;
  MyBitmap: TBitmap;
begin
  PaintRect := Rect(0, 0, ReportChartWidthC, ReportChartHeightC);
  MyBitmap := TBitmap.Create;
  try
    MyBitmap.SetSize(ReportChartWidthC, ReportChartHeightC);
    MyChart.Draw(MyBitmap.Canvas, PaintRect);
  finally
    MyBitmap.Free;
  end;
end;
And it will happen.
Is there any workarround available to get a bitmap of an OpenGL chart ?

best regards

Re: ViewPort 1282 Error

Posted: Fri Nov 21, 2014 11:26 am
by yeray
Hello,
X-Ray wrote:whenever I call the draw procedure of a OpenGL TChart I get an error message:

ViewPort 1282, VCLTee.TeeGLCanvas.pas, line 923
We could reproduce the problem here.

I'm afraid we are finding problems to draw a Chart directly to a bitmap using OpenGL.
However, note calling TeeCreateBitmap without arguments returns a correct TBitmap because it returns an internal bitmap generated when the component has been drawn in the form. So the way to go for now could be:
- Resize the main chart, temporally, to the size of the destination TBitmap and repaint it.
- Call TeeCreateBitmap without arguments to get the internal TBitmap.
- Restore the Chart original size.

This produces a little flickering though.
GLtoBitmap.zip
(1.83 KiB) Downloaded 690 times

Re: ViewPort 1282 Error

Posted: Fri Nov 21, 2014 1:46 pm
by 16561419
Hello Yeray,

the problem actually persists, I have the Chart on a Tab of a Page Control (there are actually many charts on different pages)
and when the Chart is on a hidden page I still get the same crash (ViewPort 1282, line 923)!
So let me re-formulate my question, is there any way to get a bitmap of an invisible OpenGL TChart?

best regards

Re: ViewPort 1282 Error

Posted: Fri Nov 21, 2014 2:27 pm
by yeray
Hi,
X-Ray wrote:So let me re-formulate my question, is there any way to get a bitmap of an invisible OpenGL TChart?
The technique described above seems to work fine for me with v2014.12 even if I hide the TChart.
Here it is an example showing 3 techniques: Drawing directly to the TBitmap (crashes), using TeeCreateBitmap passing the desired size to it (crashes) and using TeeCreateBitmap without arguments but modifying the TChart size before and after that call as described above (it works).
GLtoBitmap.zip
(2 KiB) Downloaded 679 times

Re: ViewPort 1282 Error

Posted: Mon Nov 24, 2014 7:23 am
by 16561419
Hello Yeray,

You are right, I forgot the the Chart.Draw call.
When I include this call before calling Chart.TeeCreateBitmap it works fine.
Thank you !
Still it would be nice if the other calls would be fixed.

best regards

Re: ViewPort 1282 Error

Posted: Mon Nov 24, 2014 8:37 am
by yeray
Hello,

We've made some changes to the sources so I can confirm calling Chart.TeeCreateBitmap with Rectangle as a parameter returns a bitmap with the correct size, but we may loose the AntiAlias. We ask the OpenGL dll for the AntiAlias, who ask for it to the GPU driver; if this didn't success, then we retry to create the OpenGL, this time without AntiAlias.
2014-11-24_0932.png
2014-11-24_0932.png (25.74 KiB) Viewed 11992 times
Note v2014.13.141124 isn't a published version. It just means it's made with today's internal sources.

Re: ViewPort 1282 Error

Posted: Tue Nov 25, 2014 3:34 pm
by yeray
Hello again,
Yeray wrote:We've made some changes to the sources so I can confirm calling Chart.TeeCreateBitmap with Rectangle as a parameter returns a bitmap with the correct size, but we may loose the AntiAlias. We ask the OpenGL dll for the AntiAlias, who ask for it to the GPU driver; if this didn't success, then we retry to create the OpenGL, this time without AntiAlias.
We've made some extra modifications and I can confirm the "Draw to Bitmap" technique also works.
It gives a non AntiAliased result, as with the "TeeCreateBitmap with Rectangle" technique, because OpenGL can only do AntiAlias when drawing on the screen.

Re: ViewPort 1282 Error

Posted: Wed Nov 26, 2014 10:46 am
by 16561419
Hello Yeray,

is there any estimation as when the new version with these fixes will be released?

Re: ViewPort 1282 Error

Posted: Thu Nov 27, 2014 8:29 am
by yeray
Hello,

Since you own the TeeChart sources, I've just sent you a mail with the current OpenGL2, TeeGLCanvas and TeeOpenGL units.