src/video/bwindow/SDL_bmodes.cc
author Nathan Heisey <nathanheisey@gmail.com>
Wed, 13 Jul 2011 09:29:43 +0000
changeset 5918 2063df37190b
child 5921 4cec9ba57dfb
permissions -rw-r--r--
Renamed all .c files in src/video/bwindow to .cc files.
nathanheisey@5918
     1
/*
nathanheisey@5918
     2
  Simple DirectMedia Layer
nathanheisey@5918
     3
  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
nathanheisey@5918
     4
nathanheisey@5918
     5
  This software is provided 'as-is', without any express or implied
nathanheisey@5918
     6
  warranty.  In no event will the authors be held liable for any damages
nathanheisey@5918
     7
  arising from the use of this software.
nathanheisey@5918
     8
nathanheisey@5918
     9
  Permission is granted to anyone to use this software for any purpose,
nathanheisey@5918
    10
  including commercial applications, and to alter it and redistribute it
nathanheisey@5918
    11
  freely, subject to the following restrictions:
nathanheisey@5918
    12
nathanheisey@5918
    13
  1. The origin of this software must not be misrepresented; you must not
nathanheisey@5918
    14
     claim that you wrote the original software. If you use this software
nathanheisey@5918
    15
     in a product, an acknowledgment in the product documentation would be
nathanheisey@5918
    16
     appreciated but is not required.
nathanheisey@5918
    17
  2. Altered source versions must be plainly marked as such, and must not be
nathanheisey@5918
    18
     misrepresented as being the original software.
nathanheisey@5918
    19
  3. This notice may not be removed or altered from any source distribution.
nathanheisey@5918
    20
*/
nathanheisey@5918
    21
nathanheisey@5918
    22
#include "../SDL_sysvideo.h"
nathanheisey@5918
    23
nathanheisey@5918
    24
int BE_InitModes(_THIS) {
nathanheisey@5918
    25
#if 0
nathanheisey@5918
    26
	display_mode *modes;
nathanheisey@5918
    27
	uint32 i, nmodes;
nathanheisey@5918
    28
	int bpp;
nathanheisey@5918
    29
nathanheisey@5918
    30
	/* It is important that this be created after SDL_InitBeApp() */
nathanheisey@5918
    31
	BScreen bscreen;
nathanheisey@5918
    32
nathanheisey@5918
    33
	/* Save the current display mode */
nathanheisey@5918
    34
	bscreen.GetMode(&saved_mode);
nathanheisey@5918
    35
	_this->info.current_w = saved_mode.virtual_width;
nathanheisey@5918
    36
	_this->info.current_h = saved_mode.virtual_height;
nathanheisey@5918
    37
        
nathanheisey@5918
    38
	/* Get the video modes we can switch to in fullscreen mode */
nathanheisey@5918
    39
	bscreen.GetModeList(&modes, &nmodes);
nathanheisey@5918
    40
	SDL_qsort(modes, nmodes, sizeof *modes, CompareModes);
nathanheisey@5918
    41
	for (i = 0; i < nmodes; ++i) {
nathanheisey@5918
    42
		bpp = ColorSpaceToBitsPerPixel(modes[i].space);
nathanheisey@5918
    43
		//if ( bpp != 0 ) { // There are bugs in changing colorspace
nathanheisey@5918
    44
		if (modes[i].space == saved_mode.space) {
nathanheisey@5918
    45
			BE_AddMode(_this, ((bpp + 7) / 8) - 1,
nathanheisey@5918
    46
				modes[i].virtual_width, modes[i].virtual_height);
nathanheisey@5918
    47
		}
nathanheisey@5918
    48
	}
nathanheisey@5918
    49
#else
nathanheisey@5918
    50
return -1;
nathanheisey@5918
    51
#endif
nathanheisey@5918
    52
}
nathanheisey@5918
    53
nathanheisey@5918
    54
int BE_QuitModes(_THIS) {
nathanheisey@5918
    55
#if 0
nathanheisey@5918
    56
    int i, j;
nathanheisey@5918
    57
	for (i = 0; i < NUM_MODELISTS; ++i) {
nathanheisey@5918
    58
		if (SDL_modelist[i]) {
nathanheisey@5918
    59
			for (j = 0; SDL_modelist[i][j]; ++j) {
nathanheisey@5918
    60
				SDL_free(SDL_modelist[i][j]);
nathanheisey@5918
    61
			}
nathanheisey@5918
    62
			SDL_free(SDL_modelist[i]);
nathanheisey@5918
    63
			SDL_modelist[i] = NULL;
nathanheisey@5918
    64
		}
nathanheisey@5918
    65
	}
nathanheisey@5918
    66
nathanheisey@5918
    67
	/* Restore the original video mode */
nathanheisey@5918
    68
	if (_this->screen) {
nathanheisey@5918
    69
		if ((_this->screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) {
nathanheisey@5918
    70
			BScreen bscreen;
nathanheisey@5918
    71
			bscreen.SetMode(&saved_mode);
nathanheisey@5918
    72
		}
nathanheisey@5918
    73
		_this->screen->pixels = NULL;
nathanheisey@5918
    74
	}
nathanheisey@5918
    75
#else
nathanheisey@5918
    76
return -1;
nathanheisey@5918
    77
#endif
nathanheisey@5918
    78
}