*** empty log message ***
authorSam Lantinga <slouken@libsdl.org>
Mon, 11 Mar 2002 17:38:56 +0000
changeset 3092de77f7b7a28
parent 308 ee32ed29a507
child 310 c97c1d3b3b5c
*** empty log message ***
README.QNX
src/video/photon/SDL_ph_modes.c
src/video/photon/SDL_ph_video.c
src/video/photon/SDL_ph_video.h
     1.1 --- a/README.QNX	Sun Mar 10 03:55:45 2002 +0000
     1.2 +++ b/README.QNX	Mon Mar 11 17:38:56 2002 +0000
     1.3 @@ -1,16 +1,19 @@
     1.4  README by Mike Gorchak <mike@malva.ua>
     1.5  
     1.6 -    OpenGL support was experimentally added in window mode (in
     1.7 -fullscreen mode not yet). If you have QNX RtP v6.1.0 w/ or w/o
     1.8 -Patch A you must download new Photon3D runtime from http://de-
     1.9 -velopers.qnx.com. The versions of OS before 6.1.0 are not sup-
    1.10 -ported.
    1.11 +    OpenGL in window mode  works well  and  stable, in fullscreen
    1.12 +mode too, but fullscreen mode has not been heavily tested.
    1.13 +    If you have QNX RtP 6.1.0 w/ or w/o Patch A you must download
    1.14 +new Photon3D runtime from http://developers.qnx.com. The versions
    1.15 +of OS before 6.1.0 are not supported.
    1.16  
    1.17  Problems:
    1.18 -1. Fullscreen mode (in OpenGL mode) has not been  written yet.
    1.19 -2. Photon has some errors in detecting  how much bits  per pi-
    1.20 -   xel videomode has.
    1.21 -3. No  shared  libraries  yet. We  need  manually  set flag to
    1.22 +1. While creating OpenGL context artificially  selected  software
    1.23 +   renderer mode (QSSL made acceleration only for  Voodoo  boards
    1.24 +   in fullscreen mode, sorry but I don't have this board, if  you
    1.25 +   want acceleration - you may remove some line in source).
    1.26 +2. Photon has some errors in detecting  how  much bits  per pixel
    1.27 +   videomode has.
    1.28 +3. No  shared  libraries  yet.  We  need  manually  set  flag  to
    1.29     'configure' --disable-shared.
    1.30  
    1.31  Some building issues:
     2.1 --- a/src/video/photon/SDL_ph_modes.c	Sun Mar 10 03:55:45 2002 +0000
     2.2 +++ b/src/video/photon/SDL_ph_modes.c	Mon Mar 11 17:38:56 2002 +0000
     2.3 @@ -155,54 +155,52 @@
     2.4  
     2.5  SDL_Rect **ph_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
     2.6  {
     2.7 -	int i = 0;
     2.8 -	int j = 0;
     2.9 -	SDL_Rect Amodelist[PH_MAX_VIDEOMODES];
    2.10 +    int i = 0;
    2.11 +    int j = 0;
    2.12 +    SDL_Rect Amodelist[PH_MAX_VIDEOMODES];
    2.13  
    2.14 -        for (i=0; i<PH_MAX_VIDEOMODES; i++)
    2.15 +    for (i=0; i<PH_MAX_VIDEOMODES; i++)
    2.16 +    {
    2.17 +        SDL_modearray[i]=&SDL_modelist[i];
    2.18 +    }
    2.19 +
    2.20 +    if (PgGetVideoModeList( &mode_list ) < 0)
    2.21 +    {
    2.22 +       fprintf(stderr,"error: PgGetVideoModeList failed\n");
    2.23 +       return NULL;
    2.24 +    }
    2.25 +
    2.26 +    mode_info.bits_per_pixel = 0;
    2.27 +
    2.28 +    for (i=0; i < mode_list.num_modes; i++) 
    2.29 +    {
    2.30 +        if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
    2.31          {
    2.32 -           SDL_modearray[i]=&SDL_modelist[i];
    2.33 +            fprintf(stderr,"error: PgGetVideoModeInfo failed on mode: 0x%x\n", mode_list.modes[i]);
    2.34 +            return NULL;
    2.35          }
    2.36 +        if(mode_info.bits_per_pixel == format->BitsPerPixel)
    2.37 +        {
    2.38 +            Amodelist[j].w = mode_info.width;
    2.39 +            Amodelist[j].h = mode_info.height;
    2.40 +            Amodelist[j].x = 0;
    2.41 +            Amodelist[j].y = 0;
    2.42 +            j++;	
    2.43 +        }
    2.44 +    }
    2.45 +	
    2.46 +    /* reorder biggest for smallest, assume width dominates */
    2.47  
    2.48 -	if (PgGetVideoModeList( &mode_list ) < 0)
    2.49 -	{
    2.50 -	   fprintf(stderr,"error: PgGetVideoModeList failed\n");
    2.51 -	   return NULL;
    2.52 -	}
    2.53 -
    2.54 -	mode_info.bits_per_pixel = 0;
    2.55 -
    2.56 -	for (i=0; i < mode_list.num_modes; i++) 
    2.57 -	{
    2.58 -            if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
    2.59 -            {
    2.60 -                fprintf(stderr,"error: PgGetVideoModeInfo failed on mode: 0x%x\n",
    2.61 -                        mode_list.modes[i]);
    2.62 -                return NULL;
    2.63 -            }
    2.64 -
    2.65 -            if(mode_info.bits_per_pixel == format->BitsPerPixel)
    2.66 -            {
    2.67 -		Amodelist[j].w = mode_info.width;
    2.68 -		Amodelist[j].h = mode_info.height;
    2.69 -		Amodelist[j].x = 0;
    2.70 -		Amodelist[j].y = 0;
    2.71 -		j++;	
    2.72 -            }
    2.73 -	}
    2.74 +    for(i=0; i<j; i++)
    2.75 +    {
    2.76 +        SDL_modelist[i].w = Amodelist[j - i -1].w;
    2.77 +        SDL_modelist[i].h = Amodelist[j - i -1].h;
    2.78 +        SDL_modelist[i].x = Amodelist[j - i -1].x;
    2.79 +        SDL_modelist[i].y = Amodelist[j - i -1].y;
    2.80 +    }
    2.81 +    SDL_modearray[j]=NULL;
    2.82  	
    2.83 -	//reorder biggest for smallest, assume width dominates
    2.84 -
    2.85 -	for(i=0; i< j ; i++)
    2.86 -	{
    2.87 -	    SDL_modelist[i].w = Amodelist[j - i -1].w;
    2.88 -	    SDL_modelist[i].h = Amodelist[j - i -1].h;
    2.89 -	    SDL_modelist[i].x = Amodelist[j - i -1].x;
    2.90 -	    SDL_modelist[i].y = Amodelist[j - i -1].y;
    2.91 -	}
    2.92 -        SDL_modearray[j]=NULL;
    2.93 -	
    2.94 -	return SDL_modearray;
    2.95 +    return SDL_modearray;
    2.96  }
    2.97  
    2.98  void ph_FreeVideoModes(_THIS)
    2.99 @@ -281,82 +279,53 @@
   2.100      }
   2.101  }
   2.102  
   2.103 -/*
   2.104 -static void get_real_resolution(_THIS, int* w, int* h)
   2.105 -{
   2.106 -
   2.107 -    if ( use_vidmode ) {
   2.108 -        //PgDisplaySettings_t settings;
   2.109 -	    PgVideoModeInfo_t		current_mode_info;
   2.110 -	    	PgHWCaps_t my_hwcaps;
   2.111 -//        int unused;
   2.112 -		
   2.113 -//        if (PgGetVideoMode( &settings ) >= 0) {
   2.114 -//			*w = settings.xres;
   2.115 -//			*h = settings.yres;
   2.116 -//            return;
   2.117 -//        }
   2.118 -            if (PgGetGraphicsHWCaps(&my_hwcaps) >= 0)
   2.119 -         	{
   2.120 -                 if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &current_mode_info) < 0)
   2.121 -           		 {
   2.122 -                fprintf(stderr,"get_real_resolution:  PgGetVideoModeInfo failed\n");
   2.123 -            		 }
   2.124 -				*w = current_mode_info.width;
   2.125 -				*h = current_mode_info.height;            
   2.126 -            }
   2.127 -    }
   2.128 -//    *w = DisplayWidth(SDL_Display, SDL_Screen);
   2.129 -//    *h = DisplayHeight(SDL_Display, SDL_Screen);
   2.130 -}
   2.131 -*/
   2.132 -
   2.133  int ph_ResizeFullScreen(_THIS)
   2.134  {
   2.135 -
   2.136 -    if ( currently_fullscreen ) {
   2.137 +    if (currently_fullscreen) {
   2.138          set_best_resolution(this, current_w, current_h);
   2.139      }
   2.140 -    return(1);
   2.141 +    return (1);
   2.142  }
   2.143  
   2.144 +/* return the mode associated with width, height and bpp */
   2.145 +/* if there is no mode then zero is returned             */
   2.146  int get_mode(int width, int height, int bpp)
   2.147 -/* return the mode associated with width, height and bpp */
   2.148 -/* if there is no mode then zero is returned */
   2.149  {
   2.150 -	int i;
   2.151 +    int i;
   2.152  
   2.153 +    if(width<640)
   2.154 +    {
   2.155 +        width=640;
   2.156 +    }
   2.157 +    if(height<480)
   2.158 +    {
   2.159 +        height=480;
   2.160 +    }
   2.161  
   2.162 -if(width <640)
   2.163 -   width = 640;
   2.164 -if(height < 480)
   2.165 -  height = 480;
   2.166 +    if (PgGetVideoModeList(&mode_list) < 0)
   2.167 +    {
   2.168 +        fprintf(stderr,"error: PgGetVideoModeList failed\n");
   2.169 +        return -1;
   2.170 +    }
   2.171  
   2.172 +    /* search list for exact match */
   2.173 +    for (i=0;i<mode_list.num_modes;i++)
   2.174 +    {
   2.175 +        if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
   2.176 +        {
   2.177 +            fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
   2.178 +            return 0;
   2.179 +        }
   2.180  
   2.181 -	if (PgGetVideoModeList( &mode_list ) < 0)
   2.182 -	{
   2.183 -	    fprintf(stderr,"error: PgGetVideoModeList failed\n");
   2.184 -    	return -1;
   2.185 -	}
   2.186 +        if ((mode_info.width == width) && 
   2.187 +            (mode_info.height == height) && 
   2.188 +            (mode_info.bits_per_pixel == bpp))
   2.189 +        {
   2.190 +            return mode_list.modes[i];
   2.191 +        }
   2.192 +    }
   2.193  
   2.194 -	// search list for exact match
   2.195 -	for (i=0;i<mode_list.num_modes;i++)
   2.196 -	{
   2.197 -		if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
   2.198 -		{
   2.199 -			fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
   2.200 -			return 0;
   2.201 -		}
   2.202 -		
   2.203 -		
   2.204 -		if ((mode_info.width == width) && 
   2.205 -			(mode_info.height == height) && 
   2.206 -			(mode_info.bits_per_pixel == bpp))
   2.207 -			{
   2.208 -			return mode_list.modes[i];
   2.209 -			}
   2.210 -	}
   2.211 -	return (i == mode_list.num_modes) ? 0 : mode_list.modes[i];
   2.212 +    return (i == mode_list.num_modes) ? 0 : mode_list.modes[i];
   2.213  }
   2.214  
   2.215  int get_mode_any_format(int width, int height, int bpp)
   2.216 @@ -421,7 +390,7 @@
   2.217  		return mode_list.modes[ closest ];
   2.218  	}
   2.219  	else
   2.220 -		return 0;
   2.221 +    return 0;
   2.222  }
   2.223  
   2.224  void ph_WaitMapped(_THIS);
   2.225 @@ -430,78 +399,88 @@
   2.226  
   2.227  int ph_ToggleFullScreen(_THIS, int on)
   2.228  {
   2.229 -
   2.230 -   if(currently_fullscreen)
   2.231 -        ph_LeaveFullScreen(this);
   2.232 -   else
   2.233 -        ph_EnterFullScreen(this);
   2.234 +    if (currently_fullscreen)
   2.235 +    {
   2.236 +        return ph_LeaveFullScreen(this);
   2.237 +    }
   2.238 +    else
   2.239 +    {
   2.240 +        return ph_EnterFullScreen(this);
   2.241 +    }
   2.242        
   2.243 -   return 0;     
   2.244 -
   2.245 +    return 0;     
   2.246  }
   2.247  
   2.248  int ph_EnterFullScreen(_THIS)
   2.249  {
   2.250 -	if ( ! currently_fullscreen ) 
   2.251 -	{
   2.252 +    if (!currently_fullscreen)
   2.253 +    {
   2.254 +        if ((this->screen->flags & SDL_OPENGL)==SDL_OPENGL)
   2.255 +        {
   2.256 +#ifdef HAVE_OPENGL
   2.257 +#endif /* HAVE_OPENGL */
   2.258 +           return 0;
   2.259 +        }
   2.260 +        else
   2.261 +        {
   2.262 +            if (old_video_mode==-1)
   2.263 +            {
   2.264 +                PgGetGraphicsHWCaps(&graphics_card_caps);
   2.265 +                old_video_mode=graphics_card_caps.current_video_mode;
   2.266 +                old_refresh_rate=graphics_card_caps.current_rrate;
   2.267 +            }
   2.268  
   2.269 -		if (old_video_mode==-1)
   2.270 -		{
   2.271 -			PgGetGraphicsHWCaps(&graphics_card_caps);
   2.272 -			old_video_mode=graphics_card_caps.current_video_mode;
   2.273 -			old_refresh_rate=graphics_card_caps.current_rrate;
   2.274 -		}
   2.275 +            if(OCImage.direct_context == NULL)
   2.276 +            {
   2.277 +                OCImage.direct_context=(PdDirectContext_t*)PdCreateDirectContext();
   2.278 +            }
   2.279 +            if(!OCImage.direct_context)
   2.280 +            {
   2.281 +                fprintf(stderr, "error: Can't create direct context\n" );
   2.282 +            }
   2.283  
   2.284 +            PdDirectStart(OCImage.direct_context);
   2.285  
   2.286 -		if(OCImage.direct_context == NULL)
   2.287 -       	 OCImage.direct_context=(PdDirectContext_t*)PdCreateDirectContext();
   2.288 -        if( !OCImage.direct_context )
   2.289 -             fprintf(stderr, "error: Can't create direct context\n" );
   2.290 -             
   2.291 -       
   2.292 -		/* Remove the cursor if in full screen mode */		
   2.293 -/*
   2.294 -		region_info.cursor_type = Ph_CURSOR_NONE;
   2.295 -		region_info.rid=PtWidgetRid(window);
   2.296 -		PhRegionChange(Ph_REGION_CURSOR,0,&region_info,NULL,NULL);
   2.297 -*/
   2.298 +            currently_fullscreen = 1;
   2.299 +        }
   2.300 +    }
   2.301  
   2.302 -	 	PdDirectStart( OCImage.direct_context );
   2.303 -
   2.304 -		currently_fullscreen = 1;
   2.305 -		}
   2.306 -
   2.307 -
   2.308 -		
   2.309 -	return 1;
   2.310 +    return 1;
   2.311  }
   2.312  
   2.313  int ph_LeaveFullScreen(_THIS )
   2.314  {
   2.315 -   PgDisplaySettings_t mymode_settings;
   2.316 +    PgDisplaySettings_t mymode_settings;
   2.317         
   2.318 -	if ( currently_fullscreen )
   2.319 -	{
   2.320 -		PdDirectStop(OCImage.direct_context);
   2.321 -		PdReleaseDirectContext(OCImage.direct_context);
   2.322 +    if (currently_fullscreen)
   2.323 +    {
   2.324 +        if ((this->screen->flags & SDL_OPENGL)==SDL_OPENGL)
   2.325 +        {
   2.326 +#ifdef HAVE_OPENGL
   2.327 +#endif /* HAVE_OPENGL */
   2.328 +           return 0;
   2.329 +        }
   2.330 +        else
   2.331 +        {
   2.332 +            PdDirectStop(OCImage.direct_context);
   2.333 +            PdReleaseDirectContext(OCImage.direct_context);
   2.334  
   2.335 -		//Restore old video mode	
   2.336 -		if (old_video_mode != -1)
   2.337 -		{
   2.338 -			mymode_settings.mode= (unsigned short) old_video_mode;
   2.339 -			mymode_settings.refresh= (unsigned short) old_refresh_rate;
   2.340 -			mymode_settings.flags = 0;
   2.341 -			if(PgSetVideoMode(&mymode_settings) < 0)
   2.342 -                        {
   2.343 -                           fprintf(stderr,"error: PgSetVideoMode failed\n");
   2.344 -        	        }
   2.345 -		}
   2.346 -	
   2.347 -		old_video_mode=-1;
   2.348 -		old_refresh_rate=-1;	
   2.349 -	
   2.350 -		// Restore cursor	
   2.351 -	
   2.352 -	}
   2.353 -	return 1;
   2.354 +            /* Restore old video mode */
   2.355 +            if (old_video_mode != -1)
   2.356 +            {
   2.357 +                mymode_settings.mode= (unsigned short) old_video_mode;
   2.358 +                mymode_settings.refresh= (unsigned short) old_refresh_rate;
   2.359 +                mymode_settings.flags = 0;
   2.360 +                if (PgSetVideoMode(&mymode_settings) < 0)
   2.361 +                {
   2.362 +                    fprintf(stderr,"error: PgSetVideoMode failed\n");
   2.363 +                }
   2.364 +            }
   2.365 +
   2.366 +            old_video_mode=-1;
   2.367 +            old_refresh_rate=-1;	
   2.368 +        }
   2.369 +
   2.370 +    }
   2.371 +    return 1;
   2.372  }
     3.1 --- a/src/video/photon/SDL_ph_video.c	Sun Mar 10 03:55:45 2002 +0000
     3.2 +++ b/src/video/photon/SDL_ph_video.c	Mon Mar 11 17:38:56 2002 +0000
     3.3 @@ -58,17 +58,24 @@
     3.4  static void ph_DeleteDevice(SDL_VideoDevice *device);
     3.5  
     3.6  #ifdef HAVE_OPENGL
     3.7 +int ph_SetupOpenGLContext(_THIS, int width, int height, int bpp, Uint32 flags);
     3.8  static void ph_GL_SwapBuffers(_THIS);
     3.9  static int ph_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value);
    3.10  #endif /* HAVE_OPENGL */
    3.11  
    3.12 -#ifdef HAVE_OPENGL
    3.13 -PdOpenGLContext_t* OGLContext=NULL;
    3.14 -#endif /* HAVE_OPENGL */
    3.15 -
    3.16  static int ph_Available(void)
    3.17  {
    3.18 -    return 1;
    3.19 +    int phstat=-1;
    3.20 +
    3.21 +    phstat=PtInit(0);
    3.22 +    if (phstat==0)
    3.23 +    {
    3.24 +       return 1;
    3.25 +    }
    3.26 +    else
    3.27 +    {
    3.28 +       return 0;
    3.29 +    }
    3.30  }
    3.31  
    3.32  static SDL_VideoDevice *ph_CreateDevice(int devindex)
    3.33 @@ -77,7 +84,7 @@
    3.34  
    3.35      /* Initialize all variables that we clean on shutdown */
    3.36      device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
    3.37 -    if ( device ) {
    3.38 +    if (device) {
    3.39          memset(device, 0, (sizeof *device));
    3.40          device->hidden = (struct SDL_PrivateVideoData *)
    3.41                  malloc((sizeof *device->hidden));
    3.42 @@ -98,10 +105,10 @@
    3.43      device->VideoInit = ph_VideoInit;
    3.44      device->ListModes = ph_ListModes;
    3.45      device->SetVideoMode = ph_SetVideoMode;
    3.46 -    device->ToggleFullScreen =  ph_ToggleFullScreen;
    3.47 +    device->ToggleFullScreen = ph_ToggleFullScreen;
    3.48      device->UpdateMouse = NULL;	
    3.49      device->SetColors = ph_SetColors;
    3.50 -    device->UpdateRects = NULL; /* ph_ResizeImage; */
    3.51 +    device->UpdateRects = NULL;         /* ph_ResizeImage */
    3.52      device->VideoQuit = ph_VideoQuit;
    3.53      device->AllocHWSurface = ph_AllocHWSurface;
    3.54      device->CheckHWBlit = NULL;
    3.55 @@ -149,13 +156,15 @@
    3.56  
    3.57  static void ph_DeleteDevice(SDL_VideoDevice *device)
    3.58  {
    3.59 -
    3.60 -    if ( device ) {
    3.61 -        if ( device->hidden ) {
    3.62 +    if (device)
    3.63 +    {
    3.64 +        if (device->hidden)
    3.65 +        {
    3.66              free(device->hidden);
    3.67              device->hidden = NULL;
    3.68          }
    3.69 -        if ( device->gl_data ) {
    3.70 +        if (device->gl_data)
    3.71 +        {
    3.72              free(device->gl_data);
    3.73              device->gl_data = NULL;
    3.74          }
    3.75 @@ -166,104 +175,68 @@
    3.76  
    3.77  static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat)
    3.78  {
    3.79 -	PtArg_t arg[1];
    3.80 -	PhDim_t dim;
    3.81 -	PgColor_t ph_palette[_Pg_MAX_PALETTE];
    3.82 -	int i;
    3.83 -	unsigned long *tempptr;
    3.84 -	int rtnval;
    3.85 -//	PgDisplaySettings_t mysettings;
    3.86 -	PgVideoModeInfo_t my_mode_info;
    3.87 -	PgHWCaps_t my_hwcaps;
    3.88 +    PgColor_t ph_palette[_Pg_MAX_PALETTE];
    3.89 +    int i;
    3.90 +    unsigned long *tempptr;
    3.91 +    int rtnval;
    3.92 +    PgVideoModeInfo_t my_mode_info;
    3.93 +    PgHWCaps_t my_hwcaps;
    3.94 +
    3.95 +    window=NULL;
    3.96 +    oglctx=NULL;
    3.97  	
    3.98 -	if( NULL == ( event = malloc( EVENT_SIZE ) ) )
    3.99 -	   exit( EXIT_FAILURE );
   3.100 +    if (NULL == (event = malloc(EVENT_SIZE)))
   3.101 +    {
   3.102 +        exit(EXIT_FAILURE);
   3.103 +    }
   3.104  
   3.105 -	/* Create a widget 'window' to capture events */
   3.106 -    dim.w=0; //JB test320;
   3.107 -    dim.h=0; //JB test240;
   3.108 -    //We need to return BytesPerPixel as it in used by CreateRGBsurface
   3.109 -	
   3.110 -    PtSetArg(&arg[0], Pt_ARG_DIM, &dim,0);
   3.111 -    
   3.112 -/*    
   3.113 -    PtSetArg(&arg[1], Pt_ARG_RESIZE_FLAGS, Pt_TRUE, Pt_RESIZE_XY_AS_REQUIRED);
   3.114 -    PtSetArg(&arg[2], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFRONT |
   3.115 -                        Ph_WM_STATE_ISMAX |
   3.116 -                        Ph_WM_STATE_ISFOCUS);
   3.117 +    /* Create the blank cursor */
   3.118 +    SDL_BlankCursor = this->CreateWMCursor(this, blank_cdata, blank_cmask,
   3.119 +                                          (int)BLANK_CWIDTH, (int)BLANK_CHEIGHT,
   3.120 +                                          (int)BLANK_CHOTX, (int)BLANK_CHOTY);
   3.121  
   3.122 -    PtSetArg(&arg[3], Pt_ARG_WINDOW_RENDER_FLAGS,Pt_FALSE,~0);
   3.123 -    PtSetArg(&arg[4], Pt_ARG_WINDOW_MANAGED_FLAGS,Pt_TRUE,
   3.124 -                        Ph_WM_FFRONT |
   3.125 -                        Ph_WM_CLOSE |
   3.126 -                        Ph_WM_TOFRONT |
   3.127 -                        Ph_WM_CONSWITCH);
   3.128 -*/    
   3.129 -    
   3.130 -    
   3.131 -	window=PtAppInit(NULL, NULL, NULL, 1, arg);
   3.132 +    if (SDL_BlankCursor == NULL)
   3.133 +    {
   3.134 +        printf("ph_VideoInit: could not create blank cursor\n");
   3.135 +    }
   3.136  
   3.137 -  	if(window == NULL)
   3.138 -  	{
   3.139 -  		printf("Photon application init failed, probably Photon is not running.\n");
   3.140 -        	exit( EXIT_FAILURE );
   3.141 -  	}
   3.142 +    if (PgGetGraphicsHWCaps(&my_hwcaps) < 0)
   3.143 +    {
   3.144 +        fprintf(stderr,"ph_VideoInit: GetGraphicsHWCaps failed!! \n");
   3.145 +    }
   3.146  
   3.147 -	//PgSetDrawBufferSize(16 *1024);
   3.148 -	PgSetRegion(PtWidgetRid(window));
   3.149 -	PgSetClipping(0,NULL);
   3.150 -	PtRealizeWidget(window);
   3.151 +    if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &my_mode_info) < 0)
   3.152 +    {
   3.153 +        fprintf(stderr,"ph_VideoInit:  PgGetVideoModeInfo failed\n");
   3.154 +    }
   3.155  
   3.156 +    /* We need to return BytesPerPixel as it in used by CreateRGBsurface */
   3.157 +    vformat->BitsPerPixel = my_mode_info.bits_per_pixel;
   3.158 +    vformat->BytesPerPixel = my_mode_info.bytes_per_scanline/my_mode_info.width;
   3.159 +         
   3.160 +    /* return a palette if we are in 256 color mode */
   3.161 +    if (vformat->BitsPerPixel == 8)
   3.162 +    {
   3.163 +        vformat->palette = malloc(sizeof(SDL_Palette));
   3.164 +        memset(vformat->palette, 0, sizeof(SDL_Palette));
   3.165 +        vformat->palette->ncolors = 256;
   3.166 +        vformat->palette->colors = (SDL_Color *)malloc(256 *sizeof(SDL_Color));
   3.167  
   3.168 -    /* Get the available video modes */
   3.169 -//    if(ph_GetVideoModes(this) < 0)
   3.170 -//        return -1;
   3.171 +        /* fill the palette */
   3.172 +        rtnval = PgGetPalette(ph_palette);
   3.173 +        if (rtnval < 0)
   3.174 +        {
   3.175 +	    fprintf(stderr, "ph_VideoInit: PgGetPalette failed\n");
   3.176 +        }
   3.177  
   3.178 -	/* Create the blank cursor */
   3.179 -	SDL_BlankCursor = this->CreateWMCursor(this, blank_cdata, blank_cmask,
   3.180 -                (int)BLANK_CWIDTH, (int)BLANK_CHEIGHT,
   3.181 -                   (int)BLANK_CHOTX, (int)BLANK_CHOTY);
   3.182 +        tempptr = (unsigned long *)vformat->palette->colors;
   3.183  
   3.184 -	if(SDL_BlankCursor == NULL)
   3.185 -	  printf("could not create blank cursor\n");
   3.186 -
   3.187 -         if (PgGetGraphicsHWCaps(&my_hwcaps) < 0)
   3.188 -         {
   3.189 -                fprintf(stderr,"ph_VideoInit:  GetGraphicsHWCaps failed!! \n");
   3.190 -         }
   3.191 -         if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &my_mode_info) < 0)
   3.192 -         {
   3.193 -                fprintf(stderr,"ph_VideoInit:  PgGetVideoModeInfo failed\n");
   3.194 -         }
   3.195 -
   3.196 -         //We need to return BytesPerPixel as it in used by CreateRGBsurface
   3.197 -         vformat->BitsPerPixel = my_mode_info.bits_per_pixel;
   3.198 -         vformat->BytesPerPixel = my_mode_info.bytes_per_scanline/my_mode_info.width;
   3.199 -         
   3.200 -         //return a palette if we are in 256 color mode           
   3.201 -		if(vformat->BitsPerPixel == 8)
   3.202 -		{
   3.203 -			vformat->palette = malloc(sizeof(SDL_Palette));
   3.204 -			memset(vformat->palette, 0, sizeof(SDL_Palette));
   3.205 -			vformat->palette->ncolors = 256;
   3.206 -			vformat->palette->colors = (SDL_Color *)malloc(256 *sizeof(SDL_Color));
   3.207 -			
   3.208 -			//fill the palette
   3.209 -			rtnval = PgGetPalette(ph_palette);
   3.210 -			if(rtnval < 0)
   3.211 -			   printf("ph_VideoInit:  PgGetPalette failed\n");
   3.212 -			   
   3.213 -                        tempptr = (unsigned long *)vformat->palette->colors;
   3.214 -
   3.215 -			for(i=0;i<256; i++)
   3.216 -			{
   3.217 -  				*tempptr = (((unsigned long)ph_palette[i]) << 8);
   3.218 -  				tempptr++;
   3.219 -
   3.220 -			}		
   3.221 -		
   3.222 -		}
   3.223 -
   3.224 +        for(i=0;i<256; i++)
   3.225 +        {
   3.226 +            *tempptr = (((unsigned long)ph_palette[i]) << 8);
   3.227 +            tempptr++;
   3.228 +        }		
   3.229 +    }
   3.230  
   3.231      currently_fullscreen = 0;
   3.232      
   3.233 @@ -276,21 +249,14 @@
   3.234                  int width, int height, int bpp, Uint32 flags)
   3.235  {
   3.236      PgDisplaySettings_t settings;
   3.237 -    int mode, actual_width, actual_height;
   3.238 -    PtArg_t arg[5];
   3.239 -    PhDim_t dim;	
   3.240 +    int mode;
   3.241 +    PtArg_t arg[32];
   3.242 +    PhDim_t dim;
   3.243      int rtnval;
   3.244      PgColor_t ph_palette[_Pg_MAX_PALETTE];
   3.245      int i;
   3.246      unsigned long *tempptr;
   3.247 -
   3.248 -#ifdef HAVE_OPENGL
   3.249 -    uint64_t OGLAttrib[PH_OGL_MAX_ATTRIBS];
   3.250 -    int OGLargc;
   3.251 -#endif /* HAVE_OPENGL */
   3.252 -
   3.253 -    actual_width = width;
   3.254 -    actual_height = height;
   3.255 +    int pargc;
   3.256  
   3.257      dim.w=width;
   3.258      dim.h=height;
   3.259 @@ -298,136 +264,131 @@
   3.260      /* Lock the event thread, in multi-threading environments */
   3.261      SDL_Lock_EventThread();
   3.262  
   3.263 -     /* Initialize the window */
   3.264 -    if (flags & SDL_FULLSCREEN) /* Direct Context , assume SDL_HWSURFACE also set */
   3.265 +    /* create window if no OpenGL support selected */
   3.266 +    if ((flags & SDL_OPENGL)!=SDL_OPENGL)
   3.267      {
   3.268 -        /* Get the video mode and set it */
   3.269 -        if (flags & SDL_ANYFORMAT)
   3.270 +        pargc=0;
   3.271 +
   3.272 +        PtSetArg(&arg[pargc++], Pt_ARG_DIM, &dim, 0);
   3.273 +        PtSetArg(&arg[pargc++], Pt_ARG_RESIZE_FLAGS, Pt_FALSE, Pt_RESIZE_XY_AS_REQUIRED);
   3.274 +
   3.275 +        if (window!=NULL)
   3.276          {
   3.277 -            if ((mode = get_mode_any_format(width, height, bpp)) == 0)
   3.278 -            {
   3.279 -                fprintf(stderr,"error: get_mode_any_format failed\n");
   3.280 -                exit(1);
   3.281 -            }
   3.282 +            PtUnrealizeWidget(window);
   3.283 +            PtDestroyWidget(window);
   3.284 +            window=NULL;
   3.285 +        }
   3.286 +
   3.287 +        window=PtCreateWidget(PtWindow, NULL, pargc-1, arg);
   3.288 +        PtRealizeWidget(window);
   3.289 +
   3.290 +        PtFlush();
   3.291 +    }
   3.292 +
   3.293 +#ifdef HAVE_OPENGL
   3.294 +    if (flags & SDL_OPENGL)
   3.295 +    {
   3.296 +        /* ph_SetupOpenGLContext creates also window as need */
   3.297 +        if (ph_SetupOpenGLContext(this, width, height, bpp, flags)==0)
   3.298 +        {
   3.299 +            current->flags=flags;
   3.300 +            /* setup OGL update function ... ugly method */
   3.301 +            ph_ResizeImage(this, current, flags); 
   3.302          }
   3.303          else
   3.304          {
   3.305 -            if ((mode = get_mode(width, height, bpp)) == 0)
   3.306 +            /* if context creation fail, report no OpenGL to high level */
   3.307 +            current->flags=(flags & (~SDL_OPENGL));
   3.308 +        }
   3.309 +#else
   3.310 +    if (flags & SDL_OPENGL) /* if no built-in OpenGL support */
   3.311 +    {
   3.312 +        fprintf(stderr, "error: no OpenGL support, try to recompile library.\n");
   3.313 +        current->flags=(flags & (~SDL_OPENGL));
   3.314 +        return NULL;
   3.315 +#endif /* HAVE_OPENGL */
   3.316 +    }
   3.317 +    else
   3.318 +    {
   3.319 +        /* Initialize the window */
   3.320 +        if (flags & SDL_FULLSCREEN) /* Direct Context , assume SDL_HWSURFACE also set */
   3.321 +        {
   3.322 +            /* Get the video mode and set it */
   3.323 +            if (flags & SDL_ANYFORMAT)
   3.324              {
   3.325 -                fprintf(stderr,"error: get_mode failed\n");
   3.326 -                exit(1);
   3.327 +                if ((mode = get_mode_any_format(width, height, bpp)) == 0)
   3.328 +                {
   3.329 +                    fprintf(stderr,"error: get_mode_any_format failed\n");
   3.330 +                    exit(1);
   3.331 +                }
   3.332 +            }
   3.333 +            else
   3.334 +            {
   3.335 +                if ((mode = get_mode(width, height, bpp)) == 0)
   3.336 +                {
   3.337 +                    fprintf(stderr,"error: get_mode failed\n");
   3.338 +                    exit(1);
   3.339 +                }
   3.340 +            }
   3.341 +            settings.mode = mode;
   3.342 +            settings.refresh = 0;
   3.343 +            settings.flags  = 0;       
   3.344 +
   3.345 +            if (PgSetVideoMode( &settings ) < 0)
   3.346 +            {
   3.347 +                fprintf(stderr,"error: PgSetVideoMode failed\n");
   3.348 +            }
   3.349 +
   3.350 +            /* Get the true height and width */
   3.351 +
   3.352 +            current->flags = (flags & (~SDL_RESIZABLE)); /* no resize for Direct Context */
   3.353 +
   3.354 +            /* Begin direct mode */
   3.355 +
   3.356 +            ph_EnterFullScreen(this);
   3.357 +
   3.358 +        } /* end fullscreen flag */
   3.359 +        else
   3.360 +        {
   3.361 +            if (flags & SDL_HWSURFACE)  /* Use offscreen memory iff SDL_HWSURFACE flag is set */
   3.362 +            {
   3.363 +                /* Hardware surface is Offsceen Context.  ph_ResizeImage handles the switch */
   3.364 +                current->flags = (flags & (~SDL_RESIZABLE)); /* no stretch blit in offscreen context */
   3.365 +            }
   3.366 +            else /* must be SDL_SWSURFACE */
   3.367 +            {
   3.368 +                current->flags = (flags | SDL_RESIZABLE); /* yes we can resize as this is a software surface */
   3.369              }
   3.370          }
   3.371 -        settings.mode = mode;
   3.372 -        settings.refresh = 0;
   3.373 -        settings.flags  = 0;       
   3.374  
   3.375 -        if (PgSetVideoMode( &settings ) < 0)
   3.376 -        {
   3.377 -            fprintf(stderr,"error: PgSetVideoMode failed\n");
   3.378 +	/* If we are setting video to use the palette make sure we have allocated memory for it */
   3.379 +	if (bpp==8)
   3.380 +	{
   3.381 +            current->format->palette = malloc(sizeof(SDL_Palette));
   3.382 +            memset(current->format->palette, 0, sizeof(SDL_Palette));
   3.383 +            current->format->palette->ncolors = 256;
   3.384 +            current->format->palette->colors = (SDL_Color *)malloc(256 *sizeof(SDL_Color));
   3.385 +            /* fill the palette */
   3.386 +            rtnval = PgGetPalette(ph_palette);
   3.387 +
   3.388 +            tempptr = (unsigned long *)current->format->palette->colors;
   3.389 +
   3.390 +            for(i=0; i<256; i++)
   3.391 +            {
   3.392 +                *tempptr = (((unsigned long)ph_palette[i]) << 8);
   3.393 +                tempptr++;
   3.394 +            }
   3.395          }
   3.396  
   3.397 -        /* Get the true height and width */
   3.398 -
   3.399 -        current->flags = (flags & (~SDL_RESIZABLE)); /* no resize for Direct Context */
   3.400 -
   3.401 -        /* Begin direct mode */
   3.402 -
   3.403 -        ph_EnterFullScreen(this);
   3.404 -
   3.405 -    } /* end fullscreen flag */
   3.406 -    else
   3.407 -    {
   3.408 -       if (flags & SDL_HWSURFACE)  /* Use offscreen memory iff SDL_HWSURFACE flag is set */
   3.409 -       {
   3.410 -         /* Hardware surface is Offsceen Context.  ph_ResizeImage handles the switch */
   3.411 -         current->flags = (flags & (~SDL_RESIZABLE)); /* no stretch blit in offscreen context */
   3.412 -       }
   3.413 -       else /* must be SDL_SWSURFACE */
   3.414 -       {
   3.415 -          current->flags = (flags | SDL_RESIZABLE); /* yes we can resize as this is a software surface */
   3.416 -       }
   3.417 -
   3.418 -#ifdef HAVE_OPENGL       
   3.419 -       if (flags & SDL_OPENGL) /* for now support OpenGL in window mode only */
   3.420 -       {
   3.421 -          OGLargc=0;
   3.422 -          if (this->gl_config.depth_size)
   3.423 -          {
   3.424 -             OGLAttrib[OGLargc++]=PHOGL_ATTRIB_DEPTH_BITS;
   3.425 -             OGLAttrib[OGLargc++]=this->gl_config.depth_size;
   3.426 -          }
   3.427 -          if (this->gl_config.stencil_size)
   3.428 -          {
   3.429 -             OGLAttrib[OGLargc++]=PHOGL_ATTRIB_STENCIL_BITS;
   3.430 -             OGLAttrib[OGLargc++]=this->gl_config.stencil_size;
   3.431 -          }
   3.432 -          OGLAttrib[OGLargc++]=PHOGL_ATTRIB_NONE;
   3.433 -          if (this->gl_config.double_buffer)
   3.434 -          {
   3.435 -             OGLContext=PdCreateOpenGLContext(2, &dim, 0, OGLAttrib);
   3.436 -          }
   3.437 -          else
   3.438 -          {
   3.439 -             OGLContext=PdCreateOpenGLContext(1, &dim, 0, OGLAttrib);
   3.440 -          }
   3.441 -          if (OGLContext==NULL)
   3.442 -          {
   3.443 -             fprintf(stderr,"error: cannot create OpenGL context.\n");
   3.444 -             exit(1);
   3.445 -          }
   3.446 -          PhDCSetCurrent(OGLContext);
   3.447 -       }
   3.448 -#else
   3.449 -       if (flags & SDL_OPENGL) /* if no OpenGL support */
   3.450 -       {
   3.451 -          fprintf(stderr, "error: no OpenGL support, try to recompile library.\n");
   3.452 -          exit(1);
   3.453 -       }
   3.454 -
   3.455 -#endif /* HAVE_OPENGL */
   3.456 -       
   3.457      }
   3.458  
   3.459 -	/* If we are setting video to use the palette make sure we have allocated memory for it */
   3.460 -	if(bpp == 8)
   3.461 -	{
   3.462 -		current->format->palette = malloc(sizeof(SDL_Palette));
   3.463 -		memset(current->format->palette, 0, sizeof(SDL_Palette));
   3.464 -		current->format->palette->ncolors = 256;
   3.465 -		current->format->palette->colors = (SDL_Color *)malloc(256 *sizeof(SDL_Color));
   3.466 -		/* fill the palette */
   3.467 -		rtnval = PgGetPalette(ph_palette);
   3.468 -
   3.469 -                tempptr = (unsigned long *)current->format->palette->colors;
   3.470 -
   3.471 -		for(i=0;i<256; i++)
   3.472 -		{
   3.473 -  			*tempptr = (((unsigned long)ph_palette[i]) << 8);
   3.474 -  			tempptr++;
   3.475 -
   3.476 -		}
   3.477 -	}
   3.478 -
   3.479 -
   3.480 -	/* Current window dimensions */
   3.481 -	PtGetResource( window, Pt_ARG_DIM, &dim, 0 );
   3.482 -
   3.483 -	/* If we need to resize the window */
   3.484 -	if((dim.w != width)||(dim.h != height))
   3.485 -	{
   3.486 -	    dim.w=width;
   3.487 -	    dim.h=height; 
   3.488 -	    PtSetArg(&arg[0], Pt_ARG_DIM, &dim,0);
   3.489 -	    PtSetResources( window, 1, arg ); 	
   3.490 -            current->w = width;
   3.491 -            current->h = height;
   3.492 -            current->format->BitsPerPixel = bpp;
   3.493 -            current->format->BytesPerPixel = (bpp+7)/8;
   3.494 -            current->pitch = SDL_CalculatePitch(current);
   3.495 -            /* Must call at least once it setup image planes */
   3.496 -            ph_ResizeImage(this, current, flags);
   3.497 -        }
   3.498 +    current->w = width;
   3.499 +    current->h = height;
   3.500 +    current->format->BitsPerPixel = bpp;
   3.501 +    current->format->BytesPerPixel = (bpp+7)/8;
   3.502 +    current->pitch = SDL_CalculatePitch(current);
   3.503 +    /* Must call at least once it setup image planes */
   3.504 +    ph_ResizeImage(this, current, flags);
   3.505  
   3.506      SDL_Unlock_EventThread();
   3.507  
   3.508 @@ -437,18 +398,47 @@
   3.509  
   3.510  static void ph_VideoQuit(_THIS)
   3.511  {
   3.512 +    PhRegion_t region_info;
   3.513 +
   3.514      ph_DestroyImage(this, SDL_VideoSurface); 
   3.515  
   3.516      if (currently_fullscreen)
   3.517      {
   3.518 -        PdDirectStop( directContext );
   3.519 -        PdReleaseDirectContext( directContext );
   3.520 +        PdDirectStop(directContext);
   3.521 +        PdReleaseDirectContext(directContext);
   3.522          directContext=0;	
   3.523 -        currently_fullscreen = 0;
   3.524 +        currently_fullscreen=0;
   3.525      }
   3.526 +
   3.527 +#ifdef HAVE_OPENGL
   3.528 +    if (((this->screen->flags & SDL_FULLSCREEN)==SDL_FULLSCREEN) &&
   3.529 +        ((this->screen->flags & SDL_OPENGL)==SDL_OPENGL))
   3.530 +    {
   3.531 +        region_info.cursor_type=Ph_CURSOR_POINTER;
   3.532 +        region_info.rid=PtWidgetRid(window);
   3.533 +        PhRegionChange(Ph_REGION_CURSOR, 0, &region_info, NULL, NULL);
   3.534 +    }
   3.535 +
   3.536 +    PtFlush();
   3.537 +#endif /* HAVE_OPENGL */
   3.538 +    
   3.539 +    if (window)
   3.540 +    {
   3.541 +        PtUnrealizeWidget(window);
   3.542 +        PtDestroyWidget(window);
   3.543 +        window=NULL;
   3.544 +    }
   3.545 +
   3.546 +#ifdef HAVE_OPENGL
   3.547 +    if (oglctx)
   3.548 +    {
   3.549 +        PhDCSetCurrent(NULL);
   3.550 +        PhDCRelease(oglctx);
   3.551 +        oglctx=NULL;
   3.552 +    }
   3.553 +#endif /* HAVE_OPENGL */
   3.554  }
   3.555  
   3.556 -
   3.557  static int ph_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
   3.558  {
   3.559  	PgColor_t *in, *out;
   3.560 @@ -508,10 +498,110 @@
   3.561  }
   3.562  
   3.563  #ifdef HAVE_OPENGL
   3.564 +
   3.565 +int ph_SetupOpenGLContext(_THIS, int width, int height, int bpp, Uint32 flags)
   3.566 +{
   3.567 +    PtArg_t args[8];
   3.568 +    PhDim_t dim;
   3.569 +    uint64_t OGLAttrib[PH_OGL_MAX_ATTRIBS];
   3.570 +    int OGLargc;
   3.571 +    int pargc;
   3.572 +
   3.573 +    dim.w=width;
   3.574 +    dim.h=height;
   3.575 +    
   3.576 +    if (oglctx!=NULL)
   3.577 +    {
   3.578 +       PhDCSetCurrent(NULL);
   3.579 +       PhDCRelease(oglctx);
   3.580 +       oglctx=NULL;
   3.581 +    }
   3.582 +
   3.583 +    OGLargc=0;
   3.584 +    if (this->gl_config.depth_size)
   3.585 +    {
   3.586 +        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_DEPTH_BITS;
   3.587 +        OGLAttrib[OGLargc++]=this->gl_config.depth_size;
   3.588 +    }
   3.589 +    if (this->gl_config.stencil_size)
   3.590 +    {
   3.591 +        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_STENCIL_BITS;
   3.592 +        OGLAttrib[OGLargc++]=this->gl_config.stencil_size;
   3.593 +    }
   3.594 +    OGLAttrib[OGLargc++]=PHOGL_ATTRIB_FORCE_SW;
   3.595 +    if (flags & SDL_FULLSCREEN)
   3.596 +    {
   3.597 +        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_FULLSCREEN;
   3.598 +        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_DIRECT;
   3.599 +        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_FULLSCREEN_BEST;
   3.600 +        OGLAttrib[OGLargc++]=PHOGL_ATTRIB_FULLSCREEN_CENTER;
   3.601 +    }
   3.602 +    OGLAttrib[OGLargc++]=PHOGL_ATTRIB_NONE;
   3.603 +
   3.604 +    if (this->gl_config.double_buffer)
   3.605 +    {
   3.606 +        oglctx=PdCreateOpenGLContext(2, &dim, 0, OGLAttrib);
   3.607 +    }
   3.608 +    else
   3.609 +    {
   3.610 +        oglctx=PdCreateOpenGLContext(1, &dim, 0, OGLAttrib);
   3.611 +    }
   3.612 +    if (oglctx==NULL)
   3.613 +    {
   3.614 +        fprintf(stderr,"error: cannot create OpenGL context.\n");
   3.615 +        return (-1);
   3.616 +    }
   3.617 +
   3.618 +    PhDCSetCurrent(oglctx);
   3.619 +
   3.620 +    pargc=0;
   3.621 +
   3.622 +    PtSetArg(&args[pargc++], Pt_ARG_DIM, &dim, 0);
   3.623 +    PtSetArg(&args[pargc++], Pt_ARG_RESIZE_FLAGS, Pt_FALSE, Pt_RESIZE_XY_AS_REQUIRED);
   3.624 +    PtSetArg(&args[pargc++], Pt_ARG_FILL_COLOR, Pg_BLACK, 0);
   3.625 +
   3.626 +    if (flags & SDL_FULLSCREEN)
   3.627 +    {
   3.628 +        PhPoint_t pos;
   3.629 +
   3.630 +        pos.x=0;
   3.631 +        pos.y=0;
   3.632 +
   3.633 +        PtSetArg(&args[pargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, ~0);
   3.634 +        PtSetArg(&args[pargc++], Pt_ARG_WINDOW_MANAGED_FLAGS,Pt_TRUE, Ph_WM_FFRONT | Ph_WM_CLOSE | Ph_WM_TOFRONT | Ph_WM_CONSWITCH);
   3.635 +        PtSetArg(&args[pargc++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISFOCUS);
   3.636 +        PtSetArg(&args[pargc++], Pt_ARG_POS, &pos, 0);
   3.637 +    }
   3.638 +
   3.639 +    if (window!=NULL)
   3.640 +    {
   3.641 +        PtUnrealizeWidget(window);
   3.642 +        PtDestroyWidget(window);
   3.643 +        window=NULL;
   3.644 +    }
   3.645 +
   3.646 +    window=PtCreateWidget(PtWindow, NULL, pargc-1, args);
   3.647 +    PtRealizeWidget(window);
   3.648 +
   3.649 +    /* disable mouse for fullscreen */
   3.650 +    if (flags & SDL_FULLSCREEN)
   3.651 +    {
   3.652 +        PhRegion_t region_info;
   3.653 +
   3.654 +        region_info.cursor_type=Ph_CURSOR_NONE;
   3.655 +        region_info.rid=PtWidgetRid(window);
   3.656 +        PhRegionChange(Ph_REGION_CURSOR, 0, &region_info, NULL, NULL);
   3.657 +    }
   3.658 +
   3.659 +    PtFlush();
   3.660 +
   3.661 +    return 0;
   3.662 +}
   3.663 +
   3.664  void ph_GL_SwapBuffers(_THIS)
   3.665  {
   3.666      PgSetRegion(PtWidgetRid(window));
   3.667 -    PdOpenGLContextSwapBuffers(OGLContext);
   3.668 +    PdOpenGLContextSwapBuffers(oglctx);
   3.669  }
   3.670  
   3.671  int ph_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
     4.1 --- a/src/video/photon/SDL_ph_video.h	Sun Mar 10 03:55:45 2002 +0000
     4.2 +++ b/src/video/photon/SDL_ph_video.h	Mon Mar 11 17:38:56 2002 +0000
     4.3 @@ -19,26 +19,6 @@
     4.4      Sam Lantinga
     4.5      slouken@libsdl.org
     4.6  */
     4.7 -/*
     4.8 -static PhEvent_t *event;
     4.9 -static PtAppContext_t app;
    4.10 -static PtWidget_t *window;
    4.11 -static PgVideoModes_t modelist;
    4.12 -static PdOffscreenContext_t *Buff[2];
    4.13 -static PdDirectContext_t *directContext;
    4.14 -static PhRect_t screenRect,windowRect;
    4.15 -static PgColor_t currRGB;
    4.16 -static PhPoint_t zeroPoint;
    4.17 -static char keyque[ QUE_SIZE ],keyMatrix[256];
    4.18 -static int queput,queget;
    4.19 -static int modeSet;
    4.20 -static PgHWCaps_t hwCaps;
    4.21 -static PgDisplaySettings_t mode_settings;
    4.22 -static int rshift1,rshift2,gshift1,gshift2,bshift1,bshift2;
    4.23 -static int backPitch;
    4.24 -static unsigned RBitMask,GBitMask,BBitMask;
    4.25 -static unsigned TranslatedFillColor;
    4.26 -*/
    4.27  
    4.28  #ifndef _SDL_ph_video_h
    4.29  #define _SDL_ph_video_h
    4.30 @@ -50,7 +30,9 @@
    4.31  #include "Pt.h"
    4.32  #include <photon/Pg.h>
    4.33  #include <photon/PdDirect.h>
    4.34 +#ifdef HAVE_OPENGL
    4.35  #include <photon/PdGL.h>
    4.36 +#endif /* HAVE_OPENGL */
    4.37  
    4.38  /* Hidden "this" pointer for the video functions */
    4.39  #define _THIS	SDL_VideoDevice *this
    4.40 @@ -76,31 +58,32 @@
    4.41      int local_ph;		/* Flag: true if local display */
    4.42      PtAppContext_t app;
    4.43      PgDisplaySettings_t mode_settings;	
    4.44 -    PtWidget_t *window;    /* used to handle input events */
    4.45 -	PhImage_t *image;	 /* used to display image */
    4.46 +    PtWidget_t *Window;    /* used to handle input events */
    4.47 +    PhImage_t *image;	   /* used to display image */
    4.48 +#ifdef HAVE_OPENGL
    4.49 +    PdOpenGLContext_t* OGLContext;
    4.50 +#endif /* HAVE_OPENGL */
    4.51  
    4.52 - 	struct {
    4.53 -       PdDirectContext_t *direct_context;
    4.54 -		PdOffscreenContext_t *offscreen_context;
    4.55 -		VidPtr_t    dc_ptr;
    4.56 -		FRAMEDATA *CurrentFrameData;
    4.57 -		FRAMEDATA *FrameData0;
    4.58 -		FRAMEDATA *FrameData1;
    4.59 -		int current;
    4.60 -		long Stride;
    4.61 -		long flags;
    4.62 -	} ocimage;
    4.63 +    struct {
    4.64 +        PdDirectContext_t *direct_context;
    4.65 +        PdOffscreenContext_t *offscreen_context;
    4.66 +        VidPtr_t dc_ptr;
    4.67 +        FRAMEDATA *CurrentFrameData;
    4.68 +        FRAMEDATA *FrameData0;
    4.69 +        FRAMEDATA *FrameData1;
    4.70 +        int current;
    4.71 +        long Stride;
    4.72 +        long flags;
    4.73 +    } ocimage;
    4.74  
    4.75      PhDrawContext_t *ScreenDC; //=NULL;
    4.76 -	signed short old_video_mode; //=-1;
    4.77 -	signed short old_refresh_rate; //=-1;
    4.78 -	PgHWCaps_t graphics_card_caps;
    4.79 +    signed short old_video_mode; //=-1;
    4.80 +    signed short old_refresh_rate; //=-1;
    4.81 +    PgHWCaps_t graphics_card_caps;
    4.82  	
    4.83 -	PdDirectContext_t *directContext;
    4.84 -	PdOffscreenContext_t *Buff[2];
    4.85 -	struct _Ph_ctrl* ctrl_channel;
    4.86 -	
    4.87 -	PhGC_t *Pt_GC, *Pg_GC; /* Graphic contexts to switch between Pt and Pg APIs */
    4.88 +    PdDirectContext_t *directContext;
    4.89 +    PdOffscreenContext_t *Buff[2];
    4.90 +    struct _Ph_ctrl* ctrl_channel;
    4.91  
    4.92      /* The variables used for displaying graphics */
    4.93  
    4.94 @@ -113,15 +96,15 @@
    4.95          int x;
    4.96          int y;
    4.97      } mouse_last;
    4.98 +
    4.99      struct {
   4.100          int numerator;
   4.101          int denominator;
   4.102          int threshold;
   4.103      } mouse_accel;
   4.104 +
   4.105      int mouse_relative;
   4.106 -	WMcursor* BlankCursor;
   4.107 -
   4.108 -  
   4.109 +    WMcursor* BlankCursor;
   4.110  
   4.111      int depth;			/* current visual depth (not bpp) */
   4.112  
   4.113 @@ -136,40 +119,39 @@
   4.114      int blit_queued;
   4.115  
   4.116      short *iconcolors;		/* List of colors used by the icon */
   4.117 -	PhEvent_t* event;
   4.118 +    PhEvent_t* event;
   4.119  };
   4.120  
   4.121 -#define local_ph 		(this->hidden->local_ph)
   4.122 -#define app				(this->hidden->app)
   4.123 -#define mode_settings	(this->hidden->mode_settings)
   4.124 -#define window			(this->hidden->window)
   4.125 -#define directContext	(this->hidden->directContext)
   4.126 -#define Buff			(this->hidden->Buff)
   4.127 -#define ctrl_channel 	(this->hidden->ctrl_channel)
   4.128 -#define SDL_Image		(this->hidden->image)
   4.129 -#define OCImage		(this->hidden->ocimage)
   4.130 -#define old_video_mode		(this->hidden->old_video_mode)
   4.131 -#define old_refresh_rate		(this->hidden->old_refresh_rate)
   4.132 -#define graphics_card_caps		(this->hidden->graphics_card_caps)
   4.133 -#define Pt_GC			(this->hidden->Pt_GC)
   4.134 -#define Pg_GC			(this->hidden->Pg_GC)
   4.135 +#define local_ph             (this->hidden->local_ph)
   4.136 +#define app                  (this->hidden->app)
   4.137 +#define mode_settings        (this->hidden->mode_settings)
   4.138 +#define window	             (this->hidden->Window)
   4.139 +#define oglctx               (this->hidden->OGLContext)
   4.140 +#define directContext	     (this->hidden->directContext)
   4.141 +#define Buff                 (this->hidden->Buff)
   4.142 +#define ctrl_channel         (this->hidden->ctrl_channel)
   4.143 +#define SDL_Image            (this->hidden->image)
   4.144 +#define OCImage              (this->hidden->ocimage)
   4.145 +#define old_video_mode       (this->hidden->old_video_mode)
   4.146 +#define old_refresh_rate     (this->hidden->old_refresh_rate)
   4.147 +#define graphics_card_caps   (this->hidden->graphics_card_caps)
   4.148  
   4.149  /* Old variable names */
   4.150 -#define swap_pixels		(this->hidden->swap_pixels)
   4.151 -#define current_w		(this->hidden->current_w)
   4.152 -#define current_h		(this->hidden->current_h)
   4.153 -#define mouse_last		(this->hidden->mouse_last)
   4.154 -#define mouse_accel		(this->hidden->mouse_accel)
   4.155 -#define mouse_relative		(this->hidden->mouse_relative)
   4.156 -#define saved_mode		(this->hidden->saved_mode)
   4.157 -#define saved_view		(this->hidden->saved_view)
   4.158 -#define use_vidmode		(this->hidden->use_vidmode)
   4.159 -#define currently_fullscreen	(this->hidden->currently_fullscreen)
   4.160 -#define switch_waiting		(this->hidden->switch_waiting)
   4.161 -#define switch_time		(this->hidden->switch_time)
   4.162 -#define blit_queued		(this->hidden->blit_queued)
   4.163 -#define SDL_iconcolorIs		(this->hidden->iconcolors)
   4.164 -#define event				(this->hidden->event)
   4.165 -#define SDL_BlankCursor     (this->hidden->BlankCursor)
   4.166 +#define swap_pixels          (this->hidden->swap_pixels)
   4.167 +#define current_w            (this->hidden->current_w)
   4.168 +#define current_h            (this->hidden->current_h)
   4.169 +#define mouse_last           (this->hidden->mouse_last)
   4.170 +#define mouse_accel          (this->hidden->mouse_accel)
   4.171 +#define mouse_relative       (this->hidden->mouse_relative)
   4.172 +#define saved_mode           (this->hidden->saved_mode)
   4.173 +#define saved_view           (this->hidden->saved_view)
   4.174 +#define use_vidmode          (this->hidden->use_vidmode)
   4.175 +#define currently_fullscreen (this->hidden->currently_fullscreen)
   4.176 +#define switch_waiting       (this->hidden->switch_waiting)
   4.177 +#define switch_time          (this->hidden->switch_time)
   4.178 +#define blit_queued          (this->hidden->blit_queued)
   4.179 +#define SDL_iconcolorIs      (this->hidden->iconcolors)
   4.180 +#define event                (this->hidden->event)
   4.181 +#define SDL_BlankCursor      (this->hidden->BlankCursor)
   4.182  
   4.183  #endif /* _SDL_x11video_h */