src/video/photon/SDL_ph_modes.c
author Sam Lantinga <slouken@libsdl.org>
Fri, 18 Jan 2002 18:14:03 +0000
changeset 266 c6abdda2f666
parent 252 e8157fcb3114
child 297 f6ffac90895c
permissions -rw-r--r--
Added QNX cleanups by Mike Gorchak (thanks!)
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@0
     3
    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
slouken@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@0
     6
    modify it under the terms of the GNU Library General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@0
     8
    version 2 of the License, or (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@0
    13
    Library General Public License for more details.
slouken@0
    14
slouken@0
    15
    You should have received a copy of the GNU Library General Public
slouken@0
    16
    License along with this library; if not, write to the Free
slouken@0
    17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@252
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@0
    22
slouken@0
    23
#ifdef SAVE_RCSID
slouken@0
    24
static char rcsid =
slouken@0
    25
 "@(#) $Id$";
slouken@0
    26
#endif
slouken@0
    27
slouken@0
    28
#include "SDL_ph_modes_c.h"
slouken@0
    29
slouken@0
    30
static unsigned long key1, key2;
slouken@0
    31
static PgVideoModeInfo_t mode_info;
slouken@0
    32
static PgVideoModes_t mode_list;
slouken@266
    33
slouken@0
    34
  /* The current list of available video modes */
slouken@266
    35
SDL_Rect  SDL_modelist[PH_MAX_VIDEOMODES];
slouken@266
    36
SDL_Rect* SDL_modearray[PH_MAX_VIDEOMODES];
slouken@0
    37
slouken@0
    38
static int compare_modes_by_res(const void* mode1, const void* mode2)
slouken@0
    39
{
slouken@0
    40
slouken@0
    41
	if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0)
slouken@0
    42
	{
slouken@0
    43
	    fprintf(stderr,"error: In compare_modes_by_res PgGetVideoModeInfo failed on mode: 0x%x\n",
slouken@0
    44
        	    *(unsigned short*)mode1);
slouken@266
    45
    	    return 0;
slouken@0
    46
	}
slouken@0
    47
	key1 = mode_info.width * mode_info.height;
slouken@0
    48
slouken@0
    49
	if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode_info) < 0)
slouken@0
    50
	{
slouken@266
    51
    	    fprintf(stderr,"error: In compare_modes_by_res PgGetVideoModeInfo failed on mode: 0x%x\n",
slouken@0
    52
	            *(unsigned short*)mode2);
slouken@0
    53
	    return 0;
slouken@0
    54
	}
slouken@266
    55
        key2 = mode_info.width * mode_info.height;
slouken@0
    56
slouken@0
    57
	if (key1 > key2)
slouken@0
    58
		return 1;
slouken@0
    59
	else if (key1 == key2)
slouken@0
    60
		return 0;
slouken@0
    61
	else
slouken@0
    62
		return -1;
slouken@0
    63
}
slouken@0
    64
slouken@266
    65
/*
slouken@0
    66
static int compare_modes_by_bpp(const void* mode1, const void* mode2)
slouken@0
    67
{
slouken@0
    68
slouken@0
    69
    if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0)
slouken@0
    70
    {
slouken@0
    71
        fprintf(stderr,"error: In compare_modes_by_bpp PgGetVideoModeInfo failed on mode: 0x%x\n",
slouken@0
    72
                *(unsigned short*)mode1);
slouken@0
    73
        return 0;
slouken@0
    74
    }
slouken@0
    75
    key1 = mode_info.bits_per_pixel;
slouken@0
    76
slouken@0
    77
    if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode_info) < 0)
slouken@0
    78
    {
slouken@0
    79
        fprintf(stderr,"error: In compare_modes_by_bpp PgGetVideoModeInfo failed on mode: 0x%x\n",
slouken@0
    80
                *(unsigned short*)mode2);
slouken@0
    81
        return 0;
slouken@0
    82
    }
slouken@0
    83
    key2 = mode_info.bits_per_pixel;
slouken@0
    84
slouken@0
    85
    if (key1 > key2)
slouken@0
    86
        return 1;
slouken@0
    87
    else if (key1 == key2)
slouken@0
    88
        return 0;
slouken@0
    89
    else
slouken@0
    90
        return -1;
slouken@0
    91
}
slouken@266
    92
*/
slouken@0
    93
slouken@266
    94
/*
slouken@0
    95
int ph_GetVideoModes(_THIS)
slouken@0
    96
{
slouken@0
    97
	unsigned short *front;
slouken@0
    98
	int i, bpp_group_size;
slouken@0
    99
slouken@0
   100
	// TODO: add mode_list member to _THIS
slouken@0
   101
	if (PgGetVideoModeList( &mode_list ) < 0)
slouken@0
   102
	{
slouken@0
   103
		fprintf(stderr,"error: PgGetVideoModeList failed\n");
slouken@0
   104
		return -1;
slouken@0
   105
	}
slouken@0
   106
	
slouken@0
   107
	// sort list first by bits per pixel (bpp), 
slouken@0
   108
	// then sort groups with same bpp by resolution.
slouken@0
   109
	qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_bpp);
slouken@0
   110
	bpp_group_size = 1;
slouken@0
   111
	front = &mode_list.modes[0];
slouken@0
   112
	for(i=0;i<mode_list.num_modes-2;i++)
slouken@0
   113
	{
slouken@0
   114
		if (compare_modes_by_bpp(&mode_list.modes[i],&mode_list.modes[i+1]))
slouken@0
   115
		{
slouken@0
   116
			qsort(front, bpp_group_size, sizeof(unsigned short), compare_modes_by_res);
slouken@0
   117
			front = &mode_list.modes[i+1];
slouken@0
   118
			bpp_group_size = 1;
slouken@0
   119
		}
slouken@0
   120
		else
slouken@0
   121
		{
slouken@0
   122
			bpp_group_size++;
slouken@0
   123
		}
slouken@0
   124
	}
slouken@0
   125
slouken@0
   126
	//SDL_modelist = (SDL_Rect **)malloc((mode_list.num_modes+1)*sizeof(SDL_Rect *));
slouken@0
   127
	if ( SDL_modelist ) {
slouken@0
   128
		for (i=0;i<mode_list.num_modes;i++) {
slouken@0
   129
        //	SDL_modelist[i] = (SDL_Rect *)malloc(sizeof(SDL_Rect));
slouken@0
   130
	     //   if ( SDL_modelist[i] == NULL ) {
slouken@0
   131
    	  //      break;
slouken@0
   132
	     //   }
slouken@0
   133
		    if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
slouken@0
   134
		    {
slouken@0
   135
        		fprintf(stderr,"error: PgGetVideoModeInfo failed on mode: 0x%x\n",
slouken@0
   136
                		mode_list.modes[i]);
slouken@0
   137
		        return -1;
slouken@0
   138
    		}
slouken@0
   139
    	    SDL_modelist[i].x = 0;
slouken@0
   140
	        SDL_modelist[i].y = 0;
slouken@0
   141
    	    SDL_modelist[i].w = mode_info.height;
slouken@0
   142
        	SDL_modelist[i].h = mode_info.width;
slouken@0
   143
	    }
slouken@0
   144
    	//SDL_modelist[i] = NULL;
slouken@0
   145
	}
slouken@0
   146
	else
slouken@0
   147
	{
slouken@0
   148
		fprintf(stderr,"error: malloc failed on SDL_modelist\n");
slouken@0
   149
		return -1;
slouken@0
   150
	}
slouken@0
   151
	
slouken@0
   152
	return 0;
slouken@0
   153
}
slouken@266
   154
*/
slouken@0
   155
slouken@266
   156
SDL_Rect **ph_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
slouken@0
   157
{
slouken@0
   158
	int i = 0;
slouken@0
   159
	int j = 0;
slouken@266
   160
	SDL_Rect Amodelist[PH_MAX_VIDEOMODES];
slouken@0
   161
slouken@266
   162
        for (i=0; i<PH_MAX_VIDEOMODES; i++)
slouken@266
   163
        {
slouken@266
   164
           SDL_modearray[i]=&SDL_modelist[i];
slouken@266
   165
        }
slouken@0
   166
slouken@0
   167
	if (PgGetVideoModeList( &mode_list ) < 0)
slouken@266
   168
	{
slouken@266
   169
	   fprintf(stderr,"error: PgGetVideoModeList failed\n");
slouken@266
   170
	   return NULL;
slouken@266
   171
	}
slouken@0
   172
slouken@0
   173
	mode_info.bits_per_pixel = 0;
slouken@0
   174
slouken@0
   175
	for (i=0; i < mode_list.num_modes; i++) 
slouken@0
   176
	{
slouken@0
   177
            if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
slouken@0
   178
            {
slouken@0
   179
                fprintf(stderr,"error: PgGetVideoModeInfo failed on mode: 0x%x\n",
slouken@0
   180
                        mode_list.modes[i]);
slouken@0
   181
                return NULL;
slouken@0
   182
            }
slouken@266
   183
slouken@0
   184
            if(mode_info.bits_per_pixel == format->BitsPerPixel)
slouken@0
   185
            {
slouken@266
   186
		Amodelist[j].w = mode_info.width;
slouken@266
   187
		Amodelist[j].h = mode_info.height;
slouken@266
   188
		Amodelist[j].x = 0;
slouken@266
   189
		Amodelist[j].y = 0;
slouken@266
   190
		j++;	
slouken@266
   191
            }
slouken@0
   192
	}
slouken@0
   193
	
slouken@266
   194
	//reorder biggest for smallest, assume width dominates
slouken@266
   195
slouken@266
   196
	for(i=0; i< j ; i++)
slouken@266
   197
	{
slouken@266
   198
	    SDL_modelist[i].w = Amodelist[j - i -1].w;
slouken@266
   199
	    SDL_modelist[i].h = Amodelist[j - i -1].h;
slouken@266
   200
	    SDL_modelist[i].x = Amodelist[j - i -1].x;
slouken@266
   201
	    SDL_modelist[i].y = Amodelist[j - i -1].y;
slouken@266
   202
	}
slouken@266
   203
        SDL_modearray[j]=NULL;
slouken@0
   204
	
slouken@266
   205
	return SDL_modearray;
slouken@0
   206
}
slouken@0
   207
slouken@0
   208
void ph_FreeVideoModes(_THIS)
slouken@0
   209
{
slouken@266
   210
   return;
slouken@0
   211
}
slouken@0
   212
slouken@0
   213
static void set_best_resolution(_THIS, int width, int height)
slouken@0
   214
{
slouken@0
   215
slouken@0
   216
    if ( use_vidmode ) {
slouken@0
   217
		PgDisplaySettings_t 	settings;
slouken@0
   218
		PgVideoModeInfo_t		current_mode_info;
slouken@204
   219
		PgHWCaps_t my_hwcaps;
slouken@0
   220
		unsigned short			current_bpp;
slouken@0
   221
        int i;
slouken@204
   222
	/*
slouken@0
   223
		if (PgGetVideoMode( &settings ) < 0)
slouken@0
   224
		{
slouken@0
   225
			fprintf(stderr,"error: PgGetVideoMode failed\n");
slouken@0
   226
			return;
slouken@0
   227
		}
slouken@0
   228
		if (PgGetVideoModeInfo( settings.mode, &current_mode_info ) < 0)
slouken@0
   229
		{
slouken@0
   230
			fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
slouken@0
   231
			return;
slouken@0
   232
		}
slouken@204
   233
		*/
slouken@204
   234
		//lu_zero 
slouken@204
   235
         if (PgGetGraphicsHWCaps(&my_hwcaps) < 0)
slouken@204
   236
         	{
slouken@204
   237
                fprintf(stderr,"set_best_resolution:  GetGraphicsHWCaps failed!! \n");
slouken@204
   238
      			//that HAVE to work
slouken@204
   239
            }
slouken@204
   240
         if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &current_mode_info) < 0)
slouken@204
   241
            {
slouken@204
   242
                fprintf(stderr,"set_best_resolution:  PgGetVideoModeInfo failed\n");
slouken@204
   243
            }
slouken@0
   244
		current_bpp = current_mode_info.bits_per_pixel;
slouken@0
   245
slouken@0
   246
        if (PgGetVideoModeList(&mode_list) >= 0)
