Skip to content
Snippets Groups Projects
Commit 3291bc79 authored by Alfred Burgess's avatar Alfred Burgess
Browse files

Got a basic window working

parent 652dcd6c
Branches
No related merge requests found
......@@ -14,7 +14,7 @@ Chunk::~Chunk()
void Chunk::generate(){ this->generate_random(); }
void Chunk::generate_random()
{
this->_logger.info( "Generating Chunk at "+this->getLocationString()+" - Random" );
// this->_logger.info( "Generating Chunk at "+this->getLocationString()+" - Random" );
this->wealth = rand();
this->weirdness = rand();
......
......@@ -19,12 +19,29 @@ int main( int argc, char* argv[] ) {
SDL_Surface* screenSurface = NULL;
//Initialize SDL
//if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
//{
//// printf( "SDL could not initialize! SDL_Error: \n%s\n", SDL_GetError() );
//}
if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
// printf( "SDL could not initialize! SDL_Error: \n%s\n", SDL_GetError() );
logger.error( "Failed to initialise SDL" );
return 1;
}
window = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
if( window == NULL )
{
printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );
} else {
//Get window surface
screenSurface = SDL_GetWindowSurface( window );
//Fill the surface white
SDL_FillRect( screenSurface, NULL, SDL_MapRGB( screenSurface->format, 0xFF, 0xFF, 0xFF ) );
//Update the surface
SDL_UpdateWindowSurface( window );
//Hack to get window to stay up
SDL_Event e; bool quit = false; while( quit == false ){ while( SDL_PollEvent( &e ) ){ if( e.type == SDL_QUIT ) quit = true; } }
}
// Genrate a Random chunk
WorldHex2D map( 5 );
//Chunk* chunk = new Chunk( 0, 0, 0);
......@@ -58,7 +75,12 @@ int main( int argc, char* argv[] ) {
}
// Clean-up
//Destroy window
SDL_DestroyWindow( window );
//Quit SDL subsystems
SDL_Quit();
// Return
logger.info( "Process Ending" );
return 0;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment