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

Author Topic: SFML2: Text rendering problem with OpenGL context set to 3.2  (Read 3624 times)

0 Members and 1 Guest are viewing this topic.

jimmy

  • Guest
SFML2: Text rendering problem with OpenGL context set to 3.2
« on: August 18, 2010, 04:38:46 pm »
Hi,

I am experiencing a strange problem with text rendering (sf::Text) when setting the OpenGL context to version 3.2 (or 3.3):
The text is just not there...

Setting the context to version 3.0 makes the text to be shown in the upper left corner, as expected.

So this works:
Code: [Select]

                // init:
sf::ContextSettings contextSettings;
contextSettings.MajorVersion = 3;
contextSettings.MinorVersion = 0;

sf::RenderWindow SFMLMainWindow(sf::VideoMode(1280,
                     720), MY_WNDCLASS, iWindowStyle, contextSettings);


                // later in the main loop:
SFMLMainWindow.Clear();
sf::Text Text(buf);
Text.SetPosition(10, 10);
Text.SetColor(sf::Color(255, 255, 255, 255));
SFMLMainWindow.Draw(Text);
SFMLMainWindow.Display();


but setting contextSettings.MinorVersion = 2; does not:

the context is successfully created as a 3.2 context, but there is no text output at screen position 10,10 ...

My graphics card is an NVIDIA GeForce 8600M GT with the latest drivers, so (according to the driver) it supports OpenGL 3.2 and 3.3 with all known extensions...

Any ideas how I can test if this behaviour is due to the driver?

Thanks & cheers,
jimmy

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML2: Text rendering problem with OpenGL context set to 3.2
« Reply #1 on: August 18, 2010, 04:56:01 pm »
What is your OS?
Laurent Gomila - SFML developer

jimmy

  • Guest
SFML2: Text rendering problem with OpenGL context set to 3.2
« Reply #2 on: August 18, 2010, 07:53:47 pm »
Quote from: "Laurent"
What is your OS?


Hi Laurent,

I am using Windows 7 64bit, and have compiled the latest sfml2 tar download myself with Visual Studio 2010 (but in 32bit mode).

Jimmy

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML2: Text rendering problem with OpenGL context set to 3.2
« Reply #3 on: August 18, 2010, 09:14:11 pm »
You have no message in the standard error output?

I think the 3.2 context that you get is not a compatibility context, which means that it doesn't support the OpenGL 1.x fixed pipeline functions that SFML uses. I don't know if it's a mistake in my code, or if it's your driver that doesn't support compatibility profiles with version 3.2.
Laurent Gomila - SFML developer

jimmy

  • Guest
[SOLVED]
« Reply #4 on: August 18, 2010, 10:52:27 pm »
Quote from: "Laurent"
I think the 3.2 context that you get is not a compatibility context, which means that it doesn't support the OpenGL 1.x fixed pipeline functions that SFML uses. I don't know if it's a mistake in my code, or if it's your driver that doesn't support compatibility profiles with version 3.2.


Salut Laurent,

yes, that was indeed a very good hint!
I made some investigations, and indeed it is not a compatible context.

I made the following change in file SFML\Window\Win32\WglContext.cpp:
Code: [Select]

int attributes[] =
{
  WGL_CONTEXT_MAJOR_VERSION_ARB, mySettings.MajorVersion,
  WGL_CONTEXT_MINOR_VERSION_ARB, mySettings.MinorVersion,
  WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, // <= added this one
  0,0
};



This explicitely sets the compatibiliy profile - now I have text rendering on the 3.2 context!

Cheers,
Jimmy

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML2: Text rendering problem with OpenGL context set to 3.2
« Reply #5 on: August 18, 2010, 11:03:03 pm »
Good job!

I'll add this flag, thanks for your help :)
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML2: Text rendering problem with OpenGL context set to 3.2
« Reply #6 on: August 18, 2010, 11:15:42 pm »
Done.
Laurent Gomila - SFML developer

 

anything