Problem with CreateRGBSurface an blitting

Hi,

I want to load a bitmap, blit it to a temporare surface and then blit the temp surface to the screen.
But the screen keeps black.
What am I doing wrong?

Bye, Matthias

#include <stdlib.h>
#include <stdio.h>

#include “SDL.h”

#define SCREEN_X (800)
#define SCREEN_Y (600)
#define SCREEN_DEPTH (8)

SDL_Surface *screen;
SDL_Surface *tile_surf;
SDL_Surface *board_surf;
SDL_Rect rect;

int
main( void )
{
if (SDL_Init (SDL_INIT_VIDEO) < 0)
{
fprintf (stderr, “SDL konnte nicht initialisiert werden: %s\n”, SDL_GetError ());
exit( EXIT_FAILURE );
}

atexit (SDL_Quit);

screen = SDL_SetVideoMode (SCREEN_X, SCREEN_Y, 8, SDL_HWSURFACE|SDL_HWPALETTE);

if (screen == NULL)
{
	fprintf (stderr, "Couldn't set %dx%d video mode: %s\n", SCREEN_X , SCREEN_Y, SDL_GetError ());
	exit (EXIT_FAILURE);
}

tile_surf = SDL_LoadBMP ( "wall.bmp" );

if (tile_surf == NULL)
{
	fprintf (stderr, "Couldn't load %s\n", SDL_GetError ());
	exit (EXIT_FAILURE);
}

board_surf = SDL_CreateRGBSurface(SDL_HWSURFACE , SCREEN_X , SCREEN_Y ,
				SCREEN_DEPTH,
				screen->format->Rmask,
				screen->format->Gmask,
				screen->format->Bmask,
				screen->format->Amask);

if ( SDL_BlitSurface( tile_surf, NULL, board_surf, NULL) <0 )
{
	fprintf (stderr, "Couldn't blit surface %s\n", SDL_GetError ());
	exit (EXIT_FAILURE);
}

if ( SDL_BlitSurface( board_surf , NULL, screen, NULL) <0 )
{
	fprintf (stderr, "Couldn't blit surface %s\n", SDL_GetError ());
	exit (EXIT_FAILURE);
}

SDL_Flip( screen );
SDL_Delay(2000);
SDL_FreeSurface( tile_surf );
SDL_FreeSurface( board_surf );
return EXIT_SUCCESS;

}

Matthias Rustler wrote:

[…]

board_surf = SDL_CreateRGBSurface(SDL_HWSURFACE , SCREEN_X , SCREEN_Y ,
SCREEN_DEPTH,
screen->format->Rmask,
screen->format->Gmask,
screen->format->Bmask,
screen->format->Amask);

From the SDL_CreateRGBSurface manpage :

If depth is 8 bits an empty palette is allocated for the surface
notice you have an empty palette by default

Stephane