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

Recommended Posts

Hello, I'd like to add a console to my 'engine'. I have no idea on how I can do with DirectX 9.0. I think to use an IDirect3DSurface9 surface. Apparently, fonts are only rendering to the backbuffer. Is it possible to render to a surface? Do I have to use bitmapped fonts? I'm also wondering how I can blit the surface on the backbuffer with alpha blending... (I use StrechRect()). All ideas are welcome... Thanks in advance!

Share on other sites
I think you're reinventing the wheel... I would use a 3rd party API for the GUI or at the very least a windows control from VisualStudio.

Share on other sites
Hi gael!
I saw an article on making a Quake stile console in the GameDev Articles section. I think it was for DirectX but it might be a little outdated though.
As for ideea itself my opinion is that a console like that is not worth the effort. It takes a significant time to build and it eats resources at run time.
For debugging usualy a simple log file is sufficient. Also if you want to change game parameters at run time you can find another 100 ways to do it.

Share on other sites
Nearly every game has a console, makes life so much easier. Shouldn't take more then 2-8 hours to implement either. Not sure how it "eats resources at runtime" but I never noticed a difference in my frame rates. I used my in game console for changing params, while I used a dos box to output data on specific objects (have it on another screen).

http://geekswithblogs.net/jolson/articles/2659.aspx

Hope it helps.

Share on other sites
To make a console you will have to look at what a console is. A general console is a simple quad that gets pulled down over your existing application. This means that you will need a quad (Simple interface for debugging and giving your engine instructions), a way to give your console an interactive environment (be able to send and receive messages from your engine).

With that said you can use a couple of methods and the most general way is to implement a scripting engine/language such as LUA or Python and many more. You will then use your scripting language as the middleware that will work between your engine and the user.

The interface screen is really a trivial exercise and all you need to do is poll your engine for a specific key such as the tilde(~) and then bring down a transparent/textured quad that will allow the user to enter commands. You can place your engine in a paused state or a state of your liking. Furthermore you will then have to create a way for your engine to poll your keyboard for keys pressed and when the keys are pressed print them to the console window, when you then press enter you will do some comparisons to check for existing methods that you might want to call.

This is just a basic outline and an article or 2 might have been written explaining this in great detail.
Take a look a these following articles
Lua as a scripting engine
Introduction to Lua

I hope this helps.
Take care.

Share on other sites
I have a fully-functional console in my current project, and I love it. I use it both for logging info, and for executing Lua commands at runtime. The console itself was very easy...just render a shaded quad, with text on top of it. I have macros that write to the console (such as LOG_INFO(), LOG_FAILURE(), and LOG_SUCCESS()), so it's very easy to use (note that these macros also output to a file).

However, adding the Lua scripting part is not trivial at all. A robust implementation takes a lot of work and consideration. Its also a thing that you continually build up, as you add more and more classes. Note that Luabind has some really annoying and ill-timed bugs, but generally, it works OK. Note that the Console is not the Scripting system - rather it is just a runtime input to it. The main input for scripting is from text file scripts loaded from the disk.

Share on other sites

How have you written the console?

Share on other sites
Quote:
 Original post by gaelHow have you written the console?

What part of it? The display was cake, just render a shaded quad (for some background color) and then draw the applicable text over it.

Share on other sites
How have you done to write characters to the surface (texture)?

Share on other sites
Quote:
 How have you done to write characters to the surface (texture)?

You could simply use the ID3DXFont interface in native DirectX or the Font in Managed DirectX to render the text.

I hope this helps.
Take care.

Share on other sites
I dont't see how to render text to my console surface with ID3DXFont...

Share on other sites
Quote:
 Original post by gaelI dont't see how to render text to my console surface with ID3DXFont...

Just set your console surface as the render target, then draw with font like normal. ie:

device->SetRenderTarget( mySurface );font->DrawText(...);

Share on other sites
In addition to the previous post:
It's not 100% necessary to reder the text to your console texture, you can reder the text directly on screen. You will display the text when the console is down and remove the text when the console is up.
If you want your text to have an up and down motion you could use the the fourth parameter from the DrawText call ( ID3DXFont -> DrawText)