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 / I Give up!

Author
Message
Dragon slayer
12
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 21st May 2013 01:18
I may as well continue learning c++ then DX or SFML I can't get any print commands or input commands to work in GDK. I can get the input command to work sometimes.

I would like to use basic cout and cin commands for that stuff but I guess you can't.

character.mName; "Fred";
dbPrint(character.mName);

I can't get this to work I have tried sprintf and sstream stuff I have seen here I can't seem to get print command to work right!

Any help would be great!
Rudolpho
13
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 21st May 2013 01:56
What is "character.mName"?
If that is your actual code you have there it doesn't look right at all, you probably meant to use an equals sign rather than the semicolon after character.mName.

Stringstream works like I described it earlier:


That should print "This should print 4, 9.2, C".


"Why do programmers get Halloween and Christmas mixed up?"
Dragon slayer
12
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 21st May 2013 02:42 Edited at: 21st May 2013 03:00
I'll give it a try character.mName is this, character is an object created from a class mName is a variable called name. That was not all the code.

Header


cpp


main


I can get the same code minus the GDK stuff to work fine in normal C++ but not in GDK

You are right about the semi colon I screwed that one up! but with an = there it won't work anyway! I really think I might give up on GDK and move on in c++. I still use DBP also and I can get by fine with that. I don't think I really need to learn c++ for quite a while I just want to. I like classes better than UDT's!
Dragon slayer
12
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 21st May 2013 02:54
Didn't work for me, here is the errors I get



Here is my code.


I have tried in the loop, out
Dragon slayer
12
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 21st May 2013 03:14
Crazy! if I include DarkGDK in my header files or CPP files I get an ambiguous something or other error which I think means it is being defined or included more than once. If I take it out of my CPP file my dbText will not work because it says it is undefined. Like I said the same code set up the same way minus the GDK commands works fine in normal c++
Rudolpho
13
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 21st May 2013 03:39
Your member declaration is wrong.
You have declared mName as a char, that is a single character (which will be easiest to compare to DBP's BYTE datatype).
C-style strings are arrays of chars. That is also what DarkGDK (1) uses and they are usually defined as char* or through the typedef LPSTRING.
The string class offers much more convenience over the old c-strings (of course they are essentially wrapper classes over char arrays still so, but they present the strings in a more easily accessible way with appropriate operators and mutatability - while you can change the contents of a C-string, it cannot be resized so a native c-string can never grow larger than the char buffer you declared for it in the first place).

Anyway, your code fails with an ambiguity warning because there is no overload of the dbPrint() function that accepts a single char as input. The char, being a numeric datatype at its core, can be implicitly cast to int however and there is a dbPrint(int) overload. But there is also a dbPrint(long) and a char can be implicitly cast to a long as well. Thus it is ambigous - the compiler cannot figure it out by itself. You can solve this by explicitly casting your char variable when passing it to dbPrint().
That would look like this: dbPrint((int)character.mName) and would print the numeric value of 'character.mName'.
However, as you stated, you cannot write 'character.mName = "Fred"'; this is because "Fred" is a shortcut for writing the c-string, or char-array ['F', 'r', 'e', 'd', '\0']. But character.mName is a single char.
If you insist on using c-strings you would solve this by changing its declaration to read

It now is a pointer to one or more characters (ie an array of them). Writing it as you have the constant string "Fred" will be allocated on the stack and thus be freed whenever it goes out of scope. With dynamically allocated c-strings you have to be wary to create and release their used memory yourself or you'll end up with memory leaks though. But you'll get to that later in your adventures I'm sure.


About my example, that is correct, I have mostly been using DarkGDK 2 lately which doesn't have that nuisance.
The thing is that dbPrint() expects a normal char*, while the std::string::c_str() member function returns a const char*.
As such you will have to do a const cast on it like so for it to work:




"Why do programmers get Halloween and Christmas mixed up?"
Dragon slayer
12
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 24th May 2013 01:08 Edited at: 24th May 2013 01:13
I have been out of action for a few days! So how do you find all this out? I don't know much at all about C. I have not seen anything in the limited GDK documentation. I don't know a lot about GDK 2. If it is better than GDK I would like to use it. I thought I saw somewhere that it was around $60.00 I can't swing it right now. Is it free for non-commercial use? If so where can I get it? I looked around that site and did not see anything about it.

I actually tried to register at that site a few days ago and never got the e-mail to confirm. I tried a couple of times.
Rudolpho
13
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 24th May 2013 01:15
GDK2 is starting to look like abandonware; the creator has not been heard from for over 6 months I believe.

It was possible to pre-purchase this library, with a promise for free upgrades to the full version once it was ready. I'm unsure whether you can still purchase the release candidate however; as said the author is nowhere to be found. There was a demo version as well but it has expired since many months.

Whether it is better is hard to say; it is essentially a plugin wrapper for the DBP plugins; as such it is compatible with all dll's that work with DBP and it can be upgraded to match the latest DBP version. GDK 1 received its last update a few years back I believe and as such it has some bugs and lacks some features over DBP. DGDK2, being a wrapper library, adds some calling overhead compared to GDK 1. It is also unfinished and as such suffers from some bugs as well, however I have so far been able to tweak it to work, albeit with fugly solutions at some places.


"Why do programmers get Halloween and Christmas mixed up?"
Dragon slayer
12
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 24th May 2013 01:34
I spelled my e-mail wrong I am in and may DL it and try but I don't think I need the extra problems as I probably am not experienced enough to tweak it to work right. So where can I learn more about the c-style stuff GDK needs to work. I know where to go learn the c commands but where do I find out what works and what I need to use in GDK?

I don't get why they would make a product that you can't print out a string and why they did not document it well to use the c commands. I am really interested in learning c++ and am learning good. The only reason I want to use GDK is the graphics commands which c++ does not have in the core language which means you have to learn direct x or something else. I have looked at SFML and I think GDK is easier because I know the commands from DBP. SFML is classes and the documentation is all over the place and not very good either.

I am only working on a text program but I would like to use different colored text which I figured out how to do in c++. I would also like to use lines on my screens around text and such to break things up. Kind of old school mid 80's type rpg games.

Login to post a reply

Server time is: 2019-09-21 11:50:47
Your offset time is: 2019-09-21 11:50:47