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
|
bool Lanceur::init() {
int larg = opt->getInteger(OPTION_NAME_LARGEUR);
int haut = opt->getInteger(OPTION_NAME_HAUTEUR);
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
cerr << "Impossible d'initialiser SDL " << SDL_GetError() << endl;
return false;
}
if (SDL_SetVideoMode(larg, haut, 32, SDL_OPENGL | SDL_HWSURFACE) == NULL) {
cerr << "Impossible de définir la surface de l'écran" << endl;
return false;
}
/* Mettre en place le double buffer */
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //noir
glClearDepth(1.0);
glDepthFunc( GL_LEQUAL );
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
/* Selectionne le type de transparence */
glBlendFunc( GL_SRC_ALPHA, GL_ONE );
glEnable(GL_BLEND); // Active la transparence
glMatrixMode(GL_PROJECTION); // On selectionne la matrice de Projection
glLoadIdentity(); // On la reinitialise
glViewport(0,0,larg,haut); // On réinitialise notre ViewPort
glOrtho(0.0f,larg,haut,0,-100.0f,100.0f); // On définit notre vue orthogonale
glMatrixMode(GL_MODELVIEW); // On sélectionne la matrice des modèles
glLoadIdentity(); // On la réinitialise
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
return true;
} |
Partager