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 / Passing String for Splash Screen

Author
Message
ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 11th Nov 2008 20:52
I'm trying to create an all purpose splash screen that I can use it for any DGDK program.

I need to pass in text that will be my title text, but I'm trying to use string but its not working too well.

Can anyone help?
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 11th Nov 2008 22:13
What's your code so far?

ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 12th Nov 2008 06:20
Well here's my problem:
Quote: "
1>------ Build started: Project: Welcome Screen, Configuration: Debug Win32 ------
1>Compiling...
1>Main.cpp
1>c:\users\rei\documents\visual studio 2008\projects\welcome screen\welcome screen\start.h(96) : error C2665: 'dbStr' : none of the 2 overloads could convert all the argument types
1> c:\program files (x86)\the game creators\dark gdk\include\darksdktext.h(37): could be 'char *dbStr(float)'
1> c:\program files (x86)\the game creators\dark gdk\include\darksdktext.h(38): or 'char *dbStr(int)'
1> while trying to match the argument list '(std::string)'
1>c:\users\rei\documents\visual studio 2008\projects\welcome screen\welcome screen\start.h(101) : error C2664: 'dbText' : cannot convert parameter 3 from 'std::string' to 'char *'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>Build log was saved at "file://c:\Users\Rei\Documents\Visual Studio 2008\Projects\Welcome Screen\Welcome Screen\Debug\BuildLog.htm"
1>Welcome Screen - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped =========="


Swordsman
16
Years of Service
User Offline
Joined: 12th Nov 2008
Location: Wigan, England
Posted: 12th Nov 2008 19:38
if the usage is like this:

SplashScreen("hi");

pass it as a char* instead of a string. Also, what is the purpose of dbStr()? I was under the impression that that returned a string representation of a passed number.

Your problem stems from the fact that the only real way to convert strings to char* is by calling the function c_str() on the string which converts it to a const char*. You then need to remove the constness, usually by creating another string and copying the const-ed string into it. It's a bit overkillish though. Here you go, works for me:

ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 13th Nov 2008 21:19
Didnt work.

Quote: "1>------ Build started: Project: Welcome Screen, Configuration: Debug Win32 ------
1>Compiling...
1>Main.cpp
1>c:\users\rei\documents\visual studio 2008\projects\welcome screen\welcome screen\start.h(23) : error C2664: 'SplashScreen' : cannot convert parameter 1 from 'std::string' to 'char *'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>Build log was saved at "file://c:\Users\Rei\Documents\Visual Studio 2008\Projects\Welcome Screen\Welcome Screen\Debug\BuildLog.htm"
1>Welcome Screen - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped =========="


Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 13th Nov 2008 22:41 Edited at: 13th Nov 2008 22:41
You're not the best problem-solver.

ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 13th Nov 2008 23:48
Its giving me this error:

Quote: "1>------ Build started: Project: Welcome Screen, Configuration: Debug Win32 ------
1>Compiling...
1>Main.cpp
1>Linking...
1>libcpmtd.lib(xdebug.obj) : warning LNK4098: defaultlib 'libcmt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>libcpmtd.lib(xdebug.obj) : error LNK2019: unresolved external symbol __malloc_dbg referenced in function "void * __cdecl operator new(unsigned int,struct std::_DebugHeapTag_t const &,char *,int)" (??2@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z)
1>libcpmtd.lib(xdebug.obj) : error LNK2019: unresolved external symbol __free_dbg referenced in function "void __cdecl operator delete(void *,struct std::_DebugHeapTag_t const &,char *,int)" (??3@YAXPAXABU_DebugHeapTag_t@std@@PADH@Z)
1>libcpmtd.lib(stdthrow.obj) : error LNK2019: unresolved external symbol __CrtDbgReportW referenced in function "void __cdecl std::_Debug_message(wchar_t const *,wchar_t const *,unsigned int)" (?_Debug_message@std@@YAXPB_W0I@Z)
1>Debug\Welcome Screen.exe : fatal error LNK1120: 3 unresolved externals
1>Build log was saved at "file://c:\Users\Rei\Documents\Visual Studio 2008\Projects\Welcome Screen\Welcome Screen\Debug\BuildLog.htm"
1>Welcome Screen - 4 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped =========="
Swordsman
16
Years of Service
User Offline
Joined: 12th Nov 2008
Location: Wigan, England
Posted: 14th Nov 2008 01:15
Quote: "Didnt work."


I imageine that you aren't using it in the usage I said :

SplashScreen("hi");

more like likely you are doing:

string myString = "hi";

SplashScreen(myString);

You cannot pass a string in to a char*. I'm not going to treate you like an idiot, but presume that your C++ isn't s strong as it could be. You should look http://www.cppreference.com/wiki/string/start for more info on strings.


@Zuka: NOOOOO!!!
You should never C-Style cast like that to remove const, it is unsafe. Also, your buffer is massive and you used new without delete, naughty man . The better option would be:



but as I said, it's a bit overkillish
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 14th Nov 2008 02:04
It tells you what's wrong, fix it.
Swordsman
16
Years of Service
User Offline
Joined: 12th Nov 2008
Location: Wigan, England
Posted: 14th Nov 2008 03:12
Quote: "It tells you what's wrong, fix it"


Be fair, maybe his is new to C++ and linker errors are especially confusing when you are new and use to IDEs doing it for you.

@ReiKumar: Your linker cannot find the malloc and free functions contained within the STL. You need to include the MicroSoft Visual C RunTime LIBrary Debug version (msvcrtd.lib in to your project.

Unfortunately, DarkGDK has already told the compiler to ignore these libraries for some reason so they are considered to be out of bounds for the GDK.

@Zuka : I'm now confused then, how can you use new, delete, malloc, free, etc without using this library? Does DarkGDK provide an alternative?
ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 14th Nov 2008 03:19 Edited at: 14th Nov 2008 07:46
Quote: "It tells you what's wrong, fix it. "


Now if I knew that then I wouldn't be here now would I?

This is a LNK2019 error. The worst and most poorly describing error.
Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 14th Nov 2008 11:09
Quote: "t tells you what's wrong, fix it. "


Zuka - Relax m8.... There are space for everybody here

Niels Henriksen
www.tales-of-the-realms.com
if Microsoft can sell software with bugs, so can I.

Login to post a reply

Server time is: 2024-11-25 07:21:01
Your offset time is: 2024-11-25 07:21:01