Archived

This topic is now archived and is closed to further replies.

Question about wrighting text to screen

This topic is 5006 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it easier to use directx to write text to your game screen or is it easier to use windows GDI to wright to my game? compiler dev-cpp I am using c++ as the languge There is no harm in asking so the old saying goes [edited by - kingpinzs on February 19, 2004 6:04:02 PM]

Share this post


Link to post
Share on other sites
Dude I can make a console programe just fine. I was asking in my windows window what is easery to display font.
I got GDI to work but I was using TextOut so it would dispaly the text on the screen in the same place no matter were my window was. So I needed to do it differntly.

It does not matter to me if dev-cpp is an integrated development environment or a compiler "
A program that translates source code into object code"
I am using Dev-cpp in its default sate so the real compiler is
gcc.exe and g++.exe. That is completely irrelevant to my question I was just trying to let you know what language and environment I was using to make my programs


Got any ideas

[edited by - kingpinzs on February 19, 2004 6:14:48 PM]

Share this post


Link to post
Share on other sites
This is off topic... but in a DOS type app what is the code for clear screen in C++

And how do i Square root? and say and

like

if(c 'and' b == 0)
std::cout<<"Not enough information"<<std::endl;



[edited by - TheNerdTk421 on February 20, 2004 11:23:04 AM]

Share this post


Link to post
Share on other sites
TheNerd :

For clearing the screen, use system( "cls" ). (I don't remember in what header the system function is defined, but I'm sure 2 minutes of Google and you'll know).

For taking a square root, use "sqrt". Again, I can't remember where it is.

The logical 'and' operator is '&&'. The bitwise one is '&'. Once again, google for them if you want to know operator precedence or search the forums if you want to know the difference between logical and bitwise.

EDIT: in the above case, you should be using if((b==0)&&(c==0))

Kingpinzs :

The easiest way is to use GDI.
The hardest, but more powerful way, is DirectX.

And you have things like SDL or OpenGL around which can help you out as well.

Victor Nicollet, INT13 game programmer



[edited by - ToohrVyk on February 20, 2004 11:31:33 AM]

Share this post


Link to post
Share on other sites
you need cstdlib for system("cls") and cmath for sqrt(), oh and he dont need to write if ((a == b) && (a == c)), its enough with if (a == b && a == c)

[edited by - Eriond on February 20, 2004 12:36:15 PM]

Share this post


Link to post
Share on other sites
OK, first to DerAnged and Rocket05. LOVE your work guys. Seriously. Oh no wait - I was getting confused. You''re f--kwits.

kingpinzs: In general falling back to GDI to overlay text on a DirectX game is a fairly bad idea; I''m an OpenGL guy myself but I understand that you''ll get a major performance hit if you do that - plus you won''t be able to take advantage of DirectX niceties like antialiased text. Not an expert as I said, please correct me if I''m wrong.

TheNerd: When you call System("cls"); as recommended by ToohrVyk you''re (under Win 2000 and XP) creating a whole new shell instance, allocating 640Kb to it, and then calling a system function that gets trapped by the emulation layer anyway (I *think*).

If you''re asking because you''re doing a console-mode game, I''d seriously recommend implementing a rendering layer using the console functions described here.

It''ll actually help you in the long run too, because you''re essentially getting a good taste of using an output API - which gives you a great context for understanding what level of abstraction you''re at when you get onto DirectX/OpenGL/whatever.

A really great implementation would be if you wrapped the console functions in a wrapper class of your own, which you then call with member functions such as renderer.OutputText (line, column, "Some text"). You could then expand the class to draw little windows for you and all sorts of stuff - AND you''d be getting really used to using an API to handle your output.

I use the console functions in my ASCII renderer class, which provides a similar implementation to that described above but doesn''t handle text output - although do feel free to extend it


www.coldcity.com
code, pics, life

Share this post


Link to post
Share on other sites
quote:
Original post by IainC
kingpinzs: In general falling back to GDI to overlay text on a DirectX game is a fairly bad idea; I''m an OpenGL guy myself but I understand that you''ll get a major performance hit if you do that - plus you won''t be able to take advantage of DirectX niceties like antialiased text. Not an expert as I said, please correct me if I''m wrong.
He did not mention making any DirectX game. I think he just started with Win32 API. That''s why I said GDI is easier, because it''s part of Win32 API.

Share this post


Link to post
Share on other sites
quote:
Original post by Rocket05
wow, you people can''t take a joke, can you?
It wasn''t funny. I had half a mind to NB you.

@kingpinzs and TheNerdTk421:
IainC gave you excellent answers.

@kingpinzs:
If you''re building a plain Win32 application, use GDI - if you''re using C++. Win32 GUIs are much more easily built in other languages/technologies, though: Visual Basic, C# and .NET, Delphi, etc.

If you''re building a DirectX application, stay away from GDI.

Share this post


Link to post
Share on other sites