Advertisement

I think I'm on to something...

Started by October 11, 2001 10:33 AM
5 comments, last by Cyberdrek 22 years, 11 months ago
I''m not sure if this already exists but here goes, I''m creating a game using SDL for the contest that was announced here some time ago and in the doing, I''ve created a 2D engine( which I had to rewrite twice ) and I''ve now come up with something that closely ressembles COM, hence the name HSCOM. Now here''s my idea, I was wondering if it would be worth it to try and use HSCOM to try and make a DX clone for Linux once my contest entry is done. Any input would be appreciated. If any of you have Lamothes book, you can look at his example that tries to demonstrate what COM is and how to create something similar to COM objects and that is basicly what HSCOM looks like. Anyhow, I think you guys get the point. "And that''s the bottom line cause I said so!" Cyberdrek Headhunter Soft A division of DLC Multimedia
Resist Windows XP''s Invasive Production Activation Technology! "gitty up" -- Kramer
[Cyberdrek | ]
Hm... in other words make a wrapper around SDL (which I have heard is easier to use that directx, but I could be wrong) so it seems like directx, which is regarded as hard to use... Hmm... well, it could be good, but I would say just make an awesome, easy to use wrapper and don''t mimic other api.
Advertisement
Although, Anon is right, it is easier to use sdl than directx, I think there may be some use for your HCOM wrapper, SDL for windows is a wrapper for DirectX 5, and I havent seen any good sdl for windows games, having something to compile your directx code in linux without a change might be really good, as directx is optimised for windows, and sdl is optimized for linux, I think you will get supperior apps porting from directx to sdl (as proven by Loki Games) than using sdl for the sake of multiplatform support, your wrapper might speed up the process from DX to SDL.

Edited by - kwizatz on October 11, 2001 4:08:43 PM
Actually, SDL is a crossplatform, very thin, library. It isn''t optimized for linux, and most games made with SDL that follow normal conventions can be ported over VERY easily. The challenge is getting people to USE SDL

Magnwa
Actually, COM emulation is a peice of piss to recreate, if you''re cunning enough.

What you need to do is create your interfaces (function pointers inside a structure), and have a function that finds the addresses of the functions, and loads up the appropriate dynamic library.
Take the following example.:

typedef struct IFakeCOM {
void (*InitCom)(void);
void (*Release)(IFakeCom *me);
};

IFakeCom *InitFakeCom(void) {
IFakeCOM *temp;

temp = (IFakeCOM *)malloc(sizeof(IFakeCOM);

temp->InitCom = AddressOfInitCom;
temp->Release = AddressOfRelease;

return temp;
}

et viola!

A very COM like interface, without much effort. Granted, loading shared opbjects adds a few more lines, but a man dlopen will explain everything for you.

The Release function should look something like this:

void *Release(IFakeCom *me) {
free(me);
}

Nurgle

After careful deliberation, I have come to the conclusion that Nazrix is not cool. I am sorry for any inconvienience my previous mistake may have caused. We now return you to the original programming

After careful deliberation, I have come to the conclusion that Nazrix is not cool. I am sorry for any inconvienience my previous mistake may have caused. We now return you to the original programming

quote: Original post by Godfree^



Actually, COM emulation is a peice of piss to recreate, if you''re cunning enough.







What you need to do is create your interfaces (function pointers inside a structure), and have a function that finds the addresses of the functions, and loads up the appropriate dynamic library.



Take the following example.:







typedef struct IFakeCOM {



void (*InitCom)(void);



void (*Release)(IFakeCom *me);



};







IFakeCom *InitFakeCom(void) {



IFakeCOM *temp;







temp = (IFakeCOM *)malloc(sizeof(IFakeCOM);







temp->InitCom = AddressOfInitCom;



temp->Release = AddressOfRelease;







return temp;



}







et viola!







A very COM like interface, without much effort. Granted, loading shared opbjects adds a few more lines, but a man dlopen will explain everything for you.







The Release function should look something like this:







void *Release(IFakeCom *me) {



free(me);



}







Nurgle







After careful deliberation, I have come to the conclusion that Nazrix is not cool. I am sorry for any inconvienience my previous mistake may have caused. We now return you to the original programming








Actually, you''re code doesn''t even come close to COM ( sorry to say that but that''s not COM like at all ). Second, if you read the message, I said that the emulator is done. At least it is for my game at the moment but I want to know if creating a COM like library for Linux would be a welcome add on for linux...





ps: yes, COM like interfaces are easy to make when you know what you''re doing...



"And that''s the bottom line cause I said so!"

Cyberdrek
Headhunter Soft
A division of DLC Multimedia

Resist Windows XP''s Invasive Production Activation Technology!

"gitty up" -- Kramer
[Cyberdrek | ]
Advertisement
Personally, I think COM just sucks.

It was created based upon some good ideas and was turned into crap. Many of the things that COM does could be done just as well with standard C++ classes. Just look at DirectX, and you should see what I mean.
A huge downside of COM is the use of GUIDs and so on, over-use of QueryInterface() and more. COM is really a buzzword technology that has gone far beyond the scope where it''s supposed to have stayed, and it''s now messing around in areas where it shouldn''t.

Of course, the idea behind COM is valuable, but Microsoft seems to do everything they can to turn it into crap. Whenever I browse the MSDN I see such wonderful interface definitions like an IXxxContainer. Now when I want to list the elements in this container, I need to QueryInterface to an IEnumXxxContainer. That''s just plain dumb.

It''s very hard to do something like COM right (wrt to programming and performance), so wherever it''s not strictly needed you should just stick to C++ classes IMO.

cu,
Prefect

One line of sourcecode says more than a thousand words.
Widelands - laid back, free software strategy

This topic is closed to new replies.

Advertisement