Jump to content
  • Advertisement
Sign in to follow this  
thedevil

SDL wont work

This topic is 5017 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

im working under mandrake 10.0 under kdevelop. my code will compile but for some reason tha is unknown to me it SDL_LoadBMP just wont work. heres my code: /* Simple blitting with SDL */ #include <SDL/SDL.h> #include <stdio.h> #include <stdlib.h> int main() { SDL_Surface *screen; SDL_Surface *image; SDL_Rect src, dest; /* Initialise and check for errors */ if (SDL_Init(SDL_INIT_VIDEO) != 0) { printf("Could not initialise SDL: %s\n", SDL_GetError()); exit(EXIT_FAILURE); } /* Ensure SDL_Quit is called when the program ends */ atexit(SDL_Quit); /* Attempt to set a 1024 x 768 32 bit video mode. */ screen = SDL_SetVideoMode(1024, 768, 32, 0); if (screen == NULL) { printf("Could not set video mode: %s\n", SDL_GetError()); exit(EXIT_FAILURE); } /* Load the bitmap file. */ puts("got to image load"); image = SDL_LoadBMP("camp.bmp"); if (image == NULL) { printf("Unable to load bitmap\n"); exit(EXIT_FAILURE); } /* Setting the Rect's */ src.x = 0; src.y = 0; src.w = image->w; // copy the entire image src.h = image->h; dest.x = 0; dest.y = 0; dest.w = image->w; dest.h = image->h; /* Blit the bitmap to the screen. */ SDL_BlitSurface(image, &src, screen, &dest); /* Ask SDL to update the entire screen */ SDL_UpdateRect(screen, 0, 0, 0, 0); /* Pause for a bit */ SDL_Delay(3000); /* Free memory */ SDL_FreeSurface(image); } it also gives mt the following error - Xlib: extension "GLX" missing on display ":0.0" Xlib: extension "GLX" missing on display ":0.0" any help ?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
What do you mean by "it won't work"?
If yout program doesn't start, you could try to replace this line:
screen = SDL_SetVideoMode(1024, 768, 32, 0);
with this one:
screen = SDL_SetVideoMode(1024, 768, 0, 0);

Share this post


Link to post
Share on other sites
what i mean by it dosen't work is that it dosent diplay the picture.

for output it write's :
got to image load
unable to load bitmap

which means that everything's good but the LoadBMP function.

Share this post


Link to post
Share on other sites
SDL_GetERROR gives the following:

Couldn't load : Couldn't open bunny.bmp

even though it's in the same directory with the .c code file.

more help ?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!