Delphi Conundrum - What Am I Doing Wrong?¶
So, I'm working on some of the rendering classes for my latest project and I've encountered an interesting issue that I can't explain and I'd greatly appreciate it if someone could explain to me what it is I'm doing wrong because I just can't see it.
These are the code snippets that I believe are relevant (hopefully it's obvious, but I've significantly simplified them leaving only what I think is relevant)....
TBaseObject is descended from TObject and just includes some debugging/logging code I want in all my objects.
The exact message I get is this:-
E2010 Incompatible types: 'TTextureAtlasClass' and 'class of TTextureAtlasOGL'
I understand this error, but what I don't get is how this use case is any different from that of TCollectionItem for example where the TCollection constructor expects a parameter of type TCollectionItemClass, which is defined as:-
And my collection item is TMyCollectionItem = class(TCollectionItem) and then I can create a collection like this:-
Why does this work (and I've included some code to test this) yet my code doesn't? I've done this before and had zero issues but for some reason the compiler just doesn't like this code.
Please help as my current work around is dirty (TTextureAtlasClass = TClass) and I'd really like to know what I've got wrong. I have also tried doing this by passing the class into the TRenderer constructor like TCollection but I still get this error.
All I can say is DOH!!! Notice this subtle difference...
This issue is a direct result of me changing my mind on naming conventions and source file layout.
There were two units... ORE.Renderer.BaseClasses.TextureAtlas and ORE.Renderer.Classes.TextureAtlas that both defined a class TTextureAtlas and both define a class reference type TTextureAtlasClass. TRenderer was using one whilst TRendererOGL where the error was occuring was using the other.
That will teach me for not sorting out my source files and being doubly careful when checking my code. DOH!!!