IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

OpenGL Discussion :

Écran noir


Sujet :

OpenGL

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre actif
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2010
    Messages
    58
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Novembre 2010
    Messages : 58
    Par défaut Écran noir
    Bonjour a tous, je suis nouveau dans l'utilisation de OpenGL , j'utilise QtCreator comme IDE, le principe est d'afficher un cerveau 3D, a partir d'un tableau de niveau de gris 1D,

    lorsque j’exécute mon code ci dessous, il m'affiche un écran noir. Juste avant j'ai réussi à afficher un seul cube centré mais lorsque j'ai mis en place les 3 boucles et les indices x,y,z dans les vertex, j'ai que du noir.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    void myWindow::reconstruction3D(const std::vector<int> & table)
    {
        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
        glMatrixMode( GL_MODELVIEW);
        glLoadIdentity( );
        glScalef(0.01, 0.01, 0.01);
        glTranslatef(0.0f, 0.0f, -6.0f);
     
        int index=0;
     
        for(int z =0 ; z<64 ; z++)
            for(int y=0 ; y < 64 ; y++)
                for (int x = 0 ; x < 64;x++)
                {
                    index = x+y*64+z*64*64;
     
                    glBegin(GL_QUADS);
     
                    //front
                    glColor3ub(table[index],table[index],table[index]);
                    glVertex3i(x-1, y-1 , z+1);
                    glVertex3i(x-1, y-1 ,z-1);
                    glVertex3i( x+1 ,y-1 ,z-1);
                    glVertex3i( x+1 ,y-1 , z+1);
     
                    //right
                    glColor3ub(table[index],table[index],table[index]);
                    glVertex3i(  x+1, y-1 , z-1);
                    glVertex3i(  x+1, y+1 ,z-1);
                    glVertex3i(  x+1 ,y+1 ,z+1);
                    glVertex3i(  x+1 ,y-1 , z+1);
     
                    //behind
                    glColor3ub(table[index],table[index],table[index]);
                    glVertex3i(  x+1 , y+1 , z-1);
                    glVertex3i(  x-1 , y+1 ,z-1);
                    glVertex3i(  x-1 ,y+1 ,z+1);
                    glVertex3i(  x+1  ,y+1 , z+1);
     
                    //left
                    glColor3ub(table[index],table[index],table[index]);
                    glVertex3i(  x-1 , y+1 , z-1);
                    glVertex3i(  x-1 ,y-1 ,z-1);
                    glVertex3i(  x-1  ,y-1 , z+1);
                    glVertex3i(  x-1 , y+1 ,z+1);
     
                    //above
                    glColor3ub(table[index],table[index],table[index]);
                    glVertex3i(  x-1 , y-1 , z+1);
                    glVertex3i(  x+1 , y-1 ,z+1);
                    glVertex3i(  x+1 ,y+1 ,z+1);
                    glVertex3i(  x-1  ,y+1 , z+1);
                    //below
                    glColor3ub(table[index],table[index],table[index]);
                    glVertex3i(  x-1 , y-1 , z-1);
                    glVertex3i(  x-1 , y+1 ,z-1);
                    glVertex3i(  x+1 ,y+1 ,z-1);
                    glVertex3i(  x+1  ,y-1 , z-1);
                    glEnd();
     
                }
     
    }
    aidez moi SVP

  2. #2
    Membre Expert
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    1 415
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Mars 2007
    Messages : 1 415
    Par défaut
    Salut

    Il est assez courant de ne rien voir affiché quand on fait de l'OpenGL et qu'on est pas habitué.

    Comment avais-tu fait le cube ? Il te manque probablement les lumières, et aussi le set correct des normales de tes vertex.

  3. #3
    Membre actif
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2010
    Messages
    58
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Novembre 2010
    Messages : 58
    Par défaut
    est ce que vous pouvez me donner une réponse plus concrète svp ?

    pour le cube j'ai utilisé ce code

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    49
    50
    51
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glMatrixMode( GL_MODELVIEW);
            glLoadIdentity();
     
     
            glTranslatef(0.0f, 0.0f, -6.0f);
     
     
            glBegin(GL_QUADS);
     //front
            glColor3ub(100,100,100);
            glVertex3i(-1, -1 , 1);
            glVertex3i(-1, -1 ,-1);
            glVertex3i( 1 ,-1 ,-1);
            glVertex3i( 1 ,-1 , 1);
    //right
            glColor3ub(255,100,100);
            glVertex3i(  1, -1 , -1);
            glVertex3i(  1, 1 ,-1);
            glVertex3i(  1 ,1 ,1);
            glVertex3i(  1 ,-1 , 1);
    //behind
            glColor3ub(100,255,100);
            glVertex3i(  1 , 1 , -1);
            glVertex3i(  -1 , 1 ,-1);
            glVertex3i(  -1 ,1 ,1);
            glVertex3i(  1  ,1 , 1);
     
    //left
            glColor3ub(100,100,255);
            glVertex3i(  -1 , 1 , -1);
            glVertex3i(  -1 ,-1 ,-1);
            glVertex3i(  -1  ,-1 , 1);
            glVertex3i(  -1 , 1 ,1);
    //above
            glColor3ub(100,255,100);
            glVertex3i(  -1 , -1 , 1);
            glVertex3i(  1 , -1 ,1);
            glVertex3i(  1 ,1 ,1);
            glVertex3i(  -1  ,1 , 1);
    //below
            glColor3ub(100,255,50);
            glVertex3i(  -1 , -1 , -1);
            glVertex3i(  -1 , 1 ,-1);
            glVertex3i(  1 ,1 ,-1);
            glVertex3i(  1  ,-1 , -1);
     
     
            glEnd();
     
    }

Discussions similaires

  1. écran noir et aucun bruit
    Par sandytarit dans le forum Périphériques
    Réponses: 22
    Dernier message: 09/12/2006, 10h52
  2. Pc monté écran noir
    Par sandytarit dans le forum Périphériques
    Réponses: 8
    Dernier message: 30/07/2006, 23h52
  3. Premier démarrage: écran noir
    Par chris21 dans le forum Périphériques
    Réponses: 2
    Dernier message: 22/02/2006, 08h30
  4. écran noir avec un shader d'éclairage au pixel près
    Par captainSeb dans le forum OpenGL
    Réponses: 2
    Dernier message: 16/05/2005, 12h30
  5. Visual C++ 6 : Problème impression d'écran noir
    Par charliejo dans le forum MFC
    Réponses: 6
    Dernier message: 24/01/2005, 09h52

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo