Created
July 19, 2012 00:17
-
-
Save Twinklebear/3139888 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main(int argc, char** argv){ | |
if (SDL_Init(SDL_INIT_EVERYTHING) == -1){ | |
std::cout << SDL_GetError() << std::endl; | |
return 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SDL_Window *win = nullptr; | |
win = SDL_CreateWindow("Hello World!", 100, 100, 640, 480, SDL_WINDOW_SHOWN); | |
if (win == nullptr){ | |
std::cout << SDL_GetError() << std::endl; | |
return 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SDL_Renderer *ren = nullptr; | |
ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); | |
if (ren == nullptr){ | |
std::cout << SDL_GetError() << std::endl; | |
return 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SDL_Surface *bmp = nullptr; | |
bmp = SDL_LoadBMP("../res/Lesson1/hello.bmp"); | |
if (bmp == nullptr){ | |
std::cout << SDL_GetError() << std::endl; | |
return 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SDL_Texture *tex = nullptr; | |
tex = SDL_CreateTextureFromSurface(ren, bmp); | |
SDL_FreeSurface(bmp); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SDL_RenderClear(ren); | |
SDL_RenderCopy(ren, tex, NULL, NULL); | |
SDL_RenderPresent(ren); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SDL_Delay(2000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SDL_DestroyTexture(tex); | |
SDL_DestroyRenderer(ren); | |
SDL_DestroyWindow(win); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SDL_Quit(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment