Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Port app from 1.6 to 2.1. Now sf::Text isn't rendering  (Read 1097 times)

0 Members and 1 Guest are viewing this topic.

dirk103

  • Newbie
  • *
  • Posts: 3
    • View Profile
Port app from 1.6 to 2.1. Now sf::Text isn't rendering
« on: December 03, 2013, 08:01:56 am »
Hey there,
I've just ported my fairly large application from SFML 1.6 to 2.1 and I've run into a bit of trouble when I go to render my sf::Text in a sf::RenderWindow.

==== Problem ====
- Under no circumstance does render_window->draw(my_sf_text); draw the text

==== Things i've checked/tried ====
- I have loaded a font and assigned it to my sf::Text
- I have verified that the font is loaded correctly by binding the sf::Texture of the font and pasted it on to a glBegin(GL_QUADS) region. This displays all the glyfs of the characters in my string.
- My GUI agent for rendering text is reporting the correct size of the font via .getLocalBounds()
- I have tried drawing some fresh text completely outside of all abstractions written in my program:
   // Setup
   sf::Text my_text;
   my_text.setFont(*Forms::default_font);
   my_text.setCharacterSize(24);
   my_text.setColor(sf::Color::Red);
   my_text.setStyle(sf::Text::Regular);
   my_text.setPosition(500, 100);
   my_text.setString("abcdefghijklnmopqrstuvwxyz1234567890 ");

   // In main loop
   // ...
   // Setup view
   App->pushGLStates();
   App->draw(my_text);
   App->popGLStates();
   // ...
   App->display();
- If I neglect to pushGLStates(), then it alters the state of opengl so that the rest of my graphics are corrupted, so I know that it's doing something.

==== Important notes (I think): ====
- I am making use of glew and initialize it after my RenderWindow has been created.


==== Question ====
- Are there any differences from 1.6 to 2.1 that I'm over looking that may lead to this?
- Is there some kind of conflict with glew in this case?

I'm sorry but I can't paste all relevant code as it's huge. If you want me to break down all of the code I'm using specifically for drawing fonts I can.


Thanks a bunch!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Port app from 1.6 to 2.1. Now sf::Text isn't rendering
« Reply #1 on: December 03, 2013, 08:41:24 am »
- I am making use of glew and initialize it after my RenderWindow has been created.
Since SFML inits GLEW first then, your init should essentially do nothing (afaik). Make sure you init GLEW before SFML gets the chance to do so.

I'm sorry but I can't paste all relevant code as it's huge. If you want me to break down all of the code I'm using specifically for drawing fonts I can.
Since you say it never works drawing a text, you should be able to create a small example from scratch, that just opens a window and draws text.

The only guess we can currently make, is that you're doing some custom OpenGL stuff, that doesn't work well with SFML. Or you're not properly resetting OpenGL states.
Have you ever tried using glFlush after drawing? Because it the past there was some issue (mostly in multithreaded applications), where the drawing call didn't get fully through. ;)


Those "glowing" titles look awful. :D
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/