#include <iostream>
#include "SDL2/SDL.h"
int main(int argc, char** argv){
if (SDL_Init(SDL_INIT_EVERYTHING) == -1){
std::cout << SDL_GetError() << std::endl;
return 1;
}
SDL_Window *win = NULL;
win = SDL_CreateWindow("Hello World!", 100, 100, 640, 480, SDL_WINDOW_SHOWN);
if (win == NULL){
std::cout << SDL_GetError() << std::endl;
return 1;
}
SDL_Renderer *ren = NULL;
ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if (ren == NULL){
std::cout << SDL_GetError() << std::endl;
return 1;
}
SDL_Surface *bmp = NULL;
bmp = SDL_LoadBMP("hello.bmp");
if (bmp == NULL){
std::cout << SDL_GetError() << std::endl;
return 1;
}
SDL_Texture *tex = NULL;
tex = SDL_CreateTextureFromSurface(ren, bmp);
SDL_FreeSurface(bmp);
SDL_RenderClear(ren);
SDL_RenderCopy(ren, tex, NULL, NULL);
SDL_RenderPresent(ren);
SDL_Delay(2000);
SDL_DestroyTexture(tex);
SDL_DestroyRenderer(ren);
SDL_DestroyWindow(win);
SDL_Quit();
return 0;
}
lunes, 1 de julio de 2013
Hola Mundo III
Este último Hola Mundo vamos a utilizar la carga de imágenes. Debemos usar un .bmp estilo Windows a si que lo mejor es pillar el paint y guardar un "hello" como bmp y ponerlo en la misma carpeta del proyecto, si quieres guardarlo en alguna carpeta hay que cambiar la direccion.
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario