• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Erik Rufelt

DirectX 9 multimonitor devices

5 posts in this topic

Hey, I'm trying to create two fullscreen devices, on two different monitors, with Direct3D 9. It works fine with windowed devices, I create the devices with different adapters and they draw fine on different monitors. Fullscreen works fine when I just use one device, but when creating two fullscreen devices I get D3DERR_DEVICELOST from the second CreateDevice. For testing I'm creating two windows, one on each screen, both covering the whole of their screens, with the WS_EX_TOPMOST style and no borders or anything. There's no visible difference between fullscreen and windowed mode now, so perhaps it doesn't matter if I tell D3D it's fullscreen or not, but I would like it to work. The only difference between "windowed" and "fullscreen" is that the 'Windowed' parameter of the D3DPRESENT_PARAMETERS is TRUE for window mode. when both devices have TRUE for windowed there's no problem. when I only use one device it works fine no matter if Windowed is TRUE or FALSE when I create the first device with Windowed TRUE it works fine to create the second with Windowed FALSE when I create the first device with Windowed FALSE I get an error no matter the Windowed mode of the second device
// This is reset before creating each device
d3dpp.Windowed = TRUE; // or FALSE for fullscreen
d3dpp.BackBufferWidth = SCREEN_WIDTH; // same on both monitors
d3dpp.BackBufferHeight = SCREEN_HEIGHT; // same on both monitors
d3dpp.hDeviceWindow = g_hWnd; // or g_hWnd2 which is located on the second monitor
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferCount = 1;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;

hResult = g_pD3D->CreateDevice(
0, // or 1 for the second monitor, this works fine
D3DDEVTYPE_HAL,
g_hWnd, // or g_hWnd2 on the second monitor
D3DCREATE_HARDWARE_VERTEXPROCESSING,
&d3dpp,
&g_pd3dDevice// or g_pd3dDevice2 for the second monitor
);

Is there something special I need to think about when setting up two fullscreen devices? Thanks, /Erik
0

Share this post


Link to post
Share on other sites
Only one screen may be fullscreen - it has the focus. Sorry.

I do many multi-monitor apps, and this does seem to be an oversight with Windows developers! Argh. Anyway, windowed mode that fills the screen looks a lot like fullscreen, doesn't have the focus issues, and still runs reasonably fast - perhaps not HL2 fast, but fast enough for all the stuff I've done with it, including quite a bit of 3D advanced techniques.

Good luck.
0

Share this post


Link to post
Share on other sites
Thanks for the reply!

That kinda sucks. Still it seems strange..
This is how MSDN describes the hDeviceWindow parameter of the D3DPRESENT_PARAMETERS structure.
Quote:

hDeviceWindow
The device window determines the location and size of the back buffer on screen. This is used by Direct3D when the back buffer contents are copied to the front buffer during Present.
For a full-screen application, this is a handle to the top window (which is the focus window).

For applications that use multiple full-screen devices (such as a multimonitor system), exactly one device can use the focus window as the device window. All other devices must have unique device windows.

For a windowed-mode application, this handle will be the default target window for Present. If this handle is NULL, the focus window will be taken.
Note that no attempt is made by the runtime to reflect user changes in window size. The back buffer is not implicitly reset when this window is reset. However, the Present method does automatically track window position changes.


Clearly seems to say that there can be multiple fullscreen-devices..

/Erik
0

Share this post


Link to post
Share on other sites
I was recently having a similar problem.

Quote:
Original post by deffer
I was digging through DXSDK documentation and found out this:
Quote:
The concept of exclusive full-screen mode is retained in Microsoft DirectX 9.0, but it is kept entirely implicit in the IDirect3D9::CreateDevice and IDirect3DDevice9::Reset method calls. Whenever a device is successfully reset or created in full-screen operation, the Microsoft Direct3D object that created the device is marked as owning all adapters on that system. This state is known as exclusive mode, and at this point the Direct3D object owns exclusive mode. Exclusive mode means that devices created by any other Direct3D9 object can neither assume full-screen operation nor allocate video memory. In addition, when a Direct3D9 object assumes exclusive mode, all devices other than the device that went full-screen are placed into the lost state.

It's the most descriptive part I could find about the problem (not very descriptive, is it?[grin]


In the end I came to a conclusion that apparently it cannot be done with focus-switching feature.
0

Share this post


Link to post
Share on other sites
That same article (I think it was the same) says that there can be many fullscreen devices on different adapters, but that they need to use the same focus window.
It works using the same focus window, but I haven't been able to make the window cover both screens, seems like DX resets the window size or something.. which is bad if the user clicks the mouse outside of the focus window, and sometimes things behind the fullscreen app gets redrawn on top of it..
But perhaps there's a solution for that too =)
0

Share this post


Link to post
Share on other sites
yeah okay i know i'm replying to an old post. here's how i did it in win7:

create a focus window for both devices.
(optionally) create a device window for the first adapter.
create a device window for the second adapter.
create a direct3d9 context.
use this to create both devices.
create the first fullscreen device using the shared focus window and (optionally) the first device window.
create the second fullscreen device using the shared focus window and the second device window.
reset the first device.
the shared focus window is passed directly as a parameter to CreateDevice.
the device windows are passed in the presentation parameters structure.

all of the above must be done in the same thread as the GetMessage loop that handles messages for the above windows.

i like to use message only windows for fullscreen device windows.

i would suggest using directx 9ex instead of directx 9.
this way you can share resources between the two devices.

if the devices are created with the multi threaded flag then you can present to them from different threads.
in this case, the devices need to be "similar".
i don't know exactly how similar they have to be.
but using the same behavior flags and presentation parameters worked for me.
if the devices are not similar enough, you could get into a nasty deadlock situation where your presents happen at 0.5 fps.

CreateDevice and Reset tend to change the presentation parameters.
you might want to pass a copy instead of the master.

g'luck.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0