1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
bool Window::init()
{
if( SDL_Init( SDL_INIT_EVERYTHING ) < 0 )
{
std::cout << "ERROR: could not initialize SDL" << std::endl;
}
SDL_GL_SetAttribute(SDL_GL_RED_SIZE,8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE,8);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,16);
SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE,32);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);
if(fullscreen)
{
if( SDL_SetVideoMode( WIDTH, HEIGHT, BPP, SDL_DOUBLEBUF|SDL_HWSURFACE|SDL_FULLSCREEN|SDL_OPENGL ) == NULL )
{
std::cout << "ERROR: could not setup a window" << std::endl;
return false;
}
}
else
{
if( SDL_SetVideoMode( WIDTH, HEIGHT, BPP, SDL_DOUBLEBUF|SDL_HWSURFACE ) == NULL )
{
std::cout << "ERROR: could not setup a window" << std::endl;
return false;
}
}
SDL_WM_SetCaption( CONSTANTS::window::CAPTION, NULL );
glClearColor(0.0f,0.0f,0.0f,1.0f);
glViewport( 0, 0, CONSTANTS::window::WIDTH, CONSTANTS::window::HEIGHT);
glOrtho( 0, CONSTANTS::window::WIDTH, CONSTANTS::window::HEIGHT, 0, -1, 1 );
glDisable(GL_DEPTH_TEST);
glDisable(GL_COLOR_MATERIAL);
glEnable(GL_BLEND);
glShadeModel(GL_SMOOTH);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
return true;
}
| |