README-winrt.md: Cleaned up sample code - Fixed the markdown. - Code can now be exited by pressing ESC. - Cleans up and returns from main() - Mushed all the `if (x) { return 0; }` blocks into else ifs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
diff --git a/docs/README-winrt.md b/docs/README-winrt.md
index 73ef372..6d22ede 100644
--- a/docs/README-winrt.md
+++ b/docs/README-winrt.md
@@ -352,38 +352,41 @@ source file, such as, "main.cpp".
your project, and open the file in Visual C++'s text editor.
7. Copy and paste the following code into the new file, then save it.
-
- #include <SDL.h>
-
- int main(int argc, char **argv)
- {
- SDL_DisplayMode mode;
- SDL_Window * window = NULL;
- SDL_Renderer * renderer = NULL;
- SDL_Event evt;
-
- if (SDL_Init(SDL_INIT_VIDEO) != 0) {
- return 1;
- }
+```c
+#include <SDL.h>
- if (SDL_GetCurrentDisplayMode(0, &mode) != 0) {
- return 1;
- }
+int main(int argc, char **argv)
+{
+ SDL_DisplayMode mode;
+ SDL_Window * window = NULL;
+ SDL_Renderer * renderer = NULL;
+ SDL_Event evt;
+ SDL_bool keep_going = SDL_TRUE;
+
+ if (SDL_Init(SDL_INIT_VIDEO) != 0) {
+ return 1;
+ } else if (SDL_GetCurrentDisplayMode(0, &mode) != 0) {
+ return 1;
+ } else if (SDL_CreateWindowAndRenderer(mode.w, mode.h, SDL_WINDOW_FULLSCREEN, &window, &renderer) != 0) {
+ return 1;
+ }
- if (SDL_CreateWindowAndRenderer(mode.w, mode.h, SDL_WINDOW_FULLSCREEN, &window, &renderer) != 0) {
- return 1;
+ while (keep_going) {
+ while (SDL_PollEvent(&evt)) {
+ if ((evt.type == SDL_KEYDOWN) && (evt.key.keysym.sym == SDLK_ESCAPE)) {
+ keep_going = SDL_FALSE;
+ }
}
- while (1) {
- while (SDL_PollEvent(&evt)) {
- }
-
- SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
- SDL_RenderClear(renderer);
- SDL_RenderPresent(renderer);
- }
+ SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
+ SDL_RenderClear(renderer);
+ SDL_RenderPresent(renderer);
}
+ SDL_Quit();
+ return 0;
+}
+```
#### 6.B. Adding code and assets ####