Skip to content

Commit

Permalink
First test with SDL2 on OSX.
Browse files Browse the repository at this point in the history
  • Loading branch information
nbrignol committed Apr 9, 2014
1 parent 5a52cb4 commit 00aaa82
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 17 deletions.
18 changes: 1 addition & 17 deletions .gitignore
@@ -1,18 +1,2 @@
# Xcode
a.out
.DS_Store
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
*.xcworkspace
!default.xcworkspace
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
3 changes: 3 additions & 0 deletions buildAndRunOsx.sh
@@ -0,0 +1,3 @@
g++ -framework SDL2 src/test.cpp
./a.out

43 changes: 43 additions & 0 deletions src/test.cpp
@@ -0,0 +1,43 @@
#include <SDL2/SDL.h>
#include <iostream>

const int WINDOW_WIDTH = 640;
const int WINDOW_HEIGHT = 480;

int main( int argc, char* args[] )
{

std::cout << "Testing SDL2..." << std::endl;

SDL_Window * window = NULL;
SDL_Surface * screenSurface = NULL;

if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) {
std::cerr << "SDL init fail. SDL_Error : " << SDL_GetError() << std::endl;
SDL_Quit();
return 1;
}

window = SDL_CreateWindow( "INCREMENTALIST step 1", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN );

if( window == NULL ) {
std::cerr << "SDL CreateWindow fail. SDL_Error : " << SDL_GetError() << std::endl;
SDL_Quit();
return 1;
}

screenSurface = SDL_GetWindowSurface( window );

//Fill the surface with color
SDL_FillRect( screenSurface, NULL, SDL_MapRGB( screenSurface->format, 0xFF, 0xFF, 0xFF ) );
SDL_UpdateWindowSurface( window );

SDL_Delay( 2000 );

SDL_DestroyWindow( window );
SDL_Quit();

std::cout << "...Done testing SDL2." << std::endl;

return 0;
}

0 comments on commit 00aaa82

Please sign in to comment.