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 :

Affichage 2D premier plan.


Sujet :

OpenGL

  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    9
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 9
    Points : 8
    Points
    8
    Par défaut Affichage 2D premier plan.
    Bonjour à tous!

    Voilà j'ai un petit problème : J'aimerais afficher de la 2D dans une fenêtre OpenGL au premier plan c'est à dire devant tous les objets en 3D! (il s'agit d'un menu)
    J'ai trouvé quelques renseignements dans la faq d'opengl : 9.030 mais je ne comprend pas comment le mettre en application : j'obtiens toujours un écran vide!

    Voilà le code d'affichage :

    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
    int drawGLScene( )
    {
          static GLint T0     = 0;
          static GLint Frames = 0;
          static GLfloat fps = 0;
          glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
          glMatrixMode(GL_PROJECTION);
          glPushMatrix();
          gluOrtho2D(0,curwidth,0,curheight);
          glMatrixMode(GL_MODELVIEW);
          glLoadIdentity();
          glTranslatef(0,0,-6);
          /* Carré à afficher */
          glBegin(GL_QUADS);  
    	glVertex2f(1,1);
    	glVertex2f(1,-1);
    	glVertex2f(-1,-1);
    	glVertex2f(-1,1);
          glEnd();
          glMatrixMode(GL_PROJECTION);
          glPopMatrix();
          SDL_GL_SwapBuffers( );
          Frames++;
          GLint t = SDL_GetTicks();
          if ( t - T0 >= 1000 )
          {
    	    GLfloat seconds = (t - T0) / 1000.0;
    	    fps = Frames / seconds;
    	    printf("%d frames in %f seconds = %f FPS\n",Frames,seconds,fps);
    	    T0 = t;
    	    Frames = 0;
          }
          return( TRUE );
    }
    Si quelqu'un à une idée??

    Merci A+

    PS : bonnes fêtes de fin d'année!!

  2. #2
    Membre du Club
    Profil pro
    Étudiant
    Inscrit en
    Décembre 2009
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2009
    Messages : 37
    Points : 41
    Points
    41
    Par défaut
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    gluOrtho2D(0,curwidth,0,curheight);
    glMatrixMode(GL_MODELVIEW);

    Tu n'oublies pas un glLoadIdentity() après que tu spécifies ta matrice de projection ?

  3. #3
    Futur Membre du Club
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    9
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 9
    Points : 8
    Points
    8
    Par défaut
    Salut,

    Merci pour ta réponse! En effet j'ai oublié un glLoadIdentity(); avant le gluOrtho2D(**);

    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
    int drawGLScene( )
    {
          static GLint T0     = 0;
          static GLint Frames = 0;
          static GLfloat fps = 0;
          glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
          glMatrixMode(GL_PROJECTION);
          glPushMatrix();
          glLoadIdentity();
          gluOrtho2D(0,curwidth,0,curheight);
          glMatrixMode(GL_MODELVIEW);
          glLoadIdentity();
          /* Carré à afficher */
          glBegin(GL_QUADS);  
    	glVertex2f(1,1);
    	glVertex2f(1,-1);
    	glVertex2f(-1,-1);
    	glVertex2f(-1,1);
          glEnd();
          glMatrixMode(GL_PROJECTION);
          glPopMatrix();
          SDL_GL_SwapBuffers( );
          Frames++;
          GLint t = SDL_GetTicks();
          if ( t - T0 >= 1000 )
          {
    	    GLfloat seconds = (t - T0) / 1000.0;
    	    fps = Frames / seconds;
    	    printf("%d frames in %f seconds = %f FPS\n",Frames,seconds,fps);
    	    T0 = t;
    	    Frames = 0;
          }
          return( TRUE );
    }
    Mais hélas ça ne change pas le problème!

    A+

  4. #4
    Membre du Club
    Profil pro
    Étudiant
    Inscrit en
    Décembre 2009
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2009
    Messages : 37
    Points : 41
    Points
    41
    Par défaut
    Ce qui joue je pense aussi, c'est le test de profondeur. Personnellement j'ai fais ceci et ça marche:

    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
     
            // Avant il y a mon rendu en 3D ...
     
            // Desactiver le depth test.
    	glDisable(GL_DEPTH_TEST);
     
            // On sauvegarde la matrice de projection.
    	glMatrixMode(GL_PROJECTION);
    	glPushMatrix();
                    // On redéfinit un nouveau repère en 2D
    		glLoadIdentity();
    		gluOrtho2D(0, WIN_W, 0, WIN_H);
     
    		glMatrixMode(GL_MODELVIEW);
    		glLoadIdentity();
     
    		glBegin(GL_QUADS);
    			glVertex2f(0, 0);
    			glVertex2f(10, 0);
    			glVertex2f(10, 10);
    			glVertex2f(0, 10);
    		glEnd();
     
    		glMatrixMode(GL_PROJECTION);
    	glPopMatrix();
     
            // On ré-active le depth test.
    	glEnable(GL_DEPTH_TEST);

  5. #5
    Futur Membre du Club
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    9
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 9
    Points : 8
    Points
    8
    Par défaut
    Salut et merci pour ton aide Soack!! ça marche impec!

    A+

Discussions similaires

  1. [PPT-2003] Affichage en premier plan les elements de la barre de dessin
    Par Alexandra 01 dans le forum VBA PowerPoint
    Réponses: 14
    Dernier message: 20/07/2010, 19h37
  2. Affichage en premier plan d'une TextBox
    Par molo2003 dans le forum Windows Forms
    Réponses: 4
    Dernier message: 20/10/2007, 13h28
  3. [c++] Souci d'affichage au premier plan
    Par Pov' typ' dans le forum DirectX
    Réponses: 2
    Dernier message: 25/06/2006, 21h02
  4. [JPanel] Affichage en premier plan
    Par Snowballz dans le forum Agents de placement/Fenêtres
    Réponses: 3
    Dernier message: 21/07/2004, 16h07
  5. [glut] forcer l'affichage au premier plan
    Par khayyam90 dans le forum OpenGL
    Réponses: 7
    Dernier message: 19/07/2004, 14h37

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