SFML community forums

Help => Graphics => Topic started by: Ahlywog on December 22, 2012, 01:11:58 am

Title: Text with OpenGL help?
Post by: Ahlywog on December 22, 2012, 01:11:58 am
Every example I can find of using text uses App.draw().  The tutorials say, for OpenGL, you open a window with sf::VideoMode() but sf::VideoMode() doesn't have a draw() option.  So how do you use text with OpenGL?
Title: Re: Text with OpenGL help?
Post by: eXpl0it3r on December 22, 2012, 01:31:46 am
You either use SFML for text rendering or you use your own custom code for text rendering.

If you go the SFML way then you have to use window.draw(), that's just how SFML works. If you want to use your custom OpenGL code you're on your own. ;)

Note: You can also use a sf::RenderWindow with OpenGL.
Note2: SFML makes use of OpenGL.
Title: Re: Text with OpenGL help?
Post by: Ahlywog on December 22, 2012, 03:34:26 am
For anyone who comes after me with this question.  The following opens our appropriate window type.

sf::WindowSettings Settings;
        Settings.DepthBits                      = 24; // Request a 24 bits depth buffer
        Settings.StencilBits            = 8;  // Request a 8 bits stencil buffer
        Settings.AntialiasingLevel      = 2;  // Request 2 levels of antialiasing
        sf::RenderWindow Window(sf::VideoMode(ScreenWidth, ScreenHeight, 32), "SFML OpenGL Window!  BYAH!", sf::Style::Close | sf::Style::Fullscreen, Settings);
 

And when you use text you need to remember to use the following before your .Draw() commands.

Window.PreserveOpenGLStates(true);