Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool init(){
- printf("Connecting to Pi Harness\t");
- if (wiringPiSetup () == -1){
- printf("Error Could not start wiringPiSetup\n");
- return false;
- }
- pinMode (0, INPUT) ; // aka BCM_GPIO pin 17
- //Coin Acceptor
- if(init_i2c() == false){
- printf("Error Could not start init_i2c\n");
- return false;
- }
- printf("loading sdl2 \n");
- if( SDL_Init( SDL_INIT_VIDEO ) < 0 ){
- printf( "SDL could not initialize! SDL Error: %s\n", SDL_GetError() );
- return false;
- }
- //Create window
- Window = SDL_CreateWindow( "SDL 2 ", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL );
- if( Window == NULL ){
- printf( "Window could not be created! SDL Error: %s\n", SDL_GetError() );
- return false;
- }
- //Initialize PNG loading
- int imgFlags = IMG_INIT_PNG;
- if( !( IMG_Init( imgFlags ) & imgFlags ) ){
- printf( "SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError() );
- return false;
- }
- //Initialize SDL_ttf
- if( TTF_Init() == -1 ){
- printf( "SDL_ttf could not initialize! SDL_ttf Error: %s\n", TTF_GetError() );
- return false;
- }
- //Create renderer for window
- Renderer = SDL_CreateRenderer( Window, -1, SDL_RENDERER_ACCELERATED );
- if( Renderer == NULL )
- {
- printf("Renderer could not be created! SDL Error: %s\n", SDL_GetError());
- return false;
- }
- //Initialize renderer color
- SDL_SetRenderDrawColor( Renderer, 0x77, 0x77, 0x77, 0xFF ); //gray?
- //Initialize SDL_mixer
- if( Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024 ) == -1 ) { printf( "SDL_mixer could not initialize! SDL_mixer Error: %s\n", Mix_GetError() ); return false; }
- //Load Files
- if(!loadMedia())
- {
- printf("failed to load graphics\n");
- return false;
- }
- printf("Game Loaded");
- //everything worked
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement