first commit
This commit is contained in:
		
						commit
						2b67dc0dc6
					
				
					 2 changed files with 74 additions and 0 deletions
				
			
		
							
								
								
									
										26
									
								
								Makefile
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								Makefile
									
										
									
									
									
										Normal file
									
								
							|  | @ -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) | ||||||
							
								
								
									
										48
									
								
								src/main.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								src/main.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,48 @@ | ||||||
|  | //include SDL2 and stdio libs
 | ||||||
|  | #include <SDL2/SDL.h> | ||||||
|  | #include <stdio.h> | ||||||
|  | 
 | ||||||
|  | //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; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue