Skip to content
Permalink
Browse files

Added current_w and current_h to the SDL_VideoInfo structure, which i…

…s set to the desktop resolution during video intialization, and then set to the current resolution when a video mode is set.

SDL_SetVideoMode() now accepts 0 for width or height and will use the current video mode (or the desktop mode if no mode has been set.)
  • Loading branch information
slouken committed Mar 15, 2006
1 parent 49d0caf commit d532c736691527b105164225957ce1545e9aea84
@@ -4,7 +4,15 @@ This is a list of API changes in SDL's version history.
Version 1.0:

1.2.10:
Added current_w and current_h to the SDL_VideoInfo structure,
which is set to the desktop resolution during video intialization,
and then set to the current resolution when a video mode is set.

SDL_SetVideoMode() now accepts 0 for width or height and will use
the current video mode (or the desktop mode if no mode has been set.)

Added SDL_GetKeyRepeat()

Added SDL_config.h, with defaults for various build environments.

1.2.7:
@@ -161,6 +161,8 @@ typedef struct SDL_VideoInfo {
Uint32 UnusedBits3 :16;
Uint32 video_mem; /* The total amount of video memory (in K) */
SDL_PixelFormat *vfmt; /* Value: The format of the video surface */
int current_w; /* Value: The current video mode width */
int current_h; /* Value: The current video mode height */
} SDL_VideoInfo;


@@ -587,6 +587,13 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
}
this = video = current_video;

/* Default to the current width and height */
if ( width == 0 ) {
width = video->info.current_w;
}
if ( height == 0 ) {
height = video->info.current_h;
}
/* Default to the current video bpp */
if ( bpp == 0 ) {
flags |= SDL_ANYFORMAT;
@@ -889,6 +896,8 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
SDL_PublicSurface = SDL_VideoSurface;
}
video->info.vfmt = SDL_VideoSurface->format;
video->info.current_w = SDL_VideoSurface->w;
video->info.current_h = SDL_VideoSurface->h;

/* We're done! */
return(SDL_PublicSurface);
@@ -275,6 +275,8 @@ int BE_VideoInit(_THIS, SDL_PixelFormat *vformat)

/* Save the current display mode */
bscreen.GetMode(&saved_mode);
_this->info.current_w = saved_mode.virtual_width;
_this->info.current_h = saved_mode.virtual_height;

/* Determine the screen depth */
vformat->BitsPerPixel = ColorSpaceToBitsPerPixel(bscreen.ColorSpace());
@@ -463,6 +463,8 @@ static int CGX_VideoInit(_THIS, SDL_PixelFormat *vformat)
SDL_SetError("Couldn't lock the display");
return(-1);
}
this->info.current_w = SDL_Display->Width;
this->info.current_h = SDL_Display->Height;

D(bug("Checking if we are using a CGX native display...\n"));

@@ -834,8 +836,6 @@ int CGX_CreateWindow(_THIS, SDL_Surface *screen,

if( !SDL_windowid ) {
CGX_SetSizeHints(this, w, h, flags);
current_w = w;
current_h = h;
}

/* Set our colormaps when not setting a GL mode */
@@ -885,8 +885,6 @@ int CGX_ResizeWindow(_THIS,
if ( ! SDL_windowid ) {
/* Resize the window manager window */
CGX_SetSizeHints(this, w, h, flags);
current_w = w;
current_h = h;

ChangeWindowBox(SDL_Window,SDL_Window->LeftEdge,SDL_Window->TopEdge, w+SDL_Window->BorderLeft+SDL_Window->BorderRight,
h+SDL_Window->BorderTop+SDL_Window->BorderBottom);
@@ -67,10 +67,6 @@ struct SDL_PrivateVideoData {
Uint8 *Ximage; /* The X image for our window */
int swap_pixels; /* Flag: true if display is swapped endian */

/* The current width and height of the fullscreen mode */
int current_w;
int current_h;

/* Support for internal mouse warping */
struct {
int x;
@@ -132,8 +128,6 @@ struct SDL_PrivateVideoData {
#define SDL_Ximage (this->hidden->Ximage)
#define SDL_GC (this->hidden->gc)
#define swap_pixels (this->hidden->swap_pixels)
#define current_w (this->hidden->current_w)
#define current_h (this->hidden->current_h)
#define mouse_last (this->hidden->mouse_last)
#define mouse_accel (this->hidden->mouse_accel)
#define mouse_relative (this->hidden->mouse_relative)
@@ -349,6 +349,10 @@ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat)
}
DGA_event_base = event_base;

/* Determine the current screen size */
this->info.current_w = DisplayWidth(DGA_Display, DGA_Screen);
this->info.current_h = DisplayHeight(DGA_Display, DGA_Screen);

/* Determine the current screen depth */
visual = DefaultVisual(DGA_Display, DGA_Screen);
{
@@ -291,6 +291,9 @@ int EPOC_VideoInit(_THIS, SDL_PixelFormat *vformat)

#endif /* __WINS__ */

_this->info.current_w = Private->EPOC_ScreenSize.iWidth;
_this->info.current_h = Private->EPOC_ScreenSize.iHeight;

/* The "best" video format should be returned to caller. */

vformat->BitsPerPixel = /*!!GetBpp(displayMode) */ 8;
@@ -636,6 +636,8 @@ static int FB_VideoInit(_THIS, SDL_PixelFormat *vformat)
}

/* Fill in our hardware acceleration capabilities */
this->info.current_w = current_w;
this->info.current_h = current_h;
this->info.wm_available = 0;
this->info.hw_available = 1;
this->info.video_mem = finfo.smem_len/1024;
@@ -529,6 +529,10 @@ int GAPI_VideoInit(_THIS, SDL_PixelFormat *vformat)
GAPI_AddMode(this, bpp, gapi->gxProperties.cxWidth, gapi->gxProperties.cyHeight);
}

/* Determine the current screen size */
this->info.current_w = gapi->gxProperties.cxWidth;
this->info.current_h = gapi->gxProperties.cyHeight;

/* Sort the mode lists */
for ( i=0; i<NUM_MODELISTS; ++i ) {
if ( gapi->SDL_nummodes[i] > 0 ) {
@@ -430,9 +430,9 @@ int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat)
/* Setup destination mfdb */
VDI_dst_mfdb.fd_addr = NULL;

/* Update hardware info */
this->info.hw_available = 0;
this->info.video_mem = 0;
/* Determine the current screen size */
this->info.current_w = VDI_w;
this->info.current_h = VDI_h;

/* Determine the screen depth */
/* we change this during the SDL_SetVideoMode implementation... */
@@ -197,6 +197,10 @@ int GGI_VideoInit(_THIS, SDL_PixelFormat *vformat)
GGI_VideoQuit(NULL);
}

/* Determine the current screen size */
this->info.current_w = mode.virt.x;
this->info.current_h = mode.virt.y;

/* Set a palette for palletized modes */
if (GT_SCHEME(mode.graphtype) == GT_PALETTE)
{
@@ -287,6 +287,10 @@ static int iPod_VideoInit (_THIS, SDL_PixelFormat *vformat)

fcntl (kbfd, F_SETFL, O_RDWR | O_NONBLOCK);

/* Determine the current screen size */
this->info.current_w = lcd_width;
this->info.current_h = lcd_height;

if ((generation >= 60000) && (generation < 70000)) {
vformat->BitsPerPixel = 16;
vformat->Rmask = 0xF800;
@@ -329,7 +329,7 @@ VideoBootStrap DSp_bootstrap = {
};

/* Use DSp/Display Manager to build mode list for given screen */
static SDL_Rect** DSp_BuildModeList (const GDHandle gDevice)
static SDL_Rect** DSp_BuildModeList (const GDHandle gDevice, int *displayWidth, int *displayHeight)
{
DSpContextAttributes attributes;
DSpContextReference context;
@@ -355,6 +355,9 @@ static SDL_Rect** DSp_BuildModeList (const GDHandle gDevice)

if ( DSpContext_GetAttributes (context, &attributes) != noErr )
return NULL;

*displayWidth = attributes.displayWidth;
*displayHeight = attributes.displayHeight;

for ( i = 0; i < SDL_arraysize(temp_list); i++ ) {
width = attributes.displayWidth;
@@ -556,14 +559,14 @@ static int DSp_VideoInit(_THIS, SDL_PixelFormat *vformat)
break;
}

if ( DSp_CreatePalette (this) < 0 ) {

SDL_SetError ("Could not create palette");
return (-1);
}
if ( DSp_CreatePalette (this) < 0 ) {
SDL_SetError ("Could not create palette");
return (-1);
}

/* Get a list of available fullscreen modes */
SDL_modelist = DSp_BuildModeList (SDL_Display);
SDL_modelist = DSp_BuildModeList (SDL_Display,
&this->info.current_w, &this->info.current_h);
if (SDL_modelist == NULL) {
SDL_SetError ("DrawSprocket could not build a mode list");
return (-1);
@@ -203,6 +203,10 @@ static int ROM_VideoInit(_THIS, SDL_PixelFormat *vformat)
/* Get a handle to the main monitor */
SDL_Display = GetMainDevice();

/* Determine the current screen size */
this->info.current_w = (**SDL_Display).gdRect.right;
this->info.current_h = (**SDL_Display).gdRect.bottom;

/* Determine pixel format */
vformat->BitsPerPixel = (**(**SDL_Display).gdPMap).pixelSize;
switch (vformat->BitsPerPixel) {
@@ -209,6 +209,10 @@ int NX_VideoInit (_THIS, SDL_PixelFormat * vformat)
GrGetScreenInfo (& si) ;
SDL_Visual.bpp = si.bpp ;

/* Determine the current screen size */
this->info.current_w = si.cols ;
this->info.current_h = si.rows ;

// GetVideoMode
SDL_modelist = (SDL_Rect **) SDL_malloc (sizeof (SDL_Rect *) * 2) ;
if (SDL_modelist) {
@@ -2724,6 +2724,10 @@ static int os2fslib_VideoInit(_THIS, SDL_PixelFormat *vformat)
return -1;
}

/* Determine the current screen size */
_this->info.current_w = 0; // FIXME!
_this->info.current_h = 0; // FIXME!

/* Determine the screen depth */
vformat->BitsPerPixel = pDesktopMode->uiBPP;
vformat->BytesPerPixel = (vformat->BitsPerPixel+7)/8;
@@ -400,6 +400,10 @@ static int ph_VideoInit(_THIS, SDL_PixelFormat* vformat)
return -1;
}

/* Determine the current screen size */
this->info.current_w = desktop_mode.width;
this->info.current_h = desktop_mode.height;

/* We need to return BytesPerPixel as it in used by CreateRGBsurface */
vformat->BitsPerPixel = desktop_mode.bits_per_pixel;
vformat->BytesPerPixel = desktop_mode.bytes_per_scanline/desktop_mode.width;
@@ -166,6 +166,10 @@ int PG_VideoInit(_THIS, SDL_PixelFormat *vformat)

PG_InitEvents(this);

/* Determine the current screen size */
this->info.current_w = this->hidden->mi.lxres;
this->info.current_h = this->hidden->mi.lyres;

/* Determine the screen depth.
* We change this during the SDL_SetVideoMode implementation...
* Round up to the nearest Bytes per pixel
@@ -298,14 +298,19 @@ static int GS_VideoInit(_THIS, SDL_PixelFormat *vformat)
return(-1);
}

/* Determine the current screen depth */
if ( ioctl(console_fd, PS2IOC_GSCREENINFO, &vinfo) < 0 ) {
close(memory_fd);
close(console_fd);
console_fd = -1;
SDL_SetError("Couldn't get console pixel format");
return(-1);
}

/* Determine the current screen size */
this->info.current_w = vinfo.w;
this->info.current_h = vinfo.h;

/* Determine the current screen depth */
switch (vinfo.psm) {
/* Supported pixel formats */
case PS2_GS_PSMCT32:
@@ -226,6 +226,10 @@ extern "C" {
QT_AddMode(_this, ((vformat->BitsPerPixel+7)/8)-1,
desktop_size.height(), desktop_size.width());

/* Determine the current screen size */
this->info.current_w = desktop_size.width();
this->info.current_h = desktop_size.height();

/* Create the window / widget */
SDL_Win = new SDL_QWin(QSize(QT_HIDDEN_SIZE, QT_HIDDEN_SIZE));
((QPEApplication*)qApp)->showMainWidget(SDL_Win);
@@ -200,6 +200,11 @@ static int QZ_VideoInit (_THIS, SDL_PixelFormat *video_format) {
CFNumberGetValue (CFDictionaryGetValue (save_mode, kCGDisplayHeight),
kCFNumberSInt32Type, &device_height);

/* Determine the current screen size */
this->info.current_w = device_width;
this->info.current_h = device_height;

/* Determine the default screen depth */
video_format->BitsPerPixel = device_bpp;

/* Set misc globals */
@@ -175,6 +175,10 @@ int RISCOS_VideoInit(_THIS, SDL_PixelFormat *vformat)
_kernel_swi(OS_ReadModeVariable, &regs, &regs);
vformat->BitsPerPixel = (1 << regs.r[2]);

/* Determine the current screen size */
this->info.current_w = 0; /* FIXME! */
this->info.current_h = 0; /* FIXME! */

/* Minimum bpp for SDL is 8 */
if (vformat->BitsPerPixel < 8) vformat->BitsPerPixel = 8;

@@ -257,6 +257,10 @@ int SVGA_VideoInit(_THIS, SDL_PixelFormat *vformat)
}
keyboard_seteventhandler(SVGA_keyboardcallback);

/* Determine the current screen size */
this->info.current_w = 0;
this->info.current_h = 0;

/* Determine the screen depth (use default 8-bit depth) */
vformat->BitsPerPixel = 8;

@@ -257,6 +257,12 @@ int VGL_VideoInit(_THIS, SDL_PixelFormat *vformat)
return -1;
}

/* Determine the current screen size */
if (VGLCurMode != NULL) {
this->info.current_w = VGLCurMode->ModeInfo.Xsize;
this->info.current_h = VGLCurMode->ModeInfo.Ysize;
}

/* Determine the screen depth */
if (VGLCurMode != NULL)
vformat->BitsPerPixel = VGLCurMode->Depth;
@@ -334,6 +334,8 @@ int DIB_VideoInit(_THIS, SDL_PixelFormat *vformat)
#endif
/* Query for the desktop resolution */
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &SDL_desktop_mode);
this->info.current_w = SDL_desktop_mode.dmPelsWidth;
this->info.current_h = SDL_desktop_mode.dmPelsHeight;

/* Query for the list of available video modes */
for ( i=0; EnumDisplaySettings(NULL, i, &settings); ++i ) {
@@ -930,6 +930,8 @@ int DX5_VideoInit(_THIS, SDL_PixelFormat *vformat)
#ifndef NO_CHANGEDISPLAYSETTINGS
/* Query for the desktop resolution */
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &SDL_desktop_mode);
this->info.current_w = SDL_desktop_mode.dmPelsWidth;
this->info.current_h = SDL_desktop_mode.dmPelsHeight;
#endif

/* Enumerate the available fullscreen modes */
@@ -300,6 +300,9 @@ int WSCONS_VideoInit(_THIS, SDL_PixelFormat *vformat)
height = private->info.height;
}

this->info.current_w = width;
this->info.current_h = height;

if (private->shadowFB) {
private->shadowmem = (Uint8 *)SDL_malloc(len);
if (private->shadowmem == NULL) {

0 comments on commit d532c73

Please sign in to comment.