How do we change the Screen/Window Resolution?

Instead of Setting the current video surface… SDL_SetVideoMode seams to
create a new video surface each time you call it…

Any ideas?

Golgoth

Instead of Setting the current video surface… SDL_SetVideoMode seams
to
create a new video surface each time you call it…

Any ideas?

Yes, and it destroys the previous one. This is the way it works. If you
must preserve the old window’s contents, copy them to a temporary
surface.On Sep 11, 2004, at 8:22 PM, Golgoth wrote:

Golgoth


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

I see… and yes I just want to change the resolution… is there any source
code/sample I can refere to how to copy the surface content… into memory?
could you help me out on this on?

THX

I see… and yes I just want to change the resolution… is there any
source
code/sample I can refere to how to copy the surface content… into
memory?
could you help me out on this on?

you’d do something like this

SDL_Surface *temp = SDL_CreateRGBSurface(flags, width, height, depth,
screen->rmask, screen->gmask, screen->bmask, screen->amask);
SDL_BlitSurface(screen, NULL, temp, NULL);
SDL_SetVideoMode(…)
SDL_BlitSurface(temp, NULL, screen, ???);

flags, width, height, and depth depend on your display format

??? you might want to set up an SDL_Rect for, but i think you MIGHT be
able to pass NULL but I don’t really know so just try it and see if it
works if you’d likeOn Sep 11, 2004, at 9:00 PM, Golgoth wrote:

THX


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Ok thx a lot man!

I ll work with this…

Is there any chance you would know how to set the window (x,y) position???
seams to be pretty random so far…

Thx again!

Golgoth

Ok thx a lot man!

I ll work with this…

Is there any chance you would know how to set the window (x,y)
position???
seams to be pretty random so far…

SDL doesn’t support this function yet. The fact is that currently your
operating system sets it for you. Under windows, it may seem pretty
random under many circumstances.On Sep 11, 2004, at 10:26 PM, Golgoth wrote:

Thx again!

Golgoth


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Donny Viszneki wrote:

you’d do something like this

SDL_Surface *temp = SDL_CreateRGBSurface(flags, width, height, depth,
screen->rmask, screen->gmask, screen->bmask, screen->amask);
SDL_BlitSurface(screen, NULL, temp, NULL);
SDL_SetVideoMode(…)
SDL_BlitSurface(temp, NULL, screen, ???);

flags, width, height, and depth depend on your display format

??? you might want to set up an SDL_Rect for, but i think you MIGHT be
able to pass NULL but I don’t really know so just try it and see if it
works if you’d like

Doesn’t work for me, must have something todo with
DirectX+Fullscreen+Doublebuffer :frowning:
Here is my simple example code to test it:

#include <SDL.h>

#define WIDTH 800
#define HEIGHT 600
#define BPP 32
#define FLAGS (SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN)

int main(int argc, char *argv[]) {
SDL_Surface *screen;
SDL_Surface *temp;
SDL_Surface *image;

SDL_Init(SDL_INIT_TIMER|SDL_INIT_VIDEO);
atexit(SDL_Quit);
screen = SDL_SetVideoMode(WIDTH, HEIGHT, BPP, FLAGS);

/* load something on screen */
image = SDL_LoadBMP(“test.bmp”);
SDL_BlitSurface(image,NULL,screen,NULL);
SDL_Flip(screen);
SDL_Delay(5000);

/* backup display */
temp =
SDL_CreateRGBSurface(SDL_HWSURFACE,screen->w,screen->h,screen->format->BitsPerPixel,screen->format->Rmask,screen->format->Gmask,screen->format->Bmask,screen->format->Amask);
SDL_BlitSurface(screen,NULL,temp,NULL);

/* change resolution */
screen = SDL_SetVideoMode(WIDTH, HEIGHT, BPP, FLAGS);

/* restore old screen */
SDL_BlitSurface(temp,NULL,screen,NULL);
SDL_Flip(screen);
SDL_Delay(5000);

SDL_FreeSurface(temp);
SDL_FreeSurface(image);
SDL_FreeSurface(screen);
exit(0);
}

Donny Viszneki wrote:

you’d do something like this

SDL_Surface *temp = SDL_CreateRGBSurface(flags, width, height, depth,
screen->rmask, screen->gmask, screen->bmask, screen->amask);
SDL_BlitSurface(screen, NULL, temp, NULL);
SDL_SetVideoMode(…)
SDL_BlitSurface(temp, NULL, screen, ???);

flags, width, height, and depth depend on your display format

??? you might want to set up an SDL_Rect for, but i think you MIGHT be
able to pass NULL but I don’t really know so just try it and see if it
works if you’d like

Doesn’t work for me, must have something todo with
DirectX+Fullscreen+Doublebuffer :frowning:
Here is my simple example code to test it:

#include <SDL.h>

#define WIDTH 800
#define HEIGHT 600
#define BPP 32
#define FLAGS (SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN)

int main(int argc, char *argv[]) {
SDL_Surface *screen;
SDL_Surface *temp;
SDL_Surface *image;

SDL_Init(SDL_INIT_TIMER|SDL_INIT_VIDEO);
atexit(SDL_Quit);
screen = SDL_SetVideoMode(WIDTH, HEIGHT, BPP, FLAGS);

/* load something on screen */
image = SDL_LoadBMP(“test.bmp”);
SDL_BlitSurface(image,NULL,screen,NULL);
SDL_Flip(screen);
SDL_Delay(5000);

/* backup display */
temp =
SDL_CreateRGBSurface(SDL_HWSURFACE,screen->w,screen->h,screen->format->Bits
PerPixel,screen->format->Rmask,screen->format->Gmask,screen->format->Bmask,s
creen->format->Amask); SDL_BlitSurface(screen,NULL,temp,NULL);

You use a hardware surface to backup the screen. But maybe you should try to
use a software surface here. I recall that DirectX loses hardware surfaces on
certain occations and a resolution change is a likely candidate. I’m not 100%
sure now, but I think that it’s worth a try.

/* change resolution */
screen = SDL_SetVideoMode(WIDTH, HEIGHT, BPP, FLAGS);

/* restore old screen */
SDL_BlitSurface(temp,NULL,screen,NULL);
SDL_Flip(screen);
SDL_Delay(5000);

SDL_FreeSurface(temp);
SDL_FreeSurface(image);
SDL_FreeSurface(screen);
exit(0);
}


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

GregorOn Monday 13 September 2004 02:27, Michael Prager wrote: