From 2b67dc0dc64a8c428f7ae732828fd2c1e03f7eaf Mon Sep 17 00:00:00 2001 From: Mark B Date: Sun, 1 Aug 2021 13:11:40 -0400 Subject: [PATCH] first commit --- Makefile | 26 ++++++++++++++++++++++++++ src/main.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 Makefile create mode 100644 src/main.cpp diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3f0f382 --- /dev/null +++ b/Makefile @@ -0,0 +1,26 @@ +#COPYRIGHT no one cares lol + +#files to compile + +OBJS = src/main.cpp + +#compiler to use + +CC = g++ + +#comp flags lul + +COMPILER_FLAGS = -w + +#libs we linkin bro + +LINKER_FLAGS = -lSDL2 + +#name of muh bin lel + +OBJ_NAME = SDL2TEST1 + +#no regerts cuz its all together now + +all : $(OBJS) + $(CC) $(OBJS) $(COMPILER_FLAGS) $(LINKER_FLAGS) -o $(OBJ_NAME) diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..ff7b991 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,48 @@ +//include SDL2 and stdio libs +#include +#include + +//window size +const int SCREEN_WIDTH = 640; +const int SCREEN_HEIGHT = 480; + +int main( int argc, char* args[] ){ + //makes the window to use + SDL_Window* window = NULL; + + //makes the surface of the window + SDL_Surface* screenSurface = NULL; + + //Start SDL + if( SDL_Init( SDL_INIT_VIDEO ) < 0 ){ + printf("Ooops SDL could not start! SDL_Error: %s\n", SDL_GetError() ); + } else { + //make window + window = SDL_CreateWindow( "My First SDL2 Program", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN ); + if( window == NULL ){ + printf("Oh no the Window could not be made! SDL_Error: %s\n", SDL_GetError() ); + } else { + //Get window surface + screenSurface = SDL_GetWindowSurface( window ); + + //Display white in the window + SDL_FillRect( screenSurface, NULL, SDL_MapRGB( screenSurface->format, 0xff, 0xff, 0xff ) ); + + //Update the surface + SDL_UpdateWindowSurface( window ); + + //wait five seconds + SDL_Delay( 5000 ); + } + } + + //Close Window + SDL_DestroyWindow( window ); + + //End SDL + SDL_Quit(); + + return 0; +} + +