So I'm trying to display a bus image with the SDL library, but when I use the function SDL_BlitSurface () I do not use anything, and what I get is a black screen. I should also keep in mind that I have a .bmp file, source and executable file in the same directory.
// SDL header #include "SDL / SDL.h" int main (int argc, char * args []) // // SDL starts SDL_Init (SDL_INIT_EVERYTHING); // SDL Surfaces are images that are going to be displayed. SDL_Surface * Hello = Faucet; SDL_Surface * screen = faucet; // sets the size of the window (length, height, color (bits), sets the surface in the software memory) screen = SDL_SetVideoMode (640, 480, 32, SDL_ SWSURFACE); // Load a .bmp image Hello = SDL_LoadBMP ("Hello.bmp"); // Apply loaded image to screen SDL_BlitSurface (hello, tap, screen, tap); // update screen sdl_flip (screen); // stop SDL Della (2000); // Removes the loaded image from memory SDL_FreeSurface (Hello); // SDL exit SDL_Quit (); Return 0; }
loadbump () is nonsense Install the SDL_image library
install sudo apt-get SDL_image SDL_image_dev (Not sure about package names. Just use appropriate or synaptic To search or do anything
and include it in
#include "SDL_image.h" you load your image >
SDL_Surface * Hello = IMG_Load ("Hello.bmp"); if (Hello!) {Printf ("Oops, something went wrong Done:% s \ n ", IMG_GetError ()); Exit (0);} Important Note: Note that you should always check the error and print the error. if (!) is if (Hello == faucet) / Code>
Comments
Post a Comment