Created
June 7, 2023 21:22
-
-
Save chastitywhiterose/bc7c4cc05fb46c8d754fefa2ebd20c01 to your computer and use it in GitHub Desktop.
Blank SDL program to test if compiling is working correctly.
This file contains hidden or 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
| #include <stdio.h> | |
| #include <SDL.h> | |
| int width=1280,height=720; | |
| int loop=1; | |
| SDL_Window *window; | |
| SDL_Surface *surface; | |
| SDL_Event e; | |
| int main(int argc, char **argv) | |
| { | |
| window=SDL_CreateWindow("SDL Program",SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,width,height,SDL_WINDOW_SHOWN ); | |
| if(window==NULL){printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );return -1;} | |
| surface = SDL_GetWindowSurface( window ); /*get surface for this window*/ | |
| SDL_FillRect(surface,NULL,0xFF00FF); | |
| SDL_UpdateWindowSurface(window); | |
| printf("SDL Program Compiled Correctly\n"); | |
| while(loop) | |
| { | |
| while(SDL_PollEvent(&e)) | |
| { | |
| if(e.type == SDL_QUIT){loop=0;} | |
| if(e.type == SDL_KEYUP) | |
| { | |
| if(e.key.keysym.sym==SDLK_ESCAPE){loop=0;} | |
| } | |
| } | |
| } | |
| SDL_DestroyWindow(window); | |
| SDL_Quit(); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment