[fpc-pascal] Moving callbackfunctions to class
Darius Blaszyk
dhkblaszyk at zeelandnet.nl
Thu Dec 30 18:27:52 CET 2010
On Dec 30, 2010, at 6:09 PM, michael.vancanneyt at wisa.be wrote:
>
>
> On Thu, 30 Dec 2010, Jonas Maebe wrote:
>
>>
>> On 30 Dec 2010, at 17:34, Darius Blaszyk wrote:
>>
>>> 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?
>>
>> Maybe with a static class method? (they may require svn trunk to work though) You won't be able to access any fields from that one, of course.
>
> That kind of defeats the purpose, if you want to create a wrapper around the
> window instance, which I understood to be the intention of Darius ?
The intention is indeed to create a wrapper around the multiple callback functions that GLut provides and additionally add some other methods and properties. I have tried using a class method (FPC 2.4.2) but not static class methods, although I don't really understand what you mean with "you won't be able to access any fields from that one". Afaik class methods have a self, right? That would suggest you can access any method or property of self from a class method?
Regards, Darius
More information about the fpc-pascal
mailing list