#ifdef WIN32 #pragma comment(lib, "SDL.lib") #pragma comment(lib, "SDLmain.lib") #endif #include "SDL.h" #include <iostream> using namespace std; int main(int argc, char *argv[]) { SDL_Surface *screen; // En yta // Initiera SDL if ( SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0 ) { cout << "Error, unable to initialize SDL: " << SDL_GetError() << endl; SDL_Quit(); return 1; } else { cout << "SDL initialized successfully!" << endl; } screen = SDL_SetVideoMode(640, 480, 16, SDL_HWSURFACE|SDL_DOUBLEBUF); if (screen == NULL) { cout << "Unable to set video mode: " << SDL_GetError() << endl; SDL_Quit(); return 1; } else { cout << "Successfully set video mode!" << endl; } // Rita ut en bild SDL_Surface* image; image = SDL_LoadBMP("test.bmp"); if (image == NULL) { cout << "Image could not be loaded!" << endl; SDL_Quit(); return 1; } SDL_BlitSurface(image, NULL, screen, NULL); SDL_Flip(screen); SDL_Delay(2000); // Pausar i 2000 ms (2 sekunder) // Stäng ner SDL och frigör resurser SDL_Quit(); return 0; }
Källa: http://blinkenlights.se/