breakout

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit e8a1ef116dc08bce468d05b076e35ccbe51006e6
parent 6527f56ebd7adfbab0ce25c11d7b4676bc79f983
Author: Christopher Ray Langford <chris@hellocld.com>
Date:   Sun, 25 Aug 2019 17:24:14 -0400

Creates a window and fills it with an ugly color

Diffstat:
Msrc/main.c | 37++++++++++++++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/src/main.c b/src/main.c @@ -1,5 +1,11 @@ #include "SDL.h" +#define WINDOW_W 320 +#define WINDOW_H 240 + +SDL_Window *window; +SDL_Renderer *renderer; + int main(int argc, char *argv[]) { if(SDL_Init(SDL_INIT_EVERYTHING) < 0) { @@ -8,9 +14,38 @@ int main(int argc, char *argv[]) } SDL_Log("SDL initialized successfully\n"); + SDL_version compiled, linked; + SDL_VERSION(&compiled); + SDL_GetVersion(&linked); + SDL_Log("Compiled with %d.%d.%d\n", compiled.major, compiled.minor, compiled.patch); + SDL_Log("Linked against %d.%d.%d\n", linked.major, linked.minor, linked.patch); + + window = SDL_CreateWindow( + "BREAKOUT", + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + WINDOW_W, + WINDOW_H, + 0 + ); + if(window == NULL) { + SDL_Log("Failed to create window: %s\n", SDL_GetError()); + return 1; + } + + renderer = SDL_CreateRenderer(window, -1, 0); + if(renderer == NULL) { + SDL_Log("Failed to create renderer: %s\n", SDL_GetError()); + return 1; + } + + SDL_SetRenderDrawColor(renderer, 128, 255, 192, 255); + SDL_RenderClear(renderer); + SDL_RenderPresent(renderer); SDL_Delay(1000); - SDL_Quit(); + SDL_DestroyWindow(window); + SDL_Quit(); return 0; }