Last active
October 7, 2015 11:58
-
-
Save Twinklebear/3161759 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
//In main... | |
SDL_Texture *image = nullptr; | |
try { | |
image = LoadImage("../res/Lesson4/image.png"); | |
} | |
catch (const std::runtime_error &e){ | |
std::cout << e.what() << std::endl; | |
return 4; | |
} | |
int iW, iH; | |
SDL_QueryTexture(image, NULL, NULL, &iW, &iH); | |
int x = SCREEN_WIDTH / 2 - iW / 2; | |
int y = SCREEN_HEIGHT / 2 - iH / 2; |
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_Event e; |
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
bool quit = false; | |
while (!quit){ | |
//Our main loop |
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
//Event polling | |
while (SDL_PollEvent(&e)){ | |
//If user closes he window | |
if (e.type == SDL_QUIT) | |
quit = true; | |
//If user presses any key | |
if (e.type == SDL_KEYDOWN) | |
quit = true; | |
//If user clicks the mouse | |
if (e.type == SDL_MOUSEBUTTONDOWN) | |
quit = true; | |
} |
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
//Rendering | |
SDL_RenderClear(renderer); | |
//Draw the image | |
ApplySurface(x, y, image, renderer); | |
//Update the screen | |
SDL_RenderPresent(renderer); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment