Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / DarkEngine - OO GDK

Author
Message
RPDan
17
Years of Service
User Offline
Joined: 29th Apr 2007
Location:
Posted: 24th Sep 2007 18:00
Some of you may know that I have recently been writing a library for use with DarkGDK to make it completely OO. After reading the documentation for kBessa's brilliant LightEngine, I found how to use properties, and realised taht I wasn't using inheritance properly.

I have begun rewriting my library completely, and the sound namespace is almost done, so I am releasing that to you now.

I am currently releasing no documentation, but I suggest taking a look at the header files. Most of the commands are fairly obvious, but I suggest downloading the LightEngine documentation, because these two engines are very similar.

To setup, create a new project that includes all the .h files and the .cpp file, and link with the two .obj files. You should edit deCPPapp:rogram::Main() before compiling, unless your disk drive contains a CD with >= 21 tracks on it.

Please post ideas for improvement or any difficulties using the engine.

Attachments

Login to view attachments
RPDan
17
Years of Service
User Offline
Joined: 29th Apr 2007
Location:
Posted: 25th Sep 2007 19:54
Does anyone knoew if it is possible to use properties without having to declare the methods as part of the class?
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 25th Sep 2007 20:24
In FreePascal, C++, VB6 you need to explicitly handle the code routines for the "READ" and the "SET" of the properties. I would imagine this is the case with C#.

With my C++ wrapper - I looked at how the Properties worked - the syntax - and the pain it would be - and decided - make it public - if they blow it up - that's their problem!

RPDan
17
Years of Service
User Offline
Joined: 29th Apr 2007
Location:
Posted: 25th Sep 2007 21:03
Thanks. I think my question was slightly vague, what I meant to ask was is there a way to stop the methods appearing in intellisense. At the moment I am using __declspec(property(get = ,put = )) int fish; etc. I am using c++.
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 25th Sep 2007 22:30
is there a way to change the scope of the method?

the equivalent in vb.net is to define the class method as Private and it wont get pushed up to the instance.

My DBP plugins page is now hosted [href]here[/href]
RPDan
17
Years of Service
User Offline
Joined: 29th Apr 2007
Location:
Posted: 25th Sep 2007 22:53
I think they need to be public, because the properties are public.

Also, I cannot load an image. DGDK says the image file exists, but after loading it into an image number, the image number is still not initialized. Anyone else have this problem?
RPDan
17
Years of Service
User Offline
Joined: 29th Apr 2007
Location:
Posted: 25th Sep 2007 23:58
Don't worry - it does work (though not for the file I wanted). Will check out in more detail.
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 26th Sep 2007 00:16
oh wait, you meant the Property Get/Set methods? Sorry, I thought you meant any methods (functions & subs) in the class.

Quote: "Does anyone knoew if it is possible to use properties without having to declare the methods as part of the class? "

now I am confused by the question.

My DBP plugins page is now hosted [href]here[/href]
PostalCOW
17
Years of Service
User Offline
Joined: 7th Sep 2007
Location: San Diego
Posted: 28th Sep 2007 05:49
I think he means to be able to access and modify a property without having the use get and set methods. You should be able to do that if you declare them as public.

Requirements for life: Food-Water-Video Games!
kBessa
17
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 28th Sep 2007 08:10
Hey RPDan, I'll have to ask you for some cash for asking people to use my docs instead of creating your own... LOL, just kidding! Great work!

I wish I could help, but I'm neither the C++ guy nor a DGDK(C++) owner.

I just wouldn't use that name
(Actually I did, up to 0.2 was DarkEngine and then became LightEngine with 0.3, and will stay with that).

Best regards and... don't ever give up
Thiago
RPDan
17
Years of Service
User Offline
Joined: 29th Apr 2007
Location:
Posted: 29th Sep 2007 22:11
Fair enough I was thinking of calling it DarkAPI before. Maybe that wouldn't be a bad idea.

Redoing a few of the commands at the moment, partly to make them a bit more familiar to STD:: users. For example, rather than Bitmpap.Circle(2,2,2);, Bitmap << DarkCircle(2,2,2); Anyone disagree with this being a good use of operator overloading?

At the moment everything's all over the place. Decided to make only two library files for the whole thing (very bad idea), and I skipped making a few abstract classes that would've been a good idea, but at least it works.

Also, I have the managed XNA framework, so I'll be taking a look at that.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 1st Oct 2007 17:44
Quote: "
Redoing a few of the commands at the moment, partly to make them a bit more familiar to STD:: users. For example, rather than Bitmpap.Circle(2,2,2);, Bitmap << DarkCircle(2,2,2); Anyone disagree with this being a good use of operator overloading?
"


Standards, (I know you mean STD library...but its a standard/common way to get things done) as a rule, are good - because it lowers learning curve. Alternatively, I read an article how operator overloading - by definition - changing what operators are normally expected to do - makes reading the code only possible after a the "Scan for all operator overloading in the source code so you know what is really going on" prerequisite is complete. This seems trivial to many - "Big deal! Just learn how to code!" and they are right - providing the person who wrote the library did so in a very logical manner - meaning - the operator overloading works as one might expect. Sometimes though - debugging can be a bit nightmare'ish if you are running into overload stuff and you don't really know what's going on in the classes youi're invoking etc.

So - as usual - two schools of thought - I guess you have to make a judgement call. I just wanted to point out there is an argument for both ways of doing it (concerning To Use or Not Use operator Overloading).

I think the hardcore C++ guys would be fine with the operator overloading - providing your operators worked in a logical way - however I would consider possibly having "More than one way to Skin the cat".

For instance - I broke the operator overload law terribly with my own string class - by making a function called Equal purposely over making an overloaded operator. Why?

This makes sense to me - and keeps the "==" available the way it was designed - allowing me to test pointers if I want AND have a way to test for Equal.


I bet there is a lot wrong with this - if picked apart - however - I do program for a living and there is always something better that could have been done - perhaps with more time available - or perhaps ... it was just a judgement call

I personally listen very carefully to IanM's suggestions on programming. I don't follow every "method" he talks about - but I think hard about them - so I have a bigger tool box of "ideas" and "ways" to do this stuff. frankly he is pretty darn good at this - I'd like to go to the convention to "rap" with some other gurus and see what thier thoughts are - bummer its in the UK

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 4th Oct 2007 15:47
Here's my 2c - only use operator overloading where it makes sense and isn't surprising for your users. If what you add *is* surprising to your users then you've made a mistake. Also, don't add it for the sake of it - only where it genuinely helps.

Following this rule, arithmetic operators do make sense for vectors, matrix's etc as they are well defined operations for those types. However, I wouldn't use another operator on a pair of vectors to get a dot-product (eg, using & or ^ etc) because it's not apparent what is going on. Instead, I'd use a free function named 'dot' that accepted two vectors as arguments.

This is my opinion, so feel free to disagree if you want, but the shift operators don't really make sense for drawing - They are only a marginal fit for the 'output something' that was added for streams.

Further, you are writing a class simply so that it can be constructed to store a position & radius to pass into your bitmap class so that the circle can be drawn, and then destroyed. None of this should cause a slow-down if you keep the circle class simple enough (the optimiser will remove all of that overhead).

Basically, lots more code for you to make a mistake with, and (IMO) harder to read for the users of your library. Why not simply keep that member function named circle in place instead?

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
RPDan
17
Years of Service
User Offline
Joined: 29th Apr 2007
Location:
Posted: 4th Oct 2007 23:50
Thanks for the comments, guys. Not quite sure what to do, but I'll stick with this for the first release.

Also, I'd like to thank kBessa for using Sandcastle, otherwise I wouldn't have looked for it. It has taken a good 2 days to work it, but so far it looks to be worth the effort. The only problem I can see is that I'll have to create prototype classes in C#, but I feel this would be a good way to design the API before implementing it in DarkGDK.
RPDan
17
Years of Service
User Offline
Joined: 29th Apr 2007
Location:
Posted: 4th Oct 2007 23:56
Also, I'm thinking about making this using managed c++. Good idea?
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 5th Oct 2007 00:55 Edited at: 5th Oct 2007 00:56
@RPDan - I just read today on some programming Forums how there is C++, C# and Managed C++ - The worst!

The discussion was about C#/.Net Garbage collection - Versus C++ having to do it yourself - Pros and Cons of each - and when someone wrote "How about get the best of both worlds with Managed C++?" there were multiple responses that kinda shot it down. I Personally Don't know - All I'm doing is relaying what I saw - and recommend that you at least do some testing before you dive in

The point for C#'s garbage collection was that it can free you to work on the "Business logic" - in our case we are in the "Business of games" The argument for the C++ was with implicit declaration and destruction of classes - you can do some tricky things that are very usuful - and sometimes its beneficial to have that lower level control.

One guy argued that "You can code C++ and waste time - or Code C# and get things done" which was followed by various responses that basically made him look like an idiot for such an ignorant statement.

The moral of that that thread was both languages have thier strong points - and it really depends on what you're trying to do etc etc... but for me - after reading that - I might consider staying away from the managed bit.... I mean I'm pretty such you can make C++ "dll's" or "Com's" and then access them from .Net and probably vice versa if done correctly.

just my 2cents and some change Good luck!

RPDan
17
Years of Service
User Offline
Joined: 29th Apr 2007
Location:
Posted: 5th Oct 2007 18:40
If I'm correct, to have make a class using garbage collection you use the __gc keyword, so I think it's optional, but not sure.

The main reason is because of .net things like properties and the sytems dll, which is put to good use in LightEngine. I think I'll do some testing.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 5th Oct 2007 23:14
I Read Some stuff suggesting you can make a ~MyClass(){function goes here}; within your class - this gets called when garbage collector gets around to it - and there is a way to make a Dispose override (An explicit destructor) but you have to call GC.SuppressFinalize or something like that so that when the garbage collector comes around - it doesn't "Re Kill" your class kinda.

RPDan
17
Years of Service
User Offline
Joined: 29th Apr 2007
Location:
Posted: 6th Oct 2007 10:59
OK. DarkAPI is now managed, which means that I can use static properties etc. It also means any documentation I make for it will be very accurate (although I think I still need to create it in C#). I had originally been trying to create a DLL containing the library, but sadly I do not think it is possible any more. I didn't seem to like me returning values from GDK functions, and I can see nothing wrong with just having to include a header file.
RPDan
17
Years of Service
User Offline
Joined: 29th Apr 2007
Location:
Posted: 8th Oct 2007 18:40
I usually make destructors for my classes, especially these DGDK ones, because they need to have their assoicuated music, object etc. number freed when they are destroyed.
RPDan
17
Years of Service
User Offline
Joined: 29th Apr 2007
Location:
Posted: 8th Oct 2007 22:53
Now I'm using managed c++, not entirely sure what route to take. I could try making something like LightEngine, XNA or make my own design from scratch (which I fear would use too much operator<<. Any ideas?

@kBessa - did you get my e-mail?
kBessa
17
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 8th Oct 2007 23:09
Hi Dan,

Yeah, I got it but did not have the time to answer it this weekend as I was occupied all these days with my band in a contest (and we won it, I'm off to go to the radio station for an interview now).

I'll get back to you as soon as possible!

Thiago
RPDan
17
Years of Service
User Offline
Joined: 29th Apr 2007
Location:
Posted: 9th Oct 2007 22:49
Sounds fun Thiago. Glad you got the e-mail. I'm not always great at getting addresses right

I really have finally given up in doing a DLL, so this will definitely become a folder of object files and headers. Never mind. Shouldn't be too much more hassle. Would really like a 0.1 release by Christmas, but might be pushing it slightly. Better start programming...

Login to post a reply

Server time is: 2024-09-29 03:21:03
Your offset time is: 2024-09-29 03:21:03