Advertisement
snake5

sgs-sdl multi-window fun

Jan 24th, 2014
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function configure()
  2. {
  3. }
  4.  
  5. function initialize()
  6. {
  7.     global Window1 = SS_CreateWindow( "Direct3D Window (hopefully)", 32, 32, 128, 128 );
  8.     Window1.initRenderer( SS_RENDERER_DONTCARE, SS_RENDERER_DONTCARE, SS_RENDERER_VSYNC );
  9.    
  10.     global Window2 = SS_CreateWindow( "OpenGL Window", 192, 32, 128, 128 );
  11.     Window2.initRenderer( SS_RENDERER_OPENGL, SS_RENDERER_DONTCARE, SS_RENDERER_VSYNC );
  12. }
  13.  
  14. function update()
  15. {
  16.     if( Window1 )
  17.     {
  18.         Window1.makeCurrent();
  19.         SS_Clear( color(0.1,0.2,0.4) );
  20.         SS_Present();
  21.     }
  22.    
  23.     if( Window2 )
  24.     {
  25.         Window2.makeCurrent();
  26.         SS_Clear( color(0.2,0.3,0.4) );
  27.         SS_Present();
  28.     }
  29. }
  30.  
  31. function on_event( e )
  32. {
  33.     if( e.type == SDL_QUIT )
  34.         global sys_exit = true;
  35.     if( e.type == SDL_WINDOWEVENT && e.event == SDL_WINDOWEVENT_CLOSE )
  36.     {
  37.         win = SS_GetWindowFromID( e.windowID );
  38.         if( win == Window1 )
  39.             global Window1 = null;
  40.         if( win == Window2 )
  41.             global Window2 = null;
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement