I have NO idea what-so-ever why this code doesn’t work
correctly.
I compile it like this:
[gdog at localhost sdl]$ gcc sdlbitmap.c -lSDL -ldl
[gdog at localhost sdl]$ ./a.out
Unable to map surface! :
SDL Warning: 1 SDL surfaces extant
[gdog at localhost sdl]$
What does that “SDL Warning: 1 SDL surfaces extant” mean?
Anyhow…I compile the source and run the app.
All I get is a blank window that is black and it complains about not
being able to map the surface. From what I can see I can’t notice any
errors in my code.
The image that I am loading in my program can be obtained here:
http://pknet.com/~gdog/fool.bmp.gz
I know that it’s a 256x256 BMP at 8 bits per pixel.
Other than that I have no clue at why all I see is just a black screen.
(black)
I am running in a 16 bit video mode under X windows.
Here is the source:
#include <SDL.h>
#include <stdio.h>
#include <stdlib.h>
main() {
SDL_Surface *bitmap;
SDL_Surface *screen;
atexit(SDL_Quit);
if(SDL_Init(SDL_INIT_VIDEO) < 0)
printf(“Can’t init SDL!\n”), exit(1);
bitmap = SDL_LoadBMP(“fool.bmp”);
if(bitmap == NULL)
printf(“Can’t load the damn bitmap!\n”), exit(1);
screen = SDL_SetVideoMode(bitmap->w + 5, bitmap->h + 5, 8,
SDL_SWSURFACE);
if(screen ==NULL)
printf(“Unable to Set the freaking video mode! %s\n”, SDL_GetError());
/* Set palette according to BMP file palette */
if(SDL_SetColors(screen, bitmap->format->palette->colors, 1,
bitmap->format->palette->ncolors) == 0)
printf(“Couldn’t set all the damn colors! : %s\n”, SDL_GetError());
if(SDL_MapSurface(bitmap, screen->format) == 0)
printf(“Unable to map surface! : %s\n”, SDL_GetError());
if(SDL_BlitSurface(bitmap, NULL, screen, NULL) == 0)
printf(“Unable to perform blit! : %s\n”, SDL_GetError());
SDL_UpdateRect(screen, 0, 0, 0, 0);
SDL_Delay(5000);
}
Oh yes. One more question.
Concerning the development of a Win32 version of SDL applications.
Do I need to get the Microsoft DirectX SDK and compile it under a Linux
environment. (assuming that I get the Win32 development
libraries…Where can I get those by the way?) or can I just have a
friend with MS Visual C++ download and compile SDL/ install it and then
I send him the source for my program and he compiles it with Visual C++
under Windows? Is the conceivable?
The reason I’m asking this question is because I noticed that you
included a PERL script that modifies parts of the DirectX SDK…and I
was curious if that would also be necessary if the development was done
under a Win32 environment…
Thanks,
Paul Lowe
xpaull at ultraviolet.org