Original Post
I'm fairly new with SDL. What I want to do is load an image and display it. For fast blitting, I convert it to the display format using SDL_DisplayFormat. Here's how I load my image: As I have indicated, I initialize SDL before executing this code. When I call SDL_SetVideoMode with flags SW_SURFACE, then everything works fine and the output appears to be correct: with = 76, height = 67, pitch = 304 When I call it with flags SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_FULLSCREEN, then I get the following: with = 76, height = 67, pitch = 320 pixels NULL! Why is the pixels data NULL in this case? The surface seems to be unusable that way. And why is pitch 320 instead of 304? (Note: 76 width * 4 depth = 304 pitch) Is it not possible to convert pixelformat to a hardware-surface? I thought it's just the same, converting to 4 byte color depth. I'm using WindowsXP, VisualStudio, Cpp, SDL for graphics and an NVIDIA GeForce FX 5200 graphics card, if it matters. Thanks for help! [smile]
// initialize SDL first...
SDL_Surface *image = IMG_Load("image.png"); // load image
if (image != NULL) {
// convert to display-native pixel format, for fast blitting
SDL_Surface *dfImage = SDL_DisplayFormat(image);
SDL_FreeSurface(image);
if (dfImage != NULL) {
LOG("with = " << dfImage->w << ", height = " << dfImage->h << ", pitch = " << dfImage->pitch);
if (dfImage->pixels == NULL)
LOG("pixels NULL!");
}
}