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 / cout problem

Author
Message
Pyro_guy
20
Years of Service
User Offline
Joined: 10th Oct 2003
Location: England
Posted: 2nd May 2010 19:41
Hello.
Whenever I attempt to print some debug info via cout, I get a whole load of linker errors:



Can anyone explain why this is? Is there a different way I should be using to output text?

I was attempting to output the scancode of the currently pressed key.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 2nd May 2010 20:09
cout can't be used with dgdk ( or directx generally ), if mi not mistaken, it's only for dos applications, you can use dbText to show text on screen:

dbText ( x, y, str );

also, note that if you want to show some variables in the string, use sprintf

Pyro_guy
20
Years of Service
User Offline
Joined: 10th Oct 2003
Location: England
Posted: 2nd May 2010 20:33
Ah I see. My experience is mostly with OpenGL.
Out of curiosity, why exactly can't I use cout with DirectX?

Here is how I am outputting text for anyone who finds this thread with a similar problem:
Ultimate_H
15
Years of Service
User Offline
Joined: 11th Mar 2009
Location: A place that is neither here nor there
Posted: 2nd May 2010 20:39
the cout and cin classes are used in DOS applications(at the very least) for text display and retrieval, because GDK is a Win32 application (which uses directX), these won't work.

if you want to display debug text, you can use the GDK text commands (under Text in the documentation) or you can use the DirectX font method, which is faster/looks nicer, but is more complicated. here is a nice tut I used to learn about directx text.

hope that makes sense
-H

JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 2nd May 2010 20:48
Well, you can if you really want to...

All you have to do is create a new output-stream that emits the characters to the back-buffer [bitmap(0)] and assign it to the std::cout value. An aweful lot of work to send text to the screen if you ask me, but it IS possible... LOL

Personally, I would just stick with the dbText() approach.

JTK
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 2nd May 2010 20:50 Edited at: 2nd May 2010 20:50
also, if you are drawing alot of text, with different colors and styles, GDK's dbText won't be the best choice, you can study some directX for better results, or use my little text plugin: http://forum.thegamecreators.com/?m=forum_view&t=167715&b=22

Login to post a reply

Server time is: 2024-07-07 01:21:04
Your offset time is: 2024-07-07 01:21:04