Bienvenue, Invité. Merci de vous connecter ou de vous inscrire.
Avez-vous perdu votre e-mail d'activation ?

Auteur Sujet: [SFML 2.0 | OpenGL] Du texte dans un sf::Window ?  (Lu 8795 fois)

0 Membres et 1 Invité sur ce sujet

lanquemar

  • Newbie
  • *
  • Messages: 21
    • Voir le profil
    • E-mail
[SFML 2.0 | OpenGL] Du texte dans un sf::Window ?
« le: Octobre 03, 2012, 10:04:59 pm »
Bonsoir,
Alors voilà, cela fait une heure que je cherche, mais je ne trouve rien, alors qu'il me semble avoir déjà lu quelque chose quelque part... Je m'excuse donc d'avance pour un probable double post  :-\
En fait, j'ai un contexte OpenGL 3.3 grâce à un sf::Window, et je voudrais tout simplement écrire du texte (2D) (sf::Text) sur ma fenêtre... Apparemment, il faudrait absolument passer par un sf::RenderWindow pour avoir la méthode draw, mais il n'y aurait vraiment pas moyen de garder un sf:Window ?
Désolé du dérangement,
Merci beaucoup !  :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Messages: 32504
    • Voir le profil
    • SFML's website
    • E-mail
Re : [SFML 2.0 | OpenGL] Du texte dans un sf::Window ?
« Réponse #1 le: Octobre 04, 2012, 08:03:08 am »
Citer
il faudrait absolument passer par un sf::RenderWindow pour avoir la méthode draw
Voilà, t'as tout compris. Et quel est le problème à utiliser sf::RenderWindow ?
Laurent Gomila - SFML developer

lanquemar

  • Newbie
  • *
  • Messages: 21
    • Voir le profil
    • E-mail
Re : [SFML 2.0 | OpenGL] Du texte dans un sf::Window ?
« Réponse #2 le: Octobre 04, 2012, 07:24:48 pm »
Merci de la réponse !

Ben en fait, je n'arrive pas à modifier mon code pour passer de sf::Window à sf::RenderWindow.
Ce que je veux dire c'est que si je change seulement mes sf::Window en sf::RenderWindow, j'ai des milliers d'erreurs (dans glew apparemment :/).

Laurent

  • Administrator
  • Hero Member
  • *****
  • Messages: 32504
    • Voir le profil
    • SFML's website
    • E-mail
Re : [SFML 2.0 | OpenGL] Du texte dans un sf::Window ?
« Réponse #3 le: Octobre 04, 2012, 08:33:50 pm »
Les erreurs sont faites pour être résolues, pas contournées. Et si tu veux de l'aide il va falloir être plus précis quant aux messages d'erreur ;)
Laurent Gomila - SFML developer

lanquemar

  • Newbie
  • *
  • Messages: 21
    • Voir le profil
    • E-mail
Re : [SFML 2.0 | OpenGL] Du texte dans un sf::Window ?
« Réponse #4 le: Octobre 04, 2012, 08:41:22 pm »
D'accord, pas de problème ! Merci de m'aider ! :)

Alors voilà, dans mon code, j'ai seulement et uniquement remplacé :
sf::Window *m_window;
par
sf::RenderWindow *m_window;
Et
m_window = new sf::Window(sf::VideoMode(m_xWin, m_yWin), m_titleWin.c_str(), sf::Style::Default, m_setSettings);
par
m_window = new sf::RenderWindow(sf::VideoMode(m_xWin, m_yWin), m_titleWin.c_str(), sf::Style::Default, m_setSettings);

