mirror of https://github.com/encounter/SDL.git
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.
This commit is contained in:
parent
32f909f7e3
commit
178c95f82c
|
@ -352,7 +352,7 @@ source file, such as, "main.cpp".
|
||||||
your project, and open the file in Visual C++'s text editor.
|
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.
|
7. Copy and paste the following code into the new file, then save it.
|
||||||
|
|
||||||
|
```c
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
@ -361,29 +361,32 @@ your project, and open the file in Visual C++'s text editor.
|
||||||
SDL_Window * window = NULL;
|
SDL_Window * window = NULL;
|
||||||
SDL_Renderer * renderer = NULL;
|
SDL_Renderer * renderer = NULL;
|
||||||
SDL_Event evt;
|
SDL_Event evt;
|
||||||
|
SDL_bool keep_going = SDL_TRUE;
|
||||||
|
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
} else if (SDL_GetCurrentDisplayMode(0, &mode) != 0) {
|
||||||
|
return 1;
|
||||||
if (SDL_GetCurrentDisplayMode(0, &mode) != 0) {
|
} else if (SDL_CreateWindowAndRenderer(mode.w, mode.h, SDL_WINDOW_FULLSCREEN, &window, &renderer) != 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_CreateWindowAndRenderer(mode.w, mode.h, SDL_WINDOW_FULLSCREEN, &window, &renderer) != 0) {
|
while (keep_going) {
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
while (SDL_PollEvent(&evt)) {
|
while (SDL_PollEvent(&evt)) {
|
||||||
|
if ((evt.type == SDL_KEYDOWN) && (evt.key.keysym.sym == SDLK_ESCAPE)) {
|
||||||
|
keep_going = SDL_FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
|
SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
|
||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
SDL_Quit();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
#### 6.B. Adding code and assets ####
|
#### 6.B. Adding code and assets ####
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue