View Full Version: dx full screen

C++ Learning Community > Direct X > dx full screen


Title: dx full screen
Description: debugging


mikeg - February 18, 2004 02:35 AM (GMT)
What is the best technique to debug a program when in full screen mode? we are using ms vs c++ 6.0. two monitors is one idea, output to strerr, any others?

the two monitor idea would be nice because then a person could run the view the program running in one monitor and then step through the code in the other. haven't tried this one yet but am tempted to buy another monitor and video card.

thanks, mike

Programmer16 - February 19, 2004 06:59 PM (GMT)
Test for errors, and then write something to a file if it fails/works. If you know how to use printf(), you can use this function:
#include <fstream.h>
#include <stdio.h>
#include <stdlib.h>
void WriteError(char* pErrorMsg, ...)
{
char Text[1024];
va_list valist;


va_start(valist,pErrorMsg);
vsprintf(Text,pErrorMsg,valist);

va_end(valist);

ofstream fout("ErrorLog.txt", ios::app);
fout<<Text<<endl;
fout<<endl;
fout.close();
}

Then just call it like you would printf().

Refresher:
WriteError("Failed to create graphics.\n\tWidth: %i\n\tHeight: %i", iWidth, iHeight);
The only % identifiers I know are:
%i - integer
%s - string
%f - float

inuyaga - March 2, 2004 03:10 AM (GMT)
I assume you are using a win32app. you can write win32apps in a consol mode. That is assuming the only thing you needd is a process inst in which case you can call GetModuleHandle(NULL); to get HINSTANCE pram of the WinMain instance.

//Example
CODE


#include <windows.h>
#include <stdio.h>

#define PROCESS_INST GetModuleHandle(NULL)
int main(int argc, cahr* argv[])
{
      HINSTANCE h_inst = PROCESS_INST;
     
      printf("Registering window class\n");
      WNDCLASSEX wc;
      wc.hInstance = h_inst;
      //WNDCLASSEX stuff here
      printf("Creating Window\n");
      HWND h_wnd = CreateWindowEx(bla,bla,bla);
      return 0;
}


There are probs with this code but it givs the basic idea. If all goes well you should end up with a consol and a window. There is some complications but you will figure it out. I have faith

P.S. just for refrence thoes %i %u %li are formatt specifiers. used by vprinf i think but there used for varg funcs ... things at end.

Programmer16 - March 2, 2004 11:19 PM (GMT)
QUOTE (inuyaga @ Mar 2 2004, 03:10 AM)
P.S. just for refrence thoes %i %u %li are formatt specifiers. used by vprinf i think but there used for varg funcs ... things at end.

My code needs to be modified:
CODE

#include <fstream> // Had to change this
#include <stdio.h>
#include <stdlib.h>

using namespace std; // and add this

void WriteError(char* pErrorMsg, ...)
{
char Text[1024];

va_list valist;
va_start(valist,pErrorMsg);
vsprintf(Text,pErrorMsg,valist);
va_end(valist);

ofstream fout("ErrorLog.txt", ios::app);
fout<<Text<<endl;
fout.close();
}


@inuyaga: If you're refferring to my code then (if I understand what you're saying), you're wrong. The format specifiers are not used by just vprintf, but all of the printf functions (or any ellipsis function). My function works perfectly for what he wants and is a lot better idea than implementing a console window, for the fact that you would have to make the program wait at the end or he wouldn't be able to see what was print to it.

mikeg - March 5, 2004 08:22 PM (GMT)
I did buy a new video card and monitor. It works just fine. Worth the $200 plus the time to get it setup.

TheHawgMaster - March 5, 2004 08:34 PM (GMT)
QUOTE (mikeg @ Mar 5 2004, 01:22 PM)
I did buy a new video card and monitor. It works just fine. Worth the $200 plus the time to get it setup.

Ugh, all you need for a debugging monitor is like a cheap PCI video card and a monochome monitor. You don't need to spend that much.

mikeg - March 5, 2004 08:45 PM (GMT)
Thanks for the response. I know I am not being very clear as to what I want. I am not new to programming but am new to windows/dx programming.

Are you saying that I can run the full screen mode app in a console or what? That would be nice but I think I am misunderstanding something here. Or if I could modify the full screen to windowed, that would be nice to for debugging purposes but not sure that is feasible.

The learning curve is steep at this point.

Thanks,

Mike





* Hosted for free by InvisionFree