Skip to content

Instantly share code, notes, and snippets.

@chastitywhiterose
Created June 7, 2023 21:22
Show Gist options
  • Select an option

  • Save chastitywhiterose/bc7c4cc05fb46c8d754fefa2ebd20c01 to your computer and use it in GitHub Desktop.

Select an option

Save chastitywhiterose/bc7c4cc05fb46c8d754fefa2ebd20c01 to your computer and use it in GitHub Desktop.
Blank SDL program to test if compiling is working correctly.
#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