Output to Dynamic Console
Someone suggested this in an earlier posting as the best method for creating Debugging logs. Being an adventurous soul I thought I''d have a go and I came up with the following fuction:
void U_Console()
{
HANDLE hConsoleStdout;
DWORD count ;
AllocConsole();
hConsoleStdout = GetStdHandle(STD_OUTPUT_HANDLE);
WriteConsole(hConsoleStdout, "Test", 4, &count, NULL );
}
I call this function within my main game loop as follows:
//Read the keyboard buffer.
hRet = G.lpDIKeyboard->GetDeviceData(sizeof(DIDEVICEOBJECTDATA),
dodKey, &dwItems, 0);
if (SUCCEEDED(hRet))
{
if (hRet == DI_BUFFEROVERFLOW)
//Buffer Overflow
else
//Read the input characters into an array.
for(int iCount = 0; iCount < (INT)dwItems; iCount++)
{
if (dodKey[iCount].dwOfs == DIK_A)
{
U_Console();
pszText[iNextChar] = ''A'';
iNextChar++;
}
}
}
When I close the window I am returne to my DirectX screen but I can no longer type any more characters. Is there some sort of clash going on between the DDSCL_FULLSCREEN flag and my console window? If so, is there a way I can get round this so that I can log what is going on when using DirectDraw over the full screen?
The call to AllocConsole() will give the console focus, thus taking it away from your app.
Allocate the console before you initialize DirectX, and all will be well. Of couse, you won''t be able see the console while you''ve got a fullscreen app running... The best way is to write your debugging stuff to a file, which you can then examine after your program has run. Once you''ve got things working well enough, you can then write your debugging stuff onto a direct draw surface, and display it in-game.
codeka.com - Just click it.
Allocate the console before you initialize DirectX, and all will be well. Of couse, you won''t be able see the console while you''ve got a fullscreen app running... The best way is to write your debugging stuff to a file, which you can then examine after your program has run. Once you''ve got things working well enough, you can then write your debugging stuff onto a direct draw surface, and display it in-game.
codeka.com - Just click it.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement