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

Author Topic: sf::String rendering issue  (Read 1138 times)

0 Members and 2 Guests are viewing this topic.

Pimms

  • Newbie
  • *
  • Posts: 6
    • View Profile
sf::String rendering issue
« on: December 30, 2011, 03:06:05 pm »
Greetings! I've been trying desperately to fix this issue myself, but after 4 hours, I'm admitting defeat and asking for help.

The error I'm experiencing is that the entire window turns black - with the exception of the string - after the string has been rendered. I've played around (A LOT) with attempting to render the string on top of the existing stuff by calling Display() twice per loop, and a billion other smaller unsuccessful tweaks.

This leads be to believe that the issue is caused by an OpenGL-state floating around inside the machine - which renders (get it? ho ho) me useless, should this be the case.

The minimal code required is:

Code: [Select]

int main (int argc, char** argv)
{
sf::RenderWindow App;
App.Create(sf::VideoMode(1280, 720, 32), "snb", sf::Style::Resize | sf::Style::Close);

sf::Font font;
font.LoadFromFile("Times New Roman.ttf");

sf::String str("This is a string.", font);

while (App.IsOpened())
{
App.Clear();

glColor3f(1, 1, 1);
glLineWidth(10.f);

glBegin(GL_TRIANGLE_FAN);
glVertex2f(0, 0);
glVertex2f(1280, 0);
glVertex2f(1280, 720);
glVertex2f(0, 720);
glEnd();

                //Comment this line, and behold the beautiful white background
App.Draw(str);

App.Display();
}
}


I've tried setting glMatrixMode's, glOrtho, glLoadIdentity and all other glFunctions I use from time to time without luck.

Also, as a side issue : I can only load external resources (sprites etc) when running in admin mode. Is there a way around this? Know that this is not what is causing the rendering to fail.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::String rendering issue
« Reply #1 on: December 30, 2011, 06:11:11 pm »
Call App.PreserveOpenGLStates(true) at the beginning.

Quote
I can only load external resources (sprites etc) when running in admin mode.

Rights problem, nothing to do with SFML ;)
Laurent Gomila - SFML developer

Pimms

  • Newbie
  • *
  • Posts: 6
    • View Profile
sf::String rendering issue
« Reply #2 on: December 30, 2011, 11:34:15 pm »
Tanks a lot! :-) Really made my day.

 

anything