Código:
// ! u+21
// & u+26
// | u+7c
// % u+25
// Ʃ u+1a9
//\ u+5c 'u+27
#include<iostream>
#include<SDL2/SDL.h>
#include<SDL2/SDL_image.h>
using namespace std;
const int SCREEN_WIDTH = 1900;
const int SCREEN_HEIGHT = 1080;
SDL_Event tecla;
// g++ enginere.cpp -w -lSDL2 -lSDL2_image -lSDL2_gfx -o enginere
void iniciar();
//SDL_Init(SDL_INIT_VIDEO)
int main(int argc, char *argv[]){
SDL_Window*window = SDL_CreateWindow("juego", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,SCREEN_WIDTH,SCREEN_HEIGHT,SDL_WINDOW_FULLSCREEN_DESKTOP);
SDL_Renderer * renderer = SDL_CreateRenderer(window, -1, 0);
SDL_Surface * image = IMG_Load("fondo.png");
SDL_Texture * texture = SDL_CreateTextureFromSurface(renderer, image);
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);
while(true){
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);
while (SDL_PollEvent(&tecla)) {
if (tecla.type == SDL_QUIT) {
SDL_DestroyTexture(texture);
SDL_FreeSurface(image);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
exit(0);
}
}
}
return 0;
}
void iniciar(){
if(SDL_Init(SDL_INIT_VIDEO)<0){
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,"Error inciando subsistema","Se produjo un error cargando el subsitema de video, porfavor , vuelva a iniciar el juego ",NULL);
exit(1);
}
}