Lorsque j'essaye de compiler, voilà ce que j'ai :
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xd78): multiple definition of `__glewWindowPos2dARB'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3155: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xd7c): multiple definition of `__glewWindowPos2dvARB'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3155: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xd80): multiple definition of `__glewWindowPos2fARB'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3155: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xd84): multiple definition of `__glewWindowPos2fvARB'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3155: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xd88): multiple definition of `__glewWindowPos2iARB'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3155: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xd8c): multiple definition of `__glewWindowPos2ivARB'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3155: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xd90): multiple definition of `__glewWindowPos2sARB'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3155: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xd94): multiple definition of `__glewWindowPos2svARB'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3155: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xd98): multiple definition of `__glewWindowPos3dARB'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3156: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xd9c): multiple definition of `__glewWindowPos3dvARB'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3156: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xda0): multiple definition of `__glewWindowPos3fARB'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3156: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xda4): multiple definition of `__glewWindowPos3fvARB'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3156: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xda8): multiple definition of `__glewWindowPos3iARB'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3156: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xdac): multiple definition of `__glewWindowPos3ivARB'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3156: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xdb0): multiple definition of `__glewWindowPos3sARB'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3156: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xdb4): multiple definition of `__glewWindowPos3svARB'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3156: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xdd8): multiple definition of `__glewAlphaFragmentOp1ATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3157: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xddc): multiple definition of `__glewAlphaFragmentOp2ATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3157: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xde0): multiple definition of `__glewAlphaFragmentOp3ATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3157: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xde4): multiple definition of `__glewBeginFragmentShaderATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3157: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xde8): multiple definition of `__glewBindFragmentShaderATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3157: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xdec): multiple definition of `__glewColorFragmentOp1ATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3157: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xdf0): multiple definition of `__glewColorFragmentOp2ATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3157: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xdf4): multiple definition of `__glewColorFragmentOp3ATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3157: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xdf8): multiple definition of `__glewDeleteFragmentShaderATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3157: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xdfc): multiple definition of `__glewEndFragmentShaderATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3158: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xe00): multiple definition of `__glewGenFragmentShadersATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3158: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xe04): multiple definition of `__glewPassTexCoordATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3158: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xe08): multiple definition of `__glewSampleMapATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3158: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xe0c): multiple definition of `__glewSetFragmentShaderConstantATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3158: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xe28): multiple definition of `__glewArrayObjectATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3158: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xe2c): multiple definition of `__glewFreeObjectBufferATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3159: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xe30): multiple definition of `__glewGetArrayObjectfvATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3159: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xe34): multiple definition of `__glewGetArrayObjectivATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3159: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xe38): multiple definition of `__glewGetObjectBufferfvATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3159: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xe3c): multiple definition of `__glewGetObjectBufferivATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3159: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xe40): multiple definition of `__glewGetVariantArrayObjectfvATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3159: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xe44): multiple definition of `__glewGetVariantArrayObjectivATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3159: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xe48): multiple definition of `__glewIsObjectBufferATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3159: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xe4c): multiple definition of `__glewNewObjectBufferATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3159: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xe50): multiple definition of `__glewUpdateObjectBufferATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3159: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xe54): multiple definition of `__glewVariantArrayObjectATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3159: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xe64): multiple definition of `__glewClientActiveVertexStreamATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3160: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xe68): multiple definition of `__glewNormalStream3bATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3160: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xe6c): multiple definition of `__glewNormalStream3bvATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3160: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xe70): multiple definition of `__glewNormalStream3dATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3160: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xe74): multiple definition of `__glewNormalStream3dvATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3160: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xe78): multiple definition of `__glewNormalStream3fATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3160: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xe7c): multiple definition of `__glewNormalStream3fvATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3160: first defined here
C:\Program Files (x86)\CodeBlocks\SFML-2.0-rc\lib/libsfml-graphics-s-d.a(glew.c.o):glew.c:(.bss+0xe80): multiple definition of `__glewNormalStream3iATI'
obj\Debug\glew.o:D:/Programmation/Robot/glew.c:3160: first defined here

(Je suis désolé du long texte que ça fait  :-\ )

Sachant que j'inclue bien <GL/glew.h> avant les includes SFML :)

Merci !

Laurent

  • Administrator
  • Hero Member
  • *****
  • Messages: 32504
    • Voir le profil
    • SFML's website
    • E-mail
Re : [SFML 2.0 | OpenGL] Du texte dans un sf::Window ?
« Réponse #5 le: Octobre 04, 2012, 08:46:32 pm »
GLEW est déjà inclus à SFML, du coup quand tu lies celle-ci statiquement, et que de ton côté tu lies GLEW également statiquement (ou l'inclue dans ton code, c'est pareil), il se retrouve en double et l'éditeur de liens n'aime pas ça. Retirer glew.c de ton code devrait résoudre le problème.
Laurent Gomila - SFML developer

lanquemar

  • Newbie
  • *
  • Messages: 21
    • Voir le profil
    • E-mail
Re : [SFML 2.0 | OpenGL] Du texte dans un sf::Window ?
« Réponse #6 le: Octobre 04, 2012, 08:48:53 pm »
Et donc je ne peux pas lier statiquement glew ?

lanquemar

  • Newbie
  • *
  • Messages: 21
    • Voir le profil
    • E-mail
Re : [SFML 2.0 | OpenGL] Du texte dans un sf::Window ?
« Réponse #7 le: Octobre 04, 2012, 09:22:32 pm »
J'ai lié dynamiquement GLEW, et j'ai donc ajouté glew32.dll à côté de mon exécutable...
Plus de problème de compilation, mais quand je lance le programme, il s'ouvre, et "cesse de fonctionner"...
J'ai dû faire une erreur quelque part, mais je ne sais pas où :/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Messages: 32504
    • Voir le profil
    • SFML's website
    • E-mail
Re : [SFML 2.0 | OpenGL] Du texte dans un sf::Window ?
« Réponse #8 le: Octobre 04, 2012, 09:58:46 pm »
Non, je te disais de ne pas du tout lier GLEW. Il est déjà dans SFML.
Laurent Gomila - SFML developer

lanquemar

  • Newbie
  • *
  • Messages: 21
    • Voir le profil
    • E-mail
Re : [SFML 2.0 | OpenGL] Du texte dans un sf::Window ?
« Réponse #9 le: Octobre 04, 2012, 10:07:00 pm »
Bon, j'ai réussis à faire quelque chose qui fonctionne ! Merci !

Par contre, j'ai encore un problème...
Mon but à la base était de pouvoir écrire du texte.
Maintenant que GLEW/SFML cohabitent correctement, j'ai fait ceci :
 // Declare and load a font
     sf::Font font;
     font.loadFromFile("arial.ttf");

     // Create a text
     sf::Text text("hello");
     text.setFont(font);
     text.setCharacterSize(30);
     text.setStyle(sf::Text::Bold);
     text.setColor(sf::Color::Red);

Mais quand je lance mon programme, pas de texte du tout, et un message dans la console :
An internal OpenGL call failed in Texture.cpp (95) : unknown error, no description

Qu'est-ce que je peux faire ?  :-\

Laurent

  • Administrator
  • Hero Member
  • *****
  • Messages: 32504
    • Voir le profil
    • SFML's website
    • E-mail
Re : [SFML 2.0 | OpenGL] Du texte dans un sf::Window ?
« Réponse #10 le: Octobre 04, 2012, 10:11:33 pm »
Peux-tu extraire un code minimal et complet qui reproduit le problème ?
Laurent Gomila - SFML developer

lanquemar

  • Newbie
  • *
  • Messages: 21
    • Voir le profil
    • E-mail
Re : [SFML 2.0 | OpenGL] Du texte dans un sf::Window ?
« Réponse #11 le: Octobre 04, 2012, 10:17:39 pm »
Alors, j'ai essayé de faire un condensé de mes fonctions :

     m_window = new sf::RenderWindow(sf::VideoMode(m_xWin, m_yWin), m_titleWin.c_str(), sf::Style::Default, m_setSettings);

     GLenum glew_status = glewInit();
     if (glew_status != GLEW_OK)
     {
          std::cout << "[ERROR] Cannot init GLEW : " << glewGetErrorString(glew_status) << std::endl;
          return false;
     }

     if (!GLEW_VERSION_2_0)
     {
          std::cout << "[ERROR] Your graphic card does not support OpenGL 2.0." << std::endl;
          return false;
     }

     // Enable alpha
     glEnable(GL_BLEND);
     glEnable(GL_DEPTH_TEST);
     //glDepthFunc(GL_LESS);
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    bool running = true;

     // Declare and load a font
     sf::Font font;
     font.loadFromFile("arial.ttf");

     // Create a text
     sf::Text text("Hello");
     text.setFont(font);
     text.setCharacterSize(10);
     text.setStyle(sf::Text::Bold);
     text.setColor(sf::Color::Red);
     text.setPosition(100,100);

     sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    Cube cubeTest;
    Plan planTest;

    glm::mat4 modelview = glm::lookAt(glm::vec3(3.0, 2.0, 5.0), glm::vec3(0.0, 0.0, 0.0), glm::vec3(0.0, 1.0, 0.0));
    glm::mat4 projection = glm::perspective(60.0f, 1.0f * m_xWin/m_yWin, 0.0001f, 1000.0f);

    while (running)
    {
        // gestion des évènements
        sf::Event event;
        while (m_window->pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                // on stoppe le programme
                running = false;
            }
            else if (event.type == sf::Event::Resized)
            {
                // on ajuste le viewport lorsque la fenêtre est redimensionnée
                glViewport(0, 0, event.size.width, event.size.height);
                m_xWin = event.size.width;
                m_yWin = event.size.height;
            }
        }

        // effacement les tampons de couleur/profondeur
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        m_window->pushGLStates();
        m_window->draw(shape);
        m_window->draw(text);
        m_window->popGLStates();

        // dessin...
        cubeTest.draw(modelview, projection);
        planTest.draw(modelview, projection);

        // termine la trame courante (en interne, échange les deux tampons de rendu)
        m_window->display();
    }
 

Voilà, j'espère que c'est assez clair et concis  :-\
Il y a peut être quelques incohérences, mais le tout est placé dans plusieurs méthodes d'une classe, donc bon...

EDIT : Et avec ce code, je n'ai ni rond vert, ni texte...

Laurent

  • Administrator
  • Hero Member
  • *****
  • Messages: 32504
    • Voir le profil
    • SFML's website
    • E-mail
Re : [SFML 2.0 | OpenGL] Du texte dans un sf::Window ?
« Réponse #12 le: Octobre 04, 2012, 10:20:56 pm »
Je n'ai pas besoin de tout ton code, juste du morceau minimal qui produit l'erreur. Et ce serait bien si c'était complet, le but c'est que je puisse le copier et le tester rapidos ;)
Laurent Gomila - SFML developer

lanquemar

  • Newbie
  • *
  • Messages: 21
    • Voir le profil
    • E-mail
Re : [SFML 2.0 | OpenGL] Du texte dans un sf::Window ?
« Réponse #13 le: Octobre 04, 2012, 10:22:57 pm »
Ben en gros, j'ai un contexte OpenGL avec GLEW et SFML dans une RenderWindow, j'affiche un plan et un cube, j'essaye d'afficher du texte par dessus, mais ça ne fonctionne pas...
Est-ce que je dois faire un autre morceau de code plus concentré ?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Messages: 32504
    • Voir le profil
    • SFML's website
    • E-mail
Re : [SFML 2.0 | OpenGL] Du texte dans un sf::Window ?
« Réponse #14 le: Octobre 04, 2012, 10:28:51 pm »
Oui ! C'est vraiment pas compliqué, tu enlèves petit à petit les trucs qui ont l'air inutiles, jusqu'à ce que le bug disparaisse. Là tu as un code vraiment minimal. C'est pas pour t'embêter que je te fais faire ça, c'est juste le moyen le plus rapide de cerner un bug. Scruter un gros code pendant des heures, j'ai pas vraiment le temps de le faire ; par contre copier quelques lignes bien ciblées, tester et debugger dans la foulée, ça je peux ;)
Laurent Gomila - SFML developer