how to create a console window using directX

Started by
8 comments, last by Flimflam 16 years ago
I'm using DirectX 9.0c SDK and Visual Studio 2005 for my next 3D game. I'm want to create a console window on the screen but I'm not sure how? Do you have any suggestions of what to do? I can figure out the rest but I just need a way to help me get started.
Advertisement
The console in my game is just a textured quad with trasparency (to make it look nice). With D3DXMatrixTranslation I make the quad go up and down.

For the text I use Direct3D DrawText function ... I think this is the standard way to create a simple console.
Quote:Original post by arc4nis
The console in my game is just a textured quad with trasparency (to make it look nice). With D3DXMatrixTranslation I make the quad go up and down.


sorry for hijack, but if u translate it to go up, does that mean that you still have to draw it every frame?
There are two methods:

1. Draw the background quad(s) and text each frame and offset their position on the fly as you minimise the console to the top of the screen.

2. Render the console to texture (and only when something on it changes) and then render that texture to a quad and slide that one quad upwards.
As Dave said, the easy way is to draw it every frame which is performance unwise, the way to go is to render it to a texture only if something changes.
If you don't need to be able to see the console in DX you can set the subsystem to console. This will give you the console window used in console apps and you can use std::cin and std::cout to communicate with it. Of coarse to stop cin calls pausing your game you will need to use multi-threading but this is much simpler than the other solutions posted.


In VC it's project properties->Linker->System and then the first property. However you will need to use main instead of winmain. (To get a HINSTANCE use GetModuleHandle(NULL); )
How would one direct printf output into a char* for the purposes of rendering the text into your direct3D console window?
Quote:Original post by Khaos Dragon
How would one direct printf output into a char* for the purposes of rendering the text into your direct3D console window?


Well, there's really no reason to do that, and it probably wouldn't be the best idea to try. You're much better off rolling your own printf() function tailored to the new console.
Quote:Original post by Flimflam
Quote:Original post by Khaos Dragon
How would one direct printf output into a char* for the purposes of rendering the text into your direct3D console window?


Well, there's really no reason to do that, and it probably wouldn't be the best idea to try. You're much better off rolling your own printf() function tailored to the new console.


sprintf()
Quote:Original post by Dave
Quote:Original post by Flimflam
Quote:Original post by Khaos Dragon
How would one direct printf output into a char* for the purposes of rendering the text into your direct3D console window?


Well, there's really no reason to do that, and it probably wouldn't be the best idea to try. You're much better off rolling your own printf() function tailored to the new console.


sprintf()


Well, yes, but that's not quite what he was asking, although it would have made sense for me to point that out. He wanted (as I read it) to continue using printf and simply redirect STDOUT. I suppose I could have mentioned sprintf though.

This topic is closed to new replies.

Advertisement