SDL fails on SetVideoMode

Hi all,

I use SDL 1.2. Here is a sample of my code:

if((image->w != screen->w) || (image->h != screen->h))
{
screen->w = image->w;
screen->h = image->h;
screen = SDL_SetVideoMode(image->w, image->h, 16,
SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_RESIZABLE);
}

When image->w > screen->w or image->h > screen->h, I get a segmentation fault.
Could you help me, please?

Kat

Kat wrote:

Hi all,

I use SDL 1.2. Here is a sample of my code:

if((image->w != screen->w) || (image->h != screen->h))
{
screen->w = image->w;
screen->h = image->h;
screen = SDL_SetVideoMode(image->w, image->h, 16,
SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_RESIZABLE);
}

if((image->w != screen->w) || (image->h != screen->h))
{
// screen->w = image->w;
// screen->h = image->h;
screen = SDL_SetVideoMode(image->w, image->h, 16,
SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_RESIZABLE);
}

  • Tom

Kat wrote:

Hi all,

I use SDL 1.2. Here is a sample of my code:

if((image->w != screen->w) || (image->h != screen->h))
{
screen->w = image->w;
screen->h = image->h;
screen = SDL_SetVideoMode(image->w, image->h, 16,
SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_RESIZABLE);
}

When image->w > screen->w or image->h > screen->h, I get a segmentation fault.
Could you help me, please?

Kat
Hi,
is it possible that some of the pointers, “image” or “screen” are NULL? Then you are getting
segfault by dereferencing one of them.

Try this:
if (image != NULL && screen != NULL)
{

}

Greetings,
Alex Ellwein

The with and height are set automatically in a surface. Probably the
SDL internal functions, when working with the screen are trying to access a
pixel that is outside the actual area of the screen. That’s why you get the
segmentation fault only when you make manually the screen surface larger.

Remove both assigments of the width and height and try again.++++++++++++++++++++++++++++++++

ALBERT FERNANDEZ MARSAL
CIRSA INTERACTIVE CORP. SL
Analista senior y programador
++++++++++++++++++++++++++++++++

-----Mensaje original-----
De: sdl-bounces+afmarsal=cirsa.com at libsdl.org
[mailto:sdl-bounces+afmarsal=cirsa.com at libsdl.org] En nombre de Kat
Enviado el: domingo, 09 de octubre de 2005 23:27
Para: sdl at libsdl.org
Asunto: [SDL] SDL fails on SetVideoMode

Hi all,

I use SDL 1.2. Here is a sample of my code:

if((image->w != screen->w) || (image->h != screen->h))
{
screen->w = image->w;
screen->h = image->h;
screen = SDL_SetVideoMode(image->w, image->h, 16,
SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_RESIZABLE);
}

When image->w > screen->w or image->h > screen->h, I get a segmentation
fault.
Could you help me, please?

Kat


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

Ok, I’ll try this.

Thanks

----Message d’origine----
SDL-announce)’"

Sujet: RE: [SDL] SDL fails on SetVideoMode

The with and height are set automatically in a surface. Probably the
SDL internal functions, when working with the screen are trying to access
a
pixel that is outside the actual area of the screen. That’s why you get
the>De: Albert FernA!ndez Marsal
A: "'A list for developers using the SDL library. (includes
Date: Mon, 10 Oct 2005 12:52:40 +0200
segmentation fault only when you make manually the screen surface larger.

Remove both assigments of the width and height and try again.

++++++++++++++++++++++++++++++++
ALBERT FERNANDEZ MARSAL
CIRSA INTERACTIVE CORP. SL
Analista senior y programador
++++++++++++++++++++++++++++++++

-----Mensaje original-----
De: sdl-bounces+afmarsal=cirsa.com@libsdl.org
[mailto:sdl-bounces+afmarsal=cirsa.com@libsdl.org] En nombre de Kat
Enviado el: domingo, 09 de octubre de 2005 23:27
Para: sdl@libsdl.org
Asunto: [SDL] SDL fails on SetVideoMode

Hi all,

I use SDL 1.2. Here is a sample of my code:

if((image->w != screen->w) || (image->h != screen->h))
{
screen->w = image->w;
screen->h = image->h;
screen = SDL_SetVideoMode(image->w, image->h, 16,
SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_RESIZABLE);
}

When image->w > screen->w or image->h > screen->h, I get a segmentation
fault.
Could you help me, please?

Kat


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


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