Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Selecting Display Device  (Read 2466 times)

0 Members and 2 Guests are viewing this topic.

ronag

  • Newbie
  • *
  • Posts: 24
    • View Profile
Selecting Display Device
« on: September 02, 2010, 10:47:03 pm »
Let's say my computer is connected to two display devices (monitors).

I would like too select which one my full screen SFML window is displayed on.

Is this possible?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Selecting Display Device
« Reply #1 on: September 03, 2010, 08:37:19 am »
Nop.
Laurent Gomila - SFML developer

ronag

  • Newbie
  • *
  • Posts: 24
    • View Profile
Selecting Display Device
« Reply #2 on: September 03, 2010, 04:49:24 pm »
Figured it out-

Here is how to do it in windows at least.

Code: [Select]
DISPLAY_DEVICE dDevice;
memset(&dDevice,0,sizeof(dDevice));
dDevice.cb = sizeof(dDevice);

std::vector<DISPLAY_DEVICE> displayDevices;
for(int n = 0; EnumDisplayDevices(NULL, n, &dDevice, NULL); ++n)
{
displayDevices.push_back(dDevice);
memset(&dDevice,0,sizeof(dDevice));
dDevice.cb = sizeof(dDevice);
}

if(screenIndex_ >= displayDevices.size())
BOOST_THROW_EXCEPTION(out_of_range() << arg_name_info("screenIndex_"));

DEVMODE devmode;
memset(&devmode,0,sizeof(devmode));

if(!EnumDisplaySettings(displayDevices[screenIndex_].DeviceName, ENUM_CURRENT_SETTINGS, &devmode))
BOOST_THROW_EXCEPTION(invalid_operation() << arg_name_info("screenIndex_") << msg_info("EnumDisplaySettings"));

screenWidth_ = devmode.dmPelsWidth;
screenHeight_ = devmode.dmPelsHeight;
screenX_ = devmode.dmPosition.x;
screenY_ = devmode.dmPosition.y;


pWindow_.reset(new sf::Window());
pWindow_->Create(sf::VideoMode(width, height, 32), "My window", windowed_ ? sf::Style::Titlebar : sf::Style::Fullscreen);
pWindow_->ShowMouseCursor(false);
pWindow_->SetPosition(screenX_, screenY_);
pWindow_->SetSize(screenWidth_, screenHeight_);

 

anything