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
|
void Moteur3D::initialiserAffichage()
{
if(SDL_Init(SDL_INIT_VIDEO)!=0)
{
printf("Initialisation de la vidéo via SDl [ERREUR]\n");
SDL_Quit();
exit(1);
}
else
{
printf("Initialisation de la vidéo via SDl [OK]\n");
}
ecran=SDL_SetVideoMode(resX,resY,nbBitParPixel,SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN|SDL_OPENGL|SDL_NOFRAME);
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); // tell SDL that the GL drawing is going to be double buffered
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24); // size of depth buffer
SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 0); // we aren't going to use the stencil buffer
SDL_GL_SetAttribute( SDL_GL_ACCUM_RED_SIZE, 0); // this and the next three lines set the bits allocated per pixel -
SDL_GL_SetAttribute( SDL_GL_ACCUM_GREEN_SIZE, 0); // - for the accumulation buffer to 0
SDL_GL_SetAttribute( SDL_GL_ACCUM_BLUE_SIZE, 0);
SDL_GL_SetAttribute( SDL_GL_ACCUM_ALPHA_SIZE, 0);
if(ecran==NULL)
{
printf("Création de la fenêtre %d x %d x %d [ERREUR]\n",resX,resY,nbBitParPixel);
SDL_Quit();
exit(1);
}
else
{
printf("Création de la fenêtre %d x %d x %d [OK]\n",resX,resY,nbBitParPixel);
}
SDL_WM_SetCaption("Dungeon Hunter","Dungeon Hunter");
//Vider les buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
//Définir la vue de départ
gluLookAt(0, 0, -3, 0, -1, 1, 0, 1, 0);
} |
Partager