Skip to main content
GameDev.net gamedev.net
🔒 Locked

Debugging Windowed DirectX Application

Started by miner2049er Aug 8, 2006 at 11:21 AM 5 replies 1k views
Original Post
miner2049er
miner2049er
This must have been answered before, but my combination of search terms aren't turning anything up... I'm using Visual Studio 2005 on Windows XP SP2. I am developing on a single desktop PC with just one monitor. Currently when I have a windowed 320x240 DirectX app, when debugging I CANNOT see what is being rendered to the game window. When I set a breakpoint in my code, I can only see the game window minimized on the task bar. (FYI, my mainloop is in WinMain, and after all the initializations, I render my graphics, do the the PeekMessage stuff then loop again.) Ideally, during debugging, what I would like to happen is to see the small 320x240 game window on top at ALL times, and say upon setting a breakpoint after my frame rendering function call, every tap of F10 would do another step, and show the next frame of graphics in my games window. But I cannot see this at the moment. The game window is always out of focus and minimized to the task bar. Please let me know if I need to clarify or explain my problem better. Any tips would be appreciated, Miner2049er.
Evil Steve
Evil Steve
When you're debugging the program, it's essentially frozen, so won't be updating the window. The easiest solution is to move the MSVC window so it doesn't cover up the application window.

You might be able to call SetWindowPos() to set the window to always on top, but that means it'll obscure part of your MSVC window.

Aside from that, there's always remote debuggin (from another PC), or setting up with multiple monitors.
miner2049er
miner2049er
Thanks for the reply Evil Steve.

SetWindowPos() - had forgotten about that - thanks for reminding. And yes, it did bring the game window to the front (the game window had been obscured by the IDE all the time.)

Then setting a breakpoint after the frame rendering allowed me to step through each frame by tapping F5, plus all the other debugging facilities were available to me like step into, out of etc.

I have a dual monitor setup - actually using MaxiVista - which creates what is in effect a second monitor to my desktop PC but sends the video data over the network to my laptop. The second monitor actually appears in Display Properties.

So I dragged the game window onto my "second monitor" (the laptop display) and now have all of my main monitor area for the Visual Studio IDE.

My next question is to anyone out there who can assist - how do I set up the game window so that it appears at the start positioned on the OTHER second monitor? If someone can give me the search engine terms to use and/or the names of the necessary functions I need to call during window initialization, I think I can take it from there!

Cheers, Miner2049er.
Etherstar
Etherstar
While using Visual C# Express if I move my mouse cursor to the second monitor while maintaining focus of the VC# IDE (don't click on anything), and then press the debug button (F5) the window will be created on the monitor with the mouse cursor present.
miner2049er
miner2049er
Thanks Etherstar. I tried that tip but the window appeared on the same monitor as my IDE, even with the mouse cursor on the other monitor. Maybe it is an IDE setting?

What I'm after is something that programmatically starts my game window on the second monitor. I'm still searching the DirectX docs, but if anybody can help speed up that process it would be much appreciated!

Cheers, Miner2049er.
Xrystal
Xrystal
Take a gander at the following function:

IDirect3D9::GetAdapterIdentifier
Describes the physical display adapters present in the system when the IDirect3D9 interface was instantiated.

IDirect3D9::GetAdapterCount
Returns the number of adapters on the system.

IDirect3D9::GetAdapterMonitor
Returns the handle of the monitor associated with the Direct3D object.


From the description it looks like you use this after the DirectX Interface has been instanced. Best to look through the Adapter routines.
Evil Steve
Evil Steve
As far as I know, the window will open on whatever monitor is the default (primary) monitor. You can specify the window position when you create it, and just offset the window so it's on the secondary monitor.

I had code to do this before (But not using D3D), but I can't seem to find it. My code enumerated the monitors to get a handle to the secondary monitor (if it existed), then got the RECT describing it, and moved the window to the center of the rect.
That might be a bit overkill for what you need, but try just changing the X coordinate you pass to CreateWindow() to try and shift it onto the other monitor. E.g. if your display is 1280x1024 on both monitors, try setting the window X pos to 1280 or something.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.