ViewPort 1282 Error

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
X-Ray
Newbie
Newbie
Posts: 49
Joined: Fri Jan 27, 2012 12:00 am

ViewPort 1282 Error

Post by X-Ray » Thu Nov 20, 2014 8:49 am

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
Attachments
TChartCrashCapture.PNG
TChartCrashCapture.PNG (24.63 KiB) Viewed 11243 times

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: ViewPort 1282 Error

Post by Yeray » Fri Nov 21, 2014 11:26 am

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 592 times
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

X-Ray
Newbie
Newbie
Posts: 49
Joined: Fri Jan 27, 2012 12:00 am

Re: ViewPort 1282 Error

Post by X-Ray » Fri Nov 21, 2014 1:46 pm

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

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: ViewPort 1282 Error

Post by Yeray » Fri Nov 21, 2014 2:27 pm

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 576 times
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

X-Ray
Newbie
Newbie
Posts: 49
Joined: Fri Jan 27, 2012 12:00 am

Re: ViewPort 1282 Error

Post by X-Ray » Mon Nov 24, 2014 7:23 am

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

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: ViewPort 1282 Error

Post by Yeray » Mon Nov 24, 2014 8:37 am

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 11154 times
Note v2014.13.141124 isn't a published version. It just means it's made with today's internal sources.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: ViewPort 1282 Error

Post by Yeray » Tue Nov 25, 2014 3:34 pm

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.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

X-Ray
Newbie
Newbie
Posts: 49
Joined: Fri Jan 27, 2012 12:00 am

Re: ViewPort 1282 Error

Post by X-Ray » Wed Nov 26, 2014 10:46 am

Hello Yeray,

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

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: ViewPort 1282 Error

Post by Yeray » Thu Nov 27, 2014 8:29 am

Hello,

Since you own the TeeChart sources, I've just sent you a mail with the current OpenGL2, TeeGLCanvas and TeeOpenGL units.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply