[SDL] RE: Parashute

alteest alteest at rambler.ru
Mon Jul 22 19:17:01 PDT 2002


i have some troubble:
when i try do something with

SDL_Surface *screen;

after intialization and create main window (it's ok), later (something other
with "screen") i resieve:

"Fatal signal Segmentation Fault (SDL Parashute Deployed)"

i can't do anything with "screen". i download last sdl libs - nothing.
what to do?

this is code:

#include "sdl.h"

int fullscreen = 0;

BOOL CreateServerWindow(char* title, int width, int height, int bits, BOOL
fullscreenflag)
{
	Uint32 flags;
	flags = SDL_HWSURFACE|SDL_DOUBLEBUF; // I tried with different flags
	if ( fullscreenflag )
		flags |= SDL_FULLSCREEN;
	if ( SDL_SetVideoMode(width, height, bits, flags) == NULL )
		return FALSE;
	SDL_WM_SetCaption(title, NULL);
	return TRUE;
}


BOOL SetWindowWhite(SDL_Surface *screen)
{
	SDL_Rect rect;
	rect.x = 20;
	rect.y = 20;
	rect.w = 50;
	rect.h = 50;
	Uint32 white;
	SDL_PixelFormat *frmt;
	.
	.
	if ( SDL_MUSTLOCK(screen) ) {
		if ( SDL_LockSurface(screen) < 0 ) { // HERE IS GOES IN ERROR
			fprintf(stderr, "Can't lock screen: %s\n", SDL_GetError());
			return FALSE;
		}
	}
	.
	.
    return TRUE;
}

void SDLInit()
{
	int i, done;
	SDL_Event event;
	SDL_Surface *screen;

	if (SDL_Init(SDL_INIT_VIDEO) < 0) {
		fprintf(stderr, "Couldn't initialize SDL; %s\n", SDL_GetError());
		exit(1);
	}
	atexit(SDL_Quit);
	if (!CreateServerWindow("server", 640, 480, 16, fullscreen)) {
		fprintf(stderr, "Couldn.t set 640x480x16 video mode: %s\n", SDL_GetError);
		SDL_Quit();
		exit(1);
	}
	if (!SetWindowWhite(screen))
		exit(1);
	done = 0;
	while (!done) {
		while(SDL_PollEvent(&event)) {
			if (event.type == SDL_QUIT)
				done = 1;
			if (event.type == SDL_KEYDOWN)
				if (event.key.keysym.sym == SDLK_SPACE) {
					done = 1;
				}
		}
	}
	SDL_Quit();
}





More information about the SDL mailing list