Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SDL/SDL.h>
- #include <stdio.h>
- int main(int argc, char* args[])
- {
- SDL_Window* window = NULL;
- SDL_Surface* window_surface = NULL;
- SDL_Surface* background_surface = NULL;
- SDL_Surface* button_surface = NULL;
- SDL_Surface* image_3 = NULL;
- if (SDL_Init(SDL_INIT_VIDEO) < 0)
- {
- printf("SDL did not init: %s\n", SDL_GetError());
- return 1;
- }
- window = SDL_CreateWindow("SDL example", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_SHOWN);
- if (window == NULL)
- {
- printf("Window could not be opened: %s\n", SDL_GetError());
- return 1;
- }
- window_surface = SDL_GetWindowSurface(window);
- background_surface = SDL_LoadBMP("./background.bmp");
- button_surface = SDL_LoadBMP("./button.bmp");
- image_3 = SDL_LoadBMP("./image3.bmp");
- SDL_Rect image_3_dest_rect;
- image_3_dest_rect.x = 200;
- image_3_dest_rect.y = 200;
- int running = 1;
- while (running)
- {
- SDL_Event sevent;
- while (SDL_PollEvent(&sevent))
- {
- switch (sevent.type)
- {
- case SDL_KEYDOWN:
- {
- if (sevent.key.keysym.sym == SDLK_ESCAPE)
- running = 0;
- break;
- }
- case SDL_QUIT:
- {
- running = 0;
- break;
- }
- }
- }
- SDL_BlitSurface(background_surface, NULL, window_surface, NULL);
- SDL_BlitSurface(button_surface, NULL, window_surface, NULL);
- SDL_BlitSurface(image_3, NULL, window_surface, &image_3_dest_rect);
- SDL_UpdateWindowSurface(window);
- }
- SDL_DestroyWindow(window);
- SDL_Quit();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement