2

I'm trying to build a Windows application using SDL2 library that should display graphics and animations in fullscreen mode on multiple (2) monitors. My current OS is Windows XP and I have a single dual-head graphic card (1 VGA and 1 DVI connectors). I wrote few lines of code to test the application behaviour

int main(int argc, char **argv){

SDL_Window      *window1, *window2;
SDL_Surface     *mainsurface1, *mainsurface2;
SDL_Surface     *image1, *image2;

// initialize SDL library
if ( SDL_Init( SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_EVENTS ) != 0 ) {
    printf( "SDL_Init Error! %s\n", SDL_GetError() );
    return 1;
}
// create a window on 1st display and another window on 2nd display 
window1 = SDL_CreateWindow( "Wnd1", SDL_WINDOWPOS_CENTERED_DISPLAY(0), SDL_WINDOWPOS_CENTERED_DISPLAY(0), 640, 480, SDL_WINDOW_FULLSCREEN ); 
window2 = SDL_CreateWindow( "Wnd2", SDL_WINDOWPOS_CENTERED_DISPLAY(1), SDL_WINDOWPOS_CENTERED_DISPLAY(1), 640, 480, SDL_WINDOW_FULLSCREEN ); 
// load test images
image1 = SDL_LoadBMP( "images\\background1.bmp" );
image2 = SDL_LoadBMP( "images\\background2.bmp" );
// get main surface of each window
mainsurface1 = SDL_GetWindowSurface( window1 );
mainsurface2 = SDL_GetWindowSurface( window2 );
// print an image on each window    
SDL_BlitSurface( image1, 0, mainsurface1, 0 );
SDL_BlitSurface( image2, 0, mainsurface2, 0 );
// update windows
SDL_UpdateWindowSurface( window1 );
SDL_UpdateWindowSurface( window2 );

// stay for a while...
Sleep( 5000 );

// ...and exit
SDL_FreeSurface( image1 );
SDL_FreeSurface( image2 );
SDL_DestroyWindow( window1 );
SDL_DestroyWindow( window2 );
SDL_Quit();

return 0;

}

These code works perfectly without SDL_WINDOW_FULLSCREEN flag, but I need windows in fullscreen mode. If SDL_WINDOW_FULLSCREEN flag is set, only the last window created with SDL_CreateWindow is visible and in fullscreen mode, the other monitor is unchanged (still showing the desktop). If I set SDL_WINDOW_BORDERLESS|SDL_WINDOW_MAXIMIZED it seems to work but monitors keep desktop resolution (in my case 1280x1024) instead of desired resolution (640x480 or else). I think that the problem is in how SDL library deal with DirectX Devices (creation and reset).

How can I deal correctly with multiple monitor in fullscreen mode using SDL or SDL2 library? Is there a way to create a single double-sized window (eg: 2560*1024 or 1280*2048) using horizontal/vertical span feature? (I know that this is possible with X11 on Linux)

macfij
  • 3,093
  • 1
  • 19
  • 24
user3909174
  • 21
  • 1
  • 5
  • Any reason you can't use the SDL Renderer stuff and `SDL_RenderSetLogicalSize()`? – genpfault Aug 08 '14 at 14:31
  • Hi, thanks for reply. I have to avoid using renderers for several reasons about surfaces and textures. Anyway I tried SDL_RenderSetLogicalSize() but it can't help me: in fullscreen there's still a mess, windowed doesn't change anything – user3909174 Aug 21 '14 at 07:50
  • I have solved this problem. See http://stackoverflow.com/a/26776879/1465500. – loki Nov 06 '14 at 10:54

0 Answers0