bool Engine::init() {
	if (!app) {
		Log::print("App not informed");
		return false;
	}

	if (!initSDL()) {
		return false;
	}

	setupOpenGL();

	if (!initSDLWindow()) {
		return false;
	}

	if (!initSDLGLContext()) {
		return false;
	}

	if (!initGLEW()) {
		return false;
	}

	printVersions();

	if (!app->init()) {
		return false;
	}

	reshape();

	return true;
}
Beispiel #2
0
int main(int argc, char** argv) {

    SDL_Surface *screen;
    screen = initSDLWindow();
    editEvent(screen);
    SDL_Quit();

    return (EXIT_SUCCESS);
}
Beispiel #3
0
// -----------------------------------------------------------------------------
Window::Window()
    : sdlWindow(nullptr), context(nullptr), scene(nullptr),
      eventTimerId(0), fpsTimerId(0), keyboardManager(this), running(true),
      frameCounter(0)  {
  initSDLWindow();
}
Beispiel #4
0
//MAIN//
int main( int argc, char* args[] ) {
	//Init Rand to clock 
	srand ( time(NULL) );	
    //Initialize Window
    initSDLWindow( SCREENWIDTH, SCREENHEIGHT, SCREENBPP );
	
    //Load Files
	loadFiles();
	//Create Text
	createText();
	
	//Init classes
    Timer fps;
	Level *theLevel;


    //GAME LOOP//
    while( run ) {
        //Start the frame timer
        fps.start();

		//Init Events for keyboard 
		initSDLEvents();
		
        //Apply the background
        applySurface( 0, 0, background, screen, NULL );
		//MENU
		if ( menu ) {
			applySurface( ( SCREENWIDTH - menuTitle->w ) / 2, (SCREENHEIGHT / 5), menuTitle, screen, NULL );
			applySurface( ( SCREENWIDTH - menuScreen->w ) / 2, (SCREENHEIGHT / 6)*4, menuScreen, screen, NULL );
			if (initSDLEvents() == 'e') {
				menu = 0;
				game = 1;
				theLevel = new Level(screen, SCREENWIDTH, SCREENHEIGHT);
			}
	
		}//MENU END
		//GAME
		if ( game ) {
			
			if ((theLevel->play(frame)) == true) {
				menu = 1;
				game = 0;
				delete theLevel;
			}
			
		}//GAME END

        //Update the screen
        if( SDL_Flip( screen ) == -1 ) {
            return 1;
        }
		//Set frame rate
		setTimer( fps, FRAMESPERSECOND, frame, true );
		
		//check for quit
		checkQuit(initSDLEvents());	
    }//GAME LOOP END//
	
    //Clean up
	quitSDL();
	
    return 0;
}//END MAIN//