slouken@0
   247
		{
slouken@0
   248
			qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_res);
slouken@0
   249
#ifdef PH_DEBUG
slouken@0
   250
  			printf("Available modes:\n");
slouken@0
   251
  			for ( i = 0; i < mode_list.num_modes; ++i ) 
slouken@0
   252
			{
slouken@0
   253
				PgGetVideoModeInfo(mode_list.modes[i], &mode_info);
slouken@0
   254
    			printf("Mode %d: %dx%d\n", i, mode_info.width, mode_info.height);
slouken@0
   255
  			}
slouken@0
   256
#endif
slouken@0
   257
            for ( i = mode_list.num_modes-1; i >= 0 ; --i ) 
slouken@0
   258
			{
slouken@0
   259
				if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
slouken@0
   260
				{
slouken@0
   261
					fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
slouken@0
   262
				}
slouken@0
   263
                if ( (mode_info.width >= width) &&
slouken@0
   264
                     (mode_info.height >= height) &&
slouken@0
   265
					 (mode_info.bits_per_pixel == current_bpp) )
slouken@0
   266
                    break;
slouken@0
   267
            }
slouken@0
   268
			if (i >= 0)
slouken@0
   269
			{
slouken@0
   270
                if ( (mode_info.width != current_mode_info.width) ||
slouken@0
   271
                     (mode_info.height != current_mode_info.height) ) 
slouken@0
   272
				{
slouken@0
   273
					settings.mode = mode_list.modes[i];
slouken@0
   274
					if(PgSetVideoMode( &settings ) < 0)	
slouken@0
   275
					{
slouken@0
   276
						fprintf(stderr,"error: PgSetVideoMode failed\n");
slouken@0
   277
					}
slouken@0
   278
                }
slouken@0
   279
            }
slouken@0
   280
        }
slouken@0
   281
    }
slouken@0
   282
}
slouken@0
   283
slouken@266
   284
/*
slouken@0
   285
static void get_real_resolution(_THIS, int* w, int* h)
slouken@0
   286
{
slouken@0
   287
slouken@0
   288
    if ( use_vidmode ) {
slouken@204
   289
        //PgDisplaySettings_t settings;
slouken@204
   290
	    PgVideoModeInfo_t		current_mode_info;
slouken@204
   291
	    	PgHWCaps_t my_hwcaps;
slouken@266
   292
//        int unused;
slouken@266
   293
		
slouken@266
   294
//        if (PgGetVideoMode( &settings ) >= 0) {
slouken@266
   295
//			*w = settings.xres;
slouken@266
   296
//			*h = settings.yres;
slouken@266
   297
//            return;
slouken@266
   298
//        }
slouken@204
   299
            if (PgGetGraphicsHWCaps(&my_hwcaps) >= 0)
slouken@204
   300
         	{
slouken@204
   301
                 if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &current_mode_info) < 0)
slouken@204
   302
           		 {
slouken@204
   303
                fprintf(stderr,"get_real_resolution:  PgGetVideoModeInfo failed\n");
slouken@204
   304
            		 }
slouken@204
   305
				*w = current_mode_info.width;
slouken@204
   306
				*h = current_mode_info.height;            
slouken@204
   307
            }
slouken@0
   308
    }
slouken@0
   309
//    *w = DisplayWidth(SDL_Display, SDL_Screen);
slouken@0
   310
//    *h = DisplayHeight(SDL_Display, SDL_Screen);
slouken@0
   311
}
slouken@266
   312
*/
slouken@0
   313
slouken@0
   314
int ph_ResizeFullScreen(_THIS)
slouken@0
   315
{
slouken@0
   316
slouken@0
   317
    if ( currently_fullscreen ) {
slouken@0
   318
        set_best_resolution(this, current_w, current_h);
slouken@0
   319
    }
slouken@0
   320
    return(1);
slouken@0
   321
}
slouken@0
   322
slouken@0
   323
int get_mode(int width, int height, int bpp)
slouken@0
   324
/* return the mode associated with width, height and bpp */
slouken@0
   325
/* if there is no mode then zero is returned */
slouken@0
   326
{
slouken@0
   327
	int i;
slouken@0
   328
slouken@0
   329
slouken@0
   330
if(width <640)
slouken@0
   331
   width = 640;
slouken@0
   332
if(height < 480)
slouken@0
   333
  height = 480;
slouken@0
   334
slouken@0
   335
slouken@0
   336
	if (PgGetVideoModeList( &mode_list ) < 0)
slouken@0
   337
	{
slouken@0
   338
	    fprintf(stderr,"error: PgGetVideoModeList failed\n");
slouken@0
   339
    	return -1;
slouken@0
   340
	}
slouken@0
   341
slouken@0
   342
	// search list for exact match
slouken@0
   343
	for (i=0;i<mode_list.num_modes;i++)
slouken@0
   344
	{
slouken@0
   345
		if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
slouken@0
   346
		{
slouken@0
   347
			fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
slouken@0
   348
			return 0;
slouken@0
   349
		}
slouken@0
   350
		
slouken@0
   351
		
slouken@0
   352
		if ((mode_info.width == width) && 
slouken@0
   353
			(mode_info.height == height) && 
slouken@0
   354
			(mode_info.bits_per_pixel == bpp))
slouken@0
   355
			{
slouken@0
   356
			return mode_list.modes[i];
slouken@0
   357
			}
slouken@0
   358
	}
slouken@0
   359
	return (i == mode_list.num_modes) ? 0 : mode_list.modes[i];
slouken@0
   360
}
slouken@0
   361
slouken@0
   362
int get_mode_any_format(int width, int height, int bpp)
slouken@0
   363
/* return the mode associated with width, height and bpp */
slouken@0
   364
/* if requested bpp is not found the mode with closest bpp is returned */
slouken@0
   365
{
slouken@0
   366
    int i, closest, delta, min_delta;
slouken@0
   367
slouken@0
   368
	if (PgGetVideoModeList( &mode_list ) < 0)
slouken@0
   369
	{
slouken@0
   370
	    fprintf(stderr,"error: PgGetVideoModeList failed\n");
slouken@0
   371
	    return -1;
slouken@0
   372
	}
slouken@0
   373
slouken@0
   374
	qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_res);
slouken@0
   375
	for(i=0;i<mode_list.num_modes;i++)
slouken@0
   376
	{
slouken@0
   377
       if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
slouken@0
   378
       {
slouken@0
   379
           fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
slouken@0
   380
           return 0;
slouken@0
   381
       }
slouken@0
   382
       if ((mode_info.width == width) &&
slouken@0
   383
           (mode_info.height == height))
slouken@0
   384
           break;
slouken@0
   385
	}
slouken@0
   386
	if (i<mode_list.num_modes)
slouken@0
   387
	{
slouken@0
   388
		// get closest bpp
slouken@0
   389
		closest = i++;
slouken@0
   390
		if (mode_info.bits_per_pixel == bpp)
slouken@0
   391
			return mode_list.modes[ closest ];
slouken@0
   392
slouken@0
   393
		min_delta = abs(mode_info.bits_per_pixel - bpp);
slouken@0
   394
		while(1)
slouken@0
   395
		{
slouken@0
   396
			if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
slouken@0
   397
			{
slouken@0
   398
			    fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
slouken@0
   399
			    return 0;
slouken@0
   400
			}
slouken@0
   401
slouken@0
   402
			if ((mode_info.width != width) ||
slouken@0
   403
				(mode_info.height != height))
slouken@0
   404
				break;
slouken@0
   405
			else if (mode_info.bits_per_pixel == bpp)
slouken@0
   406
			{
slouken@0
   407
				closest = i;
slouken@0
   408
				break;
slouken@0
   409
			}
slouken@0
   410
			else
slouken@0
   411
			{
slouken@0
   412
				delta = abs(mode_info.bits_per_pixel - bpp);
slouken@0
   413
				if (delta < min_delta)
slouken@0
   414
				{
slouken@0
   415
					closest = i;
slouken@0
   416
					min_delta = delta;
slouken@0
   417
				}
slouken@0
   418
				i++;
slouken@0
   419
			}
slouken@0
   420
		}
slouken@0
   421
		return mode_list.modes[ closest ];
slouken@0
   422
	}
slouken@0
   423
	else
slouken@0
   424
		return 0;
slouken@0
   425
}
slouken@0
   426
slouken@0
   427
void ph_WaitMapped(_THIS);
slouken@0
   428
void ph_WaitUnmapped(_THIS);
slouken@0
   429
void ph_QueueEnterFullScreen(_THIS);
slouken@0
   430
slouken@0
   431
int ph_ToggleFullScreen(_THIS, int on)
slouken@0
   432
{
slouken@0
   433
slouken@0
   434
   if(currently_fullscreen)
slouken@0
   435
        ph_LeaveFullScreen(this);
slouken@0
   436
   else
slouken@0
   437
        ph_EnterFullScreen(this);
slouken@0
   438
      
slouken@0
   439
   return 0;     
slouken@0
   440
slouken@0
   441
}
slouken@0
   442
slouken@0
   443
int ph_EnterFullScreen(_THIS)
slouken@0
   444
{
slouken@0
   445
	if ( ! currently_fullscreen ) 
slouken@0
   446
	{
slouken@0
   447
slouken@0
   448
		if (old_video_mode==-1)
slouken@0
   449
		{
slouken@0
   450
			PgGetGraphicsHWCaps(&graphics_card_caps);
slouken@0
   451
			old_video_mode=graphics_card_caps.current_video_mode;
slouken@0
   452
			old_refresh_rate=graphics_card_caps.current_rrate;
slouken@0
   453
		}
slouken@0
   454
slouken@0
   455
slouken@0
   456
		if(OCImage.direct_context == NULL)
slouken@0
   457
       	 OCImage.direct_context=(PdDirectContext_t*)PdCreateDirectContext();
slouken@0
   458
        if( !OCImage.direct_context )
slouken@0
   459
             fprintf(stderr, "error: Can't create direct context\n" );
slouken@0
   460
             
slouken@0
   461
       
slouken@0
   462
		/* Remove the cursor if in full screen mode */		
slouken@0
   463
/*
slouken@0
   464
		region_info.cursor_type = Ph_CURSOR_NONE;
slouken@0
   465
		region_info.rid=PtWidgetRid(window);
slouken@0
   466
		PhRegionChange(Ph_REGION_CURSOR,0,&region_info,NULL,NULL);
slouken@0
   467
*/
slouken@0
   468
slouken@0
   469
	 	PdDirectStart( OCImage.direct_context );
slouken@0
   470
slouken@0
   471
		currently_fullscreen = 1;
slouken@0
   472
		}
slouken@0
   473
slouken@0
   474
slouken@0
   475
		
slouken@0
   476
	return 1;
slouken@0
   477
}
slouken@0
   478
slouken@0
   479
int ph_LeaveFullScreen(_THIS )
slouken@0
   480
{
slouken@0
   481
   PgDisplaySettings_t mymode_settings;
slouken@0
   482
       
slouken@0
   483
	if ( currently_fullscreen )
slouken@0
   484
	{
slouken@0
   485
		PdDirectStop(OCImage.direct_context);
slouken@0
   486
		PdReleaseDirectContext(OCImage.direct_context);
slouken@0
   487
slouken@0
   488
		//Restore old video mode	
slouken@0
   489
		if (old_video_mode != -1)
slouken@0
   490
		{
slouken@0
   491
			mymode_settings.mode= (unsigned short) old_video_mode;
slouken@0
   492
			mymode_settings.refresh= (unsigned short) old_refresh_rate;
slouken@0
   493
			mymode_settings.flags = 0;
slouken@0
   494
			if(PgSetVideoMode(&mymode_settings) < 0)
slouken@266
   495
                        {
slouken@266
   496
                           fprintf(stderr,"error: PgSetVideoMode failed\n");
slouken@266
   497
        	        }
slouken@0
   498
		}
slouken@0
   499
	
slouken@0
   500
		old_video_mode=-1;
slouken@0
   501
		old_refresh_rate=-1;	
slouken@0
   502
	
slouken@0
   503
		// Restore cursor	
slouken@0
   504
	
slouken@0
   505
	}
slouken@0
   506
	return 1;
slouken@0
   507
}