[fpc-pascal] Moving callbackfunctions to class

Michael Van Canneyt michael at freepascal.org
Thu Dec 30 18:01:38 CET 2010



On Thu, 30 Dec 2010, Darius Blaszyk wrote:

> Hi,
> 
> GLut defines callback functions, one of them is the display function, which is defined as:
> 
> TGlutVoidCallback = procedure; cdecl;
> 
> This is set by calling glutDisplayFunc(@MyDisplayFunc); 
> 
> As these functions are needed per window, I would like to encapsulate each window in a class something like:
> 
> TMyGLutWindow = class
>   private
>     procedure MyDisplayFunc; cdecl;
>   public
>     constructor Create;
> end;
> 
> In the constructor I would like to set the displayfunction. But doing this I get the error:
> 
> Error: Incompatible types: got "<procedure variable type of procedure of object;CDecl>" expected "<procedure variable type of
> procedure;CDecl>"
> 
> Though I understand the error, I do not know if there is a way to circumvent this?

No, there isn't.

Michael.


More information about the fpc-pascal mailing list